@limetech/lime-elements 39.24.1 → 39.24.2

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 (152) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/{_assignValue-DpsLUlF4.js → _assignValue-DQh76m39.js} +2 -2
  3. package/dist/cjs/{_baseEach-C570gT5Y.js → _baseEach-Bygi-un6.js} +2 -2
  4. package/dist/cjs/{_baseIsEqual-aOPReRWl.js → _baseIsEqual-CQZKiKbe.js} +20 -365
  5. package/dist/cjs/{_baseIteratee-DggA4e7a.js → _baseIteratee-DDklwtn9.js} +6 -4
  6. package/dist/cjs/{_defineProperty-BDFOiqJL.js → _defineProperty-Csu6P9HT.js} +1 -1
  7. package/dist/cjs/{_getAllKeysIn-BQIV8aw7.js → _getAllKeysIn-BJsgUTAt.js} +5 -4
  8. package/dist/cjs/{_getNative-B4n5HX2B.js → _getNative-Cf52giNE.js} +2 -2
  9. package/dist/cjs/_getTag-BC28Za7d.js +355 -0
  10. package/dist/cjs/_isIndex-Bu45fvR7.js +27 -0
  11. package/dist/cjs/{_isIterateeCall-CPWXFS_s.js → _isIterateeCall-BUGt9SrH.js} +4 -3
  12. package/dist/cjs/{cloneDeep-CxFNKF1Y.js → cloneDeep-hE40Q8aw.js} +13 -12
  13. package/dist/cjs/{difference-Bfsq4sXB.js → difference-B543MGsY.js} +5 -4
  14. package/dist/cjs/eq-DFcUoVzv.js +39 -0
  15. package/dist/cjs/file-metadata-BrhOssGG.js +76 -0
  16. package/dist/cjs/{files-Cf615Ytp.js → files-Bt11HLi4.js} +1 -1
  17. package/dist/cjs/{focus-trigger-element-Brw8VubX.js → focus-trigger-element-BfnJmxKO.js} +1 -1
  18. package/dist/{esm/file-metadata-BwF9vTXN.js → cjs/icons-isR5V1X0.js} +4 -69
  19. package/dist/cjs/{isArrayLike-_dR1U5-Y.js → isArrayLike-C2RwZMG4.js} +2 -27
  20. package/dist/cjs/{isEmpty-EBCFxX1S.js → isEmpty-CCxl3bYc.js} +6 -6
  21. package/dist/cjs/{isEqual-bXyw7kXo.js → isEqual-Cd9J8a5-.js} +1 -1
  22. package/dist/cjs/{eq-B1KBAwmK.js → isFunction-RSHwsz1x.js} +0 -37
  23. package/dist/cjs/lime-elements.cjs.js +1 -1
  24. package/dist/cjs/{limel-breadcrumbs_7.cjs.entry.js → limel-breadcrumbs_8.cjs.entry.js} +74 -8
  25. package/dist/cjs/limel-chip-set.cjs.entry.js +578 -0
  26. package/dist/cjs/limel-chip_2.cjs.entry.js +33 -540
  27. package/dist/cjs/limel-dialog.cjs.entry.js +9 -6
  28. package/dist/cjs/limel-email-viewer.cjs.entry.js +15 -10
  29. package/dist/cjs/limel-file-dropzone_2.cjs.entry.js +12 -8
  30. package/dist/cjs/limel-file.cjs.entry.js +2 -1
  31. package/dist/cjs/limel-flatpickr-adapter.cjs.entry.js +5 -3
  32. package/dist/cjs/limel-form.cjs.entry.js +28 -25
  33. package/dist/cjs/limel-helper-line.cjs.entry.js +42 -0
  34. package/dist/cjs/limel-popover_2.cjs.entry.js +6 -5
  35. package/dist/cjs/limel-profile-picture.cjs.entry.js +3 -2
  36. package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js +16 -12
  37. package/dist/cjs/limel-tab-bar.cjs.entry.js +11 -8
  38. package/dist/cjs/limel-table.cjs.entry.js +14 -11
  39. package/dist/cjs/loader.cjs.js +1 -1
  40. package/dist/cjs/{pickBy-kLjYLoam.js → pickBy-D-X6S5kg.js} +5 -5
  41. package/dist/collection/components/email-viewer/email-viewer.css +12 -32
  42. package/dist/collection/components/email-viewer/email-viewer.js +16 -9
  43. package/dist/esm/{_assignValue-DOEO9byf.js → _assignValue-CEFvyZxO.js} +2 -2
  44. package/dist/esm/{_baseEach-C4UJIc96.js → _baseEach-lvj-g1Zj.js} +2 -2
  45. package/dist/esm/{_baseIsEqual-DCZXUzsZ.js → _baseIsEqual-B6bIeexY.js} +10 -346
  46. package/dist/esm/{_baseIteratee-CI-QZdpx.js → _baseIteratee-CEZRuq23.js} +4 -2
  47. package/dist/esm/{_defineProperty-yVdnnt__.js → _defineProperty-C69Btzid.js} +1 -1
  48. package/dist/esm/{_getAllKeysIn-v-KlW5r_.js → _getAllKeysIn-kT3KizYN.js} +3 -2
  49. package/dist/esm/{_getNative-aN4R8EiP.js → _getNative-COawFdVX.js} +1 -1
  50. package/dist/esm/_getTag-CMJL-6hk.js +344 -0
  51. package/dist/esm/_isIndex-B--C3qwe.js +25 -0
  52. package/dist/esm/{_isIterateeCall-CTcCv8Mb.js → _isIterateeCall-Bb4gUZLK.js} +3 -2
  53. package/dist/esm/{cloneDeep-V4fB8wfG.js → cloneDeep-CL7UD3mR.js} +4 -3
  54. package/dist/esm/{difference-CWrdq-hd.js → difference-DND5tWiA.js} +4 -3
  55. package/dist/esm/eq-CZ30nDJE.js +37 -0
  56. package/dist/esm/file-metadata-BHzkIH4g.js +71 -0
  57. package/dist/esm/{files-P324wLau.js → files-CZAZotms.js} +1 -1
  58. package/dist/esm/{focus-trigger-element-DubROLkE.js → focus-trigger-element-BOFcjLq3.js} +1 -1
  59. package/dist/{cjs/file-metadata-rQ0WzFlZ.js → esm/icons-Bu_YRgCL.js} +1 -75
  60. package/dist/esm/{isArrayLike-D1QkaJU2.js → isArrayLike-CyVGB489.js} +2 -26
  61. package/dist/esm/{isEmpty-BFxMjh_H.js → isEmpty-DHgukT5k.js} +2 -2
  62. package/dist/esm/{isEqual-CsrptmTU.js → isEqual-4tbMaaf_.js} +1 -1
  63. package/dist/esm/{eq-D7VMHFyO.js → isFunction-9zQTeQI8.js} +1 -37
  64. package/dist/esm/lime-elements.js +1 -1
  65. package/dist/esm/{limel-breadcrumbs_7.entry.js → limel-breadcrumbs_8.entry.js} +71 -6
  66. package/dist/esm/limel-chip-set.entry.js +576 -0
  67. package/dist/esm/limel-chip_2.entry.js +35 -542
  68. package/dist/esm/limel-dialog.entry.js +9 -6
  69. package/dist/esm/limel-email-viewer.entry.js +15 -10
  70. package/dist/esm/limel-file-dropzone_2.entry.js +12 -8
  71. package/dist/esm/limel-file.entry.js +2 -1
  72. package/dist/esm/limel-flatpickr-adapter.entry.js +5 -3
  73. package/dist/esm/limel-form.entry.js +18 -15
  74. package/dist/esm/limel-helper-line.entry.js +40 -0
  75. package/dist/esm/limel-popover_2.entry.js +6 -5
  76. package/dist/esm/limel-profile-picture.entry.js +3 -2
  77. package/dist/esm/limel-prosemirror-adapter.entry.js +16 -12
  78. package/dist/esm/limel-tab-bar.entry.js +11 -8
  79. package/dist/esm/limel-table.entry.js +14 -11
  80. package/dist/esm/loader.js +1 -1
  81. package/dist/esm/{pickBy-D8CUtxE4.js → pickBy-C4C3CM4m.js} +4 -4
  82. package/dist/lime-elements/lime-elements.esm.js +1 -1
  83. package/dist/lime-elements/p-00b424d7.entry.js +1 -0
  84. package/dist/lime-elements/p-01651634.entry.js +1 -0
  85. package/dist/lime-elements/p-4ecd565b.entry.js +1 -0
  86. package/dist/lime-elements/p-5442e09e.entry.js +13 -0
  87. package/dist/lime-elements/p-56bkn1D-.js +1 -0
  88. package/dist/lime-elements/p-60327283.entry.js +1 -0
  89. package/dist/lime-elements/{p-cfe85e59.entry.js → p-6eaa9776.entry.js} +10 -10
  90. package/dist/lime-elements/p-72b9d03e.entry.js +1 -0
  91. package/dist/lime-elements/p-80162ba0.entry.js +1 -0
  92. package/dist/lime-elements/p-86ff06d1.entry.js +1 -0
  93. package/dist/lime-elements/p-9W8bTt2G.js +1 -0
  94. package/dist/lime-elements/p-B--C3qwe.js +1 -0
  95. package/dist/lime-elements/p-B8yl2MCT.js +1 -0
  96. package/dist/lime-elements/p-BAR6am-7.js +1 -0
  97. package/dist/lime-elements/p-BCq5M9TE.js +1 -0
  98. package/dist/lime-elements/p-BE1Efiuj.js +1 -0
  99. package/dist/lime-elements/p-BYfPV0O4.js +1 -0
  100. package/dist/lime-elements/p-BcJ-TDVt.js +1 -0
  101. package/dist/lime-elements/p-BsX7ma3n.js +1 -0
  102. package/dist/lime-elements/p-Bu_YRgCL.js +1 -0
  103. package/dist/lime-elements/p-ByzvFNMm.js +1 -0
  104. package/dist/lime-elements/{p-CWuGCKo1.js → p-C4caLnTg.js} +1 -1
  105. package/dist/lime-elements/p-CR7u-m0b.js +1 -0
  106. package/dist/lime-elements/p-CVzgpz9P.js +1 -0
  107. package/dist/lime-elements/p-CZ30nDJE.js +1 -0
  108. package/dist/lime-elements/{p-BvDmWgCs.js → p-D0F7gOYG.js} +1 -1
  109. package/dist/lime-elements/p-D4RdItCq.js +1 -0
  110. package/dist/lime-elements/p-D8H5afYg.js +1 -0
  111. package/dist/lime-elements/p-DbBZn7JO.js +1 -0
  112. package/dist/lime-elements/p-DtrvybFR.js +1 -0
  113. package/dist/lime-elements/{p-8139d26a.entry.js → p-a712087a.entry.js} +3 -3
  114. package/dist/lime-elements/p-b1645d2d.entry.js +1 -0
  115. package/dist/lime-elements/{p-e720f65c.entry.js → p-d00ec6c2.entry.js} +3 -3
  116. package/dist/lime-elements/{p-a416d439.entry.js → p-e5c7cac0.entry.js} +2 -2
  117. package/dist/lime-elements/p-f6e58e6c.entry.js +1 -0
  118. package/dist/lime-elements/p-f867b424.entry.js +1 -0
  119. package/dist/lime-elements/p-mmkVLOjW.js +1 -0
  120. package/dist/types/components/email-viewer/email-viewer.d.ts +0 -1
  121. package/package.json +1 -1
  122. package/dist/cjs/limel-helper-line_2.cjs.entry.js +0 -107
  123. package/dist/cjs/limel-linear-progress.cjs.entry.js +0 -59
  124. package/dist/esm/limel-helper-line_2.entry.js +0 -104
  125. package/dist/esm/limel-linear-progress.entry.js +0 -57
  126. package/dist/lime-elements/p-4118be32.entry.js +0 -13
  127. package/dist/lime-elements/p-48db87d3.entry.js +0 -1
  128. package/dist/lime-elements/p-4e9baf08.entry.js +0 -1
  129. package/dist/lime-elements/p-59f1460d.entry.js +0 -1
  130. package/dist/lime-elements/p-7uuv3HUP.js +0 -1
  131. package/dist/lime-elements/p-811c4820.entry.js +0 -1
  132. package/dist/lime-elements/p-83e084f9.entry.js +0 -1
  133. package/dist/lime-elements/p-9a378cf0.entry.js +0 -1
  134. package/dist/lime-elements/p-BTHqaZIi.js +0 -1
  135. package/dist/lime-elements/p-Bj622DVt.js +0 -1
  136. package/dist/lime-elements/p-Bp0tNo1s.js +0 -1
  137. package/dist/lime-elements/p-C3Myy3mA.js +0 -1
  138. package/dist/lime-elements/p-CXgJVvTe.js +0 -1
  139. package/dist/lime-elements/p-CxfAgSVd.js +0 -1
  140. package/dist/lime-elements/p-DNIqLXTL.js +0 -1
  141. package/dist/lime-elements/p-D_uMnX5g.js +0 -1
  142. package/dist/lime-elements/p-DbC-smVQ.js +0 -1
  143. package/dist/lime-elements/p-DlJXKdhK.js +0 -1
  144. package/dist/lime-elements/p-DtS35Df5.js +0 -1
  145. package/dist/lime-elements/p-SvuA3Boo.js +0 -1
  146. package/dist/lime-elements/p-b306735b.entry.js +0 -1
  147. package/dist/lime-elements/p-c1c635c1.entry.js +0 -1
  148. package/dist/lime-elements/p-cebdd797.entry.js +0 -1
  149. package/dist/lime-elements/p-efBXH4mj.js +0 -1
  150. package/dist/lime-elements/p-f_1nwOC8.js +0 -1
  151. package/dist/lime-elements/p-fd4a4f87.entry.js +0 -1
  152. package/dist/lime-elements/p-v6b303K5.js +0 -1
@@ -0,0 +1 @@
1
+ import{r as t,c as e,h as r,H as i,a as n}from"./p-DBTJNfo7.js";import{E as s,L as o,M as l,e as u}from"./p-BWYo6dLf.js";import{g as h,m as a,s as f}from"./p-DdYOzHlg.js";import{h as c}from"./p-56bkn1D-.js";import{c as d}from"./p-DJvGLFul.js";import{t as p}from"./p-Dv3YcsA7.js";import{c as m}from"./p-JbKhhoXs.js";import{i as g}from"./p-CrvUOVvg.js";import{c as w}from"./p-C4caLnTg.js";import{i as b}from"./p-CVzgpz9P.js";import{d as v}from"./p-BviYUVSD.js";import"./p-B85MJLTf.js";import"./p-mmkVLOjW.js";import"./p-CZ30nDJE.js";import"./p-D4RdItCq.js";import"./p-BJQylLSL.js";import"./p-oiMYqRQ0.js";import"./p-BYfPV0O4.js";import"./p-BcJ-TDVt.js";import"./p-DbBZn7JO.js";import"./p-B8VKuhvH.js";import"./p-B--C3qwe.js";import"./p-ByzvFNMm.js";import"./p-9W8bTt2G.js";import"./p-BsX7ma3n.js";import"./p-BCq5M9TE.js";import"./p-Bu_YRgCL.js";import"./p-CgNJbSP4.js";import"./p-D6dCQvwl.js";import"./p-BOEi1C7r.js";function k(t){this.content=t}function D(t,e,r){for(let i=0;;i++){if(i==t.childCount||i==e.childCount)return t.childCount==e.childCount?null:r;let n=t.child(i),s=e.child(i);if(n!=s){if(!n.sameMarkup(s))return r;if(n.isText&&n.text!=s.text){for(let t=0;n.text[t]==s.text[t];t++)r++;return r}if(n.content.size||s.content.size){let t=D(n.content,s.content,r+1);if(null!=t)return t}r+=n.nodeSize}else r+=n.nodeSize}}function y(t,e,r,i){for(let n=t.childCount,s=e.childCount;;){if(0==n||0==s)return n==s?null:{a:r,b:i};let o=t.child(--n),l=e.child(--s),u=o.nodeSize;if(o!=l){if(!o.sameMarkup(l))return{a:r,b:i};if(o.isText&&o.text!=l.text){let t=0,e=Math.min(o.text.length,l.text.length);for(;t<e&&o.text[o.text.length-t-1]==l.text[l.text.length-t-1];)t++,r--,i--;return{a:r,b:i}}if(o.content.size||l.content.size){let t=y(o.content,l.content,r-1,i-1);if(t)return t}r-=u,i-=u}else r-=u,i-=u}}k.prototype={constructor:k,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return-1==e?void 0:this.content[e+1]},update:function(t,e,r){var i=r&&r!=t?this.remove(r):this,n=i.find(t),s=i.content.slice();return-1==n?s.push(r||t,e):(s[n+1]=e,r&&(s[n]=r)),new k(s)},remove:function(t){var e=this.find(t);if(-1==e)return this;var r=this.content.slice();return r.splice(e,2),new k(r)},addToStart:function(t,e){return new k([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var r=this.remove(t).content.slice();return r.push(t,e),new k(r)},addBefore:function(t,e,r){var i=this.remove(e),n=i.content.slice(),s=i.find(t);return n.splice(-1==s?n.length:s,0,e,r),new k(n)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return(t=k.from(t)).size?new k(t.content.concat(this.subtract(t).content)):this},append:function(t){return(t=k.from(t)).size?new k(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=k.from(t);for(var r=0;r<t.content.length;r+=2)e=e.remove(t.content[r]);return e},toObject:function(){var t={};return this.forEach((function(e,r){t[e]=r})),t},get size(){return this.content.length>>1}},k.from=function(t){if(t instanceof k)return t;var e=[];if(t)for(var r in t)e.push(r,t[r]);return new k(e)};class E{constructor(t,e){if(this.content=t,this.size=e||0,null==e)for(let e=0;e<t.length;e++)this.size+=t[e].nodeSize}nodesBetween(t,e,r,i=0,n){for(let s=0,o=0;o<e;s++){let l=this.content[s],u=o+l.nodeSize;if(u>t&&!1!==r(l,i+o,n||null,s)&&l.content.size){let n=o+1;l.nodesBetween(Math.max(0,t-n),Math.min(l.content.size,e-n),r,i+n)}o=u}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,r,i){let n="",s=!0;return this.nodesBetween(t,e,((o,l)=>{let u=o.isText?o.text.slice(Math.max(t,l)-l,e-l):o.isLeaf?i?"function"==typeof i?i(o):i:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&u||o.isTextblock)&&r&&(s?s=!1:n+=r),n+=u}),0),n}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,r=t.firstChild,i=this.content.slice(),n=0;for(e.isText&&e.sameMarkup(r)&&(i[i.length-1]=e.withText(e.text+r.text),n=1);n<t.content.length;n++)i.push(t.content[n]);return new E(i,this.size+t.size)}cut(t,e=this.size){if(0==t&&e==this.size)return this;let r=[],i=0;if(e>t)for(let n=0,s=0;s<e;n++){let o=this.content[n],l=s+o.nodeSize;l>t&&((s<t||l>e)&&(o=o.isText?o.cut(Math.max(0,t-s),Math.min(o.text.length,e-s)):o.cut(Math.max(0,t-s-1),Math.min(o.content.size,e-s-1))),r.push(o),i+=o.nodeSize),s=l}return new E(r,i)}cutByIndex(t,e){return t==e?E.empty:0==t&&e==this.content.length?this:new E(this.content.slice(t,e))}replaceChild(t,e){let r=this.content[t];if(r==e)return this;let i=this.content.slice(),n=this.size+e.nodeSize-r.nodeSize;return i[t]=e,new E(i,n)}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(t){if(this.content.length!=t.content.length)return!1;for(let e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))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(t){let e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e}maybeChild(t){return this.content[t]||null}forEach(t){for(let e=0,r=0;e<this.content.length;e++){let i=this.content[e];t(i,r,e),r+=i.nodeSize}}findDiffStart(t,e=0){return D(this,t,e)}findDiffEnd(t,e=this.size,r=t.size){return y(this,t,e,r)}findIndex(t,e=-1){if(0==t)return F(0,t);if(t==this.size)return F(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let r=0,i=0;;r++){let n=i+this.child(r).nodeSize;if(n>=t)return n==t||e>0?F(r+1,n):F(r,i);i=n}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((t=>t.toJSON())):null}static fromJSON(t,e){if(!e)return E.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new E(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return E.empty;let e,r=0;for(let i=0;i<t.length;i++){let n=t[i];r+=n.nodeSize,i&&n.isText&&t[i-1].sameMarkup(n)?(e||(e=t.slice(0,i)),e[e.length-1]=n.withText(e[e.length-1].text+n.text)):e&&e.push(n)}return new E(e||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 new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}E.empty=new E([],0);const x={index:0,offset:0};function F(t,e){return x.index=t,x.offset=e,x}function M(t,e){if(t===e)return!0;if(!t||"object"!=typeof t||!e||"object"!=typeof e)return!1;let r=Array.isArray(t);if(Array.isArray(e)!=r)return!1;if(r){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!M(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!M(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}class C{constructor(t,e){this.type=t,this.attrs=e}addToSet(t){let e,r=!1;for(let i=0;i<t.length;i++){let n=t[i];if(this.eq(n))return t;if(this.type.excludes(n.type))e||(e=t.slice(0,i));else{if(n.type.excludes(this.type))return t;!r&&n.type.rank>this.type.rank&&(e||(e=t.slice(0,i)),e.push(this),r=!0),e&&e.push(n)}}return e||(e=t.slice()),r||e.push(this),e}removeFromSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t}isInSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return!0;return!1}eq(t){return this==t||this.type==t.type&&M(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");let r=t.marks[e.type];if(!r)throw new RangeError(`There is no mark type ${e.type} in this schema`);let i=r.create(e.attrs);return r.checkAttrs(i.attrs),i}static sameSet(t,e){if(t==e)return!0;if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!t[r].eq(e[r]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&0==t.length)return C.none;if(t instanceof C)return[t];let e=t.slice();return e.sort(((t,e)=>t.type.rank-e.type.rank)),e}}C.none=[];class A extends Error{}class S{constructor(t,e,r){this.content=t,this.openStart=e,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,e){let r=$(this.content,t+this.openStart,e);return r&&new S(r,this.openStart,this.openEnd)}removeBetween(t,e){return new S(O(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,e){if(!e)return S.empty;let r=e.openStart||0,i=e.openEnd||0;if("number"!=typeof r||"number"!=typeof i)throw new RangeError("Invalid input for Slice.fromJSON");return new S(E.fromJSON(t,e.content),r,i)}static maxOpen(t,e=!0){let r=0,i=0;for(let i=t.firstChild;i&&!i.isLeaf&&(e||!i.type.spec.isolating);i=i.firstChild)r++;for(let r=t.lastChild;r&&!r.isLeaf&&(e||!r.type.spec.isolating);r=r.lastChild)i++;return new S(t,r,i)}}function O(t,e,r){let{index:i,offset:n}=t.findIndex(e),s=t.maybeChild(i),{index:o,offset:l}=t.findIndex(r);if(n==e||s.isText){if(l!=r&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(r))}if(i!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(i,s.copy(O(s.content,e-n-1,r-n-1)))}function $(t,e,r){let{index:i,offset:n}=t.findIndex(e),s=t.maybeChild(i);if(n==e||s.isText)return t.cut(0,e).append(r).append(t.cut(e));let o=$(s.content,e-n-1,r);return o&&t.replaceChild(i,s.copy(o))}function B(t,e,r){if(r.openStart>t.depth)throw new A("Inserted content deeper than insertion position");if(t.depth-r.openStart!=e.depth-r.openEnd)throw new A("Inconsistent open depths");return R(t,e,r,0)}function R(t,e,r,i){let n=t.index(i),s=t.node(i);if(n==e.index(i)&&i<t.depth-r.openStart){let o=R(t,e,r,i+1);return s.copy(s.content.replaceChild(n,o))}if(r.content.size){if(r.openStart||r.openEnd||t.depth!=i||e.depth!=i){let{start:n,end:o}=function(t,e){let r=e.depth-t.openStart,i=e.node(r).copy(t.content);for(let t=r-1;t>=0;t--)i=e.node(t).copy(E.from(i));return{start:i.resolveNoCache(t.openStart+r),end:i.resolveNoCache(i.content.size-t.openEnd-r)}}(r,t);return q(s,I(t,n,o,e,i))}{let i=t.parent,n=i.content;return q(i,n.cut(0,t.parentOffset).append(r.content).append(n.cut(e.parentOffset)))}}return q(s,j(t,e,i))}function N(t,e){if(!e.type.compatibleContent(t.type))throw new A("Cannot join "+e.type.name+" onto "+t.type.name)}function _(t,e,r){let i=t.node(r);return N(i,e.node(r)),i}function T(t,e){let r=e.length-1;r>=0&&t.isText&&t.sameMarkup(e[r])?e[r]=t.withText(e[r].text+t.text):e.push(t)}function z(t,e,r,i){let n=(e||t).node(r),s=0,o=e?e.index(r):n.childCount;t&&(s=t.index(r),t.depth>r?s++:t.textOffset&&(T(t.nodeAfter,i),s++));for(let t=s;t<o;t++)T(n.child(t),i);e&&e.depth==r&&e.textOffset&&T(e.nodeBefore,i)}function q(t,e){return t.type.checkContent(e),t.copy(e)}function I(t,e,r,i,n){let s=t.depth>n&&_(t,e,n+1),o=i.depth>n&&_(r,i,n+1),l=[];return z(null,t,n,l),s&&o&&e.index(n)==r.index(n)?(N(s,o),T(q(s,I(t,e,r,i,n+1)),l)):(s&&T(q(s,j(t,e,n+1)),l),z(e,r,n,l),o&&T(q(o,j(r,i,n+1)),l)),z(i,null,n,l),new E(l)}function j(t,e,r){let i=[];return z(null,t,r,i),t.depth>r&&T(q(_(t,e,r+1),j(t,e,r+1)),i),z(e,null,r,i),new E(i)}S.empty=new S(E.empty,0,0);class P{constructor(t,e,r){this.pos=t,this.path=e,this.parentOffset=r,this.depth=e.length/3-1}resolveDepth(t){return null==t?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[3*this.resolveDepth(t)]}index(t){return this.path[3*this.resolveDepth(t)+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t!=this.depth||this.textOffset?1:0)}start(t){return 0==(t=this.resolveDepth(t))?0:this.path[3*t-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]}after(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]+this.path[3*t].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=t.child(e);return r?t.child(e).cut(r):i}get nodeBefore(){let t=this.index(this.depth),e=this.pos-this.path[this.path.length-1];return e?this.parent.child(t).cut(0,e):0==t?null:this.parent.child(t-1)}posAtIndex(t,e){e=this.resolveDepth(e);let r=this.path[3*e],i=0==e?0:this.path[3*e-1]+1;for(let e=0;e<t;e++)i+=r.child(e).nodeSize;return i}marks(){let t=this.parent,e=this.index();if(0==t.content.size)return C.none;if(this.textOffset)return t.child(e).marks;let r=t.maybeChild(e-1),i=t.maybeChild(e);if(!r){let t=r;r=i,i=t}let n=r.marks;for(var s=0;s<n.length;s++)!1!==n[s].type.spec.inclusive||i&&n[s].isInSet(i.marks)||(n=n[s--].removeFromSet(n));return n}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let r=e.marks,i=t.parent.maybeChild(t.index());for(var n=0;n<r.length;n++)!1!==r[n].type.spec.inclusive||i&&r[n].isInSet(i.marks)||(r=r[n--].removeFromSet(r));return r}sharedDepth(t){for(let e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0}blockRange(t=this,e){if(t.pos<this.pos)return t.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);r>=0;r--)if(t.pos<=this.end(r)&&(!e||e(this.node(r))))return new V(this,t,r);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset}static resolve(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");let r=[],i=0,n=e;for(let e=t;;){let{index:t,offset:s}=e.content.findIndex(n),o=n-s;if(r.push(e,t,i+s),!o)break;if(e=e.child(t),e.isText)break;n=o-1,i+=s+1}return new P(e,r,n)}static resolveCached(t,e){let r=U.get(t);if(r)for(let t=0;t<r.elts.length;t++){let i=r.elts[t];if(i.pos==e)return i}else U.set(t,r=new L);let i=r.elts[r.i]=P.resolve(t,e);return r.i=(r.i+1)%J,i}}class L{constructor(){this.elts=[],this.i=0}}const J=12,U=new WeakMap;class V{constructor(t,e,r){this.$from=t,this.$to=e,this.depth=r}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)}}const H=Object.create(null);class W{constructor(t,e,r,i=C.none){this.type=t,this.attrs=e,this.marks=i,this.content=r||E.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,e,r,i=0){this.content.nodesBetween(t,e,r,i,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,e,r,i){return this.content.textBetween(t,e,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,e,r){return this.type==t&&M(this.attrs,e||t.defaultAttrs||H)&&C.sameSet(this.marks,r||C.none)}copy(t=null){return t==this.content?this:new W(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new W(this.type,this.attrs,this.content,t)}cut(t,e=this.content.size){return 0==t&&e==this.content.size?this:this.copy(this.content.cut(t,e))}slice(t,e=this.content.size,r=!1){if(t==e)return S.empty;let i=this.resolve(t),n=this.resolve(e),s=r?0:i.sharedDepth(e),o=i.start(s),l=i.node(s).content.cut(i.pos-o,n.pos-o);return new S(l,i.depth-s,n.depth-s)}replace(t,e,r){return B(this.resolve(t),this.resolve(e),r)}nodeAt(t){for(let e=this;;){let{index:r,offset:i}=e.content.findIndex(t);if(e=e.maybeChild(r),!e)return null;if(i==t||e.isText)return e;t-=i+1}}childAfter(t){let{index:e,offset:r}=this.content.findIndex(t);return{node:this.content.maybeChild(e),index:e,offset:r}}childBefore(t){if(0==t)return{node:null,index:0,offset:0};let{index:e,offset:r}=this.content.findIndex(t);if(r<t)return{node:this.content.child(e),index:e,offset:r};let i=this.content.child(e-1);return{node:i,index:e-1,offset:r-i.nodeSize}}resolve(t){return P.resolveCached(this,t)}resolveNoCache(t){return P.resolve(this,t)}rangeHasMark(t,e,r){let i=!1;return e>t&&this.nodesBetween(t,e,(t=>(r.isInSet(t.marks)&&(i=!0),!i))),i}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 t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),Z(this.marks,t)}contentMatchAt(t){let e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e}canReplace(t,e,r=E.empty,i=0,n=r.childCount){let s=this.contentMatchAt(t).matchFragment(r,i,n),o=s&&s.matchFragment(this.content,e);if(!o||!o.validEnd)return!1;for(let t=i;t<n;t++)if(!this.type.allowsMarks(r.child(t).marks))return!1;return!0}canReplaceWith(t,e,r,i){if(i&&!this.type.allowsMarks(i))return!1;let n=this.contentMatchAt(t).matchType(r),s=n&&n.matchFragment(this.content,e);return!!s&&s.validEnd}canAppend(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let t=C.none;for(let e=0;e<this.marks.length;e++){let r=this.marks[e];r.type.checkAttrs(r.attrs),t=r.addToSet(t)}if(!C.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((t=>t.type.name))}`);this.content.forEach((t=>t.check()))}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map((t=>t.toJSON()))),t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");let r;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=e.marks.map(t.markFromJSON)}if("text"==e.type){if("string"!=typeof e.text)throw new RangeError("Invalid text node in JSON");return t.text(e.text,r)}let i=E.fromJSON(t,e.content),n=t.nodeType(e.type).create(e.attrs,i,r);return n.type.checkAttrs(n.attrs),n}}W.prototype.text=void 0;class G extends W{constructor(t,e,r,i){if(super(t,e,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Z(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,e){return this.text.slice(t,e)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new G(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new G(this.type,this.attrs,t,this.marks)}cut(t=0,e=this.text.length){return 0==t&&e==this.text.length?this:this.withText(this.text.slice(t,e))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}}function Z(t,e){for(let r=t.length-1;r>=0;r--)e=t[r].type.name+"("+e+")";return e}class K{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,e){let r=new Y(t,e);if(null==r.next)return K.empty;let i=X(r);r.next&&r.err("Unexpected trailing text");let n=function(t){let e=Object.create(null);return function r(i){let n=[];i.forEach((e=>{t[e].forEach((({term:e,to:r})=>{if(!e)return;let i;for(let t=0;t<n.length;t++)n[t][0]==e&&(i=n[t][1]);nt(t,r).forEach((t=>{i||n.push([e,i=[]]),-1==i.indexOf(t)&&i.push(t)}))}))}));let s=e[i.join(",")]=new K(i.indexOf(t.length-1)>-1);for(let t=0;t<n.length;t++){let i=n[t][1].sort(it);s.next.push({type:n[t][0],next:e[i.join(",")]||r(i)})}return s}(nt(t,0))}(function(t){let e=[[]];return n(function t(e,s){if("choice"==e.type)return e.exprs.reduce(((e,r)=>e.concat(t(r,s))),[]);if("seq"!=e.type){if("star"==e.type){let o=r();return i(s,o),n(t(e.expr,o),o),[i(o)]}if("plus"==e.type){let o=r();return n(t(e.expr,s),o),n(t(e.expr,o),o),[i(o)]}if("opt"==e.type)return[i(s)].concat(t(e.expr,s));if("range"==e.type){let o=s;for(let i=0;i<e.min;i++){let i=r();n(t(e.expr,o),i),o=i}if(-1==e.max)n(t(e.expr,o),o);else for(let s=e.min;s<e.max;s++){let s=r();i(o,s),n(t(e.expr,o),s),o=s}return[i(o)]}if("name"==e.type)return[i(s,void 0,e.value)];throw new Error("Unknown expr type")}for(let i=0;;i++){let o=t(e.exprs[i],s);if(i==e.exprs.length-1)return o;n(o,s=r())}}(t,0),r()),e;function r(){return e.push([])-1}function i(t,r,i){let n={term:i,to:r};return e[t].push(n),n}function n(t,e){t.forEach((t=>t.to=e))}}(i));return function(t,e){for(let r=0,i=[t];r<i.length;r++){let t=i[r],n=!t.validEnd,s=[];for(let e=0;e<t.next.length;e++){let{type:r,next:o}=t.next[e];s.push(r.name),!n||r.isText||r.hasRequiredAttrs()||(n=!1),-1==i.indexOf(o)&&i.push(o)}n&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(n,r),n}matchType(t){for(let e=0;e<this.next.length;e++)if(this.next[e].type==t)return this.next[e].next;return null}matchFragment(t,e=0,r=t.childCount){let i=this;for(let n=e;i&&n<r;n++)i=i.matchType(t.child(n).type);return i}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:e}=this.next[t];if(!e.isText&&!e.hasRequiredAttrs())return e}return null}compatible(t){for(let e=0;e<this.next.length;e++)for(let r=0;r<t.next.length;r++)if(this.next[e].type==t.next[r].type)return!0;return!1}fillBefore(t,e=!1,r=0){let i=[this];return function n(s,o){let l=s.matchFragment(t,r);if(l&&(!e||l.validEnd))return E.from(o.map((t=>t.createAndFill())));for(let t=0;t<s.next.length;t++){let{type:e,next:r}=s.next[t];if(!e.isText&&!e.hasRequiredAttrs()&&-1==i.indexOf(r)){i.push(r);let t=n(r,o.concat(e));if(t)return t}}return null}(this,[])}findWrapping(t){for(let e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];let e=this.computeWrapping(t);return this.wrapCache.push(t,e),e}computeWrapping(t){let e=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),n=i.match;if(n.matchType(t)){let t=[];for(let e=i;e.type;e=e.via)t.push(e.type);return t.reverse()}for(let t=0;t<n.next.length;t++){let{type:s,next:o}=n.next[t];s.isLeaf||s.hasRequiredAttrs()||s.name in e||i.type&&!o.validEnd||(r.push({match:s.contentMatch,type:s,via:i}),e[s.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];return function e(r){t.push(r);for(let i=0;i<r.next.length;i++)-1==t.indexOf(r.next[i].next)&&e(r.next[i].next)}(this),t.map(((e,r)=>{let i=r+(e.validEnd?"*":" ")+" ";for(let r=0;r<e.next.length;r++)i+=(r?", ":"")+e.next[r].type.name+"->"+t.indexOf(e.next[r].next);return i})).join("\n")}}K.empty=new K(!0);class Y{constructor(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.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(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}}function X(t){let e=[];do{e.push(Q(t))}while(t.eat("|"));return 1==e.length?e[0]:{type:"choice",exprs:e}}function Q(t){let e=[];do{e.push(tt(t))}while(t.next&&")"!=t.next&&"|"!=t.next);return 1==e.length?e[0]:{type:"seq",exprs:e}}function tt(t){let e=function(t){if(t.eat("(")){let e=X(t);return t.eat(")")||t.err("Missing closing paren"),e}if(!/\W/.test(t.next)){let e=function(t,e){let r=t.nodeTypes,i=r[e];if(i)return[i];let n=[];for(let t in r){let i=r[t];i.groups.indexOf(e)>-1&&n.push(i)}return 0==n.length&&t.err("No node type or group '"+e+"' found"),n}(t,t.next).map((e=>(null==t.inline?t.inline=e.isInline:t.inline!=e.isInline&&t.err("Mixing inline and block content"),{type:"name",value:e})));return t.pos++,1==e.length?e[0]:{type:"choice",exprs:e}}t.err("Unexpected token '"+t.next+"'")}(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else{if(!t.eat("{"))break;e=rt(t,e)}return e}function et(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function rt(t,e){let r=et(t),i=r;return t.eat(",")&&(i="}"!=t.next?et(t):-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:r,max:i,expr:e}}function it(t,e){return e-t}function nt(t,e){let r=[];return function e(i){let n=t[i];if(1==n.length&&!n[0].term)return e(n[0].to);r.push(i);for(let t=0;t<n.length;t++){let{term:i,to:s}=n[t];i||-1!=r.indexOf(s)||e(s)}}(e),r.sort(it)}function st(t){let e=Object.create(null);for(let r in t){let i=t[r];if(!i.hasDefault)return null;e[r]=i.default}return e}function ot(t,e){let r=Object.create(null);for(let i in t){let n=e&&e[i];if(void 0===n){let e=t[i];if(!e.hasDefault)throw new RangeError("No value supplied for attribute "+i);n=e.default}r[i]=n}return r}function lt(t,e,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${r} of type ${i}`);for(let r in t){let i=t[r];i.validate&&i.validate(e[r])}}function ut(t,e){let r=Object.create(null);if(e)for(let i in e)r[i]=new at(t,i,e[i]);return r}let ht=class t{constructor(t,e,r){this.name=t,this.schema=e,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=ut(t,r.attrs),this.defaultAttrs=st(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||"text"==t),this.isText="text"==t}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==K.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){return!t&&this.defaultAttrs?this.defaultAttrs:ot(this.attrs,t)}create(t=null,e,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new W(this,this.computeAttrs(t),E.from(e),C.setFrom(r))}createChecked(t=null,e,r){return e=E.from(e),this.checkContent(e),new W(this,this.computeAttrs(t),e,C.setFrom(r))}createAndFill(t=null,e,r){if(t=this.computeAttrs(t),(e=E.from(e)).size){let t=this.contentMatch.fillBefore(e);if(!t)return null;e=t.append(e)}let i=this.contentMatch.matchFragment(e),n=i&&i.fillBefore(E.empty,!0);return n?new W(this,t,e.append(n),C.setFrom(r)):null}validContent(t){let e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return!1;for(let e=0;e<t.childCount;e++)if(!this.allowsMarks(t.child(e).marks))return!1;return!0}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}checkAttrs(t){lt(this.attrs,t,"node")}allowsMarkType(t){return null==this.markSet||this.markSet.indexOf(t)>-1}allowsMarks(t){if(null==this.markSet)return!0;for(let e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return!1;return!0}allowedMarks(t){if(null==this.markSet)return t;let e;for(let r=0;r<t.length;r++)this.allowsMarkType(t[r].type)?e&&e.push(t[r]):e||(e=t.slice(0,r));return e?e.length?e:C.none:t}static compile(e,r){let i=Object.create(null);e.forEach(((e,n)=>i[e]=new t(e,r,n)));let n=r.spec.topNode||"doc";if(!i[n])throw new RangeError("Schema is missing its top node type ('"+n+"')");if(!i.text)throw new RangeError("Every schema needs a 'text' type");for(let t in i.text.attrs)throw new RangeError("The text node type should not have attributes");return i}};class at{constructor(t,e,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate="string"==typeof r.validate?function(t,e,r){let i=r.split("|");return r=>{let n=null===r?"null":typeof r;if(i.indexOf(n)<0)throw new RangeError(`Expected value of type ${i} for attribute ${e} on type ${t}, got ${n}`)}}(t,e,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class ft{constructor(t,e,r,i){this.name=t,this.rank=e,this.schema=r,this.spec=i,this.attrs=ut(t,i.attrs),this.excluded=null;let n=st(this.attrs);this.instance=n?new C(this,n):null}create(t=null){return!t&&this.instance?this.instance:new C(this,ot(this.attrs,t))}static compile(t,e){let r=Object.create(null),i=0;return t.forEach(((t,n)=>r[t]=new ft(t,i++,e,n))),r}removeFromSet(t){for(var e=0;e<t.length;e++)t[e].type==this&&(t=t.slice(0,e).concat(t.slice(e+1)),e--);return t}isInSet(t){for(let e=0;e<t.length;e++)if(t[e].type==this)return t[e]}checkAttrs(t){lt(this.attrs,t,"mark")}excludes(t){return this.excluded.indexOf(t)>-1}}class ct{constructor(t){this.linebreakReplacement=null,this.cached=Object.create(null);let e=this.spec={};for(let r in t)e[r]=t[r];e.nodes=k.from(t.nodes),e.marks=k.from(t.marks||{}),this.nodes=ht.compile(this.spec.nodes,this),this.marks=ft.compile(this.spec.marks,this);let r=Object.create(null);for(let t in this.nodes){if(t in this.marks)throw new RangeError(t+" can not be both a node and a mark");let e=this.nodes[t],i=e.spec.content||"",n=e.spec.marks;if(e.contentMatch=r[i]||(r[i]=K.parse(i,this.nodes)),e.inlineContent=e.contentMatch.inlineContent,e.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!e.isInline||!e.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=e}e.markSet="_"==n?null:n?dt(this,n.split(" ")):""!=n&&e.inlineContent?null:[]}for(let t in this.marks){let e=this.marks[t],r=e.spec.excludes;e.excluded=null==r?[e]:""==r?[]:dt(this,r.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(t,e=null,r,i){if("string"==typeof t)t=this.nodeType(t);else{if(!(t instanceof ht))throw new RangeError("Invalid node type: "+t);if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}return t.createChecked(e,r,i)}text(t,e){let r=this.nodes.text;return new G(r,r.defaultAttrs,t,C.setFrom(e))}mark(t,e){return"string"==typeof t&&(t=this.marks[t]),t.create(e)}nodeFromJSON(t){return W.fromJSON(this,t)}markFromJSON(t){return C.fromJSON(this,t)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}}function dt(t,e){let r=[];for(let i=0;i<e.length;i++){let n=e[i],s=t.marks[n],o=s;if(s)r.push(s);else for(let e in t.marks){let i=t.marks[e];("_"==n||i.spec.group&&i.spec.group.split(" ").indexOf(n)>-1)&&r.push(o=i)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[i]+"'")}return r}class pt{constructor(t,e){this.schema=t,this.rules=e,this.tags=[],this.styles=[];let r=this.matchedStyles=[];e.forEach((t=>{if(function(t){return null!=t.tag}(t))this.tags.push(t);else if(function(t){return null!=t.style}(t)){let e=/[^=]*/.exec(t.style)[0];r.indexOf(e)<0&&r.push(e),this.styles.push(t)}})),this.normalizeLists=!this.tags.some((e=>{if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return!1;let r=t.nodes[e.node];return r.contentMatch.matchType(r)}))}parse(t,e={}){let r=new kt(this,e,!1);return r.addAll(t,C.none,e.from,e.to),r.finish()}parseSlice(t,e={}){let r=new kt(this,e,!0);return r.addAll(t,C.none,e.from,e.to),S.maxOpen(r.finish())}matchTag(t,e,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let r=this.tags[i];if(Dt(t,r.tag)&&(void 0===r.namespace||t.namespaceURI==r.namespace)&&(!r.context||e.matchesContext(r.context))){if(r.getAttrs){let e=r.getAttrs(t);if(!1===e)continue;r.attrs=e||void 0}return r}}}matchStyle(t,e,r,i){for(let n=i?this.styles.indexOf(i)+1:0;n<this.styles.length;n++){let i=this.styles[n],s=i.style;if(!(0!=s.indexOf(t)||i.context&&!r.matchesContext(i.context)||s.length>t.length&&(61!=s.charCodeAt(t.length)||s.slice(t.length+1)!=e))){if(i.getAttrs){let t=i.getAttrs(e);if(!1===t)continue;i.attrs=t||void 0}return i}}}static schemaRules(t){let e=[];function r(t){let r=null==t.priority?50:t.priority,i=0;for(;i<e.length;i++){let t=e[i];if((null==t.priority?50:t.priority)<r)break}e.splice(i,0,t)}for(let e in t.marks){let i=t.marks[e].spec.parseDOM;i&&i.forEach((t=>{r(t=yt(t)),t.mark||t.ignore||t.clearMark||(t.mark=e)}))}for(let e in t.nodes){let i=t.nodes[e].spec.parseDOM;i&&i.forEach((t=>{r(t=yt(t)),t.node||t.ignore||t.mark||(t.node=e)}))}return e}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new pt(t,pt.schemaRules(t)))}}const mt={address:!0,article:!0,aside:!0,blockquote:!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},gt={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},wt={ol:!0,ul:!0};function bt(t,e,r){return null!=e?(e?1:0)|("full"===e?2:0):t&&"pre"==t.whitespace?3:-5&r}class vt{constructor(t,e,r,i,n,s){this.type=t,this.attrs=e,this.marks=r,this.solid=i,this.options=s,this.content=[],this.activeMarks=C.none,this.match=n||(4&s?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(E.from(t));if(!e){let e,r=this.type.contentMatch;return(e=r.findWrapping(t.type))?(this.match=r,e):null}this.match=this.type.contentMatch.matchFragment(e)}return this.match.findWrapping(t.type)}finish(t){if(!(1&this.options)){let t,e=this.content[this.content.length-1];if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let r=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=r.withText(r.text.slice(0,r.text.length-t[0].length))}}let e=E.from(this.content);return!t&&this.match&&(e=e.append(this.match.fillBefore(E.empty,!0))),this.type?this.type.create(this.attrs,e,this.marks):e}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!mt.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class kt{constructor(t,e,r){this.parser=t,this.options=e,this.isOpen=r,this.open=0;let i,n=e.topNode,s=bt(null,e.preserveWhitespace,0)|(r?4:0);i=n?new vt(n.type,n.attrs,C.none,!0,e.topMatch||n.type.contentMatch,s):new vt(r?null:t.schema.topNodeType,null,C.none,!0,null,s),this.nodes=[i],this.find=e.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t,e){3==t.nodeType?this.addTextNode(t,e):1==t.nodeType&&this.addElement(t,e)}addTextNode(t,e){let r=t.nodeValue,i=this.top;if(2&i.options||i.inlineContext(t)||/[^ \t\r\n\u000c]/.test(r)){if(1&i.options)r=2&i.options?r.replace(/\r\n?/g,"\n"):r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let e=i.content[i.content.length-1],n=t.previousSibling;(!e||n&&"BR"==n.nodeName||e.isText&&/[ \t\r\n\u000c]$/.test(e.text))&&(r=r.slice(1))}r&&this.insertNode(this.parser.schema.text(r),e),this.findInText(t)}else this.findInside(t)}addElement(t,e,r){let i,n=t.nodeName.toLowerCase();wt.hasOwnProperty(n)&&this.parser.normalizeLists&&function(t){for(let e=t.firstChild,r=null;e;e=e.nextSibling){let t=1==e.nodeType?e.nodeName.toLowerCase():null;t&&wt.hasOwnProperty(t)&&r?(r.appendChild(e),e=r):"li"==t?r=e:t&&(r=null)}}(t);let s=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(i=this.parser.matchTag(t,this,r));if(s?s.ignore:gt.hasOwnProperty(n))this.findInside(t),this.ignoreFallback(t,e);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(t=s.skip);let r,i=this.top,o=this.needsBlock;if(mt.hasOwnProperty(n))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),r=!0,i.type||(this.needsBlock=!0);else if(!t.firstChild)return void this.leafFallback(t,e);let l=s&&s.skip?e:this.readStyles(t,e);l&&this.addAll(t,l),r&&this.sync(i),this.needsBlock=o}else{let r=this.readStyles(t,e);r&&this.addElementByRule(t,s,r,!1===s.consuming?i:void 0)}}leafFallback(t,e){"BR"==t.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode("\n"),e)}ignoreFallback(t,e){"BR"!=t.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),e)}readStyles(t,e){let r=t.style;if(r&&r.length)for(let t=0;t<this.parser.matchedStyles.length;t++){let i=this.parser.matchedStyles[t],n=r.getPropertyValue(i);if(n)for(let t;;){let r=this.parser.matchStyle(i,n,this,t);if(!r)break;if(r.ignore)return null;if(e=r.clearMark?e.filter((t=>!r.clearMark(t))):e.concat(this.parser.schema.marks[r.mark].create(r.attrs)),!1!==r.consuming)break;t=r}}return e}addElementByRule(t,e,r,i){let n,s;if(e.node)if(s=this.parser.schema.nodes[e.node],s.isLeaf)this.insertNode(s.create(e.attrs),r)||this.leafFallback(t,r);else{let t=this.enter(s,e.attrs||null,r,e.preserveWhitespace);t&&(n=!0,r=t)}else r=r.concat(this.parser.schema.marks[e.mark].create(e.attrs));let o=this.top;if(s&&s.isLeaf)this.findInside(t);else if(i)this.addElement(t,r,i);else if(e.getContent)this.findInside(t),e.getContent(t,this.parser.schema).forEach((t=>this.insertNode(t,r)));else{let i=t;"string"==typeof e.contentElement?i=t.querySelector(e.contentElement):"function"==typeof e.contentElement?i=e.contentElement(t):e.contentElement&&(i=e.contentElement),this.findAround(t,i,!0),this.addAll(i,r)}n&&this.sync(o)&&this.open--}addAll(t,e,r,i){let n=r||0;for(let s=r?t.childNodes[r]:t.firstChild,o=null==i?null:t.childNodes[i];s!=o;s=s.nextSibling,++n)this.findAtPoint(t,n),this.addDOM(s,e);this.findAtPoint(t,n)}findPlace(t,e){let r,i;for(let e=this.open;e>=0;e--){let n=this.nodes[e],s=n.findWrapping(t);if(s&&(!r||r.length>s.length)&&(r=s,i=n,!s.length))break;if(n.solid)break}if(!r)return null;this.sync(i);for(let t=0;t<r.length;t++)e=this.enterInner(r[t],null,e,!1);return e}insertNode(t,e){if(t.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();t&&(e=this.enterInner(t,null,e))}let r=this.findPlace(t,e);if(r){this.closeExtra();let e=this.top;e.match&&(e.match=e.match.matchType(t.type));let i=C.none;for(let n of r.concat(t.marks))(e.type?e.type.allowsMarkType(n.type):Et(n.type,t.type))&&(i=n.addToSet(i));return e.content.push(t.mark(i)),!0}return!1}enter(t,e,r,i){let n=this.findPlace(t.create(e),r);return n&&(n=this.enterInner(t,e,r,!0,i)),n}enterInner(t,e,r,i=!1,n){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(t);let o=bt(t,n,s.options);4&s.options&&0==s.content.length&&(o|=4);let l=C.none;return r=r.filter((e=>!(s.type?s.type.allowsMarkType(e.type):Et(e.type,t))||(l=e.addToSet(l),!1))),this.nodes.push(new vt(t,e,l,i,null,o)),this.open++,r}closeExtra(t=!1){let e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));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(t){for(let e=this.open;e>=0;e--)if(this.nodes[e]==t)return this.open=e,!0;return!1}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let r=this.nodes[e].content;for(let e=r.length-1;e>=0;e--)t+=r[e].nodeSize;e&&t++}return t}findAtPoint(t,e){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==t&&this.find[r].offset==e&&(this.find[r].pos=this.currentPos)}findInside(t){if(this.find)for(let e=0;e<this.find.length;e++)null==this.find[e].pos&&1==t.nodeType&&t.contains(this.find[e].node)&&(this.find[e].pos=this.currentPos)}findAround(t,e,r){if(t!=e&&this.find)for(let i=0;i<this.find.length;i++)null==this.find[i].pos&&1==t.nodeType&&t.contains(this.find[i].node)&&e.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(t){if(this.find)for(let e=0;e<this.find.length;e++)this.find[e].node==t&&(this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let e=t.split("/"),r=this.options.context,i=!(this.isOpen||r&&r.parent.type!=this.nodes[0].type),n=(i?0:1)-(r?r.depth+1:0),s=(t,o)=>{for(;t>=0;t--){let l=e[t];if(""==l){if(t==e.length-1||0==t)continue;for(;o>=n;o--)if(s(t-1,o))return!0;return!1}{let t=o>0||0==o&&i?this.nodes[o].type:r&&o>=n?r.node(o-n).type:null;if(!t||t.name!=l&&-1==t.groups.indexOf(l))return!1;o--}}return!0};return s(e.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let e=t.depth;e>=0;e--){let r=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let e=this.parser.schema.nodes[t];if(e.isTextblock&&e.defaultAttrs)return e}}}function Dt(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function yt(t){let e={};for(let r in t)e[r]=t[r];return e}function Et(t,e){let r=e.schema.nodes;for(let i in r){let n=r[i];if(!n.allowsMarkType(t))continue;let s=[],o=t=>{s.push(t);for(let r=0;r<t.edgeCount;r++){let{type:i,next:n}=t.edge(r);if(i==e)return!0;if(s.indexOf(n)<0&&o(n))return!0}};if(o(n.contentMatch))return!0}}class xt{constructor(t,e){this.nodes=t,this.marks=e}serializeFragment(t,e={},r){r||(r=Mt(e).createDocumentFragment());let i=r,n=[];return t.forEach((t=>{if(n.length||t.marks.length){let r=0,s=0;for(;r<n.length&&s<t.marks.length;){let e=t.marks[s];if(this.marks[e.type.name]){if(!e.eq(n[r][0])||!1===e.type.spec.spanning)break;r++,s++}else s++}for(;r<n.length;)i=n.pop()[1];for(;s<t.marks.length;){let r=t.marks[s++],o=this.serializeMark(r,t.isInline,e);o&&(n.push([r,i]),i.appendChild(o.dom),i=o.contentDOM||o.dom)}}i.appendChild(this.serializeNodeInner(t,e))})),r}serializeNodeInner(t,e){let{dom:r,contentDOM:i}=At(Mt(e),this.nodes[t.type.name](t),null,t.attrs);if(i){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,e,i)}return r}serializeNode(t,e={}){let r=this.serializeNodeInner(t,e);for(let i=t.marks.length-1;i>=0;i--){let n=this.serializeMark(t.marks[i],t.isInline,e);n&&((n.contentDOM||n.dom).appendChild(r),r=n.dom)}return r}serializeMark(t,e,r={}){let i=this.marks[t.type.name];return i&&At(Mt(r),i(t,e),null,t.attrs)}static renderSpec(t,e,r=null,i){return At(t,e,r,i)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new xt(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let e=Ft(t.nodes);return e.text||(e.text=t=>t.text),e}static marksFromSchema(t){return Ft(t.marks)}}function Ft(t){let e={};for(let r in t){let i=t[r].spec.toDOM;i&&(e[r]=i)}return e}function Mt(t){return t.document||window.document}const Ct=new WeakMap;function At(t,e,r,i){if("string"==typeof e)return{dom:t.createTextNode(e)};if(null!=e.nodeType)return{dom:e};if(e.dom&&null!=e.dom.nodeType)return e;let n,s=e[0];if("string"!=typeof s)throw new RangeError("Invalid array passed to renderSpec");if(i&&(n=function(t){let e=Ct.get(t);return void 0===e&&Ct.set(t,e=function(t){let e=null;return function t(r){if(r&&"object"==typeof r)if(Array.isArray(r))if("string"==typeof r[0])e||(e=[]),e.push(r);else for(let e=0;e<r.length;e++)t(r[e]);else for(let e in r)t(r[e])}(t),e}(t)),e}(i))&&n.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o,l=s.indexOf(" ");l>0&&(r=s.slice(0,l),s=s.slice(l+1));let u=r?t.createElementNS(r,s):t.createElement(s),h=e[1],a=1;if(h&&"object"==typeof h&&null==h.nodeType&&!Array.isArray(h)){a=2;for(let t in h)if(null!=h[t]){let e=t.indexOf(" ");e>0?u.setAttributeNS(t.slice(0,e),t.slice(e+1),h[t]):u.setAttribute(t,h[t])}}for(let n=a;n<e.length;n++){let s=e[n];if(0===s){if(n<e.length-1||n>a)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}{let{dom:e,contentDOM:n}=At(t,s,r,i);if(u.appendChild(e),n){if(o)throw new RangeError("Multiple content holes");o=n}}}return{dom:u,contentDOM:o}}const St=Math.pow(2,16);function Ot(t){return 65535&t}class $t{constructor(t,e,r){this.pos=t,this.delInfo=e,this.recover=r}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class Bt{constructor(t,e=!1){if(this.ranges=t,this.inverted=e,!t.length&&Bt.empty)return Bt.empty}recover(t){let e=0,r=Ot(t);if(!this.inverted)for(let t=0;t<r;t++)e+=this.ranges[3*t+2]-this.ranges[3*t+1];return this.ranges[3*r]+e+function(t){return(t-(65535&t))/St}(t)}mapResult(t,e=1){return this._map(t,e,!1)}map(t,e=1){return this._map(t,e,!0)}_map(t,e,r){let i=0,n=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let l=this.ranges[o]-(this.inverted?i:0);if(l>t)break;let u=this.ranges[o+n],h=this.ranges[o+s],a=l+u;if(t<=a){let n=l+i+((u?t==l?-1:t==a?1:e:e)<0?0:h);if(r)return n;let s=t==l?2:t==a?1:4;return(e<0?t!=l:t!=a)&&(s|=8),new $t(n,s,t==(e<0?l:a)?null:o/3+(t-l)*St)}i+=h-u}return r?t+i:new $t(t+i,0,null)}touches(t,e){let r=0,i=Ot(e),n=this.inverted?2:1,s=this.inverted?1:2;for(let e=0;e<this.ranges.length;e+=3){let o=this.ranges[e]-(this.inverted?r:0);if(o>t)break;let l=this.ranges[e+n];if(t<=o+l&&e==3*i)return!0;r+=this.ranges[e+s]-l}return!1}forEach(t){let e=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,n=0;i<this.ranges.length;i+=3){let s=this.ranges[i],o=s-(this.inverted?n:0),l=s+(this.inverted?0:n),u=this.ranges[i+e],h=this.ranges[i+r];t(o,o+u,l,l+h),n+=h-u}}invert(){return new Bt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return 0==t?Bt.empty:new Bt(t<0?[0,-t,0]:[0,0,t])}}Bt.empty=new Bt([]);class Rt{constructor(t=[],e,r=0,i=t.length){this.maps=t,this.mirror=e,this.from=r,this.to=i}slice(t=0,e=this.maps.length){return new Rt(this.maps,this.mirror,t,e)}copy(){return new Rt(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(t,e){this.to=this.maps.push(t),null!=e&&this.setMirror(this.maps.length-1,e)}appendMapping(t){for(let e=0,r=this.maps.length;e<t.maps.length;e++){let i=t.getMirror(e);this.appendMap(t.maps[e],null!=i&&i<e?r+i:void 0)}}getMirror(t){if(this.mirror)for(let e=0;e<this.mirror.length;e++)if(this.mirror[e]==t)return this.mirror[e+(e%2?-1:1)]}setMirror(t,e){this.mirror||(this.mirror=[]),this.mirror.push(t,e)}appendMappingInverted(t){for(let e=t.maps.length-1,r=this.maps.length+t.maps.length;e>=0;e--){let i=t.getMirror(e);this.appendMap(t.maps[e].invert(),null!=i&&i>e?r-i-1:void 0)}}invert(){let t=new Rt;return t.appendMappingInverted(this),t}map(t,e=1){if(this.mirror)return this._map(t,e,!0);for(let r=this.from;r<this.to;r++)t=this.maps[r].map(t,e);return t}mapResult(t,e=1){return this._map(t,e,!1)}_map(t,e,r){let i=0;for(let r=this.from;r<this.to;r++){let n=this.maps[r].mapResult(t,e);if(null!=n.recover){let e=this.getMirror(r);if(null!=e&&e>r&&e<this.to){r=e,t=this.maps[e].recover(n.recover);continue}}i|=n.delInfo,t=n.pos}return r?t:new $t(t,i,null)}}const Nt=Object.create(null);class _t{getMap(){return Bt.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Nt[e.stepType];if(!r)throw new RangeError(`No step type ${e.stepType} defined`);return r.fromJSON(t,e)}static jsonID(t,e){if(t in Nt)throw new RangeError("Duplicate use of step JSON ID "+t);return Nt[t]=e,e.prototype.jsonID=t,e}}class Tt{constructor(t,e){this.doc=t,this.failed=e}static ok(t){return new Tt(t,null)}static fail(t){return new Tt(null,t)}static fromReplace(t,e,r,i){try{return Tt.ok(t.replace(e,r,i))}catch(t){if(t instanceof A)return Tt.fail(t.message);throw t}}}function zt(t,e,r){let i=[];for(let n=0;n<t.childCount;n++){let s=t.child(n);s.content.size&&(s=s.copy(zt(s.content,e,s))),s.isInline&&(s=e(s,r,n)),i.push(s)}return E.fromArray(i)}class qt extends _t{constructor(t,e,r){super(),this.from=t,this.to=e,this.mark=r}apply(t){let e=t.slice(this.from,this.to),r=t.resolve(this.from),i=r.node(r.sharedDepth(this.to)),n=new S(zt(e.content,((t,e)=>t.isAtom&&e.type.allowsMarkType(this.mark.type)?t.mark(this.mark.addToSet(t.marks)):t),i),e.openStart,e.openEnd);return Tt.fromReplace(t,this.from,this.to,n)}invert(){return new It(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return e.deleted&&r.deleted||e.pos>=r.pos?null:new qt(e.pos,r.pos,this.mark)}merge(t){return t instanceof qt&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new qt(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,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new qt(e.from,e.to,t.markFromJSON(e.mark))}}_t.jsonID("addMark",qt);class It extends _t{constructor(t,e,r){super(),this.from=t,this.to=e,this.mark=r}apply(t){let e=t.slice(this.from,this.to),r=new S(zt(e.content,(t=>t.mark(this.mark.removeFromSet(t.marks))),t),e.openStart,e.openEnd);return Tt.fromReplace(t,this.from,this.to,r)}invert(){return new qt(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return e.deleted&&r.deleted||e.pos>=r.pos?null:new It(e.pos,r.pos,this.mark)}merge(t){return t instanceof It&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new It(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,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new It(e.from,e.to,t.markFromJSON(e.mark))}}_t.jsonID("removeMark",It);class jt extends _t{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return Tt.fail("No node at mark step's position");let r=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return Tt.fromReplace(t,this.pos,this.pos+1,new S(E.from(r),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(e){let t=this.mark.addToSet(e.marks);if(t.length==e.marks.length){for(let r=0;r<e.marks.length;r++)if(!e.marks[r].isInSet(t))return new jt(this.pos,e.marks[r]);return new jt(this.pos,this.mark)}}return new Pt(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new jt(e.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new jt(e.pos,t.markFromJSON(e.mark))}}_t.jsonID("addNodeMark",jt);class Pt extends _t{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return Tt.fail("No node at mark step's position");let r=e.type.create(e.attrs,null,this.mark.removeFromSet(e.marks));return Tt.fromReplace(t,this.pos,this.pos+1,new S(E.from(r),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);return e&&this.mark.isInSet(e.marks)?new jt(this.pos,this.mark):this}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Pt(e.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Pt(e.pos,t.markFromJSON(e.mark))}}_t.jsonID("removeNodeMark",Pt);class Lt extends _t{constructor(t,e,r,i=!1){super(),this.from=t,this.to=e,this.slice=r,this.structure=i}apply(t){return this.structure&&Ut(t,this.from,this.to)?Tt.fail("Structure replace would overwrite content"):Tt.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new Bt([this.from,this.to-this.from,this.slice.size])}invert(t){return new Lt(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return e.deletedAcross&&r.deletedAcross?null:new Lt(e.pos,Math.max(e.pos,r.pos),this.slice)}merge(t){if(!(t instanceof Lt)||t.structure||this.structure)return null;if(this.from+this.slice.size!=t.from||this.slice.openEnd||t.slice.openStart){if(t.to!=this.from||this.slice.openStart||t.slice.openEnd)return null;{let e=this.slice.size+t.slice.size==0?S.empty:new S(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new Lt(t.from,this.to,e,this.structure)}}{let e=this.slice.size+t.slice.size==0?S.empty:new S(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new Lt(this.from,this.to+(t.to-t.from),e,this.structure)}}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Lt(e.from,e.to,S.fromJSON(t,e.slice),!!e.structure)}}_t.jsonID("replace",Lt);class Jt extends _t{constructor(t,e,r,i,n,s,o=!1){super(),this.from=t,this.to=e,this.gapFrom=r,this.gapTo=i,this.slice=n,this.insert=s,this.structure=o}apply(t){if(this.structure&&(Ut(t,this.from,this.gapFrom)||Ut(t,this.gapTo,this.to)))return Tt.fail("Structure gap-replace would overwrite content");let e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return Tt.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,e.content);return r?Tt.fromReplace(t,this.from,this.to,r):Tt.fail("Content does not fit in gap")}getMap(){return new Bt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let e=this.gapTo-this.gapFrom;return new Jt(this.from,this.from+this.slice.size+e,this.from+this.insert,this.from+this.insert+e,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?e.pos:t.map(this.gapFrom,-1),n=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return e.deletedAcross&&r.deletedAcross||i<e.pos||n>r.pos?null:new Jt(e.pos,r.pos,i,n,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to||"number"!=typeof e.gapFrom||"number"!=typeof e.gapTo||"number"!=typeof e.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Jt(e.from,e.to,e.gapFrom,e.gapTo,S.fromJSON(t,e.slice),e.insert,!!e.structure)}}function Ut(t,e,r){let i=t.resolve(e),n=r-e,s=i.depth;for(;n>0&&s>0&&i.indexAfter(s)==i.node(s).childCount;)s--,n--;if(n>0){let t=i.node(s).maybeChild(i.indexAfter(s));for(;n>0;){if(!t||t.isLeaf)return!0;t=t.firstChild,n--}}return!1}function Vt(t,e,r,i=r.contentMatch,n=!0){let s=t.doc.nodeAt(e),o=[],l=e+1;for(let e=0;e<s.childCount;e++){let u=s.child(e),h=l+u.nodeSize,a=i.matchType(u.type);if(a){i=a;for(let e=0;e<u.marks.length;e++)r.allowsMarkType(u.marks[e].type)||t.step(new It(l,h,u.marks[e]));if(n&&u.isText&&"pre"!=r.whitespace){let t,e,i=/\r?\n|\r/g;for(;t=i.exec(u.text);)e||(e=new S(E.from(r.schema.text(" ",r.allowedMarks(u.marks))),0,0)),o.push(new Lt(l+t.index,l+t.index+t[0].length,e))}}else o.push(new Lt(l,h,S.empty));l=h}if(!i.validEnd){let e=i.fillBefore(E.empty,!0);t.replace(l,l,new S(e,0,0))}for(let e=o.length-1;e>=0;e--)t.step(o[e])}function Ht(t,e,r){return(0==e||t.canReplace(e,t.childCount))&&(r==t.childCount||t.canReplace(0,r))}function Wt(t){let e=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth;;--r){let i=t.$from.node(r),n=t.$from.index(r),s=t.$to.indexAfter(r);if(r<t.depth&&i.canReplace(n,s,e))return r;if(0==r||i.type.spec.isolating||!Ht(i,n,s))break}return null}function Gt(t,e,r=null,i=t){let n=function(t,e){let{parent:r,startIndex:i,endIndex:n}=t,s=r.contentMatchAt(i).findWrapping(e);return s&&r.canReplaceWith(i,n,s.length?s[0]:e)?s:null}(t,e),s=n&&function(t,e){let{parent:r,startIndex:i,endIndex:n}=t,s=r.child(i),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let l=(o.length?o[o.length-1]:e).contentMatch;for(let t=i;l&&t<n;t++)l=l.matchType(r.child(t).type);return l&&l.validEnd?o:null}(i,e);return s?n.map(Zt).concat({type:e,attrs:r}).concat(s.map(Zt)):null}function Zt(t){return{type:t,attrs:null}}function Kt(t,e,r,i){e.forEach(((n,s)=>{if(n.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(n.text);){let n=t.mapping.slice(i).map(r+1+s+o.index);t.replaceWith(n,n+1,e.type.schema.linebreakReplacement.create())}}}))}function Yt(t,e,r,i){e.forEach(((n,s)=>{if(n.type==n.type.schema.linebreakReplacement){let n=t.mapping.slice(i).map(r+1+s);t.replaceWith(n,n+1,e.type.schema.text("\n"))}}))}function Xt(t,e,r=1,i){let n=t.resolve(e),s=n.depth-r,o=i&&i[i.length-1]||n.parent;if(s<0||n.parent.type.spec.isolating||!n.parent.canReplace(n.index(),n.parent.childCount)||!o.type.validContent(n.parent.content.cutByIndex(n.index(),n.parent.childCount)))return!1;for(let t=n.depth-1,e=r-2;t>s;t--,e--){let r=n.node(t),s=n.index(t);if(r.type.spec.isolating)return!1;let o=r.content.cutByIndex(s,r.childCount),l=i&&i[e+1];l&&(o=o.replaceChild(0,l.type.create(l.attrs)));let u=i&&i[e]||r;if(!r.canReplace(s+1,r.childCount)||!u.type.validContent(o))return!1}let l=n.indexAfter(s),u=i&&i[0];return n.node(s).canReplaceWith(l,l,u?u.type:n.node(s+1).type)}function Qt(t,e){let r=t.resolve(e),i=r.index();return te(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(i,i+1)}function te(t,e){return!(!t||!e||t.isLeaf||!function(t,e){e.content.size||t.type.compatibleContent(e.type);let r=t.contentMatchAt(t.childCount),{linebreakReplacement:i}=t.type.schema;for(let n=0;n<e.childCount;n++){let s=e.child(n);if(r=r.matchType(s.type==i?t.type.schema.nodes.text:s.type),!r)return!1;if(!t.type.allowsMarks(s.marks))return!1}return r.validEnd}(t,e))}function ee(t,e,r=-1){let i=t.resolve(e);for(let t=i.depth;;t--){let n,s,o=i.index(t);if(t==i.depth?(n=i.nodeBefore,s=i.nodeAfter):r>0?(n=i.node(t+1),o++,s=i.node(t).maybeChild(o)):(n=i.node(t).maybeChild(o-1),s=i.node(t+1)),n&&!n.isTextblock&&te(n,s)&&i.node(t).canReplace(o,o+1))return e;if(0==t)break;e=r<0?i.before(t):i.after(t)}}function re(t,e,r){let i=t.resolve(e);if(!r.content.size)return e;let n=r.content;for(let t=0;t<r.openStart;t++)n=n.firstChild.content;for(let t=1;t<=(0==r.openStart&&r.size?2:1);t++)for(let e=i.depth;e>=0;e--){let r=e==i.depth?0:i.pos<=(i.start(e+1)+i.end(e+1))/2?-1:1,s=i.index(e)+(r>0?1:0),o=i.node(e),l=!1;if(1==t)l=o.canReplace(s,s,n);else{let t=o.contentMatchAt(s).findWrapping(n.firstChild.type);l=t&&o.canReplaceWith(s,s,t[0])}if(l)return 0==r?i.pos:r<0?i.before(e+1):i.after(e+1)}return null}function ie(t,e,r=e,i=S.empty){if(e==r&&!i.size)return null;let n=t.resolve(e),s=t.resolve(r);return ne(n,s,i)?new Lt(e,r,i):new se(n,s,i).fit()}function ne(t,e,r){return!r.openStart&&!r.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),r.content)}_t.jsonID("replaceAround",Jt);class se{constructor(t,e,r){this.$from=t,this.$to=e,this.unplaced=r,this.frontier=[],this.placed=E.empty;for(let e=0;e<=t.depth;e++){let r=t.node(e);this.frontier.push({type:r.type,match:r.contentMatchAt(t.indexAfter(e))})}for(let e=t.depth;e>0;e--)this.placed=E.from(t.node(e).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let t=this.findFittable();t?this.placeNodes(t):this.openMore()||this.dropNode()}let t=this.mustMoveInline(),e=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(t<0?this.$to:r.doc.resolve(t));if(!i)return null;let n=this.placed,s=r.depth,o=i.depth;for(;s&&o&&1==n.childCount;)n=n.firstChild.content,s--,o--;let l=new S(n,s,o);return t>-1?new Jt(r.pos,t,this.$to.pos,this.$to.end(),l,e):l.size||r.pos!=this.$to.pos?new Lt(r.pos,i.pos,l):null}findFittable(){let t=this.unplaced.openStart;for(let e=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<t;r++){let n=e.firstChild;if(e.childCount>1&&(i=0),n.type.spec.isolating&&i<=r){t=r;break}e=n.content}for(let e=1;e<=2;e++)for(let r=1==e?t:this.unplaced.openStart;r>=0;r--){let t,i=null;r?(i=ue(this.unplaced.content,r-1).firstChild,t=i.content):t=this.unplaced.content;let n=t.firstChild;for(let t=this.depth;t>=0;t--){let s,{type:o,match:l}=this.frontier[t],u=null;if(1==e&&(n?l.matchType(n.type)||(u=l.fillBefore(E.from(n),!1)):i&&o.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:t,parent:i,inject:u};if(2==e&&n&&(s=l.findWrapping(n.type)))return{sliceDepth:r,frontierDepth:t,parent:i,wrap:s};if(i&&l.matchType(i.type))break}}}openMore(){let{content:t,openStart:e,openEnd:r}=this.unplaced,i=ue(t,e);return!(!i.childCount||i.firstChild.isLeaf||(this.unplaced=new S(t,e+1,Math.max(r,i.size+e>=t.size-r?e+1:0)),0))}dropNode(){let{content:t,openStart:e,openEnd:r}=this.unplaced,i=ue(t,e);if(i.childCount<=1&&e>0){let n=t.size-e<=e+i.size;this.unplaced=new S(oe(t,e-1,1),e-1,n?e-1:r)}else this.unplaced=new S(oe(t,e,1),e,r)}placeNodes({sliceDepth:t,frontierDepth:e,parent:r,inject:i,wrap:n}){for(;this.depth>e;)this.closeFrontierNode();if(n)for(let t=0;t<n.length;t++)this.openFrontierNode(n[t]);let s=this.unplaced,o=r?r.content:s.content,l=s.openStart-t,u=0,h=[],{match:a,type:f}=this.frontier[e];if(i){for(let t=0;t<i.childCount;t++)h.push(i.child(t));a=a.matchFragment(i)}let c=o.size+t-(s.content.size-s.openEnd);for(;u<o.childCount;){let t=o.child(u),e=a.matchType(t.type);if(!e)break;u++,(u>1||0==l||t.content.size)&&(a=e,h.push(he(t.mark(f.allowedMarks(t.marks)),1==u?l:0,u==o.childCount?c:-1)))}let d=u==o.childCount;d||(c=-1),this.placed=le(this.placed,e,E.from(h)),this.frontier[e].match=a,d&&c<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let t=0,e=o;t<c;t++){let t=e.lastChild;this.frontier.push({type:t.type,match:t.contentMatchAt(t.childCount)}),e=t.content}this.unplaced=d?0==t?S.empty:new S(oe(s.content,t-1,1),t-1,c<0?s.openEnd:t-1):new S(oe(s.content,t,u),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t,e=this.frontier[this.depth];if(!e.type.isTextblock||!ae(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:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(t){t:for(let e=Math.min(this.depth,t.depth);e>=0;e--){let{match:r,type:i}=this.frontier[e],n=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1)),s=ae(t,e,i,r,n);if(s){for(let r=e-1;r>=0;r--){let{match:e,type:i}=this.frontier[r],n=ae(t,r,i,e,!0);if(!n||n.childCount)continue t}return{depth:e,fit:s,move:n?t.doc.resolve(t.after(e+1)):t}}}}close(t){let e=this.findCloseLevel(t);if(!e)return null;for(;this.depth>e.depth;)this.closeFrontierNode();e.fit.childCount&&(this.placed=le(this.placed,e.depth,e.fit)),t=e.move;for(let r=e.depth+1;r<=t.depth;r++){let e=t.node(r),i=e.type.contentMatch.fillBefore(e.content,!0,t.index(r));this.openFrontierNode(e.type,e.attrs,i)}return t}openFrontierNode(t,e=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(t),this.placed=le(this.placed,this.depth,E.from(t.create(e,r))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(E.empty,!0);t.childCount&&(this.placed=le(this.placed,this.frontier.length,t))}}function oe(t,e,r){return 0==e?t.cutByIndex(r,t.childCount):t.replaceChild(0,t.firstChild.copy(oe(t.firstChild.content,e-1,r)))}function le(t,e,r){return 0==e?t.append(r):t.replaceChild(t.childCount-1,t.lastChild.copy(le(t.lastChild.content,e-1,r)))}function ue(t,e){for(let r=0;r<e;r++)t=t.firstChild.content;return t}function he(t,e,r){if(e<=0)return t;let i=t.content;return e>1&&(i=i.replaceChild(0,he(i.firstChild,e-1,1==i.childCount?r-1:0))),e>0&&(i=t.type.contentMatch.fillBefore(i).append(i),r<=0&&(i=i.append(t.type.contentMatch.matchFragment(i).fillBefore(E.empty,!0)))),t.copy(i)}function ae(t,e,r,i,n){let s=t.node(e),o=n?t.indexAfter(e):t.index(e);if(o==s.childCount&&!r.compatibleContent(s.type))return null;let l=i.fillBefore(s.content,!0,o);return l&&!function(t,e,r){for(let i=r;i<e.childCount;i++)if(!t.allowsMarks(e.child(i).marks))return!0;return!1}(r,s.content,o)?l:null}function fe(t,e,r,i,n){if(e<r){let n=t.firstChild;t=t.replaceChild(0,n.copy(fe(n.content,e+1,r,i,n)))}if(e>i){let e=n.contentMatchAt(0),r=e.fillBefore(t).append(t);t=r.append(e.matchFragment(r).fillBefore(E.empty,!0))}return t}function ce(t,e){let r=[];for(let i=Math.min(t.depth,e.depth);i>=0;i--){let n=t.start(i);if(n<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(n==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==n-1)&&r.push(i)}return r}class de extends _t{constructor(t,e,r){super(),this.pos=t,this.attr=e,this.value=r}apply(t){let e=t.nodeAt(this.pos);if(!e)return Tt.fail("No node at attribute step's position");let r=Object.create(null);for(let t in e.attrs)r[t]=e.attrs[t];r[this.attr]=this.value;let i=e.type.create(r,null,e.marks);return Tt.fromReplace(t,this.pos,this.pos+1,new S(E.from(i),0,e.isLeaf?0:1))}getMap(){return Bt.empty}invert(t){return new de(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new de(e.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,e){if("number"!=typeof e.pos||"string"!=typeof e.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new de(e.pos,e.attr,e.value)}}_t.jsonID("attr",de);class pe extends _t{constructor(t,e){super(),this.attr=t,this.value=e}apply(t){let e=Object.create(null);for(let r in t.attrs)e[r]=t.attrs[r];e[this.attr]=this.value;let r=t.type.create(e,t.content,t.marks);return Tt.ok(r)}getMap(){return Bt.empty}invert(t){return new pe(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,e){if("string"!=typeof e.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new pe(e.attr,e.value)}}_t.jsonID("docAttr",pe);let me=class extends Error{};me=function t(e){let r=Error.call(this,e);return r.__proto__=t.prototype,r},(me.prototype=Object.create(Error.prototype)).constructor=me,me.prototype.name="TransformError";class ge{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new Rt}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new me(e.failed);return this}maybeStep(t){let e=t.apply(this.doc);return e.failed||this.addStep(t,e.doc),e}get docChanged(){return this.steps.length>0}addStep(t,e){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=e}replace(t,e=t,r=S.empty){let i=ie(this.doc,t,e,r);return i&&this.step(i),this}replaceWith(t,e,r){return this.replace(t,e,new S(E.from(r),0,0))}delete(t,e){return this.replace(t,e,S.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,r){return function(t,e,r,i){if(!i.size)return t.deleteRange(e,r);let n=t.doc.resolve(e),s=t.doc.resolve(r);if(ne(n,s,i))return t.step(new Lt(e,r,i));let o=ce(n,t.doc.resolve(r));0==o[o.length-1]&&o.pop();let l=-(n.depth+1);o.unshift(l);for(let t=n.depth,e=n.pos-1;t>0;t--,e--){let r=n.node(t).type.spec;if(r.defining||r.definingAsContext||r.isolating)break;o.indexOf(t)>-1?l=t:n.before(t)==e&&o.splice(1,0,-t)}let u=o.indexOf(l),h=[],a=i.openStart;for(let t=i.content,e=0;;e++){let r=t.firstChild;if(h.push(r),e==i.openStart)break;t=r.content}for(let t=a-1;t>=0;t--){let e=h[t],r=(f=e.type).spec.defining||f.spec.definingForContent;if(r&&!e.sameMarkup(n.node(Math.abs(l)-1)))a=t;else if(r||!e.type.isTextblock)break}var f;for(let e=i.openStart;e>=0;e--){let l=(e+a+1)%(i.openStart+1),f=h[l];if(f)for(let e=0;e<o.length;e++){let h=o[(e+u)%o.length],a=!0;h<0&&(a=!1,h=-h);let c=n.node(h-1),d=n.index(h-1);if(c.canReplaceWith(d,d,f.type,f.marks))return t.replace(n.before(h),a?s.after(h):r,new S(fe(i.content,0,i.openStart,l),l,i.openEnd))}}let c=t.steps.length;for(let l=o.length-1;l>=0&&(t.replace(e,r,i),!(t.steps.length>c));l--){let t=o[l];t<0||(e=n.before(t),r=s.after(t))}}(this,t,e,r),this}replaceRangeWith(t,e,r){return function(t,e,r,i){if(!i.isInline&&e==r&&t.doc.resolve(e).parent.content.size){let n=function(t,e,r){let i=t.resolve(e);if(i.parent.canReplaceWith(i.index(),i.index(),r))return e;if(0==i.parentOffset)for(let t=i.depth-1;t>=0;t--){let e=i.index(t);if(i.node(t).canReplaceWith(e,e,r))return i.before(t+1);if(e>0)return null}if(i.parentOffset==i.parent.content.size)for(let t=i.depth-1;t>=0;t--){let e=i.indexAfter(t);if(i.node(t).canReplaceWith(e,e,r))return i.after(t+1);if(e<i.node(t).childCount)return null}return null}(t.doc,e,i.type);null!=n&&(e=r=n)}t.replaceRange(e,r,new S(E.from(i),0,0))}(this,t,e,r),this}deleteRange(t,e){return function(t,e,r){let i=t.doc.resolve(e),n=t.doc.resolve(r),s=ce(i,n);for(let e=0;e<s.length;e++){let r=s[e],o=e==s.length-1;if(o&&0==r||i.node(r).type.contentMatch.validEnd)return t.delete(i.start(r),n.end(r));if(r>0&&(o||i.node(r-1).canReplace(i.index(r-1),n.indexAfter(r-1))))return t.delete(i.before(r),n.after(r))}for(let s=1;s<=i.depth&&s<=n.depth;s++)if(e-i.start(s)==i.depth-s&&r>i.end(s)&&n.end(s)-r!=n.depth-s&&i.start(s-1)==n.start(s-1)&&i.node(s-1).canReplace(i.index(s-1),n.index(s-1)))return t.delete(i.before(s),r);t.delete(e,r)}(this,t,e),this}lift(t,e){return function(t,e,r){let{$from:i,$to:n,depth:s}=e,o=i.before(s+1),l=n.after(s+1),u=o,h=l,a=E.empty,f=0;for(let t=s,e=!1;t>r;t--)e||i.index(t)>0?(e=!0,a=E.from(i.node(t).copy(a)),f++):u--;let c=E.empty,d=0;for(let t=s,e=!1;t>r;t--)e||n.after(t+1)<n.end(t)?(e=!0,c=E.from(n.node(t).copy(c)),d++):h++;t.step(new Jt(u,h,o,l,new S(a.append(c),f,d),a.size-f,!0))}(this,t,e),this}join(t,e=1){return function(t,e,r){let i=null,{linebreakReplacement:n}=t.doc.type.schema,s=t.doc.resolve(e-r),o=s.node().type;if(n&&o.inlineContent){let t="pre"==o.whitespace,e=!!o.contentMatch.matchType(n);t&&!e?i=!1:!t&&e&&(i=!0)}let l=t.steps.length;if(!1===i){let i=t.doc.resolve(e+r);Yt(t,i.node(),i.before(),l)}o.inlineContent&&Vt(t,e+r-1,o,s.node().contentMatchAt(s.index()),null==i);let u=t.mapping.slice(l),h=u.map(e-r);if(t.step(new Lt(h,u.map(e+r,-1),S.empty,!0)),!0===i){let e=t.doc.resolve(h);Kt(t,e.node(),e.before(),t.steps.length)}}(this,t,e),this}wrap(t,e){return function(t,e,r){let i=E.empty;for(let t=r.length-1;t>=0;t--){if(i.size){let e=r[t].type.contentMatch.matchFragment(i);if(!e||!e.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}i=E.from(r[t].type.create(r[t].attrs,i))}let n=e.start,s=e.end;t.step(new Jt(n,s,n,s,new S(i,0,0),r.length,!0))}(this,t,e),this}setBlockType(t,e=t,r,i=null){return function(t,e,r,i,n){if(!i.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,r,((e,r)=>{let o="function"==typeof n?n(e):n;if(e.isTextblock&&!e.hasMarkup(i,o)&&function(t,e,r){let i=t.resolve(e),n=i.index();return i.parent.canReplaceWith(n,n+1,r)}(t.doc,t.mapping.slice(s).map(r),i)){let n=null;if(i.schema.linebreakReplacement){let t="pre"==i.whitespace,e=!!i.contentMatch.matchType(i.schema.linebreakReplacement);t&&!e?n=!1:!t&&e&&(n=!0)}!1===n&&Yt(t,e,r,s),Vt(t,t.mapping.slice(s).map(r,1),i,void 0,null===n);let l=t.mapping.slice(s),u=l.map(r,1),h=l.map(r+e.nodeSize,1);return t.step(new Jt(u,h,u+1,h-1,new S(E.from(i.create(o,null,e.marks)),0,0),1,!0)),!0===n&&Kt(t,e,r,s),!1}}))}(this,t,e,r,i),this}setNodeMarkup(t,e,r=null,i){return function(t,e,r,i,n){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");r||(r=s.type);let o=r.create(i,null,n||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,o);if(!r.validContent(s.content))throw new RangeError("Invalid content for node type "+r.name);t.step(new Jt(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new S(E.from(o),0,0),1,!0))}(this,t,e,r,i),this}setNodeAttribute(t,e,r){return this.step(new de(t,e,r)),this}setDocAttribute(t,e){return this.step(new pe(t,e)),this}addNodeMark(t,e){return this.step(new jt(t,e)),this}removeNodeMark(t,e){if(!(e instanceof C)){let r=this.doc.nodeAt(t);if(!r)throw new RangeError("No node at position "+t);if(!(e=e.isInSet(r.marks)))return this}return this.step(new Pt(t,e)),this}split(t,e=1,r){return function(t,e,r=1,i){let n=t.doc.resolve(e),s=E.empty,o=E.empty;for(let t=n.depth,e=n.depth-r,l=r-1;t>e;t--,l--){s=E.from(n.node(t).copy(s));let e=i&&i[l];o=E.from(e?e.type.create(e.attrs,o):n.node(t).copy(o))}t.step(new Lt(e,e,new S(s.append(o),r,r),!0))}(this,t,e,r),this}addMark(t,e,r){return function(t,e,r,i){let n,s,o=[],l=[];t.doc.nodesBetween(e,r,((t,u,h)=>{if(!t.isInline)return;let a=t.marks;if(!i.isInSet(a)&&h.type.allowsMarkType(i.type)){let h=Math.max(u,e),f=Math.min(u+t.nodeSize,r),c=i.addToSet(a);for(let t=0;t<a.length;t++)a[t].isInSet(c)||(n&&n.to==h&&n.mark.eq(a[t])?n.to=f:o.push(n=new It(h,f,a[t])));s&&s.to==h?s.to=f:l.push(s=new qt(h,f,i))}})),o.forEach((e=>t.step(e))),l.forEach((e=>t.step(e)))}(this,t,e,r),this}removeMark(t,e,r){return function(t,e,r,i){let n=[],s=0;t.doc.nodesBetween(e,r,((t,o)=>{if(!t.isInline)return;s++;let l=null;if(i instanceof ft){let e,r=t.marks;for(;e=i.isInSet(r);)(l||(l=[])).push(e),r=e.removeFromSet(r)}else i?i.isInSet(t.marks)&&(l=[i]):l=t.marks;if(l&&l.length){let i=Math.min(o+t.nodeSize,r);for(let t=0;t<l.length;t++){let r,u=l[t];for(let t=0;t<n.length;t++){let e=n[t];e.step==s-1&&u.eq(n[t].style)&&(r=e)}r?(r.to=i,r.step=s):n.push({style:u,from:Math.max(o,e),to:i,step:s})}}})),n.forEach((e=>t.step(new It(e.from,e.to,e.style))))}(this,t,e,r),this}clearIncompatible(t,e,r){return Vt(this,t,e,r),this}}const we=Object.create(null);class be{constructor(t,e,r){this.$anchor=t,this.$head=e,this.ranges=r||[new ve(t.min(e),t.max(e))]}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 t=this.ranges;for(let e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,e=S.empty){let r=e.content.lastChild,i=null;for(let t=0;t<e.openEnd;t++)i=r,r=r.lastChild;let n=t.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:l,$to:u}=s[o],h=t.mapping.slice(n);t.replaceRange(h.map(l.pos),h.map(u.pos),o?S.empty:e),0==o&&Se(t,n,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(t,e){let r=t.steps.length,i=this.ranges;for(let n=0;n<i.length;n++){let{$from:s,$to:o}=i[n],l=t.mapping.slice(r),u=l.map(s.pos),h=l.map(o.pos);n?t.deleteRange(u,h):(t.replaceRangeWith(u,h,e),Se(t,r,e.isInline?-1:1))}}static findFrom(t,e,r=!1){let i=t.parent.inlineContent?new ye(t):Ae(t.node(0),t.parent,t.pos,t.index(),e,r);if(i)return i;for(let i=t.depth-1;i>=0;i--){let n=e<0?Ae(t.node(0),t.node(i),t.before(i+1),t.index(i),e,r):Ae(t.node(0),t.node(i),t.after(i+1),t.index(i)+1,e,r);if(n)return n}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new Me(t.node(0))}static atStart(t){return Ae(t,t,0,0,1)||new Me(t)}static atEnd(t){return Ae(t,t,t.content.size,t.childCount,-1)||new Me(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=we[e.type];if(!r)throw new RangeError(`No selection type ${e.type} defined`);return r.fromJSON(t,e)}static jsonID(t,e){if(t in we)throw new RangeError("Duplicate use of selection JSON ID "+t);return we[t]=e,e.prototype.jsonID=t,e}getBookmark(){return ye.between(this.$anchor,this.$head).getBookmark()}}be.prototype.visible=!0;class ve{constructor(t,e){this.$from=t,this.$to=e}}let ke=!1;function De(t){ke||t.parent.inlineContent||(ke=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class ye extends be{constructor(t,e=t){De(t),De(e),super(t,e)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,e){let r=t.resolve(e.map(this.head));if(!r.parent.inlineContent)return be.near(r);let i=t.resolve(e.map(this.anchor));return new ye(i.parent.inlineContent?i:r,r)}replace(t,e=S.empty){if(super.replace(t,e),e==S.empty){let e=this.$from.marksAcross(this.$to);e&&t.ensureMarks(e)}}eq(t){return t instanceof ye&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Ee(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,e){if("number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new ye(t.resolve(e.anchor),t.resolve(e.head))}static create(t,e,r=e){let i=t.resolve(e);return new this(i,r==e?i:t.resolve(r))}static between(t,e,r){let i=t.pos-e.pos;if(r&&!i||(r=i>=0?1:-1),!e.parent.inlineContent){let t=be.findFrom(e,r,!0)||be.findFrom(e,-r,!0);if(!t)return be.near(e,r);e=t.$head}return t.parent.inlineContent||(0==i||(t=(be.findFrom(t,-r,!0)||be.findFrom(t,r,!0)).$anchor).pos<e.pos!=i<0)&&(t=e),new ye(t,e)}}be.jsonID("text",ye);class Ee{constructor(t,e){this.anchor=t,this.head=e}map(t){return new Ee(t.map(this.anchor),t.map(this.head))}resolve(t){return ye.between(t.resolve(this.anchor),t.resolve(this.head))}}class xe extends be{constructor(t){let e=t.nodeAfter,r=t.node(0).resolve(t.pos+e.nodeSize);super(t,r),this.node=e}map(t,e){let{deleted:r,pos:i}=e.mapResult(this.anchor),n=t.resolve(i);return r?be.near(n):new xe(n)}content(){return new S(E.from(this.node),0,0)}eq(t){return t instanceof xe&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Fe(this.anchor)}static fromJSON(t,e){if("number"!=typeof e.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new xe(t.resolve(e.anchor))}static create(t,e){return new xe(t.resolve(e))}static isSelectable(t){return!t.isText&&!1!==t.type.spec.selectable}}xe.prototype.visible=!1,be.jsonID("node",xe);class Fe{constructor(t){this.anchor=t}map(t){let{deleted:e,pos:r}=t.mapResult(this.anchor);return e?new Ee(r,r):new Fe(r)}resolve(t){let e=t.resolve(this.anchor),r=e.nodeAfter;return r&&xe.isSelectable(r)?new xe(e):be.near(e)}}class Me extends be{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,e=S.empty){if(e==S.empty){t.delete(0,t.doc.content.size);let e=be.atStart(t.doc);e.eq(t.selection)||t.setSelection(e)}else super.replace(t,e)}toJSON(){return{type:"all"}}static fromJSON(t){return new Me(t)}map(t){return new Me(t)}eq(t){return t instanceof Me}getBookmark(){return Ce}}be.jsonID("all",Me);const Ce={map(){return this},resolve:t=>new Me(t)};function Ae(t,e,r,i,n,s=!1){if(e.inlineContent)return ye.create(t,r);for(let o=i-(n>0?0:1);n>0?o<e.childCount:o>=0;o+=n){let i=e.child(o);if(i.isAtom){if(!s&&xe.isSelectable(i))return xe.create(t,r-(n<0?i.nodeSize:0))}else{let e=Ae(t,i,r+n,n<0?i.childCount:0,n,s);if(e)return e}r+=i.nodeSize*n}return null}function Se(t,e,r){let i=t.steps.length-1;if(i<e)return;let n,s=t.steps[i];(s instanceof Lt||s instanceof Jt)&&(t.mapping.maps[i].forEach(((t,e,r,i)=>{null==n&&(n=i)})),t.setSelection(be.near(t.doc.resolve(n),r)))}class Oe extends ge{constructor(t){super(t.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=t.selection,this.storedMarks=t.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(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=t,this.curSelectionFor=this.steps.length,this.updated=-3&this.updated|1,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(t){return this.storedMarks=t,this.updated|=2,this}ensureMarks(t){return C.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(t,e){super.addStep(t,e),this.updated=-3&this.updated,this.storedMarks=null}setTime(t){return this.time=t,this}replaceSelection(t){return this.selection.replace(this,t),this}replaceSelectionWith(t,e=!0){let r=this.selection;return e&&(t=t.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||C.none))),r.replaceWith(this,t),this}deleteSelection(){return this.selection.replace(this),this}insertText(t,e,r){let i=this.doc.type.schema;if(null==e)return t?this.replaceSelectionWith(i.text(t),!0):this.deleteSelection();{if(null==r&&(r=e),r=null==r?e:r,!t)return this.deleteRange(e,r);let n=this.storedMarks;if(!n){let t=this.doc.resolve(e);n=r==e?t.marks():t.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(e,r,i.text(t,n)),this.selection.empty||this.setSelection(be.near(this.selection.$to)),this}}setMeta(t,e){return this.meta["string"==typeof t?t:t.key]=e,this}getMeta(t){return this.meta["string"==typeof t?t:t.key]}get isGeneric(){for(let t in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function $e(t,e){return e&&t?t.bind(e):t}class Be{constructor(t,e,r){this.name=t,this.init=$e(e.init,r),this.apply=$e(e.apply,r)}}const Re=[new Be("doc",{init:t=>t.doc||t.schema.topNodeType.createAndFill(),apply:t=>t.doc}),new Be("selection",{init:(t,e)=>t.selection||be.atStart(e.doc),apply:t=>t.selection}),new Be("storedMarks",{init:t=>t.storedMarks||null,apply:(t,e,r,i)=>i.selection.$cursor?t.storedMarks:null}),new Be("scrollToSelection",{init:()=>0,apply:(t,e)=>t.scrolledIntoView?e+1:e})];class Ne{constructor(t,e){this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Re.slice(),e&&e.forEach((t=>{if(this.pluginsByKey[t.key])throw new RangeError("Adding different instances of a keyed plugin ("+t.key+")");this.plugins.push(t),this.pluginsByKey[t.key]=t,t.spec.state&&this.fields.push(new Be(t.key,t.spec.state,t))}))}}class _e{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,e=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=e){let e=this.config.plugins[r];if(e.spec.filterTransaction&&!e.spec.filterTransaction.call(e,t,this))return!1}return!0}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let e=[t],r=this.applyInner(t),i=null;for(;;){let n=!1;for(let s=0;s<this.config.plugins.length;s++){let o=this.config.plugins[s];if(o.spec.appendTransaction){let l=i?i[s].n:0,u=i?i[s].state:this,h=l<e.length&&o.spec.appendTransaction.call(o,l?e.slice(l):e,u,r);if(h&&r.filterTransaction(h,s)){if(h.setMeta("appendedTransaction",t),!i){i=[];for(let t=0;t<this.config.plugins.length;t++)i.push(t<s?{state:r,n:e.length}:{state:this,n:0})}e.push(h),r=r.applyInner(h),n=!0}i&&(i[s]={state:r,n:e.length})}}if(!n)return{state:r,transactions:e}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let e=new _e(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let n=r[i];e[n.name]=n.apply(t,this[n.name],this,e)}return e}get tr(){return new Oe(this)}static create(t){let e=new Ne(t.doc?t.doc.type.schema:t.schema,t.plugins),r=new _e(e);for(let i=0;i<e.fields.length;i++)r[e.fields[i].name]=e.fields[i].init(t,r);return r}reconfigure(t){let e=new Ne(this.schema,t.plugins),r=e.fields,i=new _e(e);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(t){let e={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(e.storedMarks=this.storedMarks.map((t=>t.toJSON()))),t&&"object"==typeof t)for(let r in t){if("doc"==r||"selection"==r)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=t[r],n=i.spec.state;n&&n.toJSON&&(e[r]=n.toJSON.call(i,this[i.key]))}return e}static fromJSON(t,e,r){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let i=new Ne(t.schema,t.plugins),n=new _e(i);return i.fields.forEach((i=>{if("doc"==i.name)n.doc=W.fromJSON(t.schema,e.doc);else if("selection"==i.name)n.selection=be.fromJSON(n.doc,e.selection);else if("storedMarks"==i.name)e.storedMarks&&(n.storedMarks=e.storedMarks.map(t.schema.markFromJSON));else{if(r)for(let s in r){let o=r[s],l=o.spec.state;if(o.key==i.name&&l&&l.fromJSON&&Object.prototype.hasOwnProperty.call(e,s))return void(n[i.name]=l.fromJSON.call(o,t,e[s],n))}n[i.name]=i.init(t,n)}})),n}}function Te(t,e,r){for(let i in t){let n=t[i];n instanceof Function?n=n.bind(e):"handleDOMEvents"==i&&(n=Te(n,e,{})),r[i]=n}return r}class ze{constructor(t){this.spec=t,this.props={},t.props&&Te(t.props,this,this.props),this.key=t.key?t.key.key:Ie("plugin")}getState(t){return t[this.key]}}const qe=Object.create(null);function Ie(t){return t in qe?t+"$"+ ++qe[t]:(qe[t]=0,t+"$")}class je{constructor(t="key"){this.key=Ie(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const Pe=function(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e},Le=function(t){let e=t.assignedSlot||t.parentNode;return e&&11==e.nodeType?e.host:e};let Je=null;const Ue=function(t,e,r){let i=Je||(Je=document.createRange());return i.setEnd(t,null==r?t.nodeValue.length:r),i.setStart(t,e||0),i},Ve=function(t,e,r,i){return r&&(We(t,e,r,i,-1)||We(t,e,r,i,1))},He=/^(img|br|input|textarea|hr)$/i;function We(t,e,r,i,n){for(;;){if(t==r&&e==i)return!0;if(e==(n<0?0:Ge(t))){let r=t.parentNode;if(!r||1!=r.nodeType||Ze(t)||He.test(t.nodeName)||"false"==t.contentEditable)return!1;e=Pe(t)+(n<0?0:1),t=r}else{if(1!=t.nodeType)return!1;if("false"==(t=t.childNodes[e+(n<0?-1:0)]).contentEditable)return!1;e=n<0?Ge(t):0}}}function Ge(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Ze(t){let e;for(let r=t;r&&!(e=r.pmViewDesc);r=r.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const Ke=function(t){return t.focusNode&&Ve(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Ye(t,e){let r=document.createEvent("Event");return r.initEvent("keydown",!0,!0),r.keyCode=t,r.key=r.code=e,r}const Xe="undefined"!=typeof navigator?navigator:null,Qe="undefined"!=typeof document?document:null,tr=Xe&&Xe.userAgent||"",er=/Edge\/(\d+)/.exec(tr),rr=/MSIE \d/.exec(tr),ir=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(tr),nr=!!(rr||ir||er),sr=rr?document.documentMode:ir?+ir[1]:er?+er[1]:0,or=!nr&&/gecko\/(\d+)/i.test(tr),lr=!nr&&/Chrome\/(\d+)/.exec(tr),ur=!!lr,hr=lr?+lr[1]:0,ar=!nr&&!!Xe&&/Apple Computer/.test(Xe.vendor),fr=ar&&(/Mobile\/\w+/.test(tr)||!!Xe&&Xe.maxTouchPoints>2),cr=fr||!!Xe&&/Mac/.test(Xe.platform),dr=!!Xe&&/Win/.test(Xe.platform),pr=/Android \d/.test(tr),mr=!!Qe&&"webkitFontSmoothing"in Qe.documentElement.style,gr=mr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function wr(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function br(t,e){return"number"==typeof t?t:t[e]}function vr(t){let e=t.getBoundingClientRect();return{left:e.left,right:e.left+t.clientWidth*(e.width/t.offsetWidth||1),top:e.top,bottom:e.top+t.clientHeight*(e.height/t.offsetHeight||1)}}function kr(t,e,r){let i=t.someProp("scrollThreshold")||0,n=t.someProp("scrollMargin")||5,s=t.dom.ownerDocument;for(let o=r||t.dom;o;o=Le(o)){if(1!=o.nodeType)continue;let t=o,r=t==s.body,l=r?wr(s):vr(t),u=0,h=0;if(e.top<l.top+br(i,"top")?h=-(l.top-e.top+br(n,"top")):e.bottom>l.bottom-br(i,"bottom")&&(h=e.bottom-e.top>l.bottom-l.top?e.top+br(n,"top")-l.top:e.bottom-l.bottom+br(n,"bottom")),e.left<l.left+br(i,"left")?u=-(l.left-e.left+br(n,"left")):e.right>l.right-br(i,"right")&&(u=e.right-l.right+br(n,"right")),u||h)if(r)s.defaultView.scrollBy(u,h);else{let r=t.scrollLeft,i=t.scrollTop;h&&(t.scrollTop+=h),u&&(t.scrollLeft+=u);let n=t.scrollLeft-r,s=t.scrollTop-i;e={left:e.left-n,top:e.top-s,right:e.right-n,bottom:e.bottom-s}}if(r||/^(fixed|sticky)$/.test(getComputedStyle(o).position))break}}function Dr(t){let e=[],r=t.ownerDocument;for(let i=t;i&&(e.push({dom:i,top:i.scrollTop,left:i.scrollLeft}),t!=r);i=Le(i));return e}function yr(t,e){for(let r=0;r<t.length;r++){let{dom:i,top:n,left:s}=t[r];i.scrollTop!=n+e&&(i.scrollTop=n+e),i.scrollLeft!=s&&(i.scrollLeft=s)}}let Er=null;function xr(t,e){let r,i,n,s,o=2e8,l=0,u=e.top,h=e.top;for(let a=t.firstChild,f=0;a;a=a.nextSibling,f++){let t;if(1==a.nodeType)t=a.getClientRects();else{if(3!=a.nodeType)continue;t=Ue(a).getClientRects()}for(let c=0;c<t.length;c++){let d=t[c];if(d.top<=u&&d.bottom>=h){u=Math.max(d.bottom,u),h=Math.min(d.top,h);let t=d.left>e.left?d.left-e.left:d.right<e.left?e.left-d.right:0;if(t<o){r=a,o=t,i=t&&3==r.nodeType?{left:d.right<e.left?d.right:d.left,top:e.top}:e,1==a.nodeType&&t&&(l=f+(e.left>=(d.left+d.right)/2?1:0));continue}}else d.top>e.top&&!n&&d.left<=e.left&&d.right>=e.left&&(n=a,s={left:Math.max(d.left,Math.min(d.right,e.left)),top:d.top});!r&&(e.left>=d.right&&e.top>=d.top||e.left>=d.left&&e.top>=d.bottom)&&(l=f+1)}}return!r&&n&&(r=n,i=s,o=0),r&&3==r.nodeType?function(t,e){let r=t.nodeValue.length,i=document.createRange();for(let n=0;n<r;n++){i.setEnd(t,n+1),i.setStart(t,n);let r=Sr(i,1);if(r.top!=r.bottom&&Fr(e,r))return{node:t,offset:n+(e.left>=(r.left+r.right)/2?1:0)}}return{node:t,offset:0}}(r,i):!r||o&&1==r.nodeType?{node:t,offset:l}:xr(r,i)}function Fr(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Mr(t,e,r){let i=t.childNodes.length;if(i&&r.top<r.bottom)for(let n=Math.max(0,Math.min(i-1,Math.floor(i*(e.top-r.top)/(r.bottom-r.top))-2)),s=n;;){let r=t.childNodes[s];if(1==r.nodeType){let t=r.getClientRects();for(let i=0;i<t.length;i++){let n=t[i];if(Fr(e,n))return Mr(r,e,n)}}if((s=(s+1)%i)==n)break}return t}function Cr(t,e){let r,i=t.dom.ownerDocument,n=0,s=function(t,e,r){if(t.caretPositionFromPoint)try{let i=t.caretPositionFromPoint(e,r);if(i)return{node:i.offsetNode,offset:Math.min(Ge(i.offsetNode),i.offset)}}catch(t){}if(t.caretRangeFromPoint){let i=t.caretRangeFromPoint(e,r);if(i)return{node:i.startContainer,offset:Math.min(Ge(i.startContainer),i.startOffset)}}}(i,e.left,e.top);s&&({node:r,offset:n}=s);let o,l=(t.root.elementFromPoint?t.root:i).elementFromPoint(e.left,e.top);if(!l||!t.dom.contains(1!=l.nodeType?l.parentNode:l)){let r=t.dom.getBoundingClientRect();if(!Fr(e,r))return null;if(l=Mr(t.dom,e,r),!l)return null}if(ar)for(let t=l;r&&t;t=Le(t))t.draggable&&(r=void 0);if(l=function(t,e){let r=t.parentNode;return r&&/^li$/i.test(r.nodeName)&&e.left<t.getBoundingClientRect().left?r:t}(l,e),r){if(or&&1==r.nodeType&&(n=Math.min(n,r.childNodes.length),n<r.childNodes.length)){let t,i=r.childNodes[n];"IMG"==i.nodeName&&(t=i.getBoundingClientRect()).right<=e.left&&t.bottom>e.top&&n++}let i;mr&&n&&1==r.nodeType&&1==(i=r.childNodes[n-1]).nodeType&&"false"==i.contentEditable&&i.getBoundingClientRect().top>=e.top&&n--,r==t.dom&&n==r.childNodes.length-1&&1==r.lastChild.nodeType&&e.top>r.lastChild.getBoundingClientRect().bottom?o=t.state.doc.content.size:0!=n&&1==r.nodeType&&"BR"==r.childNodes[n-1].nodeName||(o=function(t,e,r,i){let n=-1;for(let r=e,s=!1;r!=t.dom;){let e,o=t.docView.nearestDesc(r,!0);if(!o)return null;if(1==o.dom.nodeType&&(o.node.isBlock&&o.parent||!o.contentDOM)&&((e=o.dom.getBoundingClientRect()).width||e.height)&&(o.node.isBlock&&o.parent&&(!s&&e.left>i.left||e.top>i.top?n=o.posBefore:(!s&&e.right<i.left||e.bottom<i.top)&&(n=o.posAfter),s=!0),!o.contentDOM&&n<0&&!o.node.isText))return(o.node.isBlock?i.top<(e.top+e.bottom)/2:i.left<(e.left+e.right)/2)?o.posBefore:o.posAfter;r=o.dom.parentNode}return n>-1?n:t.docView.posFromDOM(e,r,-1)}(t,r,n,e))}null==o&&(o=function(t,e,r){let{node:i,offset:n}=xr(e,r),s=-1;if(1==i.nodeType&&!i.firstChild){let t=i.getBoundingClientRect();s=t.left!=t.right&&r.left>(t.left+t.right)/2?1:-1}return t.docView.posFromDOM(i,n,s)}(t,l,e));let u=t.docView.nearestDesc(l,!0);return{pos:o,inside:u?u.posAtStart-u.border:-1}}function Ar(t){return t.top<t.bottom||t.left<t.right}function Sr(t,e){let r=t.getClientRects();if(r.length){let t=r[e<0?0:r.length-1];if(Ar(t))return t}return Array.prototype.find.call(r,Ar)||t.getBoundingClientRect()}const Or=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function $r(t,e,r){let{node:i,offset:n,atom:s}=t.docView.domFromPos(e,r<0?-1:1),o=mr||or;if(3==i.nodeType){if(!o||!Or.test(i.nodeValue)&&(r<0?n:n!=i.nodeValue.length)){let t=n,e=n,s=r<0?1:-1;return r<0&&!n?(e++,s=-1):r>=0&&n==i.nodeValue.length?(t--,s=1):r<0?t--:e++,Br(Sr(Ue(i,t,e),s),s<0)}{let t=Sr(Ue(i,n,n),r);if(or&&n&&/\s/.test(i.nodeValue[n-1])&&n<i.nodeValue.length){let e=Sr(Ue(i,n-1,n-1),-1);if(e.top==t.top){let r=Sr(Ue(i,n,n+1),-1);if(r.top!=t.top)return Br(r,r.left<e.left)}}return t}}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(null==s&&n&&(r<0||n==Ge(i))){let t=i.childNodes[n-1];if(1==t.nodeType)return Rr(t.getBoundingClientRect(),!1)}if(null==s&&n<Ge(i)){let t=i.childNodes[n];if(1==t.nodeType)return Rr(t.getBoundingClientRect(),!0)}return Rr(i.getBoundingClientRect(),r>=0)}if(null==s&&n&&(r<0||n==Ge(i))){let t=i.childNodes[n-1],e=3==t.nodeType?Ue(t,Ge(t)-(o?0:1)):1!=t.nodeType||"BR"==t.nodeName&&t.nextSibling?null:t;if(e)return Br(Sr(e,1),!1)}if(null==s&&n<Ge(i)){let t=i.childNodes[n];for(;t.pmViewDesc&&t.pmViewDesc.ignoreForCoords;)t=t.nextSibling;let e=t?3==t.nodeType?Ue(t,0,o?0:1):1==t.nodeType?t:null:null;if(e)return Br(Sr(e,-1),!0)}return Br(Sr(3==i.nodeType?Ue(i):i,-r),r>=0)}function Br(t,e){if(0==t.width)return t;let r=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:r,right:r}}function Rr(t,e){if(0==t.height)return t;let r=e?t.top:t.bottom;return{top:r,bottom:r,left:t.left,right:t.right}}function Nr(t,e,r){let i=t.state,n=t.root.activeElement;i!=e&&t.updateState(e),n!=t.dom&&t.focus();try{return r()}finally{i!=e&&t.updateState(i),n!=t.dom&&n&&n.focus()}}const _r=/[\u0590-\u08ac]/;let Tr=null,zr=null,qr=!1;class Ir{constructor(t,e,r,i){this.parent=t,this.children=e,this.dom=r,this.contentDOM=i,this.dirty=0,r.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,e,r){return!1}matchesHack(t){return!1}parseRule(){return null}stopEvent(t){return!1}get size(){let t=0;for(let e=0;e<this.children.length;e++)t+=this.children[e].size;return t}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let e=0,r=this.posAtStart;;e++){let i=this.children[e];if(i==t)return r;r+=i.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(t,e,r){if(this.contentDOM&&this.contentDOM.contains(1==t.nodeType?t:t.parentNode)){if(r<0){let r,i;if(t==this.contentDOM)r=t.childNodes[e-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;r=t.previousSibling}for(;r&&(!(i=r.pmViewDesc)||i.parent!=this);)r=r.previousSibling;return r?this.posBeforeChild(i)+i.size:this.posAtStart}{let r,i;if(t==this.contentDOM)r=t.childNodes[e];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;r=t.nextSibling}for(;r&&(!(i=r.pmViewDesc)||i.parent!=this);)r=r.nextSibling;return r?this.posBeforeChild(i):this.posAtEnd}}let i;if(t==this.dom&&this.contentDOM)i=e>Pe(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=2&t.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==e)for(let e=t;;e=e.parentNode){if(e==this.dom){i=!1;break}if(e.previousSibling)break}if(null==i&&e==t.childNodes.length)for(let e=t;;e=e.parentNode){if(e==this.dom){i=!0;break}if(e.nextSibling)break}}return(null==i?r>0:i)?this.posAtEnd:this.posAtStart}nearestDesc(t,e=!1){for(let r=!0,i=t;i;i=i.parentNode){let n,s=this.getDesc(i);if(s&&(!e||s.node)){if(!r||!(n=s.nodeDOM)||(1==n.nodeType?n.contains(1==t.nodeType?t:t.parentNode):n==t))return s;r=!1}}}getDesc(t){let e=t.pmViewDesc;for(let t=e;t;t=t.parent)if(t==this)return e}posFromDOM(t,e,r){for(let i=t;i;i=i.parentNode){let n=this.getDesc(i);if(n)return n.localPosFromDOM(t,e,r)}return-1}descAt(t){for(let e=0,r=0;e<this.children.length;e++){let i=this.children[e],n=r+i.size;if(r==t&&n!=r){for(;!i.border&&i.children.length;)for(let t=0;t<i.children.length;t++){let e=i.children[t];if(e.size){i=e;break}}return i}if(t<n)return i.descAt(t-r-i.border);r=n}}domFromPos(t,e){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let r=0,i=0;for(let e=0;r<this.children.length;r++){let n=this.children[r],s=e+n.size;if(s>t||n instanceof Hr){i=t-e;break}e=s}if(i)return this.children[r].domFromPos(i-this.children[r].border,e);for(let t;r&&!(t=this.children[r-1]).size&&t instanceof jr&&t.side>=0;r--);if(e<=0){let t,i=!0;for(;t=r?this.children[r-1]:null,t&&t.dom.parentNode!=this.contentDOM;r--,i=!1);return t&&e&&i&&!t.border&&!t.domAtom?t.domFromPos(t.size,e):{node:this.contentDOM,offset:t?Pe(t.dom)+1:0}}{let t,i=!0;for(;t=r<this.children.length?this.children[r]:null,t&&t.dom.parentNode!=this.contentDOM;r++,i=!1);return t&&i&&!t.border&&!t.domAtom?t.domFromPos(0,e):{node:this.contentDOM,offset:t?Pe(t.dom):this.contentDOM.childNodes.length}}}parseRange(t,e,r=0){if(0==this.children.length)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,n=-1;for(let s=r,o=0;;o++){let r=this.children[o],l=s+r.size;if(-1==i&&t<=l){let n=s+r.border;if(t>=n&&e<=l-r.border&&r.node&&r.contentDOM&&this.contentDOM.contains(r.contentDOM))return r.parseRange(t,e,n);t=s;for(let e=o;e>0;e--){let r=this.children[e-1];if(r.size&&r.dom.parentNode==this.contentDOM&&!r.emptyChildAt(1)){i=Pe(r.dom)+1;break}t-=r.size}-1==i&&(i=0)}if(i>-1&&(l>e||o==this.children.length-1)){e=l;for(let t=o+1;t<this.children.length;t++){let r=this.children[t];if(r.size&&r.dom.parentNode==this.contentDOM&&!r.emptyChildAt(-1)){n=Pe(r.dom);break}e+=r.size}-1==n&&(n=this.contentDOM.childNodes.length);break}s=l}return{node:this.contentDOM,from:t,to:e,fromOffset:i,toOffset:n}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return!1;let e=this.children[t<0?0:this.children.length-1];return 0==e.size||e.emptyChildAt(t)}domAfterPos(t){let{node:e,offset:r}=this.domFromPos(t,0);if(1!=e.nodeType||r==e.childNodes.length)throw new RangeError("No node after pos "+t);return e.childNodes[r]}setSelection(t,e,r,i=!1){let n=Math.min(t,e),s=Math.max(t,e);for(let o=0,l=0;o<this.children.length;o++){let u=this.children[o],h=l+u.size;if(n>l&&s<h)return u.setSelection(t-l-u.border,e-l-u.border,r,i);l=h}let o=this.domFromPos(t,t?-1:1),l=e==t?o:this.domFromPos(e,e?-1:1),u=r.root.getSelection(),h=r.domSelectionRange(),a=!1;if((or||ar)&&t==e){let{node:t,offset:e}=o;if(3==t.nodeType){if(a=!(!e||"\n"!=t.nodeValue[e-1]),a&&e==t.nodeValue.length)for(let e,r=t;r;r=r.parentNode){if(e=r.nextSibling){"BR"==e.nodeName&&(o=l={node:e.parentNode,offset:Pe(e)+1});break}let t=r.pmViewDesc;if(t&&t.node&&t.node.isBlock)break}}else{let r=t.childNodes[e-1];a=r&&("BR"==r.nodeName||"false"==r.contentEditable)}}if(or&&h.focusNode&&h.focusNode!=l.node&&1==h.focusNode.nodeType){let t=h.focusNode.childNodes[h.focusOffset];t&&"false"==t.contentEditable&&(i=!0)}if(!(i||a&&ar)&&Ve(o.node,o.offset,h.anchorNode,h.anchorOffset)&&Ve(l.node,l.offset,h.focusNode,h.focusOffset))return;let f=!1;if((u.extend||t==e)&&!a){u.collapse(o.node,o.offset);try{t!=e&&u.extend(l.node,l.offset),f=!0}catch(t){}}if(!f){if(t>e){let t=o;o=l,l=t}let r=document.createRange();r.setEnd(l.node,l.offset),r.setStart(o.node,o.offset),u.removeAllRanges(),u.addRange(r)}}ignoreMutation(t){return!this.contentDOM&&"selection"!=t.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,e){for(let r=0,i=0;i<this.children.length;i++){let n=this.children[i],s=r+n.size;if(r==s?t<=s&&e>=r:t<s&&e>r){let i=r+n.border,o=s-n.border;if(t>=i&&e<=o)return this.dirty=t==r||e==s?2:1,void(t!=i||e!=o||!n.contentLost&&n.dom.parentNode==this.contentDOM?n.markDirty(t-i,e-i):n.dirty=3);n.dirty=n.dom!=n.contentDOM||n.dom.parentNode!=this.contentDOM||n.children.length?3:2}r=s}this.dirty=2}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let r=1==t?2:1;e.dirty<r&&(e.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(t){return!1}}class jr extends Ir{constructor(t,e,r,i){let n,s=e.type.toDOM;if("function"==typeof s&&(s=s(r,(()=>n?n.parent?n.parent.posBeforeChild(n):void 0:i))),!e.type.spec.raw){if(1!=s.nodeType){let t=document.createElement("span");t.appendChild(s),s=t}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(t,[],s,null),this.widget=e,this.widget=e,n=this}matchesWidget(t){return 0==this.dirty&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){let e=this.widget.spec.stopEvent;return!!e&&e(t)}ignoreMutation(t){return"selection"!=t.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class Pr extends Ir{constructor(t,e,r,i){super(t,[],e,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(t,e){return t!=this.textDOM?this.posAtStart+(e?this.size:0):this.posAtStart+e}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return"characterData"===t.type&&t.target.nodeValue==t.oldValue}}class Lr extends Ir{constructor(t,e,r,i,n){super(t,[],r,i),this.mark=e,this.spec=n}static create(t,e,r,i){let n=i.nodeViews[e.type.name],s=n&&n(e,i,r);return s&&s.dom||(s=xt.renderSpec(document,e.type.spec.toDOM(e,r),null,e.attrs)),new Lr(t,e,s.dom,s.contentDOM||s.dom,s)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return 3!=this.dirty&&this.mark.eq(t)}markDirty(t,e){if(super.markDirty(t,e),0!=this.dirty){let t=this.parent;for(;!t.node;)t=t.parent;t.dirty<this.dirty&&(t.dirty=this.dirty),this.dirty=0}}slice(t,e,r){let i=Lr.create(this.parent,this.mark,!0,r),n=this.children,s=this.size;e<s&&(n=si(n,e,s,r)),t>0&&(n=si(n,0,t,r));for(let t=0;t<n.length;t++)n[t].parent=i;return i.children=n,i}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Jr extends Ir{constructor(t,e,r,i,n,s,o,l,u){super(t,[],n,s),this.node=e,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=o}static create(t,e,r,i,n,s){let o,l=n.nodeViews[e.type.name],u=l&&l(e,n,(()=>o?o.parent?o.parent.posBeforeChild(o):void 0:s),r,i),h=u&&u.dom,a=u&&u.contentDOM;if(e.isText)if(h){if(3!=h.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else h=document.createTextNode(e.text);else if(!h){let t=xt.renderSpec(document,e.type.spec.toDOM(e),null,e.attrs);({dom:h,contentDOM:a}=t)}a||e.isText||"BR"==h.nodeName||(h.hasAttribute("contenteditable")||(h.contentEditable="false"),e.type.spec.draggable&&(h.draggable=!0));let f=h;return h=ti(h,r,e),u?o=new Wr(t,e,r,i,h,a||null,f,u,n,s+1):e.isText?new Vr(t,e,r,i,h,f,n):new Jr(t,e,r,i,h,a||null,f,n,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(t.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let e=this.children.length-1;e>=0;e--){let r=this.children[e];if(this.dom.contains(r.dom.parentNode)){t.contentElement=r.dom.parentNode;break}}t.contentElement||(t.getContent=()=>E.empty)}else t.contentElement=this.contentDOM;else t.getContent=()=>this.node.content;return t}matchesNode(t,e,r){return 0==this.dirty&&t.eq(this.node)&&ei(e,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,e){let r=this.node.inlineContent,i=e,n=t.composing?this.localCompositionInfo(t,e):null,s=n&&n.pos>-1?n:null,o=n&&n.pos<0,l=new ii(this,s&&s.node,t);!function(t,e,r,i){let n=e.locals(t),s=0;if(0==n.length){for(let r=0;r<t.childCount;r++){let o=t.child(r);i(o,n,e.forChild(s,o),r),s+=o.nodeSize}return}let o=0,l=[],u=null;for(let h=0;;){let a,f,c,d;for(;o<n.length&&n[o].to==s;){let t=n[o++];t.widget&&(a?(f||(f=[a])).push(t):a=t)}if(a)if(f){f.sort(ni);for(let t=0;t<f.length;t++)r(f[t],h,!!u)}else r(a,h,!!u);if(u)d=-1,c=u,u=null;else{if(!(h<t.childCount))break;d=h,c=t.child(h++)}for(let t=0;t<l.length;t++)l[t].to<=s&&l.splice(t--,1);for(;o<n.length&&n[o].from<=s&&n[o].to>s;)l.push(n[o++]);let p=s+c.nodeSize;if(c.isText){let t=p;o<n.length&&n[o].from<t&&(t=n[o].from);for(let e=0;e<l.length;e++)l[e].to<t&&(t=l[e].to);t<p&&(u=c.cut(t-s),c=c.cut(0,t-s),p=t,d=-1)}else for(;o<n.length&&n[o].to<p;)o++;i(c,c.isInline&&!c.isLeaf?l.filter((t=>!t.inline)):l.slice(),e.forChild(s,c),d),s=p}}(this.node,this.innerDeco,((e,n,s)=>{e.spec.marks?l.syncToMarks(e.spec.marks,r,t):e.type.side>=0&&!s&&l.syncToMarks(n==this.node.childCount?C.none:this.node.child(n).marks,r,t),l.placeWidget(e,t,i)}),((e,s,u,h)=>{let a;l.syncToMarks(e.marks,r,t),l.findNodeMatch(e,s,u,h)||o&&t.state.selection.from>i&&t.state.selection.to<i+e.nodeSize&&(a=l.findIndexWithChild(n.node))>-1&&l.updateNodeAt(e,s,u,a,t)||l.updateNextNode(e,s,u,t,h,i)||l.addNode(e,s,u,t,i),i+=e.nodeSize})),l.syncToMarks([],r,t),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||2==this.dirty)&&(s&&this.protectLocalComposition(t,s),Gr(this.contentDOM,this.children,t),fr&&function(t){if("UL"==t.nodeName||"OL"==t.nodeName){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t),t.style.cssText=e}}(this.dom))}localCompositionInfo(t,e){let{from:r,to:i}=t.state.selection;if(!(t.state.selection instanceof ye)||r<e||i>e+this.node.content.size)return null;let n=t.input.compositionNode;if(!n||!this.dom.contains(n.parentNode))return null;if(this.node.inlineContent){let t=n.nodeValue,s=function(t,e,r,i){for(let n=0,s=0;n<t.childCount&&s<=i;){let o=t.child(n++),l=s;if(s+=o.nodeSize,!o.isText)continue;let u=o.text;for(;n<t.childCount;){let e=t.child(n++);if(s+=e.nodeSize,!e.isText)break;u+=e.text}if(s>=r){if(s>=i&&u.slice(i-e.length-l,i-l)==e)return i-e.length;let t=l<i?u.lastIndexOf(e,i-l-1):-1;if(t>=0&&t+e.length+l>=r)return l+t;if(r==i&&u.length>=i+e.length-l&&u.slice(i-l,i-l+e.length)==e)return i}}return-1}(this.node.content,t,r-e,i-e);return s<0?null:{node:n,pos:s,text:t}}return{node:n,pos:-1,text:""}}protectLocalComposition(t,{node:e,pos:r,text:i}){if(this.getDesc(e))return;let n=e;for(;n.parentNode!=this.contentDOM;n=n.parentNode){for(;n.previousSibling;)n.parentNode.removeChild(n.previousSibling);for(;n.nextSibling;)n.parentNode.removeChild(n.nextSibling);n.pmViewDesc&&(n.pmViewDesc=void 0)}let s=new Pr(this,n,e,i);t.input.compositionNodes.push(s),this.children=si(this.children,r,r+i.length,t,s)}update(t,e,r,i){return!(3==this.dirty||!t.sameMarkup(this.node)||(this.updateInner(t,e,r,i),0))}updateInner(t,e,r,i){this.updateOuterDeco(e),this.node=t,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=0}updateOuterDeco(t){if(ei(t,this.outerDeco))return;let e=1!=this.nodeDOM.nodeType,r=this.dom;this.dom=Xr(this.dom,this.nodeDOM,Yr(this.outerDeco,this.node,e),Yr(t,this.node,e)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}selectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Ur(t,e,r,i,n){ti(i,e,t);let s=new Jr(void 0,t,e,r,i,i,i,n,0);return s.contentDOM&&s.updateChildren(n,0),s}class Vr extends Jr{constructor(t,e,r,i,n,s,o){super(t,e,r,i,n,null,s,o,0)}parseRule(){let t=this.nodeDOM.parentNode;for(;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}}update(t,e,r,i){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!t.sameMarkup(this.node)||(this.updateOuterDeco(e),0==this.dirty&&t.text==this.node.text||t.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=t.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=t,this.dirty=0,0))}inParent(){let t=this.parent.contentDOM;for(let e=this.nodeDOM;e;e=e.parentNode)if(e==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,e,r){return t==this.nodeDOM?this.posAtStart+Math.min(e,this.node.text.length):super.localPosFromDOM(t,e,r)}ignoreMutation(t){return"characterData"!=t.type&&"selection"!=t.type}slice(t,e,r){let i=this.node.cut(t,e),n=document.createTextNode(i.text);return new Vr(this.parent,i,this.outerDeco,this.innerDeco,n,n,r)}markDirty(t,e){super.markDirty(t,e),this.dom==this.nodeDOM||0!=t&&e!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}isText(t){return this.node.text==t}}class Hr extends Ir{parseRule(){return{ignore:!0}}matchesHack(t){return 0==this.dirty&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class Wr extends Jr{constructor(t,e,r,i,n,s,o,l,u,h){super(t,e,r,i,n,s,o,u,h),this.spec=l}update(t,e,r,i){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){let n=this.spec.update(t,e,r);return n&&this.updateInner(t,e,r,i),n}return!(!this.contentDOM&&!t.isLeaf)&&super.update(t,e,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,e,r,i){this.spec.setSelection?this.spec.setSelection(t,e,r.root):super.setSelection(t,e,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return!!this.spec.stopEvent&&this.spec.stopEvent(t)}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function Gr(t,e,r){let i=t.firstChild,n=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==t){for(;l!=i;)i=ri(i),n=!0;i=i.nextSibling}else n=!0,t.insertBefore(l,i);if(o instanceof Lr){let e=i?i.previousSibling:t.lastChild;Gr(o.contentDOM,o.children,r),i=e?e.nextSibling:t.firstChild}}for(;i;)i=ri(i),n=!0;n&&r.trackWrites==t&&(r.trackWrites=null)}const Zr=function(t){t&&(this.nodeName=t)};Zr.prototype=Object.create(null);const Kr=[new Zr];function Yr(t,e,r){if(0==t.length)return Kr;let i=r?Kr[0]:new Zr,n=[i];for(let s=0;s<t.length;s++){let o=t[s].type.attrs;if(o){o.nodeName&&n.push(i=new Zr(o.nodeName));for(let t in o){let s=o[t];null!=s&&(r&&1==n.length&&n.push(i=new Zr(e.isInline?"span":"div")),"class"==t?i.class=(i.class?i.class+" ":"")+s:"style"==t?i.style=(i.style?i.style+";":"")+s:"nodeName"!=t&&(i[t]=s))}}}return n}function Xr(t,e,r,i){if(r==Kr&&i==Kr)return e;let n=e;for(let e=0;e<i.length;e++){let s=i[e],o=r[e];if(e){let e;o&&o.nodeName==s.nodeName&&n!=t&&(e=n.parentNode)&&e.nodeName.toLowerCase()==s.nodeName||(e=document.createElement(s.nodeName),e.pmIsDeco=!0,e.appendChild(n),o=Kr[0]),n=e}Qr(n,o||Kr[0],s)}return n}function Qr(t,e,r){for(let i in e)"class"==i||"style"==i||"nodeName"==i||i in r||t.removeAttribute(i);for(let i in r)"class"!=i&&"style"!=i&&"nodeName"!=i&&r[i]!=e[i]&&t.setAttribute(i,r[i]);if(e.class!=r.class){let i=e.class?e.class.split(" ").filter(Boolean):[],n=r.class?r.class.split(" ").filter(Boolean):[];for(let e=0;e<i.length;e++)-1==n.indexOf(i[e])&&t.classList.remove(i[e]);for(let e=0;e<n.length;e++)-1==i.indexOf(n[e])&&t.classList.add(n[e]);0==t.classList.length&&t.removeAttribute("class")}if(e.style!=r.style){if(e.style){let r,i=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;r=i.exec(e.style);)t.style.removeProperty(r[1])}r.style&&(t.style.cssText+=r.style)}}function ti(t,e,r){return Xr(t,t,Kr,Yr(e,r,1!=t.nodeType))}function ei(t,e){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!t[r].type.eq(e[r].type))return!1;return!0}function ri(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class ii{constructor(t,e,r){this.lock=e,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=function(t,e){let r=e,i=r.children.length,n=t.childCount,s=new Map,o=[];t:for(;n>0;){let l;for(;;)if(i){let t=r.children[i-1];if(!(t instanceof Lr)){l=t,i--;break}r=t,i=t.children.length}else{if(r==e)break t;i=r.parent.children.indexOf(r),r=r.parent}let u=l.node;if(u){if(u!=t.child(n-1))break;--n,s.set(l,n),o.push(l)}}return{index:n,matched:s,matches:o.reverse()}}(t.node.content,t)}destroyBetween(t,e){if(t!=e){for(let r=t;r<e;r++)this.top.children[r].destroy();this.top.children.splice(t,e-t),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,e,r){let i=0,n=this.stack.length>>1,s=Math.min(n,t.length);for(;i<s&&(i==n-1?this.top:this.stack[i+1<<1]).matchesMark(t[i])&&!1!==t[i].type.spec.spanning;)i++;for(;i<n;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),n--;for(;n<t.length;){this.stack.push(this.top,this.index+1);let i=-1;for(let e=this.index;e<Math.min(this.index+3,this.top.children.length);e++){let r=this.top.children[e];if(r.matchesMark(t[n])&&!this.isLocked(r.dom)){i=e;break}}if(i>-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let i=Lr.create(this.top,t[n],e,r);this.top.children.splice(this.index,0,i),this.top=i,this.changed=!0}this.index=0,n++}}findNodeMatch(t,e,r,i){let n,s=-1;if(i>=this.preMatch.index&&(n=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&n.matchesNode(t,e,r))s=this.top.children.indexOf(n,this.index);else for(let i=this.index,n=Math.min(this.top.children.length,i+5);i<n;i++){let n=this.top.children[i];if(n.matchesNode(t,e,r)&&!this.preMatch.matched.has(n)){s=i;break}}return!(s<0||(this.destroyBetween(this.index,s),this.index++,0))}updateNodeAt(t,e,r,i,n){let s=this.top.children[i];return 3==s.dirty&&s.dom==s.contentDOM&&(s.dirty=2),!!s.update(t,e,r,n)&&(this.destroyBetween(this.index,i),this.index++,!0)}findIndexWithChild(t){for(;;){let e=t.parentNode;if(!e)return-1;if(e==this.top.contentDOM){let e=t.pmViewDesc;if(e)for(let t=this.index;t<this.top.children.length;t++)if(this.top.children[t]==e)return t;return-1}t=e}}updateNextNode(t,e,r,i,n,s){for(let o=this.index;o<this.top.children.length;o++){let l=this.top.children[o];if(l instanceof Jr){let u=this.preMatch.matched.get(l);if(null!=u&&u!=n)return!1;let h,a=l.dom,f=this.isLocked(a)&&!(t.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==t.text&&3!=l.dirty&&ei(e,l.outerDeco));if(!f&&l.update(t,e,r,i))return this.destroyBetween(this.index,o),l.dom!=a&&(this.changed=!0),this.index++,!0;if(!f&&(h=this.recreateWrapper(l,t,e,r,i,s)))return this.destroyBetween(this.index,o),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=2,h.updateChildren(i,s+1),h.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(t,e,r,i,n,s){if(t.dirty||e.isAtom||!t.children.length||!t.node.content.eq(e.content)||!ei(r,t.outerDeco)||!i.eq(t.innerDeco))return null;let o=Jr.create(this.top,e,r,i,n,s);if(o.contentDOM){o.children=t.children,t.children=[];for(let t of o.children)t.parent=o}return t.destroy(),o}addNode(t,e,r,i,n){let s=Jr.create(this.top,t,e,r,i,n);s.contentDOM&&s.updateChildren(i,n+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(t,e,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(!i||!i.matchesWidget(t)||t!=i.widget&&i.widget.type.toDOM.parentNode){let i=new jr(this.top,t,e,r);this.top.children.splice(this.index++,0,i),this.changed=!0}else this.index++}addTextblockHacks(){let t=this.top.children[this.index-1],e=this.top;for(;t instanceof Lr;)e=t,t=e.children[e.children.length-1];(!t||!(t instanceof Vr)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text))&&((ar||ur)&&t&&"false"==t.dom.contentEditable&&this.addHackNode("IMG",e),this.addHackNode("BR",this.top))}addHackNode(t,e){if(e==this.top&&this.index<e.children.length&&e.children[this.index].matchesHack(t))this.index++;else{let r=document.createElement(t);"IMG"==t&&(r.className="ProseMirror-separator",r.alt=""),"BR"==t&&(r.className="ProseMirror-trailingBreak");let i=new Hr(this.top,[],r,null);e!=this.top?e.children.push(i):e.children.splice(this.index++,0,i),this.changed=!0}}isLocked(t){return this.lock&&(t==this.lock||1==t.nodeType&&t.contains(this.lock.parentNode))}}function ni(t,e){return t.type.side-e.type.side}function si(t,e,r,i,n){let s=[];for(let o=0,l=0;o<t.length;o++){let u=t[o],h=l,a=l+=u.size;h>=r||a<=e?s.push(u):(h<e&&s.push(u.slice(0,e-h,i)),n&&(s.push(n),n=void 0),a>r&&s.push(u.slice(r-h,u.size,i)))}return s}function oi(t,e=null){let r=t.domSelectionRange(),i=t.state.doc;if(!r.focusNode)return null;let n=t.docView.nearestDesc(r.focusNode),s=n&&0==n.size,o=t.docView.posFromDOM(r.focusNode,r.focusOffset,1);if(o<0)return null;let l,u,h=i.resolve(o);if(Ke(r)){for(l=o;n&&!n.node;)n=n.parent;let t=n.node;if(n&&t.isAtom&&xe.isSelectable(t)&&n.parent&&(!t.isInline||!function(t,e,r){for(let i=0==e,n=e==Ge(t);i||n;){if(t==r)return!0;let e=Pe(t);if(!(t=t.parentNode))return!1;i=i&&0==e,n=n&&e==Ge(t)}}(r.focusNode,r.focusOffset,n.dom))){let t=n.posBefore;u=new xe(o==t?h:i.resolve(t))}}else{if(r instanceof t.dom.ownerDocument.defaultView.Selection&&r.rangeCount>1){let e=o,n=o;for(let i=0;i<r.rangeCount;i++){let s=r.getRangeAt(i);e=Math.min(e,t.docView.posFromDOM(s.startContainer,s.startOffset,1)),n=Math.max(n,t.docView.posFromDOM(s.endContainer,s.endOffset,-1))}if(e<0)return null;[l,o]=n==t.state.selection.anchor?[n,e]:[e,n],h=i.resolve(o)}else l=t.docView.posFromDOM(r.anchorNode,r.anchorOffset,1);if(l<0)return null}let a=i.resolve(l);return u||(u=mi(t,a,h,"pointer"==e||t.state.selection.head<h.pos&&!s?1:-1)),u}function li(t){return t.editable?t.hasFocus():wi(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function ui(t,e=!1){let r=t.state.selection;if(di(t,r),li(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&ur){let e=t.domSelectionRange(),r=t.domObserver.currentSelection;if(e.anchorNode&&r.anchorNode&&Ve(e.anchorNode,e.anchorOffset,r.anchorNode,r.anchorOffset))return t.input.mouseDown.delayedSelectionSync=!0,void t.domObserver.setCurSelection()}if(t.domObserver.disconnectSelection(),t.cursorWrapper)!function(t){let e=t.domSelection(),r=document.createRange();if(!e)return;let i=t.cursorWrapper.dom,n="IMG"==i.nodeName;n?r.setStart(i.parentNode,Pe(i)+1):r.setStart(i,0),r.collapse(!0),e.removeAllRanges(),e.addRange(r),!n&&!t.state.selection.visible&&nr&&sr<=11&&(i.disabled=!0,i.disabled=!1)}(t);else{let i,n,{anchor:s,head:o}=r;!hi||r instanceof ye||(r.$from.parent.inlineContent||(i=ai(t,r.from)),r.empty||r.$from.parent.inlineContent||(n=ai(t,r.to))),t.docView.setSelection(s,o,t,e),hi&&(i&&ci(i),n&&ci(n)),r.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let r=t.domSelectionRange(),i=r.anchorNode,n=r.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{r.anchorNode==i&&r.anchorOffset==n||(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout((()=>{li(t)&&!t.state.selection.visible||t.dom.classList.remove("ProseMirror-hideselection")}),20))})}(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const hi=ar||ur&&hr<63;function ai(t,e){let{node:r,offset:i}=t.docView.domFromPos(e,0),n=i<r.childNodes.length?r.childNodes[i]:null,s=i?r.childNodes[i-1]:null;if(ar&&n&&"false"==n.contentEditable)return fi(n);if(!(n&&"false"!=n.contentEditable||s&&"false"!=s.contentEditable)){if(n)return fi(n);if(s)return fi(s)}}function fi(t){return t.contentEditable="true",ar&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function ci(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function di(t,e){if(e instanceof xe){let r=t.docView.descAt(e.from);r!=t.lastSelectedViewDesc&&(pi(t),r&&r.selectNode(),t.lastSelectedViewDesc=r)}else pi(t)}function pi(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function mi(t,e,r,i){return t.someProp("createSelectionBetween",(i=>i(t,e,r)))||ye.between(e,r,i)}function gi(t){return!(t.editable&&!t.hasFocus())&&wi(t)}function wi(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(3==e.anchorNode.nodeType?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(3==e.focusNode.nodeType?e.focusNode.parentNode:e.focusNode))}catch(t){return!1}}function bi(t,e){let{$anchor:r,$head:i}=t.selection,n=e>0?r.max(i):r.min(i),s=n.parent.inlineContent?n.depth?t.doc.resolve(e>0?n.after():n.before()):null:n;return s&&be.findFrom(s,e)}function vi(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function ki(t,e,r){let i=t.state.selection;if(!(i instanceof ye)){if(i instanceof xe&&i.node.isInline)return vi(t,new ye(e>0?i.$to:i.$from));{let r=bi(t.state,e);return!!r&&vi(t,r)}}if(r.indexOf("s")>-1){let{$head:r}=i,n=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter;if(!n||n.isText||!n.isLeaf)return!1;let s=t.state.doc.resolve(r.pos+n.nodeSize*(e<0?-1:1));return vi(t,new ye(i.$anchor,s))}if(!i.empty)return!1;if(t.endOfTextblock(e>0?"forward":"backward")){let r=bi(t.state,e);return!!(r&&r instanceof xe)&&vi(t,r)}if(!(cr&&r.indexOf("m")>-1)){let r,n=i.$head,s=n.textOffset?null:e<0?n.nodeBefore:n.nodeAfter;if(!s||s.isText)return!1;let o=e<0?n.pos-s.nodeSize:n.pos;return!!(s.isAtom||(r=t.docView.descAt(o))&&!r.contentDOM)&&(xe.isSelectable(s)?vi(t,new xe(e<0?t.state.doc.resolve(n.pos-s.nodeSize):n)):!!mr&&vi(t,new ye(t.state.doc.resolve(e<0?o:o+s.nodeSize))))}}function Di(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function yi(t,e){let r=t.pmViewDesc;return r&&0==r.size&&(e<0||t.nextSibling||"BR"!=t.nodeName)}function Ei(t,e){return e<0?function(t){let e=t.domSelectionRange(),r=e.focusNode,i=e.focusOffset;if(!r)return;let n,s,o=!1;for(or&&1==r.nodeType&&i<Di(r)&&yi(r.childNodes[i],-1)&&(o=!0);;)if(i>0){if(1!=r.nodeType)break;{let t=r.childNodes[i-1];if(yi(t,-1))n=r,s=--i;else{if(3!=t.nodeType)break;r=t,i=r.nodeValue.length}}}else{if(xi(r))break;{let e=r.previousSibling;for(;e&&yi(e,-1);)n=r.parentNode,s=Pe(e),e=e.previousSibling;if(e)r=e,i=Di(r);else{if(r=r.parentNode,r==t.dom)break;i=0}}}o?Fi(t,r,i):n&&Fi(t,n,s)}(t):function(t){let e=t.domSelectionRange(),r=e.focusNode,i=e.focusOffset;if(!r)return;let n,s,o=Di(r);for(;;)if(i<o){if(1!=r.nodeType)break;if(!yi(r.childNodes[i],1))break;n=r,s=++i}else{if(xi(r))break;{let e=r.nextSibling;for(;e&&yi(e,1);)n=e.parentNode,s=Pe(e)+1,e=e.nextSibling;if(e)r=e,i=0,o=Di(r);else{if(r=r.parentNode,r==t.dom)break;i=o=0}}}n&&Fi(t,n,s)}(t)}function xi(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Fi(t,e,r){if(3!=e.nodeType){let t,i;(i=function(t,e){for(;t&&e==t.childNodes.length&&!Ze(t);)e=Pe(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let r=t.childNodes[e];if(3==r.nodeType)return r;if(1==r.nodeType&&"false"==r.contentEditable)break;t=r,e=0}}(e,r))?(e=i,r=0):(t=function(t,e){for(;t&&!e&&!Ze(t);)e=Pe(t),t=t.parentNode;for(;t&&e;){let r=t.childNodes[e-1];if(3==r.nodeType)return r;if(1==r.nodeType&&"false"==r.contentEditable)break;e=(t=r).childNodes.length}}(e,r))&&(e=t,r=t.nodeValue.length)}let i=t.domSelection();if(!i)return;if(Ke(i)){let t=document.createRange();t.setEnd(e,r),t.setStart(e,r),i.removeAllRanges(),i.addRange(t)}else i.extend&&i.extend(e,r);t.domObserver.setCurSelection();let{state:n}=t;setTimeout((()=>{t.state==n&&ui(t)}),50)}function Mi(t,e){let r=t.state.doc.resolve(e);if(!ur&&!dr&&r.parent.inlineContent){let i=t.coordsAtPos(e);if(e>r.start()){let r=t.coordsAtPos(e-1),n=(r.top+r.bottom)/2;if(n>i.top&&n<i.bottom&&Math.abs(r.left-i.left)>1)return r.left<i.left?"ltr":"rtl"}if(e<r.end()){let r=t.coordsAtPos(e+1),n=(r.top+r.bottom)/2;if(n>i.top&&n<i.bottom&&Math.abs(r.left-i.left)>1)return r.left>i.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(t.dom).direction?"rtl":"ltr"}function Ci(t,e,r){let i=t.state.selection;if(i instanceof ye&&!i.empty||r.indexOf("s")>-1)return!1;if(cr&&r.indexOf("m")>-1)return!1;let{$from:n,$to:s}=i;if(!n.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let r=bi(t.state,e);if(r&&r instanceof xe)return vi(t,r)}if(!n.parent.inlineContent){let r=e<0?n:s,o=i instanceof Me?be.near(r,e):be.findFrom(r,e);return!!o&&vi(t,o)}return!1}function Ai(t,e){if(!(t.state.selection instanceof ye))return!0;let{$head:r,$anchor:i,empty:n}=t.state.selection;if(!r.sameParent(i))return!0;if(!n)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!r.textOffset&&(e<0?r.nodeBefore:r.nodeAfter);if(s&&!s.isText){let i=t.state.tr;return e<0?i.delete(r.pos-s.nodeSize,r.pos):i.delete(r.pos,r.pos+s.nodeSize),t.dispatch(i),!0}return!1}function Si(t,e,r){t.domObserver.stop(),e.contentEditable=r,t.domObserver.start()}function Oi(t,e){t.someProp("transformCopied",(r=>{e=r(e,t)}));let r=[],{content:i,openStart:n,openEnd:s}=e;for(;n>1&&s>1&&1==i.childCount&&1==i.firstChild.childCount;){n--,s--;let t=i.firstChild;r.push(t.type.name,t.attrs!=t.type.defaultAttrs?t.attrs:null),i=t.content}let o=t.someProp("clipboardSerializer")||xt.fromSchema(t.state.schema),l=ji(),u=l.createElement("div");u.appendChild(o.serializeFragment(i,{document:l}));let h,a=u.firstChild,f=0;for(;a&&1==a.nodeType&&(h=qi[a.nodeName.toLowerCase()]);){for(let t=h.length-1;t>=0;t--){let e=l.createElement(h[t]);for(;u.firstChild;)e.appendChild(u.firstChild);u.appendChild(e),f++}a=u.firstChild}return a&&1==a.nodeType&&a.setAttribute("data-pm-slice",`${n} ${s}${f?` -${f}`:""} ${JSON.stringify(r)}`),{dom:u,text:t.someProp("clipboardTextSerializer",(r=>r(e,t)))||e.content.textBetween(0,e.content.size,"\n\n"),slice:e}}function $i(t,e,r,i,n){let s,o,l=n.parent.type.spec.code;if(!r&&!e)return null;let u=e&&(i||l||!r);if(u){if(t.someProp("transformPastedText",(r=>{e=r(e,l||i,t)})),l)return e?new S(E.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0):S.empty;let r=t.someProp("clipboardTextParser",(r=>r(e,n,i,t)));if(r)o=r;else{let r=n.marks(),{schema:i}=t.state,o=xt.fromSchema(i);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach((t=>{let e=s.appendChild(document.createElement("p"));t&&e.appendChild(o.serializeNode(i.text(t,r)))}))}}else t.someProp("transformPastedHTML",(e=>{r=e(r,t)})),s=function(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let r,i=ji().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(t);if((r=n&&qi[n[1].toLowerCase()])&&(t=r.map((t=>"<"+t+">")).join("")+t+r.map((t=>"</"+t+">")).reverse().join("")),i.innerHTML=function(t){let e=window.trustedTypes;return e?(Pi||(Pi=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Pi.createHTML(t)):t}(t),r)for(let t=0;t<r.length;t++)i=i.querySelector(r[t])||i;return i}(r),mr&&function(t){let e=t.querySelectorAll(ur?"span:not([class]):not([style])":"span.Apple-converted-space");for(let r=0;r<e.length;r++){let i=e[r];1==i.childNodes.length&&" "==i.textContent&&i.parentNode&&i.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),i)}}(s);let h=s&&s.querySelector("[data-pm-slice]"),a=h&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(h.getAttribute("data-pm-slice")||"");if(a&&a[3])for(let t=+a[3];t>0;t--){let t=s.firstChild;for(;t&&1!=t.nodeType;)t=t.nextSibling;if(!t)break;s=t}if(!o){let e=t.someProp("clipboardParser")||t.someProp("domParser")||pt.fromSchema(t.state.schema);o=e.parseSlice(s,{preserveWhitespace:!(!u&&!a),context:n,ruleFromNode:t=>"BR"!=t.nodeName||t.nextSibling||!t.parentNode||Bi.test(t.parentNode.nodeName)?null:{ignore:!0}})}if(a)o=function(t,e){if(!t.size)return t;let r,i=t.content.firstChild.type.schema;try{r=JSON.parse(e)}catch(e){return t}let{content:n,openStart:s,openEnd:o}=t;for(let t=r.length-2;t>=0;t-=2){let e=i.nodes[r[t]];if(!e||e.hasRequiredAttrs())break;n=E.from(e.create(r[t+1],n)),s++,o++}return new S(n,s,o)}(zi(o,+a[1],+a[2]),a[4]);else if(o=S.maxOpen(function(t,e){if(t.childCount<2)return t;for(let r=e.depth;r>=0;r--){let i,n=e.node(r).contentMatchAt(e.index(r)),s=[];if(t.forEach((t=>{if(!s)return;let e,r=n.findWrapping(t.type);if(!r)return s=null;if(e=s.length&&i.length&&Ni(r,i,t,s[s.length-1],0))s[s.length-1]=e;else{s.length&&(s[s.length-1]=_i(s[s.length-1],i.length));let e=Ri(t,r);s.push(e),n=n.matchType(e.type),i=r}})),s)return E.from(s)}return t}(o.content,n),!0),o.openStart||o.openEnd){let t=0,e=0;for(let e=o.content.firstChild;t<o.openStart&&!e.type.spec.isolating;t++,e=e.firstChild);for(let t=o.content.lastChild;e<o.openEnd&&!t.type.spec.isolating;e++,t=t.lastChild);o=zi(o,t,e)}return t.someProp("transformPasted",(e=>{o=e(o,t)})),o}const Bi=/^(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 Ri(t,e,r=0){for(let i=e.length-1;i>=r;i--)t=e[i].create(null,E.from(t));return t}function Ni(t,e,r,i,n){if(n<t.length&&n<e.length&&t[n]==e[n]){let s=Ni(t,e,r,i.lastChild,n+1);if(s)return i.copy(i.content.replaceChild(i.childCount-1,s));if(i.contentMatchAt(i.childCount).matchType(n==t.length-1?r.type:t[n+1]))return i.copy(i.content.append(E.from(Ri(r,t,n+1))))}}function _i(t,e){if(0==e)return t;let r=t.content.replaceChild(t.childCount-1,_i(t.lastChild,e-1)),i=t.contentMatchAt(t.childCount).fillBefore(E.empty,!0);return t.copy(r.append(i))}function Ti(t,e,r,i,n,s){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(s=0),n<i-1&&(l=Ti(l,e,r,i,n+1,s)),n>=r&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=n).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(E.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function zi(t,e,r){return e<t.openStart&&(t=new S(Ti(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),r<t.openEnd&&(t=new S(Ti(t.content,1,r,t.openEnd,0,0),t.openStart,r)),t}const qi={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Ii=null;function ji(){return Ii||(Ii=document.implementation.createHTMLDocument("title"))}let Pi=null;const Li={},Ji={},Ui={touchstart:!0,touchmove:!0};class Vi{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},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.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Hi(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function Wi(t){t.someProp("handleDOMEvents",(e=>{for(let r in e)t.input.eventHandlers[r]||t.dom.addEventListener(r,t.input.eventHandlers[r]=e=>Gi(t,e))}))}function Gi(t,e){return t.someProp("handleDOMEvents",(r=>{let i=r[e.type];return!!i&&(i(t,e)||e.defaultPrevented)}))}function Zi(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let r=e.target;r!=t.dom;r=r.parentNode)if(!r||11==r.nodeType||r.pmViewDesc&&r.pmViewDesc.stopEvent(e))return!1;return!0}function Ki(t){return{left:t.clientX,top:t.clientY}}function Yi(t,e,r,i,n){if(-1==i)return!1;let s=t.state.doc.resolve(i);for(let i=s.depth+1;i>0;i--)if(t.someProp(e,(e=>i>s.depth?e(t,r,s.nodeAfter,s.before(i),n,!0):e(t,r,s.node(i),s.before(i),n,!1))))return!0;return!1}function Xi(t,e){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function Qi(t,e,r,i){return Yi(t,"handleDoubleClickOn",e,r,i)||t.someProp("handleDoubleClick",(r=>r(t,e,i)))}function tn(t,e,r,i){return Yi(t,"handleTripleClickOn",e,r,i)||t.someProp("handleTripleClick",(r=>r(t,e,i)))||function(t,e,r){if(0!=r.button)return!1;let i=t.state.doc;if(-1==e)return!!i.inlineContent&&(Xi(t,ye.create(i,0,i.content.size)),!0);let n=i.resolve(e);for(let e=n.depth+1;e>0;e--){let r=e>n.depth?n.nodeAfter:n.node(e),s=n.before(e);if(r.inlineContent)Xi(t,ye.create(i,s+1,s+1+r.content.size));else{if(!xe.isSelectable(r))continue;Xi(t,xe.create(i,s))}return!0}}(t,r,i)}function en(t){return hn(t)}Ji.keydown=(t,e)=>{let r=e;if(t.input.shiftKey=16==r.keyCode||r.shiftKey,!sn(t,r)&&(t.input.lastKeyCode=r.keyCode,t.input.lastKeyCodeTime=Date.now(),!pr||!ur||13!=r.keyCode))if(229!=r.keyCode&&t.domObserver.forceFlush(),!fr||13!=r.keyCode||r.ctrlKey||r.altKey||r.metaKey)t.someProp("handleKeyDown",(e=>e(t,r)))||function(t,e){let r=e.keyCode,i=function(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}(e);if(8==r||cr&&72==r&&"c"==i)return Ai(t,-1)||Ei(t,-1);if(46==r&&!e.shiftKey||cr&&68==r&&"c"==i)return Ai(t,1)||Ei(t,1);if(13==r||27==r)return!0;if(37==r||cr&&66==r&&"c"==i){let e=37==r?"ltr"==Mi(t,t.state.selection.from)?-1:1:-1;return ki(t,e,i)||Ei(t,e)}if(39==r||cr&&70==r&&"c"==i){let e=39==r?"ltr"==Mi(t,t.state.selection.from)?1:-1:1;return ki(t,e,i)||Ei(t,e)}return 38==r||cr&&80==r&&"c"==i?Ci(t,-1,i)||Ei(t,-1):40==r||cr&&78==r&&"c"==i?function(t){if(!ar||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:r}=t.domSelectionRange();if(e&&1==e.nodeType&&0==r&&e.firstChild&&"false"==e.firstChild.contentEditable){let r=e.firstChild;Si(t,r,"true"),setTimeout((()=>Si(t,r,"false")),20)}return!1}(t)||Ci(t,1,i)||Ei(t,1):i==(cr?"m":"c")&&(66==r||73==r||89==r||90==r)}(t,r)?r.preventDefault():Hi(t,"key");else{let e=Date.now();t.input.lastIOSEnter=e,t.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{t.input.lastIOSEnter==e&&(t.someProp("handleKeyDown",(e=>e(t,Ye(13,"Enter")))),t.input.lastIOSEnter=0)}),200)}},Ji.keyup=(t,e)=>{16==e.keyCode&&(t.input.shiftKey=!1)},Ji.keypress=(t,e)=>{let r=e;if(sn(t,r)||!r.charCode||r.ctrlKey&&!r.altKey||cr&&r.metaKey)return;if(t.someProp("handleKeyPress",(e=>e(t,r))))return void r.preventDefault();let i=t.state.selection;if(!(i instanceof ye&&i.$from.sameParent(i.$to))){let e=String.fromCharCode(r.charCode);/[\r\n]/.test(e)||t.someProp("handleTextInput",(r=>r(t,i.$from.pos,i.$to.pos,e)))||t.dispatch(t.state.tr.insertText(e).scrollIntoView()),r.preventDefault()}};const rn=cr?"metaKey":"ctrlKey";Li.mousedown=(t,e)=>{let r=e;t.input.shiftKey=r.shiftKey;let i=en(t),n=Date.now(),s="singleClick";n-t.input.lastClick.time<500&&function(t,e){let r=e.x-t.clientX,i=e.y-t.clientY;return r*r+i*i<100}(r,t.input.lastClick)&&!r[rn]&&("singleClick"==t.input.lastClick.type?s="doubleClick":"doubleClick"==t.input.lastClick.type&&(s="tripleClick")),t.input.lastClick={time:n,x:r.clientX,y:r.clientY,type:s};let o=t.posAtCoords(Ki(r));o&&("singleClick"==s?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new nn(t,o,r,!!i)):("doubleClick"==s?Qi:tn)(t,o.pos,o.inside,r)?r.preventDefault():Hi(t,"pointer"))};class nn{constructor(t,e,r,i){let n,s;if(this.view=t,this.pos=e,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!r[rn],this.allowDefault=r.shiftKey,e.inside>-1)n=t.state.doc.nodeAt(e.inside),s=e.inside;else{let r=t.state.doc.resolve(e.pos);n=r.parent,s=r.depth?r.before():0}const o=i?null:r.target,l=o?t.docView.nearestDesc(o,!0):null;this.target=l&&1==l.dom.nodeType?l.dom:null;let{selection:u}=t.state;(0==r.button&&n.type.spec.draggable&&!1!==n.type.spec.selectable||u instanceof xe&&u.from<=s&&u.to>s)&&(this.mightDrag={node:n,pos:s,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!or||this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout((()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")}),20),this.view.domObserver.start()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),Hi(t,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout((()=>ui(this.view))),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let e=this.pos;this.view.state.doc!=this.startDoc&&(e=this.view.posAtCoords(Ki(t))),this.updateAllowDefault(t),this.allowDefault||!e?Hi(this.view,"pointer"):function(t,e,r,i,n){return Yi(t,"handleClickOn",e,r,i)||t.someProp("handleClick",(r=>r(t,e,i)))||(n?function(t,e){if(-1==e)return!1;let r,i,n=t.state.selection;n instanceof xe&&(r=n.node);let s=t.state.doc.resolve(e);for(let t=s.depth+1;t>0;t--){let e=t>s.depth?s.nodeAfter:s.node(t);if(xe.isSelectable(e)){i=r&&n.$from.depth>0&&t>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?s.before(n.$from.depth):s.before(t);break}}return null!=i&&(Xi(t,xe.create(t.state.doc,i)),!0)}(t,r):function(t,e){if(-1==e)return!1;let r=t.state.doc.resolve(e),i=r.nodeAfter;return!!(i&&i.isAtom&&xe.isSelectable(i))&&(Xi(t,new xe(r)),!0)}(t,r))}(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():0==t.button&&(this.flushed||ar&&this.mightDrag&&!this.mightDrag.node.isAtom||ur&&!this.view.state.selection.visible&&Math.min(Math.abs(e.pos-this.view.state.selection.from),Math.abs(e.pos-this.view.state.selection.to))<=2)?(Xi(this.view,be.near(this.view.state.doc.resolve(e.pos))),t.preventDefault()):Hi(this.view,"pointer")}move(t){this.updateAllowDefault(t),Hi(this.view,"pointer"),0==t.buttons&&this.done()}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}}function sn(t,e){return!!t.composing||!!(ar&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500)&&(t.input.compositionEndedAt=-2e8,!0)}Li.touchstart=t=>{t.input.lastTouch=Date.now(),en(t),Hi(t,"pointer")},Li.touchmove=t=>{t.input.lastTouch=Date.now(),Hi(t,"pointer")},Li.contextmenu=t=>en(t);const on=pr?5e3:-1;function ln(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout((()=>hn(t)),e))}function un(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=function(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function hn(t,e=!1){if(!(pr&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),un(t),e||t.docView&&t.docView.dirty){let r=oi(t);return r&&!r.eq(t.state.selection)?t.dispatch(t.state.tr.setSelection(r)):!t.markCursor&&!e||t.state.selection.empty?t.updateState(t.state):t.dispatch(t.state.tr.deleteSelection()),!0}return!1}}Ji.compositionstart=Ji.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,r=e.selection.$to;if(e.selection instanceof ye&&(e.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some((t=>!1===t.type.spec.inclusive))))t.markCursor=t.state.storedMarks||r.marks(),hn(t,!0),t.markCursor=null;else if(hn(t,!e.selection.empty),or&&e.selection.empty&&r.parentOffset&&!r.textOffset&&r.nodeBefore.marks.length){let e=t.domSelectionRange();for(let r=e.focusNode,i=e.focusOffset;r&&1==r.nodeType&&0!=i;){let e=i<0?r.lastChild:r.childNodes[i-1];if(!e)break;if(3==e.nodeType){let r=t.domSelection();r&&r.collapse(e,e.nodeValue.length);break}r=e,i=-1}}t.input.composing=!0}ln(t,on)},Ji.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then((()=>t.domObserver.flush())),t.input.compositionID++,ln(t,20))};const an=nr&&sr<15||fr&&gr<604;function fn(t,e,r,i,n){let s=$i(t,e,r,i,t.state.selection.$from);if(t.someProp("handlePaste",(e=>e(t,n,s||S.empty))))return!0;if(!s)return!1;let o=function(t){return 0==t.openStart&&0==t.openEnd&&1==t.content.childCount?t.content.firstChild:null}(s),l=o?t.state.tr.replaceSelectionWith(o,i):t.state.tr.replaceSelection(s);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function cn(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let r=t.getData("text/uri-list");return r?r.replace(/\r?\n/g," "):""}Li.copy=Ji.cut=(t,e)=>{let r=e,i=t.state.selection,n="cut"==r.type;if(i.empty)return;let s=an?null:r.clipboardData,o=i.content(),{dom:l,text:u}=Oi(t,o);s?(r.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",u)):function(t,e){if(!t.dom.parentNode)return;let r=t.dom.parentNode.appendChild(document.createElement("div"));r.appendChild(e),r.style.cssText="position: fixed; left: -10000px; top: 10px";let i=getSelection(),n=document.createRange();n.selectNodeContents(e),t.dom.blur(),i.removeAllRanges(),i.addRange(n),setTimeout((()=>{r.parentNode&&r.parentNode.removeChild(r),t.focus()}),50)}(t,l),n&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},Ji.paste=(t,e)=>{let r=e;if(t.composing&&!pr)return;let i=an?null:r.clipboardData,n=t.input.shiftKey&&45!=t.input.lastKeyCode;i&&fn(t,cn(i),i.getData("text/html"),n,r)?r.preventDefault():function(t,e){if(!t.dom.parentNode)return;let r=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,i=t.dom.parentNode.appendChild(document.createElement(r?"textarea":"div"));r||(i.contentEditable="true"),i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus();let n=t.input.shiftKey&&45!=t.input.lastKeyCode;setTimeout((()=>{t.focus(),i.parentNode&&i.parentNode.removeChild(i),r?fn(t,i.value,null,n,e):fn(t,i.textContent,i.innerHTML,n,e)}),50)}(t,r)};class dn{constructor(t,e,r){this.slice=t,this.move=e,this.node=r}}const pn=cr?"altKey":"ctrlKey";Li.dragstart=(t,e)=>{let r=e,i=t.input.mouseDown;if(i&&i.done(),!r.dataTransfer)return;let n,s=t.state.selection,o=s.empty?null:t.posAtCoords(Ki(r));if(o&&o.pos>=s.from&&o.pos<=(s instanceof xe?s.to-1:s.to));else if(i&&i.mightDrag)n=xe.create(t.state.doc,i.mightDrag.pos);else if(r.target&&1==r.target.nodeType){let e=t.docView.nearestDesc(r.target,!0);e&&e.node.type.spec.draggable&&e!=t.docView&&(n=xe.create(t.state.doc,e.posBefore))}let l=(n||t.state.selection).content(),{dom:u,text:h,slice:a}=Oi(t,l);(!r.dataTransfer.files.length||!ur||hr>120)&&r.dataTransfer.clearData(),r.dataTransfer.setData(an?"Text":"text/html",u.innerHTML),r.dataTransfer.effectAllowed="copyMove",an||r.dataTransfer.setData("text/plain",h),t.dragging=new dn(a,!r[pn],n)},Li.dragend=t=>{let e=t.dragging;window.setTimeout((()=>{t.dragging==e&&(t.dragging=null)}),50)},Ji.dragover=Ji.dragenter=(t,e)=>e.preventDefault(),Ji.drop=(t,e)=>{let r=e,i=t.dragging;if(t.dragging=null,!r.dataTransfer)return;let n=t.posAtCoords(Ki(r));if(!n)return;let s=t.state.doc.resolve(n.pos),o=i&&i.slice;o?t.someProp("transformPasted",(e=>{o=e(o,t)})):o=$i(t,cn(r.dataTransfer),an?null:r.dataTransfer.getData("text/html"),!1,s);let l=!(!i||r[pn]);if(t.someProp("handleDrop",(e=>e(t,r,o||S.empty,l))))return void r.preventDefault();if(!o)return;r.preventDefault();let u=o?re(t.state.doc,s.pos,o):s.pos;null==u&&(u=s.pos);let h=t.state.tr;if(l){let{node:t}=i;t?t.replace(h):h.deleteSelection()}let a=h.mapping.map(u),f=0==o.openStart&&0==o.openEnd&&1==o.content.childCount,c=h.doc;if(f?h.replaceRangeWith(a,a,o.content.firstChild):h.replaceRange(a,a,o),h.doc.eq(c))return;let d=h.doc.resolve(a);if(f&&xe.isSelectable(o.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(o.content.firstChild))h.setSelection(new xe(d));else{let e=h.mapping.map(u);h.mapping.maps[h.mapping.maps.length-1].forEach(((t,r,i,n)=>e=n)),h.setSelection(mi(t,d,h.doc.resolve(e)))}t.focus(),t.dispatch(h.setMeta("uiEvent","drop"))},Li.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout((()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&ui(t)}),20))},Li.blur=(t,e)=>{let r=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),r.relatedTarget&&t.dom.contains(r.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)},Li.beforeinput=(t,e)=>{if(ur&&pr&&"deleteContentBackward"==e.inputType){t.domObserver.flushSoon();let{domChangeCount:e}=t.input;setTimeout((()=>{if(t.input.domChangeCount!=e)return;if(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",(e=>e(t,Ye(8,"Backspace")))))return;let{$cursor:r}=t.state.selection;r&&r.pos>0&&t.dispatch(t.state.tr.delete(r.pos-1,r.pos).scrollIntoView())}),50)}};for(let t in Ji)Li[t]=Ji[t];function mn(t,e){if(t==e)return!0;for(let r in t)if(t[r]!==e[r])return!1;for(let r in e)if(!(r in t))return!1;return!0}class gn{constructor(t,e){this.toDOM=t,this.spec=e||Dn,this.side=this.spec.side||0}map(t,e,r,i){let{pos:n,deleted:s}=t.mapResult(e.from+i,this.side<0?-1:1);return s?null:new vn(n-r,n-r,this)}valid(){return!0}eq(t){return this==t||t instanceof gn&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&mn(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}}class wn{constructor(t,e){this.attrs=t,this.spec=e||Dn}map(t,e,r,i){let n=t.map(e.from+i,this.spec.inclusiveStart?-1:1)-r,s=t.map(e.to+i,this.spec.inclusiveEnd?1:-1)-r;return n>=s?null:new vn(n,s,this)}valid(t,e){return e.from<e.to}eq(t){return this==t||t instanceof wn&&mn(this.attrs,t.attrs)&&mn(this.spec,t.spec)}static is(t){return t.type instanceof wn}destroy(){}}class bn{constructor(t,e){this.attrs=t,this.spec=e||Dn}map(t,e,r,i){let n=t.mapResult(e.from+i,1);if(n.deleted)return null;let s=t.mapResult(e.to+i,-1);return s.deleted||s.pos<=n.pos?null:new vn(n.pos-r,s.pos-r,this)}valid(t,e){let r,{index:i,offset:n}=t.content.findIndex(e.from);return n==e.from&&!(r=t.child(i)).isText&&n+r.nodeSize==e.to}eq(t){return this==t||t instanceof bn&&mn(this.attrs,t.attrs)&&mn(this.spec,t.spec)}destroy(){}}class vn{constructor(t,e,r){this.from=t,this.to=e,this.type=r}copy(t,e){return new vn(t,e,this.type)}eq(t,e=0){return this.type.eq(t.type)&&this.from+e==t.from&&this.to+e==t.to}map(t,e,r){return this.type.map(t,this,e,r)}static widget(t,e,r){return new vn(t,t,new gn(e,r))}static inline(t,e,r,i){return new vn(t,e,new wn(r,i))}static node(t,e,r,i){return new vn(t,e,new bn(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof wn}get widget(){return this.type instanceof gn}}const kn=[],Dn={};class yn{constructor(t,e){this.local=t.length?t:kn,this.children=e.length?e:kn}static create(t,e){return e.length?An(e,t,0,Dn):En}find(t,e,r){let i=[];return this.findInner(null==t?0:t,null==e?1e9:e,i,0,r),i}findInner(t,e,r,i,n){for(let s=0;s<this.local.length;s++){let o=this.local[s];o.from<=e&&o.to>=t&&(!n||n(o.spec))&&r.push(o.copy(o.from+i,o.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<e&&this.children[s+1]>t){let o=this.children[s]+1;this.children[s+2].findInner(t-o,e-o,r,i+o,n)}}map(t,e,r){return this==En||0==t.maps.length?this:this.mapInner(t,e,0,0,r||Dn)}mapInner(t,e,r,i,n){let s;for(let o=0;o<this.local.length;o++){let l=this.local[o].map(t,r,i);l&&l.type.valid(e,l)?(s||(s=[])).push(l):n.onRemove&&n.onRemove(this.local[o].spec)}return this.children.length?function(t,e,r,i,n,s,o){let l=t.slice();for(let t=0,e=s;t<r.maps.length;t++){let i=0;r.maps[t].forEach(((t,r,n,s)=>{let o=s-n-(r-t);for(let n=0;n<l.length;n+=3){let s=l[n+1];if(s<0||t>s+e-i)continue;let u=l[n]+e-i;r>=u?l[n+1]=t<=u?-2:-1:t>=e&&o&&(l[n]+=o,l[n+1]+=o)}i+=o})),e=r.maps[t].map(e,-1)}let u=!1;for(let e=0;e<l.length;e+=3)if(l[e+1]<0){if(-2==l[e+1]){u=!0,l[e+1]=-1;continue}let h=r.map(t[e]+s),a=h-n;if(a<0||a>=i.content.size){u=!0;continue}let f=r.map(t[e+1]+s,-1)-n,{index:c,offset:d}=i.content.findIndex(a),p=i.maybeChild(c);if(p&&d==a&&d+p.nodeSize==f){let i=l[e+2].mapInner(r,p,h+1,t[e]+s+1,o);i!=En?(l[e]=a,l[e+1]=f,l[e+2]=i):(l[e+1]=-2,u=!0)}else u=!0}if(u){let u=function(t,e,r,i,n,s,o){function l(t,e){for(let s=0;s<t.local.length;s++){let l=t.local[s].map(i,n,e);l?r.push(l):o.onRemove&&o.onRemove(t.local[s].spec)}for(let r=0;r<t.children.length;r+=3)l(t.children[r+2],t.children[r]+e+1)}for(let r=0;r<t.length;r+=3)-1==t[r+1]&&l(t[r+2],e[r]+s+1);return r}(l,t,e,r,n,s,o),h=An(u,i,0,o);e=h.local;for(let t=0;t<l.length;t+=3)l[t+1]<0&&(l.splice(t,3),t-=3);for(let t=0,e=0;t<h.children.length;t+=3){let r=h.children[t];for(;e<l.length&&l[e]<r;)e+=3;l.splice(e,0,h.children[t],h.children[t+1],h.children[t+2])}}return new yn(e.sort(Sn),l)}(this.children,s||[],t,e,r,i,n):s?new yn(s.sort(Sn),kn):En}add(t,e){return e.length?this==En?yn.create(t,e):this.addInner(t,e,0):this}addInner(t,e,r){let i,n=0;t.forEach(((t,s)=>{let o,l=s+r;if(o=Mn(e,t,l)){for(i||(i=this.children.slice());n<i.length&&i[n]<s;)n+=3;i[n]==s?i[n+2]=i[n+2].addInner(t,o,l+1):i.splice(n,0,s,s+t.nodeSize,An(o,t,l+1,Dn)),n+=3}}));let s=Fn(n?Cn(e):e,-r);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||s.splice(e--,1);return new yn(s.length?this.local.concat(s).sort(Sn):this.local,i||this.children)}remove(t){return 0==t.length||this==En?this:this.removeInner(t,0)}removeInner(t,e){let r=this.children,i=this.local;for(let i=0;i<r.length;i+=3){let n,s=r[i]+e,o=r[i+1]+e;for(let e,r=0;r<t.length;r++)(e=t[r])&&e.from>s&&e.to<o&&(t[r]=null,(n||(n=[])).push(e));if(!n)continue;r==this.children&&(r=this.children.slice());let l=r[i+2].removeInner(n,s+1);l!=En?r[i+2]=l:(r.splice(i,3),i-=3)}if(i.length)for(let r,n=0;n<t.length;n++)if(r=t[n])for(let t=0;t<i.length;t++)i[t].eq(r,e)&&(i==this.local&&(i=this.local.slice()),i.splice(t--,1));return r==this.children&&i==this.local?this:i.length||r.length?new yn(i,r):En}forChild(t,e){if(this==En)return this;if(e.isLeaf)return yn.empty;let r,i;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(r=this.children[e+2]);break}let n=t+1,s=n+e.content.size;for(let t=0;t<this.local.length;t++){let e=this.local[t];if(e.from<s&&e.to>n&&e.type instanceof wn){let t=Math.max(n,e.from)-n,r=Math.min(s,e.to)-n;t<r&&(i||(i=[])).push(e.copy(t,r))}}if(i){let t=new yn(i.sort(Sn),kn);return r?new xn([t,r]):t}return r||En}eq(t){if(this==t)return!0;if(!(t instanceof yn)||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(t){return On(this.localsInner(t))}localsInner(t){if(this==En)return kn;if(t.inlineContent||!this.local.some(wn.is))return this.local;let e=[];for(let t=0;t<this.local.length;t++)this.local[t].type instanceof wn||e.push(this.local[t]);return e}forEachSet(t){t(this)}}yn.empty=new yn([],[]),yn.removeOverlap=On;const En=yn.empty;class xn{constructor(t){this.members=t}map(t,e){const r=this.members.map((r=>r.map(t,e,Dn)));return xn.from(r)}forChild(t,e){if(e.isLeaf)return yn.empty;let r=[];for(let i=0;i<this.members.length;i++){let n=this.members[i].forChild(t,e);n!=En&&(n instanceof xn?r=r.concat(n.members):r.push(n))}return xn.from(r)}eq(t){if(!(t instanceof xn)||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(t){let e,r=!0;for(let i=0;i<this.members.length;i++){let n=this.members[i].localsInner(t);if(n.length)if(e){r&&(e=e.slice(),r=!1);for(let t=0;t<n.length;t++)e.push(n[t])}else e=n}return e?On(r?e:e.sort(Sn)):kn}static from(t){switch(t.length){case 0:return En;case 1:return t[0];default:return new xn(t.every((t=>t instanceof yn))?t:t.reduce(((t,e)=>t.concat(e instanceof yn?e:e.members)),[]))}}forEachSet(t){for(let e=0;e<this.members.length;e++)this.members[e].forEachSet(t)}}function Fn(t,e){if(!e||!t.length)return t;let r=[];for(let i=0;i<t.length;i++){let n=t[i];r.push(new vn(n.from+e,n.to+e,n.type))}return r}function Mn(t,e,r){if(e.isLeaf)return null;let i=r+e.nodeSize,n=null;for(let e,s=0;s<t.length;s++)(e=t[s])&&e.from>r&&e.to<i&&((n||(n=[])).push(e),t[s]=null);return n}function Cn(t){let e=[];for(let r=0;r<t.length;r++)null!=t[r]&&e.push(t[r]);return e}function An(t,e,r,i){let n=[],s=!1;e.forEach(((e,o)=>{let l=Mn(t,e,o+r);if(l){s=!0;let t=An(l,e,r+o+1,i);t!=En&&n.push(o,o+e.nodeSize,t)}}));let o=Fn(s?Cn(t):t,-r).sort(Sn);for(let t=0;t<o.length;t++)o[t].type.valid(e,o[t])||(i.onRemove&&i.onRemove(o[t].spec),o.splice(t--,1));return o.length||n.length?new yn(o,n):En}function Sn(t,e){return t.from-e.from||t.to-e.to}function On(t){let e=t;for(let r=0;r<e.length-1;r++){let i=e[r];if(i.from!=i.to)for(let n=r+1;n<e.length;n++){let s=e[n];if(s.from!=i.from){s.from<i.to&&(e==t&&(e=t.slice()),e[r]=i.copy(i.from,s.from),$n(e,n,i.copy(s.from,i.to)));break}s.to!=i.to&&(e==t&&(e=t.slice()),e[n]=s.copy(s.from,i.to),$n(e,n+1,s.copy(i.to,s.to)))}}return e}function $n(t,e,r){for(;e<t.length&&Sn(r,t[e])>0;)e++;t.splice(e,0,r)}function Bn(t){let e=[];return t.someProp("decorations",(r=>{let i=r(t.state);i&&i!=En&&e.push(i)})),t.cursorWrapper&&e.push(yn.create(t.state.doc,[t.cursorWrapper.deco])),xn.from(e)}const Rn={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Nn=nr&&sr<=11;class _n{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}}class Tn{constructor(t,e){this.view=t,this.handleDOMChange=e,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new _n,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver((t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);nr&&sr<=11&&t.some((t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length))?this.flushSoon():this.flush()})),Nn&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout((()=>{this.flushingSoon=-1,this.flush()}),20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Rn)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let e=0;e<t.length;e++)this.queue.push(t[e]);window.setTimeout((()=>this.flush()),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout((()=>this.suppressingSelectionUpdates=!1),50)}onSelectionChange(){if(gi(this.view)){if(this.suppressingSelectionUpdates)return ui(this.view);if(nr&&sr<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&Ve(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return!0;let e,r=new Set;for(let e=t.focusNode;e;e=Le(e))r.add(e);for(let i=t.anchorNode;i;i=Le(i))if(r.has(i)){e=i;break}let i=e&&this.view.docView.nearestDesc(e);return i&&i.ignoreMutation({type:"selection",target:3==e.nodeType?e.parentNode:e})?(this.setCurSelection(),!0):void 0}pendingRecords(){if(this.observer)for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let e=this.pendingRecords();e.length&&(this.queue=[]);let r=t.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&gi(t)&&!this.ignoreSelectionChange(r),n=-1,s=-1,o=!1,l=[];if(t.editable)for(let t=0;t<e.length;t++){let r=this.registerMutation(e[t],l);r&&(n=n<0?r.from:Math.min(r.from,n),s=s<0?r.to:Math.max(r.to,s),r.typeOver&&(o=!0))}if(or&&l.length){let e=l.filter((t=>"BR"==t.nodeName));if(2==e.length){let[t,r]=e;t.parentNode&&t.parentNode.parentNode==r.parentNode?r.remove():t.remove()}else{let{focusNode:r}=this.currentSelection;for(let i of e){let e=i.parentNode;!e||"LI"!=e.nodeName||r&&jn(t,r)==e||i.remove()}}}let u=null;n<0&&i&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&Ke(r)&&(u=oi(t))&&u.eq(be.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,ui(t),this.currentSelection.set(r),t.scrollToSelection()):(n>-1||i)&&(n>-1&&(t.docView.markDirty(n,s),function(t){if(!zn.has(t)&&(zn.set(t,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace))){if(t.requiresGeckoHackNode=or,qn)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."),qn=!0}}(t)),this.handleDOMChange(n,s,o,l),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(r)||ui(t),this.currentSelection.set(r))}registerMutation(t,e){if(e.indexOf(t.target)>-1)return null;let r=this.view.docView.nearestDesc(t.target);if("attributes"==t.type&&(r==this.view.docView||"contenteditable"==t.attributeName||"style"==t.attributeName&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!r||r.ignoreMutation(t))return null;if("childList"==t.type){for(let r=0;r<t.addedNodes.length;r++){let i=t.addedNodes[r];e.push(i),3==i.nodeType&&(this.lastChangedTextNode=i)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(t.target))return{from:r.posBefore,to:r.posAfter};let i=t.previousSibling,n=t.nextSibling;if(nr&&sr<=11&&t.addedNodes.length)for(let e=0;e<t.addedNodes.length;e++){let{previousSibling:r,nextSibling:s}=t.addedNodes[e];(!r||Array.prototype.indexOf.call(t.addedNodes,r)<0)&&(i=r),(!s||Array.prototype.indexOf.call(t.addedNodes,s)<0)&&(n=s)}let s=i&&i.parentNode==t.target?Pe(i)+1:0,o=r.localPosFromDOM(t.target,s,-1),l=n&&n.parentNode==t.target?Pe(n):t.target.childNodes.length;return{from:o,to:r.localPosFromDOM(t.target,l,1)}}return"attributes"==t.type?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=t.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:t.target.nodeValue==t.oldValue})}}let zn=new WeakMap,qn=!1;function In(t,e){let r=e.startContainer,i=e.startOffset,n=e.endContainer,s=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return Ve(o.node,o.offset,n,s)&&([r,i,n,s]=[n,s,r,i]),{anchorNode:r,anchorOffset:i,focusNode:n,focusOffset:s}}function jn(t,e){for(let r=e.parentNode;r&&r!=t.dom;r=r.parentNode){let e=t.docView.nearestDesc(r,!0);if(e&&e.node.isBlock)return r}return null}function Pn(t){let e=t.pmViewDesc;if(e)return e.parseRule();if("BR"==t.nodeName&&t.parentNode){if(ar&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}if(t.parentNode.lastChild==t||ar&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if("IMG"==t.nodeName&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Ln=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Jn(t,e,r){return Math.max(r.anchor,r.head)>e.content.size?null:mi(t,e.resolve(r.anchor),e.resolve(r.head))}function Un(t,e,r){let i=t.depth,n=e?t.end():t.pos;for(;i>0&&(e||t.indexAfter(i)==t.node(i).childCount);)i--,n++,e=!1;if(r){let e=t.node(i).maybeChild(t.indexAfter(i));for(;e&&!e.isLeaf;)e=e.firstChild,n++}return n}function Vn(t){if(2!=t.length)return!1;let e=t.charCodeAt(0),r=t.charCodeAt(1);return e>=56320&&e<=57343&&r>=55296&&r<=56319}class Hn{constructor(t,e){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 Vi,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=e,this.state=e.state,this.directPlugins=e.plugins||[],this.directPlugins.forEach(Yn),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):"function"==typeof t?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=Zn(this),Gn(this),this.nodeViews=Kn(this),this.docView=Ur(this.state.doc,Wn(this),Bn(this),this.dom,this),this.domObserver=new Tn(this,((t,e,r,i)=>function(t,e,r,i,n){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let e=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,r=oi(t,e);if(r&&!t.state.selection.eq(r)){if(ur&&pr&&13===t.input.lastKeyCode&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",(e=>e(t,Ye(13,"Enter")))))return;let i=t.state.tr.setSelection(r);"pointer"==e?i.setMeta("pointer",!0):"key"==e&&i.scrollIntoView(),s&&i.setMeta("composition",s),t.dispatch(i)}return}let o=t.state.doc.resolve(e),l=o.sharedDepth(r);e=o.before(l+1),r=t.state.doc.resolve(r).after(l+1);let u,h,a=t.state.selection,f=function(t,e,r){let i,{node:n,fromOffset:s,toOffset:o,from:l,to:u}=t.docView.parseRange(e,r),h=t.domSelectionRange(),a=h.anchorNode;if(a&&t.dom.contains(1==a.nodeType?a:a.parentNode)&&(i=[{node:a,offset:h.anchorOffset}],Ke(h)||i.push({node:h.focusNode,offset:h.focusOffset})),ur&&8===t.input.lastKeyCode)for(let t=o;t>s;t--){let e=n.childNodes[t-1],r=e.pmViewDesc;if("BR"==e.nodeName&&!r){o=t;break}if(!r||r.size)break}let f=t.state.doc,c=t.someProp("domParser")||pt.fromSchema(t.state.schema),d=f.resolve(l),p=null,m=c.parse(n,{topNode:d.parent,topMatch:d.parent.contentMatchAt(d.index()),topOpen:!0,from:s,to:o,preserveWhitespace:"pre"!=d.parent.type.whitespace||"full",findPositions:i,ruleFromNode:Pn,context:d});if(i&&null!=i[0].pos){let t=i[0].pos,e=i[1]&&i[1].pos;null==e&&(e=t),p={anchor:t+l,head:e+l}}return{doc:m,sel:p,from:l,to:u}}(t,e,r),c=t.state.doc,d=c.slice(f.from,f.to);8===t.input.lastKeyCode&&Date.now()-100<t.input.lastKeyCodeTime?(u=t.state.selection.to,h="end"):(u=t.state.selection.from,h="start"),t.input.lastKeyCode=null;let p=function(t,e,r,i,n){let s=t.findDiffStart(e,r);if(null==s)return null;let{a:o,b:l}=t.findDiffEnd(e,r+t.size,r+e.size);if("end"==n&&(i-=o+Math.max(0,s-Math.min(o,l))-s),o<s&&t.size<e.size){let t=i<=s&&i>=o?s-i:0;s-=t,s&&s<e.size&&Vn(e.textBetween(s-1,s+1))&&(s+=t?1:-1),l=s+(l-o),o=s}else if(l<s){let e=i<=s&&i>=l?s-i:0;s-=e,s&&s<t.size&&Vn(t.textBetween(s-1,s+1))&&(s+=e?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}(d.content,f.doc.content,f.from,u,h);if(p&&t.input.domChangeCount++,(fr&&t.input.lastIOSEnter>Date.now()-225||pr)&&n.some((t=>1==t.nodeType&&!Ln.test(t.nodeName)))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",(e=>e(t,Ye(13,"Enter")))))return void(t.input.lastIOSEnter=0);if(!p){if(!(i&&a instanceof ye&&!a.empty&&a.$head.sameParent(a.$anchor))||t.composing||f.sel&&f.sel.anchor!=f.sel.head){if(f.sel){let e=Jn(t,t.state.doc,f.sel);if(e&&!e.eq(t.state.selection)){let r=t.state.tr.setSelection(e);s&&r.setMeta("composition",s),t.dispatch(r)}}return}p={start:a.from,endA:a.to,endB:a.to}}t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof ye&&(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=f.from?p.start=t.state.selection.from:p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=f.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),nr&&sr<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>f.from&&"  "==f.doc.textBetween(p.start-f.from-1,p.start-f.from+1)&&(p.start--,p.endA--,p.endB--);let m,g=f.doc.resolveNoCache(p.start-f.from),w=f.doc.resolveNoCache(p.endB-f.from),b=c.resolve(p.start),v=g.sameParent(w)&&g.parent.inlineContent&&b.end()>=p.endA;if((fr&&t.input.lastIOSEnter>Date.now()-225&&(!v||n.some((t=>"DIV"==t.nodeName||"P"==t.nodeName)))||!v&&g.pos<f.doc.content.size&&!g.sameParent(w)&&(m=be.findFrom(f.doc.resolve(g.pos+1),1,!0))&&m.head==w.pos)&&t.someProp("handleKeyDown",(e=>e(t,Ye(13,"Enter")))))return void(t.input.lastIOSEnter=0);if(t.state.selection.anchor>p.start&&function(t,e,r,i,n){if(r-e<=n.pos-i.pos||Un(i,!0,!1)<n.pos)return!1;let s=t.resolve(e);if(!i.parent.isTextblock){let t=s.nodeAfter;return null!=t&&r==e+t.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=t.resolve(Un(s,!0,!0));return!(!o.parent.isTextblock||o.pos>r||Un(o,!0,!1)<r)&&i.parent.content.cut(i.parentOffset).eq(o.parent.content)}(c,p.start,p.endA,g,w)&&t.someProp("handleKeyDown",(e=>e(t,Ye(8,"Backspace")))))return void(pr&&ur&&t.domObserver.suppressSelectionUpdates());ur&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),pr&&!v&&g.start()!=w.start()&&0==w.parentOffset&&g.depth==w.depth&&f.sel&&f.sel.anchor==f.sel.head&&f.sel.head==p.endA&&(p.endB-=2,w=f.doc.resolveNoCache(p.endB-f.from),setTimeout((()=>{t.someProp("handleKeyDown",(function(e){return e(t,Ye(13,"Enter"))}))}),20));let k,D,y,x=p.start,F=p.endA;if(v)if(g.pos==w.pos)nr&&sr<=11&&0==g.parentOffset&&(t.domObserver.suppressSelectionUpdates(),setTimeout((()=>ui(t)),20)),k=t.state.tr.delete(x,F),D=c.resolve(p.start).marksAcross(c.resolve(p.endA));else if(p.endA==p.endB&&(y=function(t,e){let r,i,n,s=t.firstChild.marks,o=e.firstChild.marks,l=s,u=o;for(let t=0;t<o.length;t++)l=o[t].removeFromSet(l);for(let t=0;t<s.length;t++)u=s[t].removeFromSet(u);if(1==l.length&&0==u.length)i=l[0],r="add",n=t=>t.mark(i.addToSet(t.marks));else{if(0!=l.length||1!=u.length)return null;i=u[0],r="remove",n=t=>t.mark(i.removeFromSet(t.marks))}let h=[];for(let t=0;t<e.childCount;t++)h.push(n(e.child(t)));if(E.from(h).eq(t))return{mark:i,type:r}}(g.parent.content.cut(g.parentOffset,w.parentOffset),b.parent.content.cut(b.parentOffset,p.endA-b.start()))))k=t.state.tr,"add"==y.type?k.addMark(x,F,y.mark):k.removeMark(x,F,y.mark);else if(g.parent.child(g.index()).isText&&g.index()==w.index()-(w.textOffset?0:1)){let e=g.parent.textBetween(g.parentOffset,w.parentOffset);if(t.someProp("handleTextInput",(r=>r(t,x,F,e))))return;k=t.state.tr.insertText(e,x,F)}if(k||(k=t.state.tr.replace(x,F,f.doc.slice(p.start-f.from,p.endB-f.from))),f.sel){let e=Jn(t,k.doc,f.sel);e&&!(ur&&t.composing&&e.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(e.head==x||e.head==k.mapping.map(F)-1)||nr&&e.empty&&e.head==x)&&k.setSelection(e)}D&&k.ensureMarks(D),s&&k.setMeta("composition",s),t.dispatch(k.scrollIntoView())}(this,t,e,r,i))),this.domObserver.start(),function(t){for(let e in Li){let r=Li[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=e=>{!Zi(t,e)||Gi(t,e)||!t.editable&&e.type in Ji||r(t,e)},Ui[e]?{passive:!0}:void 0)}ar&&t.dom.addEventListener("input",(()=>null)),Wi(t)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let e in t)this._props[e]=t[e];this._props.state=this.state}return this._props}update(t){t.handleDOMEvents!=this._props.handleDOMEvents&&Wi(this);let e=this._props;this._props=t,t.plugins&&(t.plugins.forEach(Yn),this.directPlugins=t.plugins),this.updateStateInner(t.state,e)}setProps(t){let e={};for(let t in this._props)e[t]=this._props[t];e.state=this.state;for(let r in t)e[r]=t[r];this.update(e)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,e){var r;let i=this.state,n=!1,s=!1;t.storedMarks&&this.composing&&(un(this),s=!0),this.state=t;let o=i.plugins!=t.plugins||this._props.plugins!=e.plugins;if(o||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let t=Kn(this);(function(t,e){let r=0,i=0;for(let i in t){if(t[i]!=e[i])return!0;r++}for(let t in e)i++;return r!=i})(t,this.nodeViews)&&(this.nodeViews=t,n=!0)}(o||e.handleDOMEvents!=this._props.handleDOMEvents)&&Wi(this),this.editable=Zn(this),Gn(this);let l=Bn(this),u=Wn(this),h=i.plugins==t.plugins||i.doc.eq(t.doc)?t.scrollToSelection>i.scrollToSelection?"to selection":"preserve":"reset",a=n||!this.docView.matchesNode(t.doc,u,l);!a&&t.selection.eq(i.selection)||(s=!0);let f="preserve"==h&&s&&null==this.dom.style.overflowAnchor&&function(t){let e,r,i=t.dom.getBoundingClientRect(),n=Math.max(0,i.top);for(let s=(i.left+i.right)/2,o=n+1;o<Math.min(innerHeight,i.bottom);o+=5){let i=t.root.elementFromPoint(s,o);if(!i||i==t.dom||!t.dom.contains(i))continue;let l=i.getBoundingClientRect();if(l.top>=n-20){e=i,r=l.top;break}}return{refDOM:e,refTop:r,stack:Dr(t.dom)}}(this);if(s){this.domObserver.stop();let e=a&&(nr||ur)&&!this.composing&&!i.selection.empty&&!t.selection.empty&&function(t,e){let r=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(r)!=e.$anchor.start(r)}(i.selection,t.selection);if(a){let r=ur?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=function(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let r=function(t,e){for(;;){if(3==t.nodeType&&e)return t;if(1==t.nodeType&&e>0){if("false"==t.contentEditable)return null;e=Ge(t=t.childNodes[e-1])}else{if(!t.parentNode||Ze(t))return null;e=Pe(t),t=t.parentNode}}}(e.focusNode,e.focusOffset),i=function(t,e){for(;;){if(3==t.nodeType&&e<t.nodeValue.length)return t;if(1==t.nodeType&&e<t.childNodes.length){if("false"==t.contentEditable)return null;t=t.childNodes[e],e=0}else{if(!t.parentNode||Ze(t))return null;e=Pe(t)+1,t=t.parentNode}}}(e.focusNode,e.focusOffset);if(r&&i&&r!=i){let e=i.pmViewDesc,n=t.domObserver.lastChangedTextNode;if(r==n||i==n)return n;if(!e||!e.isText(i.nodeValue))return i;if(t.input.compositionNode==i){let t=r.pmViewDesc;if(t&&t.isText(r.nodeValue))return i}}return r||i}(this)),!n&&this.docView.update(t.doc,u,l,this)||(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=Ur(t.doc,u,l,this.dom,this)),r&&!this.trackWrites&&(e=!0)}e||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),r=t.domSelectionRange();return Ve(e.node,e.offset,r.anchorNode,r.anchorOffset)}(this))?ui(this,e):(di(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),(null===(r=this.dragging)||void 0===r?void 0:r.node)&&!i.doc.eq(t.doc)&&this.updateDraggedNode(this.dragging,i),"reset"==h?this.dom.scrollTop=0:"to selection"==h?this.scrollToSelection():f&&function({refDOM:t,refTop:e,stack:r}){let i=t?t.getBoundingClientRect().top:0;yr(r,0==i?0:i-e)}(f)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(t&&this.dom.contains(1==t.nodeType?t:t.parentNode))if(this.someProp("handleScrollToSelection",(t=>t(this))));else if(this.state.selection instanceof xe){let e=this.docView.domAfterPos(this.state.selection.from);1==e.nodeType&&kr(this,e.getBoundingClientRect(),t)}else kr(this,this.coordsAtPos(this.state.selection.head,1),t)}destroyPluginViews(){let t;for(;t=this.pluginViews.pop();)t.destroy&&t.destroy()}updatePluginViews(t){if(t&&t.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let e=0;e<this.pluginViews.length;e++){let r=this.pluginViews[e];r.update&&r.update(this,t)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let e=this.directPlugins[t];e.spec.view&&this.pluginViews.push(e.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let e=this.state.plugins[t];e.spec.view&&this.pluginViews.push(e.spec.view(this))}}}updateDraggedNode(t,e){let r=t.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let t=r.from+(this.state.doc.content.size-e.doc.content.size);(t>0&&this.state.doc.nodeAt(t))==r.node&&(i=t)}this.dragging=new dn(t.slice,t.move,i<0?void 0:xe.create(this.state.doc,i))}someProp(t,e){let r,i=this._props&&this._props[t];if(null!=i&&(r=e?e(i):i))return r;for(let i=0;i<this.directPlugins.length;i++){let n=this.directPlugins[i].props[t];if(null!=n&&(r=e?e(n):n))return r}let n=this.state.plugins;if(n)for(let i=0;i<n.length;i++){let s=n[i].props[t];if(null!=s&&(r=e?e(s):s))return r}}hasFocus(){if(nr){let t=this.root.activeElement;if(t==this.dom)return!0;if(!t||!this.dom.contains(t))return!1;for(;t&&this.dom!=t&&this.dom.contains(t);){if("false"==t.contentEditable)return!1;t=t.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(t){if(t.setActive)return t.setActive();if(Er)return t.focus(Er);let e=Dr(t);t.focus(null==Er?{get preventScroll(){return Er={preventScroll:!0},!0}}:void 0),Er||(Er=!1,yr(e,0))}(this.dom),ui(this),this.domObserver.start()}get root(){let t=this._root;if(null==t)for(let t=this.dom.parentNode;t;t=t.parentNode)if(9==t.nodeType||11==t.nodeType&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t;return t||document}updateRoot(){this._root=null}posAtCoords(t){return Cr(this,t)}coordsAtPos(t,e=1){return $r(this,t,e)}domAtPos(t,e=0){return this.docView.domFromPos(t,e)}nodeDOM(t){let e=this.docView.descAt(t);return e?e.nodeDOM:null}posAtDOM(t,e,r=-1){let i=this.docView.posFromDOM(t,e,r);if(null==i)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(t,e){return function(t,e,r){return Tr==e&&zr==r?qr:(Tr=e,zr=r,qr="up"==r||"down"==r?function(t,e,r){let i=e.selection,n="up"==r?i.$from:i.$to;return Nr(t,e,(()=>{let{node:e}=t.docView.domFromPos(n.pos,"up"==r?-1:1);for(;;){let r=t.docView.nearestDesc(e,!0);if(!r)break;if(r.node.isBlock){e=r.contentDOM||r.dom;break}e=r.dom.parentNode}let i=$r(t,n.pos,1);for(let t=e.firstChild;t;t=t.nextSibling){let e;if(1==t.nodeType)e=t.getClientRects();else{if(3!=t.nodeType)continue;e=Ue(t,0,t.nodeValue.length).getClientRects()}for(let t=0;t<e.length;t++){let n=e[t];if(n.bottom>n.top+1&&("up"==r?i.top-n.top>2*(n.bottom-i.top):n.bottom-i.bottom>2*(i.bottom-n.top)))return!1}}return!0}))}(t,e,r):function(t,e,r){let{$head:i}=e.selection;if(!i.parent.isTextblock)return!1;let n=i.parentOffset,s=!n,o=n==i.parent.content.size,l=t.domSelection();return l?_r.test(i.parent.textContent)&&l.modify?Nr(t,e,(()=>{let{focusNode:e,focusOffset:n,anchorNode:s,anchorOffset:o}=t.domSelectionRange(),u=l.caretBidiLevel;l.modify("move",r,"character");let h=i.depth?t.docView.domAfterPos(i.before()):t.dom,{focusNode:a,focusOffset:f}=t.domSelectionRange(),c=a&&!h.contains(1==a.nodeType?a:a.parentNode)||e==a&&n==f;try{l.collapse(s,o),e&&(e!=s||n!=o)&&l.extend&&l.extend(e,n)}catch(t){}return null!=u&&(l.caretBidiLevel=u),c})):"left"==r||"backward"==r?s:o:i.pos==i.start()||i.pos==i.end()}(t,e,r))}(this,e||this.state,t)}pasteHTML(t,e){return fn(this,"",t,!1,e||new ClipboardEvent("paste"))}pasteText(t,e){return fn(this,t,null,!0,e||new ClipboardEvent("paste"))}destroy(){this.docView&&(function(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Bn(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Je=null)}get isDestroyed(){return null==this.docView}dispatchEvent(t){return function(t,e){Gi(t,e)||!Li[e.type]||!t.editable&&e.type in Ji||Li[e.type](t,e)}(this,t)}dispatch(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))}domSelectionRange(){let t=this.domSelection();return t?ar&&11===this.root.nodeType&&function(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}(this.dom.ownerDocument)==this.dom&&function(t,e){if(e.getComposedRanges){let r=e.getComposedRanges(t.root)[0];if(r)return In(t,r)}let r;function i(t){t.preventDefault(),t.stopImmediatePropagation(),r=t.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",i,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",i,!0),r?In(t,r):null}(this,t)||t:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Wn(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",(r=>{if("function"==typeof r&&(r=r(t.state)),r)for(let t in r)"class"==t?e.class+=" "+r[t]:"style"==t?e.style=(e.style?e.style+";":"")+r[t]:e[t]||"contenteditable"==t||"nodeName"==t||(e[t]=String(r[t]))})),e.translate||(e.translate="no"),[vn.node(0,t.state.doc.content.size,e)]}function Gn(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:vn.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Zn(t){return!t.someProp("editable",(e=>!1===e(t.state)))}function Kn(t){let e=Object.create(null);function r(t){for(let r in t)Object.prototype.hasOwnProperty.call(e,r)||(e[r]=t[r])}return t.someProp("nodeViews",r),t.someProp("markViews",r),e}function Yn(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}const Xn=["p",0],Qn=["blockquote",0],ts=["hr"],es=["pre",["code",0]],rs=["br"],is=["em",0],ns=["strong",0],ss=["code",0],ls=new ct({nodes:{doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:()=>Xn},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:()=>Qn},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:()=>ts},heading:{attrs:{level:{default:1,validate:"number"}},content:"inline*",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:t=>["h"+t.attrs.level,0]},code_block:{content:"text*",marks:"",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM:()=>es},text:{group:"inline"},image:{inline:!0,attrs:{src:{validate:"string"},alt:{default:null,validate:"string|null"},title:{default:null,validate:"string|null"}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs:t=>({src:t.getAttribute("src"),title:t.getAttribute("title"),alt:t.getAttribute("alt")})}],toDOM(t){let{src:e,alt:r,title:i}=t.attrs;return["img",{src:e,alt:r,title:i}]}},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM:()=>rs}},marks:{link:{attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs:t=>({href:t.getAttribute("href"),title:t.getAttribute("title")})}],toDOM(t){let{href:e,title:r}=t.attrs;return["a",{href:e,title:r},0]}},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:t=>"em"==t.type.name}],toDOM:()=>is},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:t=>"normal"!=t.style.fontWeight&&null},{style:"font-weight=400",clearMark:t=>"strong"==t.type.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}],toDOM:()=>ns},code:{code:!0,parseDOM:[{tag:"code"}],toDOM:()=>ss}}}),us=["ol",0],hs=["ul",0],as=["li",0],fs={attrs:{order:{default:1}},parseDOM:[{tag:"ol",getAttrs:t=>({order:t.hasAttribute("start")?+t.getAttribute("start"):1})}],toDOM:t=>1==t.attrs.order?us:["ol",{start:t.attrs.order},0]},cs={parseDOM:[{tag:"ul"}],toDOM:()=>hs},ds={parseDOM:[{tag:"li"}],toDOM:()=>as,defining:!0};function ps(t,e){let r={};for(let e in t)r[e]=t[e];for(let t in e)r[t]=e[t];return r}function ms(t,e=null){return function(r,i){let{$from:n,$to:s}=r.selection,o=n.blockRange(s),l=!1,u=o;if(!o)return!1;if(o.depth>=2&&n.node(o.depth-1).type.compatibleContent(t)&&0==o.startIndex){if(0==n.index(o.depth-1))return!1;let t=r.doc.resolve(o.start-2);u=new V(t,t,o.depth),o.endIndex<o.parent.childCount&&(o=new V(n,r.doc.resolve(s.end(o.depth)),o.depth)),l=!0}let h=Gt(u,t,e,o);return!!h&&(i&&i(function(t,e,r,i,n){let s=E.empty;for(let t=r.length-1;t>=0;t--)s=E.from(r[t].type.create(r[t].attrs,s));t.step(new Jt(e.start-(i?2:0),e.end,e.start,e.end,new S(s,0,0),r.length,!0));let o=0;for(let t=0;t<r.length;t++)r[t].type==n&&(o=t+1);let l=r.length-o,u=e.start+r.length-(i?2:0),h=e.parent;for(let r=e.startIndex,i=e.endIndex,n=!0;r<i;r++,n=!1)!n&&Xt(t.doc,u,l)&&(t.split(u,l),u+=2*l),u+=h.child(r).nodeSize;return t}(r.tr,o,h,l,t).scrollIntoView()),!0)}}for(var gs={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:"'"},ws={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},bs="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),vs="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),ks=0;ks<10;ks++)gs[48+ks]=gs[96+ks]=String(ks);for(ks=1;ks<=24;ks++)gs[ks+111]="F"+ks;for(ks=65;ks<=90;ks++)gs[ks]=String.fromCharCode(ks+32),ws[ks]=String.fromCharCode(ks);for(var Ds in gs)ws.hasOwnProperty(Ds)||(ws[Ds]=gs[Ds]);const ys="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function Es(t){let e,r,i,n,s=t.split(/-(?!$)/),o=s[s.length-1];"Space"==o&&(o=" ");for(let t=0;t<s.length-1;t++){let o=s[t];if(/^(cmd|meta|m)$/i.test(o))n=!0;else if(/^a(lt)?$/i.test(o))e=!0;else if(/^(c|ctrl|control)$/i.test(o))r=!0;else if(/^s(hift)?$/i.test(o))i=!0;else{if(!/^mod$/i.test(o))throw new Error("Unrecognized modifier name: "+o);ys?n=!0:r=!0}}return e&&(o="Alt-"+o),r&&(o="Ctrl-"+o),n&&(o="Meta-"+o),i&&(o="Shift-"+o),o}function xs(t,e,r=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),r&&e.shiftKey&&(t="Shift-"+t),t}function Fs(t){return new ze({props:{handleKeyDown:Ms(t)}})}function Ms(t){let e=function(t){let e=Object.create(null);for(let r in t)e[Es(r)]=t[r];return e}(t);return function(t,r){let i,n=function(t){var e=!(bs&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||vs&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key)&&t.key||(t.shiftKey?ws:gs)[t.keyCode]||t.key||"Unidentified";return"Esc"==e&&(e="Escape"),"Del"==e&&(e="Delete"),"Left"==e&&(e="ArrowLeft"),"Up"==e&&(e="ArrowUp"),"Right"==e&&(e="ArrowRight"),"Down"==e&&(e="ArrowDown"),e}(r),s=e[xs(n,r)];if(s&&s(t.state,t.dispatch,t))return!0;if(1==n.length&&" "!=n){if(r.shiftKey){let i=e[xs(n,r,!1)];if(i&&i(t.state,t.dispatch,t))return!0}if((r.shiftKey||r.altKey||r.metaKey||n.charCodeAt(0)>127)&&(i=gs[r.keyCode])&&i!=n){let n=e[xs(i,r)];if(n&&n(t.state,t.dispatch,t))return!0}}return!1}}var Cs=200,As=function(){};As.prototype.append=function(t){return t.length?(t=As.from(t),!this.length&&t||t.length<Cs&&this.leafAppend(t)||this.length<Cs&&t.leafPrepend(this)||this.appendInner(t)):this},As.prototype.prepend=function(t){return t.length?As.from(t).append(this):this},As.prototype.appendInner=function(t){return new Os(this,t)},As.prototype.slice=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.length),t>=e?As.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,e))},As.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)},As.prototype.forEach=function(t,e,r){void 0===e&&(e=0),void 0===r&&(r=this.length),e<=r?this.forEachInner(t,e,r,0):this.forEachInvertedInner(t,e,r,0)},As.prototype.map=function(t,e,r){void 0===e&&(e=0),void 0===r&&(r=this.length);var i=[];return this.forEach((function(e,r){return i.push(t(e,r))}),e,r),i},As.from=function(t){return t instanceof As?t:t&&t.length?new Ss(t):As.empty};var Ss=function(t){function e(e){t.call(this),this.values=e}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(t,r){return 0==t&&r==this.length?this:new e(this.values.slice(t,r))},e.prototype.getInner=function(t){return this.values[t]},e.prototype.forEachInner=function(t,e,r,i){for(var n=e;n<r;n++)if(!1===t(this.values[n],i+n))return!1},e.prototype.forEachInvertedInner=function(t,e,r,i){for(var n=e-1;n>=r;n--)if(!1===t(this.values[n],i+n))return!1},e.prototype.leafAppend=function(t){if(this.length+t.length<=Cs)return new e(this.values.concat(t.flatten()))},e.prototype.leafPrepend=function(t){if(this.length+t.length<=Cs)return new e(t.flatten().concat(this.values))},r.length.get=function(){return this.values.length},r.depth.get=function(){return 0},Object.defineProperties(e.prototype,r),e}(As);As.empty=new Ss([]);var Os=function(t){function e(e,r){t.call(this),this.left=e,this.right=r,this.length=e.length+r.length,this.depth=Math.max(e.depth,r.depth)+1}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(t){return t<this.left.length?this.left.get(t):this.right.get(t-this.left.length)},e.prototype.forEachInner=function(t,e,r,i){var n=this.left.length;return!(e<n&&!1===this.left.forEachInner(t,e,Math.min(r,n),i))&&!(r>n&&!1===this.right.forEachInner(t,Math.max(e-n,0),Math.min(this.length,r)-n,i+n))&&void 0},e.prototype.forEachInvertedInner=function(t,e,r,i){var n=this.left.length;return!(e>n&&!1===this.right.forEachInvertedInner(t,e-n,Math.max(r,n)-n,i+n))&&!(r<n&&!1===this.left.forEachInvertedInner(t,Math.min(e,n),r,i))&&void 0},e.prototype.sliceInner=function(t,e){if(0==t&&e==this.length)return this;var r=this.left.length;return e<=r?this.left.slice(t,e):t>=r?this.right.slice(t-r,e-r):this.left.slice(t,r).append(this.right.slice(0,e-r))},e.prototype.leafAppend=function(t){var r=this.right.leafAppend(t);if(r)return new e(this.left,r)},e.prototype.leafPrepend=function(t){var r=this.left.leafPrepend(t);if(r)return new e(r,this.right)},e.prototype.appendInner=function(t){return this.left.depth>=Math.max(this.right.depth,t.depth)+1?new e(this.left,new e(this.right,t)):new e(this,t)},e}(As);class $s{constructor(t,e){this.items=t,this.eventCount=e}popEvent(t,e){if(0==this.eventCount)return null;let r,i,n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}e&&(r=this.remapping(n,this.items.length),i=r.maps.length);let s,o,l=t.tr,u=[],h=[];return this.items.forEach(((t,e)=>{if(!t.step)return r||(r=this.remapping(n,e+1),i=r.maps.length),i--,void h.push(t);if(r){h.push(new Bs(t.map));let e,n=t.step.map(r.slice(i));n&&l.maybeStep(n).doc&&(e=l.mapping.maps[l.mapping.maps.length-1],u.push(new Bs(e,void 0,void 0,u.length+h.length))),i--,e&&r.appendMap(e,i)}else l.maybeStep(t.step);return t.selection?(s=r?t.selection.map(r.slice(i)):t.selection,o=new $s(this.items.slice(0,n).append(h.reverse().concat(u)),this.eventCount-1),!1):void 0}),this.items.length,0),{remaining:o,transform:l,selection:s}}addTransform(t,e,r,i){let n=[],s=this.eventCount,o=this.items,l=!i&&o.length?o.get(o.length-1):null;for(let r=0;r<t.steps.length;r++){let u,h=t.steps[r].invert(t.docs[r]),a=new Bs(t.mapping.maps[r],h,e);(u=l&&l.merge(a))&&(a=u,r?n.pop():o=o.slice(0,o.length-1)),n.push(a),e&&(s++,e=void 0),i||(l=a)}let u=s-r.depth;return u>Ns&&(o=function(t,e){let r;return t.forEach(((t,i)=>{if(t.selection&&0==e--)return r=i,!1})),t.slice(r)}(o,u),s-=u),new $s(o.append(n),s)}remapping(t,e){let r=new Rt;return this.items.forEach(((e,i)=>{r.appendMap(e.map,null!=e.mirrorOffset&&i-e.mirrorOffset>=t?r.maps.length-e.mirrorOffset:void 0)}),t,e),r}addMaps(t){return 0==this.eventCount?this:new $s(this.items.append(t.map((t=>new Bs(t)))),this.eventCount)}rebased(t,e){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-e),n=t.mapping,s=t.steps.length,o=this.eventCount;this.items.forEach((t=>{t.selection&&o--}),i);let l=e;this.items.forEach((e=>{let i=n.getMirror(--l);if(null==i)return;s=Math.min(s,i);let u=n.maps[i];if(e.step){let s=t.steps[i].invert(t.docs[i]),h=e.selection&&e.selection.map(n.slice(l+1,i));h&&o++,r.push(new Bs(u,s,h))}else r.push(new Bs(u))}),i);let u=[];for(let t=e;t<s;t++)u.push(new Bs(n.maps[t]));let h=this.items.slice(0,i).append(u).append(r),a=new $s(h,o);return a.emptyItemCount()>500&&(a=a.compress(this.items.length-r.length)),a}emptyItemCount(){let t=0;return this.items.forEach((e=>{e.step||t++})),t}compress(t=this.items.length){let e=this.remapping(0,t),r=e.maps.length,i=[],n=0;return this.items.forEach(((s,o)=>{if(o>=t)i.push(s),s.selection&&n++;else if(s.step){let t=s.step.map(e.slice(r)),o=t&&t.getMap();if(r--,o&&e.appendMap(o,r),t){let l=s.selection&&s.selection.map(e.slice(r));l&&n++;let u,h=new Bs(o.invert(),t,l),a=i.length-1;(u=i.length&&i[a].merge(h))?i[a]=u:i.push(h)}}else s.map&&r--}),this.items.length,0),new $s(As.from(i.reverse()),n)}}$s.empty=new $s(As.empty,0);class Bs{constructor(t,e,r,i){this.map=t,this.step=e,this.selection=r,this.mirrorOffset=i}merge(t){if(this.step&&t.step&&!t.selection){let e=t.step.merge(this.step);if(e)return new Bs(e.getMap().invert(),e,this.selection)}}}class Rs{constructor(t,e,r,i,n){this.done=t,this.undone=e,this.prevRanges=r,this.prevTime=i,this.prevComposition=n}}const Ns=20;function _s(t){let e=[];return t.forEach(((t,r,i,n)=>e.push(i,n))),e}function Ts(t,e){if(!t)return null;let r=[];for(let i=0;i<t.length;i+=2){let n=e.map(t[i],1),s=e.map(t[i+1],-1);n<=s&&r.push(n,s)}return r}function zs(t,e,r,i){let n=js(e),s=Ps.get(e).spec.config,o=(i?t.undone:t.done).popEvent(e,n);if(!o)return;let l=o.selection.resolve(o.transform.doc),u=(i?t.done:t.undone).addTransform(o.transform,e.selection.getBookmark(),s,n),h=new Rs(i?u:o.remaining,i?o.remaining:u,null,0,-1);r(o.transform.setSelection(l).setMeta(Ps,{redo:i,historyState:h}).scrollIntoView())}let qs=!1,Is=null;function js(t){let e=t.plugins;if(Is!=e){qs=!1,Is=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){qs=!0;break}}return qs}const Ps=new je("history"),Ls=new je("closeHistory");const Js=(t,e)=>{let r=Ps.getState(t);return!(!r||0==r.done.eventCount||(e&&zs(r,t,e,!1),0))},Us=(t,e)=>{let r=Ps.getState(t);return!(!r||0==r.undone.eventCount||(e&&zs(r,t,e,!0),0))},Vs=(t,e)=>!t.selection.empty&&(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Hs(t,e,r=!1){for(let i=t;i;i="start"==e?i.firstChild:i.lastChild){if(i.isTextblock)return!0;if(r&&1!=i.childCount)return!1}return!1}function Ws(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function Gs(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let r=t.node(e);if(t.index(e)+1<r.childCount)return t.doc.resolve(t.after(e+1));if(r.type.spec.isolating)break}return null}const Zs=(t,e)=>{let r,i=t.selection,n=i instanceof xe;if(n){if(i.node.isTextblock||!Qt(t.doc,i.from))return!1;r=i.from}else if(r=ee(t.doc,i.from,-1),null==r)return!1;if(e){let i=t.tr.join(r);n&&i.setSelection(xe.create(i.doc,r-t.doc.resolve(r).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},Ks=(t,e)=>{let r,i=t.selection;if(i instanceof xe){if(i.node.isTextblock||!Qt(t.doc,i.to))return!1;r=i.to}else if(r=ee(t.doc,i.to,1),null==r)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},Ys=(t,e)=>{let{$from:r,$to:i}=t.selection,n=r.blockRange(i),s=n&&Wt(n);return null!=s&&(e&&e(t.tr.lift(n,s).scrollIntoView()),!0)};function Xs(t){for(let e=0;e<t.edgeCount;e++){let{type:r}=t.edge(e);if(r.isTextblock&&!r.hasRequiredAttrs())return r}return null}const Qs=(t,e)=>{let{$head:r,$anchor:i}=t.selection;if(!r.parent.type.spec.code||!r.sameParent(i))return!1;let n=r.node(-1),s=r.indexAfter(-1),o=Xs(n.contentMatchAt(s));if(!o||!n.canReplaceWith(s,s,o))return!1;if(e){let i=r.after(),n=t.tr.replaceWith(i,i,o.createAndFill());n.setSelection(be.near(n.doc.resolve(i),1)),e(n.scrollIntoView())}return!0},to=(t,e)=>{let r,{$from:i,to:n}=t.selection,s=i.sharedDepth(n);return 0!=s&&(r=i.before(s),e&&e(t.tr.setSelection(xe.create(t.doc,r))),!0)};function eo(t,e,r){let i,n,s=e.nodeBefore,o=e.nodeAfter;if(s.type.spec.isolating||o.type.spec.isolating)return!1;if(function(t,e,r){let i=e.nodeBefore,n=e.nodeAfter,s=e.index();return!(!(i&&n&&i.type.compatibleContent(n.type))||(!i.content.size&&e.parent.canReplace(s-1,s)?(r&&r(t.tr.delete(e.pos-i.nodeSize,e.pos).scrollIntoView()),0):!e.parent.canReplace(s,s+1)||!n.isTextblock&&!Qt(t.doc,e.pos)||(r&&r(t.tr.clearIncompatible(e.pos,i.type,i.contentMatchAt(i.childCount)).join(e.pos).scrollIntoView()),0)))}(t,e,r))return!0;let l=e.parent.canReplace(e.index(),e.index()+1);if(l&&(i=(n=s.contentMatchAt(s.childCount)).findWrapping(o.type))&&n.matchType(i[0]||o.type).validEnd){if(r){let n=e.pos+o.nodeSize,l=E.empty;for(let t=i.length-1;t>=0;t--)l=E.from(i[t].create(null,l));l=E.from(s.copy(l));let u=t.tr.step(new Jt(e.pos-1,n,e.pos,n,new S(l,1,0),i.length,!0)),h=n+2*i.length;Qt(u.doc,h)&&u.join(h),r(u.scrollIntoView())}return!0}let u=be.findFrom(e,1),h=u&&u.$from.blockRange(u.$to),a=h&&Wt(h);if(null!=a&&a>=e.depth)return r&&r(t.tr.lift(h,a).scrollIntoView()),!0;if(l&&Hs(o,"start",!0)&&Hs(s,"end")){let i=s,n=[];for(;n.push(i),!i.isTextblock;)i=i.lastChild;let l=o,u=1;for(;!l.isTextblock;l=l.firstChild)u++;if(i.canReplace(i.childCount,i.childCount,l.content)){if(r){let i=E.empty;for(let t=n.length-1;t>=0;t--)i=E.from(n[t].copy(i));r(t.tr.step(new Jt(e.pos-n.length,e.pos+o.nodeSize,e.pos+u,e.pos+o.nodeSize-u,new S(i,n.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function ro(t){return function(e,r){let i=e.selection,n=t<0?i.$from:i.$to,s=n.depth;for(;n.node(s).isInline;){if(!s)return!1;s--}return!!n.node(s).isTextblock&&(r&&r(e.tr.setSelection(ye.create(e.doc,t<0?n.start(s):n.end(s)))),!0)}}const io=ro(-1),no=ro(1);function so(t,e=null){return function(r,i){let{$from:n,$to:s}=r.selection,o=n.blockRange(s),l=o&&Gt(o,t,e);return!!l&&(i&&i(r.tr.wrap(o,l).scrollIntoView()),!0)}}function oo(t,e=null){return function(r,i){let n=!1;for(let i=0;i<r.selection.ranges.length&&!n;i++){let{$from:{pos:s},$to:{pos:o}}=r.selection.ranges[i];r.doc.nodesBetween(s,o,((i,s)=>{if(n)return!1;if(i.isTextblock&&!i.hasMarkup(t,e))if(i.type==t)n=!0;else{let e=r.doc.resolve(s),i=e.index();n=e.parent.canReplaceWith(i,i+1,t)}}))}if(!n)return!1;if(i){let n=r.tr;for(let i=0;i<r.selection.ranges.length;i++){let{$from:{pos:s},$to:{pos:o}}=r.selection.ranges[i];n.setBlockType(s,o,t,e)}i(n.scrollIntoView())}return!0}}function lo(t,e=null){return function(r,i){let{empty:n,$cursor:s,ranges:o}=r.selection;if(n&&!s||!function(t,e,r){for(let i=0;i<e.length;i++){let{$from:n,$to:s}=e[i],o=0==n.depth&&t.inlineContent&&t.type.allowsMarkType(r);if(t.nodesBetween(n.pos,s.pos,(t=>{if(o)return!1;o=t.inlineContent&&t.type.allowsMarkType(r)})),o)return!0}return!1}(r.doc,o,t))return!1;if(i)if(s)t.isInSet(r.storedMarks||s.marks())?i(r.tr.removeStoredMark(t)):i(r.tr.addStoredMark(t.create(e)));else{let n=!1,s=r.tr;for(let e=0;!n&&e<o.length;e++){let{$from:i,$to:s}=o[e];n=r.doc.rangeHasMark(i.pos,s.pos,t)}for(let r=0;r<o.length;r++){let{$from:i,$to:l}=o[r];if(n)s.removeMark(i.pos,l.pos,t);else{let r=i.pos,n=l.pos,o=i.nodeAfter,u=l.nodeBefore,h=o&&o.isText?/^\s*/.exec(o.text)[0].length:0,a=u&&u.isText?/\s*$/.exec(u.text)[0].length:0;r+h<n&&(r+=h,n-=a),s.addMark(r,n,t.create(e))}}i(s.scrollIntoView())}return!0}}function uo(...t){return function(e,r,i){for(let n=0;n<t.length;n++)if(t[n](e,r,i))return!0;return!1}}let ho=uo(Vs,((t,e,r)=>{let i=function(t,e){let{$cursor:r}=t.selection;return!r||(e?!e.endOfTextblock("backward",t):r.parentOffset>0)?null:r}(t,r);if(!i)return!1;let n=Ws(i);if(!n){let r=i.blockRange(),n=r&&Wt(r);return null!=n&&(e&&e(t.tr.lift(r,n).scrollIntoView()),!0)}let s=n.nodeBefore;if(!s.type.spec.isolating&&eo(t,n,e))return!0;if(0==i.parent.content.size&&(Hs(s,"end")||xe.isSelectable(s))){let r=ie(t.doc,i.before(),i.after(),S.empty);if(r&&r.slice.size<r.to-r.from){if(e){let i=t.tr.step(r);i.setSelection(Hs(s,"end")?be.findFrom(i.doc.resolve(i.mapping.map(n.pos,-1)),-1):xe.create(i.doc,n.pos-s.nodeSize)),e(i.scrollIntoView())}return!0}}return!(!s.isAtom||n.depth!=i.depth-1||(e&&e(t.tr.delete(n.pos-s.nodeSize,n.pos).scrollIntoView()),0))}),((t,e,r)=>{let{$head:i,empty:n}=t.selection,s=i;if(!n)return!1;if(i.parent.isTextblock){if(r?!r.endOfTextblock("backward",t):i.parentOffset>0)return!1;s=Ws(i)}let o=s&&s.nodeBefore;return!(!o||!xe.isSelectable(o)||(e&&e(t.tr.setSelection(xe.create(t.doc,s.pos-o.nodeSize)).scrollIntoView()),0))})),ao=uo(Vs,((t,e,r)=>{let i=function(t,e){let{$cursor:r}=t.selection;return!r||(e?!e.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)?null:r}(t,r);if(!i)return!1;let n=Gs(i);if(!n)return!1;let s=n.nodeAfter;if(eo(t,n,e))return!0;if(0==i.parent.content.size&&(Hs(s,"start")||xe.isSelectable(s))){let r=ie(t.doc,i.before(),i.after(),S.empty);if(r&&r.slice.size<r.to-r.from){if(e){let i=t.tr.step(r);i.setSelection(Hs(s,"start")?be.findFrom(i.doc.resolve(i.mapping.map(n.pos)),1):xe.create(i.doc,i.mapping.map(n.pos))),e(i.scrollIntoView())}return!0}}return!(!s.isAtom||n.depth!=i.depth-1||(e&&e(t.tr.delete(n.pos,n.pos+s.nodeSize).scrollIntoView()),0))}),((t,e,r)=>{let{$head:i,empty:n}=t.selection,s=i;if(!n)return!1;if(i.parent.isTextblock){if(r?!r.endOfTextblock("forward",t):i.parentOffset<i.parent.content.size)return!1;s=Gs(i)}let o=s&&s.nodeAfter;return!(!o||!xe.isSelectable(o)||(e&&e(t.tr.setSelection(xe.create(t.doc,s.pos)).scrollIntoView()),0))}));const fo={Enter:uo(((t,e)=>{let{$head:r,$anchor:i}=t.selection;return!(!r.parent.type.spec.code||!r.sameParent(i)||(e&&e(t.tr.insertText("\n").scrollIntoView()),0))}),((t,e)=>{let r=t.selection,{$from:i,$to:n}=r;if(r instanceof Me||i.parent.inlineContent||n.parent.inlineContent)return!1;let s=Xs(n.parent.contentMatchAt(n.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let r=(!i.parentOffset&&n.index()<n.parent.childCount?i:n).pos,o=t.tr.insert(r,s.createAndFill());o.setSelection(ye.create(o.doc,r+1)),e(o.scrollIntoView())}return!0}),((t,e)=>{let{$cursor:r}=t.selection;if(!r||r.parent.content.size)return!1;if(r.depth>1&&r.after()!=r.end(-1)){let i=r.before();if(Xt(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let i=r.blockRange(),n=i&&Wt(i);return null!=n&&(e&&e(t.tr.lift(i,n).scrollIntoView()),!0)}),((t,e)=>{let{$from:r,$to:i}=t.selection;if(t.selection instanceof xe&&t.selection.node.isBlock)return!(!r.parentOffset||!Xt(t.doc,r.pos)||(e&&e(t.tr.split(r.pos).scrollIntoView()),0));if(!r.parent.isBlock)return!1;if(e){let n=i.parentOffset==i.parent.content.size,s=t.tr;(t.selection instanceof ye||t.selection instanceof Me)&&s.deleteSelection();let o=0==r.depth?null:Xs(r.node(-1).contentMatchAt(r.indexAfter(-1))),l=n&&o?[{type:o}]:void 0,u=Xt(s.doc,s.mapping.map(r.pos),1,l);if(l||u||!Xt(s.doc,s.mapping.map(r.pos),1,o?[{type:o}]:void 0)||(o&&(l=[{type:o}]),u=!0),u&&(s.split(s.mapping.map(r.pos),1,l),!n&&!r.parentOffset&&r.parent.type!=o)){let t=s.mapping.map(r.before()),e=s.doc.resolve(t);o&&r.node(-1).canReplaceWith(e.index(),e.index()+1,o)&&s.setNodeMarkup(s.mapping.map(r.before()),o)}e(s.scrollIntoView())}return!0})),"Mod-Enter":Qs,Backspace:ho,"Mod-Backspace":ho,"Shift-Backspace":ho,Delete:ao,"Mod-Delete":ao,"Mod-a":(t,e)=>(e&&e(t.tr.setSelection(new Me(t.doc))),!0)},co={"Ctrl-h":fo.Backspace,"Alt-Backspace":fo["Mod-Backspace"],"Ctrl-d":fo.Delete,"Ctrl-Alt-Backspace":fo["Mod-Delete"],"Alt-Delete":fo["Mod-Delete"],"Alt-d":fo["Mod-Delete"],"Ctrl-a":io,"Ctrl-e":no};for(let t in fo)co[t]=fo[t];const po=("undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&"darwin"==os.platform())?co:fo;function mo(t={}){return new ze({view:e=>new go(e,t)})}class go{constructor(t,e){var r;this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!==(r=e.width)&&void 0!==r?r:1,this.color=!1===e.color?void 0:e.color||"black",this.class=e.class,this.handlers=["dragover","dragend","drop","dragleave"].map((e=>{let r=t=>{this[e](t)};return t.dom.addEventListener(e,r),{name:e,handler:r}}))}destroy(){this.handlers.forEach((({name:t,handler:e})=>this.editorView.dom.removeEventListener(t,e)))}update(t,e){null!=this.cursorPos&&e.doc!=t.state.doc&&(this.cursorPos>t.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(t){t!=this.cursorPos&&(this.cursorPos=t,null==t?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let t,e=this.editorView.state.doc.resolve(this.cursorPos),r=!e.parent.inlineContent;if(r){let r=e.nodeBefore,i=e.nodeAfter;if(r||i){let e=this.editorView.nodeDOM(this.cursorPos-(r?r.nodeSize:0));if(e){let n=e.getBoundingClientRect(),s=r?n.bottom:n.top;r&&i&&(s=(s+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),t={left:n.left,right:n.right,top:s-this.width/2,bottom:s+this.width/2}}}}if(!t){let e=this.editorView.coordsAtPos(this.cursorPos);t={left:e.left-this.width/2,right:e.left+this.width/2,top:e.top,bottom:e.bottom}}let i,n,s=this.editorView.dom.offsetParent;if(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",r),this.element.classList.toggle("prosemirror-dropcursor-inline",!r),!s||s==document.body&&"static"==getComputedStyle(s).position)i=-pageXOffset,n=-pageYOffset;else{let t=s.getBoundingClientRect();i=t.left-s.scrollLeft,n=t.top-s.scrollTop}this.element.style.left=t.left-i+"px",this.element.style.top=t.top-n+"px",this.element.style.width=t.right-t.left+"px",this.element.style.height=t.bottom-t.top+"px"}scheduleRemoval(t){clearTimeout(this.timeout),this.timeout=setTimeout((()=>this.setCursor(null)),t)}dragover(t){if(!this.editorView.editable)return;let e=this.editorView.posAtCoords({left:t.clientX,top:t.clientY}),r=e&&e.inside>=0&&this.editorView.state.doc.nodeAt(e.inside),i=r&&r.type.spec.disableDropCursor,n="function"==typeof i?i(this.editorView,e,t):i;if(e&&!n){let t=e.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=re(this.editorView.state.doc,t,this.editorView.dragging.slice);null!=e&&(t=e)}this.setCursor(t),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){t.target!=this.editorView.dom&&this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)}}class wo extends be{constructor(t){super(t,t)}map(t,e){let r=t.resolve(e.map(this.head));return wo.valid(r)?new wo(r):be.near(r)}content(){return S.empty}eq(t){return t instanceof wo&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new wo(t.resolve(e.pos))}getBookmark(){return new bo(this.anchor)}static valid(t){let e=t.parent;if(e.isTextblock||!function(t){for(let e=t.depth;e>=0;e--){let r=t.index(e),i=t.node(e);if(0!=r)for(let t=i.child(r-1);;t=t.lastChild){if(0==t.childCount&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return!0;if(t.inlineContent)return!1}else if(i.type.spec.isolating)return!0}return!0}(t)||!function(t){for(let e=t.depth;e>=0;e--){let r=t.indexAfter(e),i=t.node(e);if(r!=i.childCount)for(let t=i.child(r);;t=t.firstChild){if(0==t.childCount&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return!0;if(t.inlineContent)return!1}else if(i.type.spec.isolating)return!0}return!0}(t))return!1;let r=e.type.spec.allowGapCursor;if(null!=r)return r;let i=e.contentMatchAt(t.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(t,e,r=!1){t:for(;;){if(!r&&wo.valid(t))return t;let i=t.pos,n=null;for(let r=t.depth;;r--){let s=t.node(r);if(e>0?t.indexAfter(r)<s.childCount:t.index(r)>0){n=s.child(e>0?t.indexAfter(r):t.index(r)-1);break}if(0==r)return null;i+=e;let o=t.doc.resolve(i);if(wo.valid(o))return o}for(;;){let s=e>0?n.firstChild:n.lastChild;if(!s){if(n.isAtom&&!n.isText&&!xe.isSelectable(n)){t=t.doc.resolve(i+n.nodeSize*e),r=!1;continue t}break}n=s,i+=e;let o=t.doc.resolve(i);if(wo.valid(o))return o}return null}}}wo.prototype.visible=!1,wo.findFrom=wo.findGapCursorFrom,be.jsonID("gapcursor",wo);class bo{constructor(t){this.pos=t}map(t){return new bo(t.map(this.pos))}resolve(t){let e=t.resolve(this.pos);return wo.valid(e)?new wo(e):be.near(e)}}const vo=Ms({ArrowLeft:ko("horiz",-1),ArrowRight:ko("horiz",1),ArrowUp:ko("vert",-1),ArrowDown:ko("vert",1)});function ko(t,e){const r="vert"==t?e>0?"down":"up":e>0?"right":"left";return function(t,i,n){let s=t.selection,o=e>0?s.$to:s.$from,l=s.empty;if(s instanceof ye){if(!n.endOfTextblock(r)||0==o.depth)return!1;l=!1,o=t.doc.resolve(e>0?o.after():o.before())}let u=wo.findGapCursorFrom(o,e,l);return!!u&&(i&&i(t.tr.setSelection(new wo(u))),!0)}}function Do(t,e,r){if(!t||!t.editable)return!1;let i=t.state.doc.resolve(e);if(!wo.valid(i))return!1;let n=t.posAtCoords({left:r.clientX,top:r.clientY});return!(n&&n.inside>-1&&xe.isSelectable(t.state.doc.nodeAt(n.inside))||(t.dispatch(t.state.tr.setSelection(new wo(i))),0))}function yo(t,e){if("insertCompositionText"!=e.inputType||!(t.state.selection instanceof wo))return!1;let{$from:r}=t.state.selection,i=r.parent.contentMatchAt(r.index()).findWrapping(t.state.schema.nodes.text);if(!i)return!1;let n=E.empty;for(let t=i.length-1;t>=0;t--)n=E.from(i[t].createAndFill(null,n));let s=t.state.tr.replace(r.pos,r.pos,new S(n,0,0));return s.setSelection(ye.near(s.doc.resolve(r.pos+1))),t.dispatch(s),!1}function Eo(t){if(!(t.selection instanceof wo))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",yn.create(t.doc,[vn.widget(t.selection.head,e,{key:"gapcursor"})])}class xo{constructor(t,e,r={}){var i;this.match=t,this.match=t,this.handler="string"==typeof e?(i=e,function(t,e,r,n){let s=i;if(e[1]){let t=e[0].lastIndexOf(e[1]);s+=e[0].slice(t+e[1].length);let i=(r+=t)-n;i>0&&(s=e[0].slice(t-i,t)+s,r=n)}return t.tr.insertText(s,r,n)}):e,this.undoable=!1!==r.undoable,this.inCode=r.inCode||!1}}function Fo(t,e,r,i,n,s){if(t.composing)return!1;let o=t.state,l=o.doc.resolve(e),u=l.parent.textBetween(Math.max(0,l.parentOffset-500),l.parentOffset,null,"")+i;for(let h=0;h<n.length;h++){let a=n[h];if(l.parent.type.spec.code){if(!a.inCode)continue}else if("only"===a.inCode)continue;let f=a.match.exec(u),c=f&&a.handler(o,f,e-(f[0].length-i.length),r);if(c)return a.undoable&&c.setMeta(s,{transform:c,from:e,to:r,text:i}),t.dispatch(c),!0}return!1}const Mo=(t,e)=>{let r=t.plugins;for(let i=0;i<r.length;i++){let n,s=r[i];if(s.spec.isInputRules&&(n=s.getState(t))){if(e){let r=t.tr,i=n.transform;for(let t=i.steps.length-1;t>=0;t--)r.step(i.steps[t].invert(i.docs[t]));if(n.text){let e=r.doc.resolve(n.from).marks();r.replaceWith(n.from,n.to,t.schema.text(n.text,e))}else r.delete(n.from,n.to);e(r)}return!0}}return!1},Co=new xo(/--$/,"—"),Ao=new xo(/\.\.\.$/,"…"),So=[new xo(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),new xo(/"$/,"”"),new xo(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),new xo(/'$/,"’")];function Oo(t,e,r=null,i){return new xo(t,((t,n,s,o)=>{let l=r instanceof Function?r(n):r,u=t.tr.delete(s,o),h=u.doc.resolve(s).blockRange(),a=h&&Gt(h,e,l);if(!a)return null;u.wrap(h,a);let f=u.doc.resolve(s-1).nodeBefore;return f&&f.type==e&&Qt(u.doc,s-1)&&(!i||i(n,f))&&u.join(s-1),u}))}function $o(t,e,r=null){return new xo(t,((t,i,n,s)=>{let o=t.doc.resolve(n),l=r instanceof Function?r(i):r;return o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),e)?t.tr.delete(n,s).setBlockType(n,n,e,l):null}))}const Bo="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function Ro(t,e){let r,i={};function n(t,r){if(e){let r=e[t];if(!1===r)return;r&&(t=r)}i[t]=r}if(n("Mod-z",Js),n("Shift-Mod-z",Us),n("Backspace",Mo),Bo||n("Mod-y",Us),n("Alt-ArrowUp",Zs),n("Alt-ArrowDown",Ks),n("Mod-BracketLeft",Ys),n("Escape",to),(r=t.marks.strong)&&(n("Mod-b",lo(r)),n("Mod-B",lo(r))),(r=t.marks.em)&&(n("Mod-i",lo(r)),n("Mod-I",lo(r))),(r=t.marks.code)&&n("Mod-`",lo(r)),(r=t.nodes.bullet_list)&&n("Shift-Ctrl-8",ms(r)),(r=t.nodes.ordered_list)&&n("Shift-Ctrl-9",ms(r)),(r=t.nodes.blockquote)&&n("Ctrl->",so(r)),r=t.nodes.hard_break){let t=r,e=uo(Qs,((e,r)=>(r&&r(e.tr.replaceSelectionWith(t.create()).scrollIntoView()),!0)));n("Mod-Enter",e),n("Shift-Enter",e),Bo&&n("Ctrl-Enter",e)}var s;if((r=t.nodes.list_item)&&(n("Enter",(s=r,function(t,e){let{$from:r,$to:i,node:n}=t.selection;if(n&&n.isBlock||r.depth<2||!r.sameParent(i))return!1;let o=r.node(-1);if(o.type!=s)return!1;if(0==r.parent.content.size&&r.node(-1).childCount==r.indexAfter(-1)){if(3==r.depth||r.node(-3).type!=s||r.index(-2)!=r.node(-2).childCount-1)return!1;if(e){let i=E.empty,n=r.index(-1)?1:r.index(-2)?2:3;for(let t=r.depth-n;t>=r.depth-3;t--)i=E.from(r.node(t).copy(i));let o=r.indexAfter(-1)<r.node(-2).childCount?1:r.indexAfter(-2)<r.node(-3).childCount?2:3;i=i.append(E.from(s.createAndFill()));let l=r.before(r.depth-(n-1)),u=t.tr.replace(l,r.after(-o),new S(i,4-n,0)),h=-1;u.doc.nodesBetween(l,u.doc.content.size,((t,e)=>{if(h>-1)return!1;t.isTextblock&&0==t.content.size&&(h=e+1)})),h>-1&&u.setSelection(be.near(u.doc.resolve(h))),e(u.scrollIntoView())}return!0}let l=i.pos==r.end()?o.contentMatchAt(0).defaultType:null,u=t.tr.delete(r.pos,i.pos),h=l?[null,{type:l}]:void 0;return!!Xt(u.doc,r.pos,2,h)&&(e&&e(u.split(r.pos,2,h).scrollIntoView()),!0)})),n("Mod-[",function(t){return function(e,r){let{$from:i,$to:n}=e.selection,s=i.blockRange(n,(e=>e.childCount>0&&e.firstChild.type==t));return!!s&&(!r||(i.node(s.depth-1).type==t?function(t,e,r,i){let n=t.tr,s=i.end,o=i.$to.end(i.depth);s<o&&(n.step(new Jt(s-1,o,s,o,new S(E.from(r.create(null,i.parent.copy())),1,0),1,!0)),i=new V(n.doc.resolve(i.$from.pos),n.doc.resolve(o),i.depth));const l=Wt(i);if(null==l)return!1;n.lift(i,l);let u=n.mapping.map(s,-1)-1;return Qt(n.doc,u)&&n.join(u),e(n.scrollIntoView()),!0}(e,r,t,s):function(t,e,r){let i=t.tr,n=r.parent;for(let t=r.end,e=r.endIndex-1,s=r.startIndex;e>s;e--)t-=n.child(e).nodeSize,i.delete(t-1,t+1);let s=i.doc.resolve(r.start),o=s.nodeAfter;if(i.mapping.map(r.end)!=r.start+s.nodeAfter.nodeSize)return!1;let l=0==r.startIndex,u=r.endIndex==n.childCount,h=s.node(-1),a=s.index(-1);if(!h.canReplace(a+(l?0:1),a+1,o.content.append(u?E.empty:E.from(n))))return!1;let f=s.pos,c=f+o.nodeSize;return i.step(new Jt(f-(l?1:0),c+(u?1:0),f+1,c-1,new S((l?E.empty:E.from(n.copy(E.empty))).append(u?E.empty:E.from(n.copy(E.empty))),l?0:1,u?0:1),l?0:1)),e(i.scrollIntoView()),!0}(e,r,s)))}}(r)),n("Mod-]",function(t){return function(e,r){let{$from:i,$to:n}=e.selection,s=i.blockRange(n,(e=>e.childCount>0&&e.firstChild.type==t));if(!s)return!1;let o=s.startIndex;if(0==o)return!1;let l=s.parent,u=l.child(o-1);if(u.type!=t)return!1;if(r){let i=u.lastChild&&u.lastChild.type==l.type,n=E.from(i?t.create():null),o=new S(E.from(t.create(null,E.from(l.type.create(null,n)))),i?3:1,0),h=s.start,a=s.end;r(e.tr.step(new Jt(h-(i?3:1),a,h,a,o,1,!0)).scrollIntoView())}return!0}}(r))),(r=t.nodes.paragraph)&&n("Shift-Ctrl-0",oo(r)),(r=t.nodes.code_block)&&n("Shift-Ctrl-\\",oo(r)),r=t.nodes.heading)for(let t=1;t<=6;t++)n("Shift-Ctrl-"+t,oo(r,{level:t}));if(r=t.nodes.horizontal_rule){let t=r;n("Mod-_",((e,r)=>(r&&r(e.tr.replaceSelectionWith(t.create()).scrollIntoView()),!0)))}return i}function No(t){let e,r=So.concat(Ao,Co);return(e=t.nodes.blockquote)&&r.push(Oo(/^\s*>\s$/,e)),(e=t.nodes.ordered_list)&&r.push(Oo(/^(\d+)\.\s$/,e,(t=>({order:+t[1]})),((t,e)=>e.childCount+e.attrs.order==+t[1]))),(e=t.nodes.bullet_list)&&r.push(function(t){return Oo(/^\s*([-+*])\s$/,t)}(e)),(e=t.nodes.code_block)&&r.push(function(t){return $o(/^```$/,t)}(e)),(e=t.nodes.heading)&&r.push(function(t){return $o(new RegExp("^(#{1,6})\\s$"),t,(t=>({level:t[1].length})))}(e)),function({rules:t}){let e=new ze({state:{init:()=>null,apply(t,e){return t.getMeta(this)||(t.selectionSet||t.docChanged?null:e)}},props:{handleTextInput:(r,i,n,s)=>Fo(r,i,n,s,t,e),handleDOMEvents:{compositionend:r=>{setTimeout((()=>{let{$cursor:i}=r.state.selection;i&&Fo(r,i.pos,i.pos,"",t,e)}))}}},isInputRules:!0});return e}({rules:r})}function _o(t){let e=[No(t.schema),Fs(Ro(t.schema,t.mapKeys)),Fs(po),mo(),new ze({props:{decorations:Eo,createSelectionBetween:(t,e,r)=>e.pos==r.pos&&wo.valid(r)?new wo(r):null,handleClick:Do,handleKeyDown:vo,handleDOMEvents:{beforeinput:yo}}})];return!1!==t.history&&e.push(function(t={}){return new ze({key:Ps,state:{init:()=>new Rs($s.empty,$s.empty,null,0,-1),apply:(e,r,i)=>function(t,e,r,i){let n,s=r.getMeta(Ps);if(s)return s.historyState;r.getMeta(Ls)&&(t=new Rs(t.done,t.undone,null,0,-1));let o=r.getMeta("appendedTransaction");if(0==r.steps.length)return t;if(o&&o.getMeta(Ps))return o.getMeta(Ps).redo?new Rs(t.done.addTransform(r,void 0,i,js(e)),t.undone,_s(r.mapping.maps[r.steps.length-1]),t.prevTime,t.prevComposition):new Rs(t.done,t.undone.addTransform(r,void 0,i,js(e)),null,t.prevTime,t.prevComposition);if(!1===r.getMeta("addToHistory")||o&&!1===o.getMeta("addToHistory"))return(n=r.getMeta("rebased"))?new Rs(t.done.rebased(r,n),t.undone.rebased(r,n),Ts(t.prevRanges,r.mapping),t.prevTime,t.prevComposition):new Rs(t.done.addMaps(r.mapping.maps),t.undone.addMaps(r.mapping.maps),Ts(t.prevRanges,r.mapping),t.prevTime,t.prevComposition);{let n=r.getMeta("composition"),s=0==t.prevTime||!o&&t.prevComposition!=n&&(t.prevTime<(r.time||0)-i.newGroupDelay||!function(t,e){if(!e)return!1;if(!t.docChanged)return!0;let r=!1;return t.mapping.maps[0].forEach(((t,i)=>{for(let n=0;n<e.length;n+=2)t<=e[n+1]&&i>=e[n]&&(r=!0)})),r}(r,t.prevRanges)),l=o?Ts(t.prevRanges,r.mapping):_s(r.mapping.maps[r.steps.length-1]);return new Rs(t.done.addTransform(r,s?e.selection.getBookmark():void 0,i,js(e)),$s.empty,l,r.time,null==n?t.prevComposition:n)}}(r,i,e,t)},config:t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},props:{handleDOMEvents:{beforeinput(t,e){let r=e.inputType,i="historyUndo"==r?Js:"historyRedo"==r?Us:null;return!!i&&(e.preventDefault(),i(t.state,t.dispatch))}}}})}()),e.concat(new ze({props:{attributes:{class:"ProseMirror-example-setup-style"}}}))}const To=(t,e)=>{t.active=t=>{const{from:r,$from:i,to:n,empty:s}=t.selection;return s?!!e.isInSet(t.storedMarks||i.marks()):t.doc.rangeHasMark(r,n,e)}},zo=(t,e)=>{t.active=t=>{const{from:r,to:i}=t.selection;for(let n=r;n<=i;n++){const r=t.doc.resolve(n);for(let t=r.depth;t>0;t--){const i=r.node(t);if(i&&i.type.name===e.name)return!0}}return!1}},qo=(t,e,r)=>{const i=t.marks[e];if(!i)throw new Error(`Mark "${e}" not found in schema`);const n=lo(i,Io(e,r));return To(n,i),n},Io=(t,e)=>{if(t===s.Link&&e.href)return{href:e.href,target:jo(e.href)?"_blank":null}},jo=t=>!t.startsWith(window.location.origin),Po=(t,e,r={},i=!1)=>{const n=t.nodes[e],s=t.nodes.paragraph;return(t,e)=>{const{$from:o,$to:l}=t.selection,u=o.node(o.depth-1).type===n;return!!(t.selection instanceof ye&&o.sameParent(o.doc.resolve(l.pos)))&&(o.parent.type===n?(e&&e(t.tr.setBlockType(o.pos,l.pos,s)),!0):u?Ys(t,e):i?so(n,r)(t,e):oo(n,r)(t,e))}},Lo=(t,e,r)=>{const i=t.nodes[e];if(!i)throw new Error(`Node type "${e}" not found in schema`);let n;return n=e===o.Heading&&r?Po(t,o.Heading,{level:r}):e===s.CodeBlock?Po(t,s.CodeBlock):oo(i),((t,e,r)=>{t.active=t=>{const{$from:i}=t.selection,n=i.node(i.depth);return!(!n||n.type.name!==e.name||e.name===o.Heading&&r&&n.attrs.level!==r)}})(n,i,r),n},Jo=(t,e)=>{const r=t.nodes[e];if(!r)throw new Error(`List type "${e}" not found in schema`);const i=(t=>(e,r)=>{const{$from:i,$to:n}=e.selection,s=i.blockRange(n);if(!s)return!1;const o=s&&Gt(s,t);if(o)return r&&r(e.tr.wrap(s,o).scrollIntoView()),!0;{const t=s&&Wt(s);return null!==t&&(r&&r(e.tr.lift(s,t).scrollIntoView()),!0)}})(r);return zo(i,r),i},Uo={strong:qo,em:qo,underline:qo,strikethrough:qo,code:qo,link:(t,e,r)=>{const i=(e,i)=>{const{from:n,to:s}=e.selection,o=t.marks.link.create(h(r.href,r.href));if(n===s){const s=t.text(r.text||r.href,[o]);i(e.tr.insert(n,s))}else{const l=e.doc.textBetween(n,s," "),u=t.text(r.text||l,[o]);i(e.tr.replaceWith(n,s,u))}return!0};return To(i,t.marks.link),i},headerlevel1:t=>Lo(t,o.Heading,o.one),headerlevel2:t=>Lo(t,o.Heading,o.two),headerlevel3:t=>Lo(t,o.Heading,o.three),blockquote:t=>((t,e)=>{const r=t.nodes[e];if(!r)throw new Error(`Node type "${e}" not found in schema`);let i;return i=e===s.Blockquote?Po(t,s.Blockquote,{},!0):so(r),zo(i,r),i})(t,s.Blockquote),code_block:t=>Lo(t,s.CodeBlock),ordered_list:t=>Jo(t,s.OrderedList),bullet_list:t=>Jo(t,s.BulletList)};class Vo{constructor(t){this.schema=t}getCommand(t,e){const r=Uo[t];if(!r)throw new Error(`The Mark "${t}" is not supported`);return r(this.schema,t,e)}buildKeymap(){return{"Mod-B":this.getCommand(s.Bold),"Mod-I":this.getCommand(s.Italic),"Mod-Shift-1":this.getCommand(s.HeaderLevel1),"Mod-Shift-2":this.getCommand(s.HeaderLevel2),"Mod-Shift-3":this.getCommand(s.HeaderLevel3),"Mod-Shift-X":this.getCommand(s.Strikethrough),"Mod-`":this.getCommand(s.Code),"Mod-Shift-C":this.getCommand(s.CodeBlock)}}}const{mod:Ho,shift:Wo}=/Macintosh|MacIntel|MacPPC|Mac68K/.test(navigator.userAgent)?{mod:"⌘",option:"⌥",shift:"⇧"}:{mod:"Ctrl",option:"Alt",shift:"Shift"},Go=[{value:s.Bold,text:"Bold",commandText:`${Ho} B`,icon:"-lime-text-bold",iconOnly:!0,selected:!1},{value:s.Italic,text:"Italic",commandText:`${Ho} I`,icon:"-lime-text-italic",iconOnly:!0,selected:!1},{value:s.Strikethrough,text:"Strikethrough",commandText:`${Ho} ${Wo} X`,icon:"-lime-text-strikethrough",iconOnly:!0,selected:!1},{value:s.Link,text:"Link",icon:"-lime-text-link",iconOnly:!0},{separator:!0},{value:s.BulletList,text:"Bullet list",icon:"-lime-text-bulleted-list",iconOnly:!0,selected:!1},{value:s.OrderedList,text:"Numbered list",icon:"-lime-text-ordered-list",iconOnly:!0,selected:!1},{separator:!0},{value:s.HeaderLevel1,text:"Header 1",commandText:`${Ho} ${Wo} 1`,icon:"-lime-text-h-heading-1",iconOnly:!0,selected:!1},{value:s.HeaderLevel2,text:"Header 2",commandText:`${Ho} ${Wo} 2`,icon:"-lime-text-h-heading-2",iconOnly:!0,selected:!1},{value:s.HeaderLevel3,text:"Header 3",commandText:`${Ho} ${Wo} 3`,icon:"-lime-text-h-heading-3",iconOnly:!0,selected:!1},{separator:!0},{value:s.Blockquote,text:"Blockquote",icon:"-lime-text-blockquote",iconOnly:!0,selected:!1},{separator:!0},{value:s.Code,text:"Code",commandText:`${Ho} \``,icon:"-lime-text-code",iconOnly:!0,selected:!1},{value:s.CodeBlock,text:"Code Block",commandText:`${Ho} ${Wo} C`,icon:"-lime-text-code-block",iconOnly:!0,selected:!1}],Zo=()=>c(Go),Ko={strong:"editor-menu.bold",em:"editor-menu.italic",headerlevel1:"editor-menu.h1",headerlevel2:"editor-menu.h2",headerlevel3:"editor-menu.h3",bullet_list:"editor-menu.bulleted-list",ordered_list:"editor-menu.numbered-list",code_block:"editor-menu.code-block",blockquote:"editor-menu.blockquote",link:"editor-menu.link",strikethrough:"editor-menu.strikethrough",code:"editor-menu.code"},Yo={};function Xo(t,e){"string"!=typeof e&&(e=Xo.defaultChars);const r=function(t){let e=Yo[t];if(e)return e;e=Yo[t]=[];for(let t=0;t<128;t++){const r=String.fromCharCode(t);e.push(r)}for(let r=0;r<t.length;r++){const i=t.charCodeAt(r);e[i]="%"+("0"+i.toString(16).toUpperCase()).slice(-2)}return e}(e);return t.replace(/(%[a-f0-9]{2})+/gi,(function(t){let e="";for(let i=0,n=t.length;i<n;i+=3){const s=parseInt(t.slice(i+1,i+3),16);if(s<128)e+=r[s];else{if(192==(224&s)&&i+3<n){const r=parseInt(t.slice(i+4,i+6),16);if(128==(192&r)){const t=s<<6&1984|63&r;e+=t<128?"��":String.fromCharCode(t),i+=3;continue}}if(224==(240&s)&&i+6<n){const r=parseInt(t.slice(i+4,i+6),16),n=parseInt(t.slice(i+7,i+9),16);if(128==(192&r)&&128==(192&n)){const t=s<<12&61440|r<<6&4032|63&n;e+=t<2048||t>=55296&&t<=57343?"���":String.fromCharCode(t),i+=6;continue}}if(240==(248&s)&&i+9<n){const r=parseInt(t.slice(i+4,i+6),16),n=parseInt(t.slice(i+7,i+9),16),o=parseInt(t.slice(i+10,i+12),16);if(128==(192&r)&&128==(192&n)&&128==(192&o)){let t=s<<18&1835008|r<<12&258048|n<<6&4032|63&o;t<65536||t>1114111?e+="����":(t-=65536,e+=String.fromCharCode(55296+(t>>10),56320+(1023&t))),i+=9;continue}}e+="�"}}return e}))}Xo.defaultChars=";/?:@&=+$,#",Xo.componentChars="";const Qo={};function tl(t,e,r){"string"!=typeof e&&(r=e,e=tl.defaultChars),void 0===r&&(r=!0);const i=function(t){let e=Qo[t];if(e)return e;e=Qo[t]=[];for(let t=0;t<128;t++){const r=String.fromCharCode(t);/^[0-9a-z]$/i.test(r)?e.push(r):e.push("%"+("0"+t.toString(16).toUpperCase()).slice(-2))}for(let r=0;r<t.length;r++)e[t.charCodeAt(r)]=t[r];return e}(e);let n="";for(let e=0,s=t.length;e<s;e++){const o=t.charCodeAt(e);if(r&&37===o&&e+2<s&&/^[0-9a-f]{2}$/i.test(t.slice(e+1,e+3)))n+=t.slice(e,e+3),e+=2;else if(o<128)n+=i[o];else if(o>=55296&&o<=57343){if(o>=55296&&o<=56319&&e+1<s){const r=t.charCodeAt(e+1);if(r>=56320&&r<=57343){n+=encodeURIComponent(t[e]+t[e+1]),e++;continue}}n+="%EF%BF%BD"}else n+=encodeURIComponent(t[e])}return n}function el(t){let e="";return e+=t.protocol||"",e+=t.slashes?"//":"",e+=t.auth?t.auth+"@":"",t.hostname&&-1!==t.hostname.indexOf(":")?e+="["+t.hostname+"]":e+=t.hostname||"",e+=t.port?":"+t.port:"",e+=t.pathname||"",e+=t.search||"",e+=t.hash||"",e}function rl(){this.protocol=null,this.slashes=null,this.auth=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.pathname=null}tl.defaultChars=";/?:@&=+$,-_.!~*'()#",tl.componentChars="-_.!~*'()";const il=/^([a-z0-9.+-]+:)/i,nl=/:[0-9]*$/,sl=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,ol=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),ll=["'"].concat(ol),ul=["%","/","?",";","#"].concat(ll),hl=["/","?","#"],al=/^[+a-z0-9A-Z_-]{0,63}$/,fl=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,cl={javascript:!0,"javascript:":!0},dl={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function pl(t,e){if(t&&t instanceof rl)return t;const r=new rl;return r.parse(t,e),r}rl.prototype.parse=function(t,e){let r,i,n,s=t;if(s=s.trim(),!e&&1===t.split("#").length){const t=sl.exec(s);if(t)return this.pathname=t[1],t[2]&&(this.search=t[2]),this}let o=il.exec(s);if(o&&(o=o[0],r=o.toLowerCase(),this.protocol=o,s=s.substr(o.length)),(e||o||s.match(/^\/\/[^@\/]+@[^@\/]+/))&&(n="//"===s.substr(0,2),!n||o&&cl[o]||(s=s.substr(2),this.slashes=!0)),!cl[o]&&(n||o&&!dl[o])){let t,e,r=-1;for(let t=0;t<hl.length;t++)i=s.indexOf(hl[t]),-1!==i&&(-1===r||i<r)&&(r=i);e=-1===r?s.lastIndexOf("@"):s.lastIndexOf("@",r),-1!==e&&(t=s.slice(0,e),s=s.slice(e+1),this.auth=t),r=-1;for(let t=0;t<ul.length;t++)i=s.indexOf(ul[t]),-1!==i&&(-1===r||i<r)&&(r=i);-1===r&&(r=s.length),":"===s[r-1]&&r--;const n=s.slice(0,r);s=s.slice(r),this.parseHost(n),this.hostname=this.hostname||"";const o="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!o){const t=this.hostname.split(/\./);for(let e=0,r=t.length;e<r;e++){const r=t[e];if(r&&!r.match(al)){let i="";for(let t=0,e=r.length;t<e;t++)r.charCodeAt(t)>127?i+="x":i+=r[t];if(!i.match(al)){const i=t.slice(0,e),n=t.slice(e+1),o=r.match(fl);o&&(i.push(o[1]),n.unshift(o[2])),n.length&&(s=n.join(".")+s),this.hostname=i.join(".");break}}}}this.hostname.length>255&&(this.hostname=""),o&&(this.hostname=this.hostname.substr(1,this.hostname.length-2))}const l=s.indexOf("#");-1!==l&&(this.hash=s.substr(l),s=s.slice(0,l));const u=s.indexOf("?");return-1!==u&&(this.search=s.substr(u),s=s.slice(0,u)),s&&(this.pathname=s),dl[r]&&this.hostname&&!this.pathname&&(this.pathname=""),this},rl.prototype.parseHost=function(t){let e=nl.exec(t);e&&(e=e[0],":"!==e&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)};var ml,gl,wl=Object.freeze({__proto__:null,decode:Xo,encode:tl,format:el,parse:pl}),bl=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,vl=/[\0-\x1F\x7F-\x9F]/,kl=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\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\u1B5A-\u1B60\u1B7D\u1B7E\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[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\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]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/,Dl=/[\$\+<->\^`\|~\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-\u20C0\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-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\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-\u31E3\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-\uFBC2\uFD40-\uFD4F\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]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\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-\uDED7\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF76\uDF7B-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDE53\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC5\uDECE-\uDEDB\uDEE0-\uDEE8\uDEF0-\uDEF8\uDF00-\uDF92\uDF94-\uDFCA]/,yl=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/,El=Object.freeze({__proto__:null,Any:bl,Cc:vl,Cf:/[\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]/,P:kl,S:Dl,Z:yl});function xl(t){for(let e=1;e<t.length;e++)t[e][0]+=t[e-1][0]+1;return t}function Fl(t){return"[object String]"===function(t){return Object.prototype.toString.call(t)}(t)}new Map(xl([[9,"&Tab;"],[0,"&NewLine;"],[22,"&excl;"],[0,"&quot;"],[0,"&num;"],[0,"&dollar;"],[0,"&percnt;"],[0,"&amp;"],[0,"&apos;"],[0,"&lpar;"],[0,"&rpar;"],[0,"&ast;"],[0,"&plus;"],[0,"&comma;"],[1,"&period;"],[0,"&sol;"],[10,"&colon;"],[0,"&semi;"],[0,{v:"&lt;",n:8402,o:"&nvlt;"}],[0,{v:"&equals;",n:8421,o:"&bne;"}],[0,{v:"&gt;",n:8402,o:"&nvgt;"}],[0,"&quest;"],[0,"&commat;"],[26,"&lbrack;"],[0,"&bsol;"],[0,"&rbrack;"],[0,"&Hat;"],[0,"&lowbar;"],[0,"&DiacriticalGrave;"],[5,{n:106,o:"&fjlig;"}],[20,"&lbrace;"],[0,"&verbar;"],[0,"&rbrace;"],[34,"&nbsp;"],[0,"&iexcl;"],[0,"&cent;"],[0,"&pound;"],[0,"&curren;"],[0,"&yen;"],[0,"&brvbar;"],[0,"&sect;"],[0,"&die;"],[0,"&copy;"],[0,"&ordf;"],[0,"&laquo;"],[0,"&not;"],[0,"&shy;"],[0,"&circledR;"],[0,"&macr;"],[0,"&deg;"],[0,"&PlusMinus;"],[0,"&sup2;"],[0,"&sup3;"],[0,"&acute;"],[0,"&micro;"],[0,"&para;"],[0,"&centerdot;"],[0,"&cedil;"],[0,"&sup1;"],[0,"&ordm;"],[0,"&raquo;"],[0,"&frac14;"],[0,"&frac12;"],[0,"&frac34;"],[0,"&iquest;"],[0,"&Agrave;"],[0,"&Aacute;"],[0,"&Acirc;"],[0,"&Atilde;"],[0,"&Auml;"],[0,"&angst;"],[0,"&AElig;"],[0,"&Ccedil;"],[0,"&Egrave;"],[0,"&Eacute;"],[0,"&Ecirc;"],[0,"&Euml;"],[0,"&Igrave;"],[0,"&Iacute;"],[0,"&Icirc;"],[0,"&Iuml;"],[0,"&ETH;"],[0,"&Ntilde;"],[0,"&Ograve;"],[0,"&Oacute;"],[0,"&Ocirc;"],[0,"&Otilde;"],[0,"&Ouml;"],[0,"&times;"],[0,"&Oslash;"],[0,"&Ugrave;"],[0,"&Uacute;"],[0,"&Ucirc;"],[0,"&Uuml;"],[0,"&Yacute;"],[0,"&THORN;"],[0,"&szlig;"],[0,"&agrave;"],[0,"&aacute;"],[0,"&acirc;"],[0,"&atilde;"],[0,"&auml;"],[0,"&aring;"],[0,"&aelig;"],[0,"&ccedil;"],[0,"&egrave;"],[0,"&eacute;"],[0,"&ecirc;"],[0,"&euml;"],[0,"&igrave;"],[0,"&iacute;"],[0,"&icirc;"],[0,"&iuml;"],[0,"&eth;"],[0,"&ntilde;"],[0,"&ograve;"],[0,"&oacute;"],[0,"&ocirc;"],[0,"&otilde;"],[0,"&ouml;"],[0,"&div;"],[0,"&oslash;"],[0,"&ugrave;"],[0,"&uacute;"],[0,"&ucirc;"],[0,"&uuml;"],[0,"&yacute;"],[0,"&thorn;"],[0,"&yuml;"],[0,"&Amacr;"],[0,"&amacr;"],[0,"&Abreve;"],[0,"&abreve;"],[0,"&Aogon;"],[0,"&aogon;"],[0,"&Cacute;"],[0,"&cacute;"],[0,"&Ccirc;"],[0,"&ccirc;"],[0,"&Cdot;"],[0,"&cdot;"],[0,"&Ccaron;"],[0,"&ccaron;"],[0,"&Dcaron;"],[0,"&dcaron;"],[0,"&Dstrok;"],[0,"&dstrok;"],[0,"&Emacr;"],[0,"&emacr;"],[2,"&Edot;"],[0,"&edot;"],[0,"&Eogon;"],[0,"&eogon;"],[0,"&Ecaron;"],[0,"&ecaron;"],[0,"&Gcirc;"],[0,"&gcirc;"],[0,"&Gbreve;"],[0,"&gbreve;"],[0,"&Gdot;"],[0,"&gdot;"],[0,"&Gcedil;"],[1,"&Hcirc;"],[0,"&hcirc;"],[0,"&Hstrok;"],[0,"&hstrok;"],[0,"&Itilde;"],[0,"&itilde;"],[0,"&Imacr;"],[0,"&imacr;"],[2,"&Iogon;"],[0,"&iogon;"],[0,"&Idot;"],[0,"&imath;"],[0,"&IJlig;"],[0,"&ijlig;"],[0,"&Jcirc;"],[0,"&jcirc;"],[0,"&Kcedil;"],[0,"&kcedil;"],[0,"&kgreen;"],[0,"&Lacute;"],[0,"&lacute;"],[0,"&Lcedil;"],[0,"&lcedil;"],[0,"&Lcaron;"],[0,"&lcaron;"],[0,"&Lmidot;"],[0,"&lmidot;"],[0,"&Lstrok;"],[0,"&lstrok;"],[0,"&Nacute;"],[0,"&nacute;"],[0,"&Ncedil;"],[0,"&ncedil;"],[0,"&Ncaron;"],[0,"&ncaron;"],[0,"&napos;"],[0,"&ENG;"],[0,"&eng;"],[0,"&Omacr;"],[0,"&omacr;"],[2,"&Odblac;"],[0,"&odblac;"],[0,"&OElig;"],[0,"&oelig;"],[0,"&Racute;"],[0,"&racute;"],[0,"&Rcedil;"],[0,"&rcedil;"],[0,"&Rcaron;"],[0,"&rcaron;"],[0,"&Sacute;"],[0,"&sacute;"],[0,"&Scirc;"],[0,"&scirc;"],[0,"&Scedil;"],[0,"&scedil;"],[0,"&Scaron;"],[0,"&scaron;"],[0,"&Tcedil;"],[0,"&tcedil;"],[0,"&Tcaron;"],[0,"&tcaron;"],[0,"&Tstrok;"],[0,"&tstrok;"],[0,"&Utilde;"],[0,"&utilde;"],[0,"&Umacr;"],[0,"&umacr;"],[0,"&Ubreve;"],[0,"&ubreve;"],[0,"&Uring;"],[0,"&uring;"],[0,"&Udblac;"],[0,"&udblac;"],[0,"&Uogon;"],[0,"&uogon;"],[0,"&Wcirc;"],[0,"&wcirc;"],[0,"&Ycirc;"],[0,"&ycirc;"],[0,"&Yuml;"],[0,"&Zacute;"],[0,"&zacute;"],[0,"&Zdot;"],[0,"&zdot;"],[0,"&Zcaron;"],[0,"&zcaron;"],[19,"&fnof;"],[34,"&imped;"],[63,"&gacute;"],[65,"&jmath;"],[142,"&circ;"],[0,"&caron;"],[16,"&breve;"],[0,"&DiacriticalDot;"],[0,"&ring;"],[0,"&ogon;"],[0,"&DiacriticalTilde;"],[0,"&dblac;"],[51,"&DownBreve;"],[127,"&Alpha;"],[0,"&Beta;"],[0,"&Gamma;"],[0,"&Delta;"],[0,"&Epsilon;"],[0,"&Zeta;"],[0,"&Eta;"],[0,"&Theta;"],[0,"&Iota;"],[0,"&Kappa;"],[0,"&Lambda;"],[0,"&Mu;"],[0,"&Nu;"],[0,"&Xi;"],[0,"&Omicron;"],[0,"&Pi;"],[0,"&Rho;"],[1,"&Sigma;"],[0,"&Tau;"],[0,"&Upsilon;"],[0,"&Phi;"],[0,"&Chi;"],[0,"&Psi;"],[0,"&ohm;"],[7,"&alpha;"],[0,"&beta;"],[0,"&gamma;"],[0,"&delta;"],[0,"&epsi;"],[0,"&zeta;"],[0,"&eta;"],[0,"&theta;"],[0,"&iota;"],[0,"&kappa;"],[0,"&lambda;"],[0,"&mu;"],[0,"&nu;"],[0,"&xi;"],[0,"&omicron;"],[0,"&pi;"],[0,"&rho;"],[0,"&sigmaf;"],[0,"&sigma;"],[0,"&tau;"],[0,"&upsi;"],[0,"&phi;"],[0,"&chi;"],[0,"&psi;"],[0,"&omega;"],[7,"&thetasym;"],[0,"&Upsi;"],[2,"&phiv;"],[0,"&piv;"],[5,"&Gammad;"],[0,"&digamma;"],[18,"&kappav;"],[0,"&rhov;"],[3,"&epsiv;"],[0,"&backepsilon;"],[10,"&IOcy;"],[0,"&DJcy;"],[0,"&GJcy;"],[0,"&Jukcy;"],[0,"&DScy;"],[0,"&Iukcy;"],[0,"&YIcy;"],[0,"&Jsercy;"],[0,"&LJcy;"],[0,"&NJcy;"],[0,"&TSHcy;"],[0,"&KJcy;"],[1,"&Ubrcy;"],[0,"&DZcy;"],[0,"&Acy;"],[0,"&Bcy;"],[0,"&Vcy;"],[0,"&Gcy;"],[0,"&Dcy;"],[0,"&IEcy;"],[0,"&ZHcy;"],[0,"&Zcy;"],[0,"&Icy;"],[0,"&Jcy;"],[0,"&Kcy;"],[0,"&Lcy;"],[0,"&Mcy;"],[0,"&Ncy;"],[0,"&Ocy;"],[0,"&Pcy;"],[0,"&Rcy;"],[0,"&Scy;"],[0,"&Tcy;"],[0,"&Ucy;"],[0,"&Fcy;"],[0,"&KHcy;"],[0,"&TScy;"],[0,"&CHcy;"],[0,"&SHcy;"],[0,"&SHCHcy;"],[0,"&HARDcy;"],[0,"&Ycy;"],[0,"&SOFTcy;"],[0,"&Ecy;"],[0,"&YUcy;"],[0,"&YAcy;"],[0,"&acy;"],[0,"&bcy;"],[0,"&vcy;"],[0,"&gcy;"],[0,"&dcy;"],[0,"&iecy;"],[0,"&zhcy;"],[0,"&zcy;"],[0,"&icy;"],[0,"&jcy;"],[0,"&kcy;"],[0,"&lcy;"],[0,"&mcy;"],[0,"&ncy;"],[0,"&ocy;"],[0,"&pcy;"],[0,"&rcy;"],[0,"&scy;"],[0,"&tcy;"],[0,"&ucy;"],[0,"&fcy;"],[0,"&khcy;"],[0,"&tscy;"],[0,"&chcy;"],[0,"&shcy;"],[0,"&shchcy;"],[0,"&hardcy;"],[0,"&ycy;"],[0,"&softcy;"],[0,"&ecy;"],[0,"&yucy;"],[0,"&yacy;"],[1,"&iocy;"],[0,"&djcy;"],[0,"&gjcy;"],[0,"&jukcy;"],[0,"&dscy;"],[0,"&iukcy;"],[0,"&yicy;"],[0,"&jsercy;"],[0,"&ljcy;"],[0,"&njcy;"],[0,"&tshcy;"],[0,"&kjcy;"],[1,"&ubrcy;"],[0,"&dzcy;"],[7074,"&ensp;"],[0,"&emsp;"],[0,"&emsp13;"],[0,"&emsp14;"],[1,"&numsp;"],[0,"&puncsp;"],[0,"&ThinSpace;"],[0,"&hairsp;"],[0,"&NegativeMediumSpace;"],[0,"&zwnj;"],[0,"&zwj;"],[0,"&lrm;"],[0,"&rlm;"],[0,"&dash;"],[2,"&ndash;"],[0,"&mdash;"],[0,"&horbar;"],[0,"&Verbar;"],[1,"&lsquo;"],[0,"&CloseCurlyQuote;"],[0,"&lsquor;"],[1,"&ldquo;"],[0,"&CloseCurlyDoubleQuote;"],[0,"&bdquo;"],[1,"&dagger;"],[0,"&Dagger;"],[0,"&bull;"],[2,"&nldr;"],[0,"&hellip;"],[9,"&permil;"],[0,"&pertenk;"],[0,"&prime;"],[0,"&Prime;"],[0,"&tprime;"],[0,"&backprime;"],[3,"&lsaquo;"],[0,"&rsaquo;"],[3,"&oline;"],[2,"&caret;"],[1,"&hybull;"],[0,"&frasl;"],[10,"&bsemi;"],[7,"&qprime;"],[7,{v:"&MediumSpace;",n:8202,o:"&ThickSpace;"}],[0,"&NoBreak;"],[0,"&af;"],[0,"&InvisibleTimes;"],[0,"&ic;"],[72,"&euro;"],[46,"&tdot;"],[0,"&DotDot;"],[37,"&complexes;"],[2,"&incare;"],[4,"&gscr;"],[0,"&hamilt;"],[0,"&Hfr;"],[0,"&Hopf;"],[0,"&planckh;"],[0,"&hbar;"],[0,"&imagline;"],[0,"&Ifr;"],[0,"&lagran;"],[0,"&ell;"],[1,"&naturals;"],[0,"&numero;"],[0,"&copysr;"],[0,"&weierp;"],[0,"&Popf;"],[0,"&Qopf;"],[0,"&realine;"],[0,"&real;"],[0,"&reals;"],[0,"&rx;"],[3,"&trade;"],[1,"&integers;"],[2,"&mho;"],[0,"&zeetrf;"],[0,"&iiota;"],[2,"&bernou;"],[0,"&Cayleys;"],[1,"&escr;"],[0,"&Escr;"],[0,"&Fouriertrf;"],[1,"&Mellintrf;"],[0,"&order;"],[0,"&alefsym;"],[0,"&beth;"],[0,"&gimel;"],[0,"&daleth;"],[12,"&CapitalDifferentialD;"],[0,"&dd;"],[0,"&ee;"],[0,"&ii;"],[10,"&frac13;"],[0,"&frac23;"],[0,"&frac15;"],[0,"&frac25;"],[0,"&frac35;"],[0,"&frac45;"],[0,"&frac16;"],[0,"&frac56;"],[0,"&frac18;"],[0,"&frac38;"],[0,"&frac58;"],[0,"&frac78;"],[49,"&larr;"],[0,"&ShortUpArrow;"],[0,"&rarr;"],[0,"&darr;"],[0,"&harr;"],[0,"&updownarrow;"],[0,"&nwarr;"],[0,"&nearr;"],[0,"&LowerRightArrow;"],[0,"&LowerLeftArrow;"],[0,"&nlarr;"],[0,"&nrarr;"],[1,{v:"&rarrw;",n:824,o:"&nrarrw;"}],[0,"&Larr;"],[0,"&Uarr;"],[0,"&Rarr;"],[0,"&Darr;"],[0,"&larrtl;"],[0,"&rarrtl;"],[0,"&LeftTeeArrow;"],[0,"&mapstoup;"],[0,"&map;"],[0,"&DownTeeArrow;"],[1,"&hookleftarrow;"],[0,"&hookrightarrow;"],[0,"&larrlp;"],[0,"&looparrowright;"],[0,"&harrw;"],[0,"&nharr;"],[1,"&lsh;"],[0,"&rsh;"],[0,"&ldsh;"],[0,"&rdsh;"],[1,"&crarr;"],[0,"&cularr;"],[0,"&curarr;"],[2,"&circlearrowleft;"],[0,"&circlearrowright;"],[0,"&leftharpoonup;"],[0,"&DownLeftVector;"],[0,"&RightUpVector;"],[0,"&LeftUpVector;"],[0,"&rharu;"],[0,"&DownRightVector;"],[0,"&dharr;"],[0,"&dharl;"],[0,"&RightArrowLeftArrow;"],[0,"&udarr;"],[0,"&LeftArrowRightArrow;"],[0,"&leftleftarrows;"],[0,"&upuparrows;"],[0,"&rightrightarrows;"],[0,"&ddarr;"],[0,"&leftrightharpoons;"],[0,"&Equilibrium;"],[0,"&nlArr;"],[0,"&nhArr;"],[0,"&nrArr;"],[0,"&DoubleLeftArrow;"],[0,"&DoubleUpArrow;"],[0,"&DoubleRightArrow;"],[0,"&dArr;"],[0,"&DoubleLeftRightArrow;"],[0,"&DoubleUpDownArrow;"],[0,"&nwArr;"],[0,"&neArr;"],[0,"&seArr;"],[0,"&swArr;"],[0,"&lAarr;"],[0,"&rAarr;"],[1,"&zigrarr;"],[6,"&larrb;"],[0,"&rarrb;"],[15,"&DownArrowUpArrow;"],[7,"&loarr;"],[0,"&roarr;"],[0,"&hoarr;"],[0,"&forall;"],[0,"&comp;"],[0,{v:"&part;",n:824,o:"&npart;"}],[0,"&exist;"],[0,"&nexist;"],[0,"&empty;"],[1,"&Del;"],[0,"&Element;"],[0,"&NotElement;"],[1,"&ni;"],[0,"&notni;"],[2,"&prod;"],[0,"&coprod;"],[0,"&sum;"],[0,"&minus;"],[0,"&MinusPlus;"],[0,"&dotplus;"],[1,"&Backslash;"],[0,"&lowast;"],[0,"&compfn;"],[1,"&radic;"],[2,"&prop;"],[0,"&infin;"],[0,"&angrt;"],[0,{v:"&ang;",n:8402,o:"&nang;"}],[0,"&angmsd;"],[0,"&angsph;"],[0,"&mid;"],[0,"&nmid;"],[0,"&DoubleVerticalBar;"],[0,"&NotDoubleVerticalBar;"],[0,"&and;"],[0,"&or;"],[0,{v:"&cap;",n:65024,o:"&caps;"}],[0,{v:"&cup;",n:65024,o:"&cups;"}],[0,"&int;"],[0,"&Int;"],[0,"&iiint;"],[0,"&conint;"],[0,"&Conint;"],[0,"&Cconint;"],[0,"&cwint;"],[0,"&ClockwiseContourIntegral;"],[0,"&awconint;"],[0,"&there4;"],[0,"&becaus;"],[0,"&ratio;"],[0,"&Colon;"],[0,"&dotminus;"],[1,"&mDDot;"],[0,"&homtht;"],[0,{v:"&sim;",n:8402,o:"&nvsim;"}],[0,{v:"&backsim;",n:817,o:"&race;"}],[0,{v:"&ac;",n:819,o:"&acE;"}],[0,"&acd;"],[0,"&VerticalTilde;"],[0,"&NotTilde;"],[0,{v:"&eqsim;",n:824,o:"&nesim;"}],[0,"&sime;"],[0,"&NotTildeEqual;"],[0,"&cong;"],[0,"&simne;"],[0,"&ncong;"],[0,"&ap;"],[0,"&nap;"],[0,"&ape;"],[0,{v:"&apid;",n:824,o:"&napid;"}],[0,"&backcong;"],[0,{v:"&asympeq;",n:8402,o:"&nvap;"}],[0,{v:"&bump;",n:824,o:"&nbump;"}],[0,{v:"&bumpe;",n:824,o:"&nbumpe;"}],[0,{v:"&doteq;",n:824,o:"&nedot;"}],[0,"&doteqdot;"],[0,"&efDot;"],[0,"&erDot;"],[0,"&Assign;"],[0,"&ecolon;"],[0,"&ecir;"],[0,"&circeq;"],[1,"&wedgeq;"],[0,"&veeeq;"],[1,"&triangleq;"],[2,"&equest;"],[0,"&ne;"],[0,{v:"&Congruent;",n:8421,o:"&bnequiv;"}],[0,"&nequiv;"],[1,{v:"&le;",n:8402,o:"&nvle;"}],[0,{v:"&ge;",n:8402,o:"&nvge;"}],[0,{v:"&lE;",n:824,o:"&nlE;"}],[0,{v:"&gE;",n:824,o:"&ngE;"}],[0,{v:"&lnE;",n:65024,o:"&lvertneqq;"}],[0,{v:"&gnE;",n:65024,o:"&gvertneqq;"}],[0,{v:"&ll;",n:new Map(xl([[824,"&nLtv;"],[7577,"&nLt;"]]))}],[0,{v:"&gg;",n:new Map(xl([[824,"&nGtv;"],[7577,"&nGt;"]]))}],[0,"&between;"],[0,"&NotCupCap;"],[0,"&nless;"],[0,"&ngt;"],[0,"&nle;"],[0,"&nge;"],[0,"&lesssim;"],[0,"&GreaterTilde;"],[0,"&nlsim;"],[0,"&ngsim;"],[0,"&LessGreater;"],[0,"&gl;"],[0,"&NotLessGreater;"],[0,"&NotGreaterLess;"],[0,"&pr;"],[0,"&sc;"],[0,"&prcue;"],[0,"&sccue;"],[0,"&PrecedesTilde;"],[0,{v:"&scsim;",n:824,o:"&NotSucceedsTilde;"}],[0,"&NotPrecedes;"],[0,"&NotSucceeds;"],[0,{v:"&sub;",n:8402,o:"&NotSubset;"}],[0,{v:"&sup;",n:8402,o:"&NotSuperset;"}],[0,"&nsub;"],[0,"&nsup;"],[0,"&sube;"],[0,"&supe;"],[0,"&NotSubsetEqual;"],[0,"&NotSupersetEqual;"],[0,{v:"&subne;",n:65024,o:"&varsubsetneq;"}],[0,{v:"&supne;",n:65024,o:"&varsupsetneq;"}],[1,"&cupdot;"],[0,"&UnionPlus;"],[0,{v:"&sqsub;",n:824,o:"&NotSquareSubset;"}],[0,{v:"&sqsup;",n:824,o:"&NotSquareSuperset;"}],[0,"&sqsube;"],[0,"&sqsupe;"],[0,{v:"&sqcap;",n:65024,o:"&sqcaps;"}],[0,{v:"&sqcup;",n:65024,o:"&sqcups;"}],[0,"&CirclePlus;"],[0,"&CircleMinus;"],[0,"&CircleTimes;"],[0,"&osol;"],[0,"&CircleDot;"],[0,"&circledcirc;"],[0,"&circledast;"],[1,"&circleddash;"],[0,"&boxplus;"],[0,"&boxminus;"],[0,"&boxtimes;"],[0,"&dotsquare;"],[0,"&RightTee;"],[0,"&dashv;"],[0,"&DownTee;"],[0,"&bot;"],[1,"&models;"],[0,"&DoubleRightTee;"],[0,"&Vdash;"],[0,"&Vvdash;"],[0,"&VDash;"],[0,"&nvdash;"],[0,"&nvDash;"],[0,"&nVdash;"],[0,"&nVDash;"],[0,"&prurel;"],[1,"&LeftTriangle;"],[0,"&RightTriangle;"],[0,{v:"&LeftTriangleEqual;",n:8402,o:"&nvltrie;"}],[0,{v:"&RightTriangleEqual;",n:8402,o:"&nvrtrie;"}],[0,"&origof;"],[0,"&imof;"],[0,"&multimap;"],[0,"&hercon;"],[0,"&intcal;"],[0,"&veebar;"],[1,"&barvee;"],[0,"&angrtvb;"],[0,"&lrtri;"],[0,"&bigwedge;"],[0,"&bigvee;"],[0,"&bigcap;"],[0,"&bigcup;"],[0,"&diam;"],[0,"&sdot;"],[0,"&sstarf;"],[0,"&divideontimes;"],[0,"&bowtie;"],[0,"&ltimes;"],[0,"&rtimes;"],[0,"&leftthreetimes;"],[0,"&rightthreetimes;"],[0,"&backsimeq;"],[0,"&curlyvee;"],[0,"&curlywedge;"],[0,"&Sub;"],[0,"&Sup;"],[0,"&Cap;"],[0,"&Cup;"],[0,"&fork;"],[0,"&epar;"],[0,"&lessdot;"],[0,"&gtdot;"],[0,{v:"&Ll;",n:824,o:"&nLl;"}],[0,{v:"&Gg;",n:824,o:"&nGg;"}],[0,{v:"&leg;",n:65024,o:"&lesg;"}],[0,{v:"&gel;",n:65024,o:"&gesl;"}],[2,"&cuepr;"],[0,"&cuesc;"],[0,"&NotPrecedesSlantEqual;"],[0,"&NotSucceedsSlantEqual;"],[0,"&NotSquareSubsetEqual;"],[0,"&NotSquareSupersetEqual;"],[2,"&lnsim;"],[0,"&gnsim;"],[0,"&precnsim;"],[0,"&scnsim;"],[0,"&nltri;"],[0,"&NotRightTriangle;"],[0,"&nltrie;"],[0,"&NotRightTriangleEqual;"],[0,"&vellip;"],[0,"&ctdot;"],[0,"&utdot;"],[0,"&dtdot;"],[0,"&disin;"],[0,"&isinsv;"],[0,"&isins;"],[0,{v:"&isindot;",n:824,o:"&notindot;"}],[0,"&notinvc;"],[0,"&notinvb;"],[1,{v:"&isinE;",n:824,o:"&notinE;"}],[0,"&nisd;"],[0,"&xnis;"],[0,"&nis;"],[0,"&notnivc;"],[0,"&notnivb;"],[6,"&barwed;"],[0,"&Barwed;"],[1,"&lceil;"],[0,"&rceil;"],[0,"&LeftFloor;"],[0,"&rfloor;"],[0,"&drcrop;"],[0,"&dlcrop;"],[0,"&urcrop;"],[0,"&ulcrop;"],[0,"&bnot;"],[1,"&profline;"],[0,"&profsurf;"],[1,"&telrec;"],[0,"&target;"],[5,"&ulcorn;"],[0,"&urcorn;"],[0,"&dlcorn;"],[0,"&drcorn;"],[2,"&frown;"],[0,"&smile;"],[9,"&cylcty;"],[0,"&profalar;"],[7,"&topbot;"],[6,"&ovbar;"],[1,"&solbar;"],[60,"&angzarr;"],[51,"&lmoustache;"],[0,"&rmoustache;"],[2,"&OverBracket;"],[0,"&bbrk;"],[0,"&bbrktbrk;"],[37,"&OverParenthesis;"],[0,"&UnderParenthesis;"],[0,"&OverBrace;"],[0,"&UnderBrace;"],[2,"&trpezium;"],[4,"&elinters;"],[59,"&blank;"],[164,"&circledS;"],[55,"&boxh;"],[1,"&boxv;"],[9,"&boxdr;"],[3,"&boxdl;"],[3,"&boxur;"],[3,"&boxul;"],[3,"&boxvr;"],[7,"&boxvl;"],[7,"&boxhd;"],[7,"&boxhu;"],[7,"&boxvh;"],[19,"&boxH;"],[0,"&boxV;"],[0,"&boxdR;"],[0,"&boxDr;"],[0,"&boxDR;"],[0,"&boxdL;"],[0,"&boxDl;"],[0,"&boxDL;"],[0,"&boxuR;"],[0,"&boxUr;"],[0,"&boxUR;"],[0,"&boxuL;"],[0,"&boxUl;"],[0,"&boxUL;"],[0,"&boxvR;"],[0,"&boxVr;"],[0,"&boxVR;"],[0,"&boxvL;"],[0,"&boxVl;"],[0,"&boxVL;"],[0,"&boxHd;"],[0,"&boxhD;"],[0,"&boxHD;"],[0,"&boxHu;"],[0,"&boxhU;"],[0,"&boxHU;"],[0,"&boxvH;"],[0,"&boxVh;"],[0,"&boxVH;"],[19,"&uhblk;"],[3,"&lhblk;"],[3,"&block;"],[8,"&blk14;"],[0,"&blk12;"],[0,"&blk34;"],[13,"&square;"],[8,"&blacksquare;"],[0,"&EmptyVerySmallSquare;"],[1,"&rect;"],[0,"&marker;"],[2,"&fltns;"],[1,"&bigtriangleup;"],[0,"&blacktriangle;"],[0,"&triangle;"],[2,"&blacktriangleright;"],[0,"&rtri;"],[3,"&bigtriangledown;"],[0,"&blacktriangledown;"],[0,"&dtri;"],[2,"&blacktriangleleft;"],[0,"&ltri;"],[6,"&loz;"],[0,"&cir;"],[32,"&tridot;"],[2,"&bigcirc;"],[8,"&ultri;"],[0,"&urtri;"],[0,"&lltri;"],[0,"&EmptySmallSquare;"],[0,"&FilledSmallSquare;"],[8,"&bigstar;"],[0,"&star;"],[7,"&phone;"],[49,"&female;"],[1,"&male;"],[29,"&spades;"],[2,"&clubs;"],[1,"&hearts;"],[0,"&diamondsuit;"],[3,"&sung;"],[2,"&flat;"],[0,"&natural;"],[0,"&sharp;"],[163,"&check;"],[3,"&cross;"],[8,"&malt;"],[21,"&sext;"],[33,"&VerticalSeparator;"],[25,"&lbbrk;"],[0,"&rbbrk;"],[84,"&bsolhsub;"],[0,"&suphsol;"],[28,"&LeftDoubleBracket;"],[0,"&RightDoubleBracket;"],[0,"&lang;"],[0,"&rang;"],[0,"&Lang;"],[0,"&Rang;"],[0,"&loang;"],[0,"&roang;"],[7,"&longleftarrow;"],[0,"&longrightarrow;"],[0,"&longleftrightarrow;"],[0,"&DoubleLongLeftArrow;"],[0,"&DoubleLongRightArrow;"],[0,"&DoubleLongLeftRightArrow;"],[1,"&longmapsto;"],[2,"&dzigrarr;"],[258,"&nvlArr;"],[0,"&nvrArr;"],[0,"&nvHarr;"],[0,"&Map;"],[6,"&lbarr;"],[0,"&bkarow;"],[0,"&lBarr;"],[0,"&dbkarow;"],[0,"&drbkarow;"],[0,"&DDotrahd;"],[0,"&UpArrowBar;"],[0,"&DownArrowBar;"],[2,"&Rarrtl;"],[2,"&latail;"],[0,"&ratail;"],[0,"&lAtail;"],[0,"&rAtail;"],[0,"&larrfs;"],[0,"&rarrfs;"],[0,"&larrbfs;"],[0,"&rarrbfs;"],[2,"&nwarhk;"],[0,"&nearhk;"],[0,"&hksearow;"],[0,"&hkswarow;"],[0,"&nwnear;"],[0,"&nesear;"],[0,"&seswar;"],[0,"&swnwar;"],[8,{v:"&rarrc;",n:824,o:"&nrarrc;"}],[1,"&cudarrr;"],[0,"&ldca;"],[0,"&rdca;"],[0,"&cudarrl;"],[0,"&larrpl;"],[2,"&curarrm;"],[0,"&cularrp;"],[7,"&rarrpl;"],[2,"&harrcir;"],[0,"&Uarrocir;"],[0,"&lurdshar;"],[0,"&ldrushar;"],[2,"&LeftRightVector;"],[0,"&RightUpDownVector;"],[0,"&DownLeftRightVector;"],[0,"&LeftUpDownVector;"],[0,"&LeftVectorBar;"],[0,"&RightVectorBar;"],[0,"&RightUpVectorBar;"],[0,"&RightDownVectorBar;"],[0,"&DownLeftVectorBar;"],[0,"&DownRightVectorBar;"],[0,"&LeftUpVectorBar;"],[0,"&LeftDownVectorBar;"],[0,"&LeftTeeVector;"],[0,"&RightTeeVector;"],[0,"&RightUpTeeVector;"],[0,"&RightDownTeeVector;"],[0,"&DownLeftTeeVector;"],[0,"&DownRightTeeVector;"],[0,"&LeftUpTeeVector;"],[0,"&LeftDownTeeVector;"],[0,"&lHar;"],[0,"&uHar;"],[0,"&rHar;"],[0,"&dHar;"],[0,"&luruhar;"],[0,"&ldrdhar;"],[0,"&ruluhar;"],[0,"&rdldhar;"],[0,"&lharul;"],[0,"&llhard;"],[0,"&rharul;"],[0,"&lrhard;"],[0,"&udhar;"],[0,"&duhar;"],[0,"&RoundImplies;"],[0,"&erarr;"],[0,"&simrarr;"],[0,"&larrsim;"],[0,"&rarrsim;"],[0,"&rarrap;"],[0,"&ltlarr;"],[1,"&gtrarr;"],[0,"&subrarr;"],[1,"&suplarr;"],[0,"&lfisht;"],[0,"&rfisht;"],[0,"&ufisht;"],[0,"&dfisht;"],[5,"&lopar;"],[0,"&ropar;"],[4,"&lbrke;"],[0,"&rbrke;"],[0,"&lbrkslu;"],[0,"&rbrksld;"],[0,"&lbrksld;"],[0,"&rbrkslu;"],[0,"&langd;"],[0,"&rangd;"],[0,"&lparlt;"],[0,"&rpargt;"],[0,"&gtlPar;"],[0,"&ltrPar;"],[3,"&vzigzag;"],[1,"&vangrt;"],[0,"&angrtvbd;"],[6,"&ange;"],[0,"&range;"],[0,"&dwangle;"],[0,"&uwangle;"],[0,"&angmsdaa;"],[0,"&angmsdab;"],[0,"&angmsdac;"],[0,"&angmsdad;"],[0,"&angmsdae;"],[0,"&angmsdaf;"],[0,"&angmsdag;"],[0,"&angmsdah;"],[0,"&bemptyv;"],[0,"&demptyv;"],[0,"&cemptyv;"],[0,"&raemptyv;"],[0,"&laemptyv;"],[0,"&ohbar;"],[0,"&omid;"],[0,"&opar;"],[1,"&operp;"],[1,"&olcross;"],[0,"&odsold;"],[1,"&olcir;"],[0,"&ofcir;"],[0,"&olt;"],[0,"&ogt;"],[0,"&cirscir;"],[0,"&cirE;"],[0,"&solb;"],[0,"&bsolb;"],[3,"&boxbox;"],[3,"&trisb;"],[0,"&rtriltri;"],[0,{v:"&LeftTriangleBar;",n:824,o:"&NotLeftTriangleBar;"}],[0,{v:"&RightTriangleBar;",n:824,o:"&NotRightTriangleBar;"}],[11,"&iinfin;"],[0,"&infintie;"],[0,"&nvinfin;"],[4,"&eparsl;"],[0,"&smeparsl;"],[0,"&eqvparsl;"],[5,"&blacklozenge;"],[8,"&RuleDelayed;"],[1,"&dsol;"],[9,"&bigodot;"],[0,"&bigoplus;"],[0,"&bigotimes;"],[1,"&biguplus;"],[1,"&bigsqcup;"],[5,"&iiiint;"],[0,"&fpartint;"],[2,"&cirfnint;"],[0,"&awint;"],[0,"&rppolint;"],[0,"&scpolint;"],[0,"&npolint;"],[0,"&pointint;"],[0,"&quatint;"],[0,"&intlarhk;"],[10,"&pluscir;"],[0,"&plusacir;"],[0,"&simplus;"],[0,"&plusdu;"],[0,"&plussim;"],[0,"&plustwo;"],[1,"&mcomma;"],[0,"&minusdu;"],[2,"&loplus;"],[0,"&roplus;"],[0,"&Cross;"],[0,"&timesd;"],[0,"&timesbar;"],[1,"&smashp;"],[0,"&lotimes;"],[0,"&rotimes;"],[0,"&otimesas;"],[0,"&Otimes;"],[0,"&odiv;"],[0,"&triplus;"],[0,"&triminus;"],[0,"&tritime;"],[0,"&intprod;"],[2,"&amalg;"],[0,"&capdot;"],[1,"&ncup;"],[0,"&ncap;"],[0,"&capand;"],[0,"&cupor;"],[0,"&cupcap;"],[0,"&capcup;"],[0,"&cupbrcap;"],[0,"&capbrcup;"],[0,"&cupcup;"],[0,"&capcap;"],[0,"&ccups;"],[0,"&ccaps;"],[2,"&ccupssm;"],[2,"&And;"],[0,"&Or;"],[0,"&andand;"],[0,"&oror;"],[0,"&orslope;"],[0,"&andslope;"],[1,"&andv;"],[0,"&orv;"],[0,"&andd;"],[0,"&ord;"],[1,"&wedbar;"],[6,"&sdote;"],[3,"&simdot;"],[2,{v:"&congdot;",n:824,o:"&ncongdot;"}],[0,"&easter;"],[0,"&apacir;"],[0,{v:"&apE;",n:824,o:"&napE;"}],[0,"&eplus;"],[0,"&pluse;"],[0,"&Esim;"],[0,"&Colone;"],[0,"&Equal;"],[1,"&ddotseq;"],[0,"&equivDD;"],[0,"&ltcir;"],[0,"&gtcir;"],[0,"&ltquest;"],[0,"&gtquest;"],[0,{v:"&leqslant;",n:824,o:"&nleqslant;"}],[0,{v:"&geqslant;",n:824,o:"&ngeqslant;"}],[0,"&lesdot;"],[0,"&gesdot;"],[0,"&lesdoto;"],[0,"&gesdoto;"],[0,"&lesdotor;"],[0,"&gesdotol;"],[0,"&lap;"],[0,"&gap;"],[0,"&lne;"],[0,"&gne;"],[0,"&lnap;"],[0,"&gnap;"],[0,"&lEg;"],[0,"&gEl;"],[0,"&lsime;"],[0,"&gsime;"],[0,"&lsimg;"],[0,"&gsiml;"],[0,"&lgE;"],[0,"&glE;"],[0,"&lesges;"],[0,"&gesles;"],[0,"&els;"],[0,"&egs;"],[0,"&elsdot;"],[0,"&egsdot;"],[0,"&el;"],[0,"&eg;"],[2,"&siml;"],[0,"&simg;"],[0,"&simlE;"],[0,"&simgE;"],[0,{v:"&LessLess;",n:824,o:"&NotNestedLessLess;"}],[0,{v:"&GreaterGreater;",n:824,o:"&NotNestedGreaterGreater;"}],[1,"&glj;"],[0,"&gla;"],[0,"&ltcc;"],[0,"&gtcc;"],[0,"&lescc;"],[0,"&gescc;"],[0,"&smt;"],[0,"&lat;"],[0,{v:"&smte;",n:65024,o:"&smtes;"}],[0,{v:"&late;",n:65024,o:"&lates;"}],[0,"&bumpE;"],[0,{v:"&PrecedesEqual;",n:824,o:"&NotPrecedesEqual;"}],[0,{v:"&sce;",n:824,o:"&NotSucceedsEqual;"}],[2,"&prE;"],[0,"&scE;"],[0,"&precneqq;"],[0,"&scnE;"],[0,"&prap;"],[0,"&scap;"],[0,"&precnapprox;"],[0,"&scnap;"],[0,"&Pr;"],[0,"&Sc;"],[0,"&subdot;"],[0,"&supdot;"],[0,"&subplus;"],[0,"&supplus;"],[0,"&submult;"],[0,"&supmult;"],[0,"&subedot;"],[0,"&supedot;"],[0,{v:"&subE;",n:824,o:"&nsubE;"}],[0,{v:"&supE;",n:824,o:"&nsupE;"}],[0,"&subsim;"],[0,"&supsim;"],[2,{v:"&subnE;",n:65024,o:"&varsubsetneqq;"}],[0,{v:"&supnE;",n:65024,o:"&varsupsetneqq;"}],[2,"&csub;"],[0,"&csup;"],[0,"&csube;"],[0,"&csupe;"],[0,"&subsup;"],[0,"&supsub;"],[0,"&subsub;"],[0,"&supsup;"],[0,"&suphsub;"],[0,"&supdsub;"],[0,"&forkv;"],[0,"&topfork;"],[0,"&mlcp;"],[8,"&Dashv;"],[1,"&Vdashl;"],[0,"&Barv;"],[0,"&vBar;"],[0,"&vBarv;"],[1,"&Vbar;"],[0,"&Not;"],[0,"&bNot;"],[0,"&rnmid;"],[0,"&cirmid;"],[0,"&midcir;"],[0,"&topcir;"],[0,"&nhpar;"],[0,"&parsim;"],[9,{v:"&parsl;",n:8421,o:"&nparsl;"}],[44343,{n:new Map(xl([[56476,"&Ascr;"],[1,"&Cscr;"],[0,"&Dscr;"],[2,"&Gscr;"],[2,"&Jscr;"],[0,"&Kscr;"],[2,"&Nscr;"],[0,"&Oscr;"],[0,"&Pscr;"],[0,"&Qscr;"],[1,"&Sscr;"],[0,"&Tscr;"],[0,"&Uscr;"],[0,"&Vscr;"],[0,"&Wscr;"],[0,"&Xscr;"],[0,"&Yscr;"],[0,"&Zscr;"],[0,"&ascr;"],[0,"&bscr;"],[0,"&cscr;"],[0,"&dscr;"],[1,"&fscr;"],[1,"&hscr;"],[0,"&iscr;"],[0,"&jscr;"],[0,"&kscr;"],[0,"&lscr;"],[0,"&mscr;"],[0,"&nscr;"],[1,"&pscr;"],[0,"&qscr;"],[0,"&rscr;"],[0,"&sscr;"],[0,"&tscr;"],[0,"&uscr;"],[0,"&vscr;"],[0,"&wscr;"],[0,"&xscr;"],[0,"&yscr;"],[0,"&zscr;"],[52,"&Afr;"],[0,"&Bfr;"],[1,"&Dfr;"],[0,"&Efr;"],[0,"&Ffr;"],[0,"&Gfr;"],[2,"&Jfr;"],[0,"&Kfr;"],[0,"&Lfr;"],[0,"&Mfr;"],[0,"&Nfr;"],[0,"&Ofr;"],[0,"&Pfr;"],[0,"&Qfr;"],[1,"&Sfr;"],[0,"&Tfr;"],[0,"&Ufr;"],[0,"&Vfr;"],[0,"&Wfr;"],[0,"&Xfr;"],[0,"&Yfr;"],[1,"&afr;"],[0,"&bfr;"],[0,"&cfr;"],[0,"&dfr;"],[0,"&efr;"],[0,"&ffr;"],[0,"&gfr;"],[0,"&hfr;"],[0,"&ifr;"],[0,"&jfr;"],[0,"&kfr;"],[0,"&lfr;"],[0,"&mfr;"],[0,"&nfr;"],[0,"&ofr;"],[0,"&pfr;"],[0,"&qfr;"],[0,"&rfr;"],[0,"&sfr;"],[0,"&tfr;"],[0,"&ufr;"],[0,"&vfr;"],[0,"&wfr;"],[0,"&xfr;"],[0,"&yfr;"],[0,"&zfr;"],[0,"&Aopf;"],[0,"&Bopf;"],[1,"&Dopf;"],[0,"&Eopf;"],[0,"&Fopf;"],[0,"&Gopf;"],[1,"&Iopf;"],[0,"&Jopf;"],[0,"&Kopf;"],[0,"&Lopf;"],[0,"&Mopf;"],[1,"&Oopf;"],[3,"&Sopf;"],[0,"&Topf;"],[0,"&Uopf;"],[0,"&Vopf;"],[0,"&Wopf;"],[0,"&Xopf;"],[0,"&Yopf;"],[1,"&aopf;"],[0,"&bopf;"],[0,"&copf;"],[0,"&dopf;"],[0,"&eopf;"],[0,"&fopf;"],[0,"&gopf;"],[0,"&hopf;"],[0,"&iopf;"],[0,"&jopf;"],[0,"&kopf;"],[0,"&lopf;"],[0,"&mopf;"],[0,"&nopf;"],[0,"&oopf;"],[0,"&popf;"],[0,"&qopf;"],[0,"&ropf;"],[0,"&sopf;"],[0,"&topf;"],[0,"&uopf;"],[0,"&vopf;"],[0,"&wopf;"],[0,"&xopf;"],[0,"&yopf;"],[0,"&zopf;"]]))}],[8906,"&fflig;"],[0,"&filig;"],[0,"&fllig;"],[0,"&ffilig;"],[0,"&ffllig;"]])),function(t){t[t.XML=0]="XML",t[t.HTML=1]="HTML"}(ml||(ml={})),function(t){t[t.UTF8=0]="UTF8",t[t.ASCII=1]="ASCII",t[t.Extensive=2]="Extensive",t[t.Attribute=3]="Attribute",t[t.Text=4]="Text"}(gl||(gl={}));const Ml=Object.prototype.hasOwnProperty;function Cl(t){return Array.prototype.slice.call(arguments,1).forEach((function(e){if(e){if("object"!=typeof e)throw new TypeError(e+"must be object");Object.keys(e).forEach((function(r){t[r]=e[r]}))}})),t}function Al(t,e,r){return[].concat(t.slice(0,e),r,t.slice(e+1))}function Sl(t){return!(t>=55296&&t<=57343||t>=64976&&t<=65007||!(65535&~t&&65534!=(65535&t))||t>=0&&t<=8||11===t||t>=14&&t<=31||t>=127&&t<=159||t>1114111)}function Ol(t){return t>65535?(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t))):String.fromCharCode(t)}const $l=/\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g,Bl=new RegExp($l.source+"|"+/&([a-z#][a-z0-9]{1,31});/gi.source,"gi"),Rl=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))$/i;function Nl(t){return t.indexOf("\\")<0&&t.indexOf("&")<0?t:t.replace(Bl,(function(t,e,r){return e||function(t,e){if(35===e.charCodeAt(0)&&Rl.test(e)){const r="x"===e[1].toLowerCase()?parseInt(e.slice(2),16):parseInt(e.slice(1),10);return Sl(r)?Ol(r):t}const r=d(t);return r!==t?r:t}(t,r)}))}const _l=/[&<>"]/,Tl=/[&<>"]/g,zl={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"};function ql(t){return zl[t]}function Il(t){return _l.test(t)?t.replace(Tl,ql):t}const jl=/[.?*+^$[\]\\(){}|-]/g;function Pl(t){switch(t){case 9:case 32:return!0}return!1}function Ll(t){if(t>=8192&&t<=8202)return!0;switch(t){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 Jl(t){return kl.test(t)||Dl.test(t)}function Ul(t){switch(t){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 Vl(t){return t=t.trim().replace(/\s+/g," "),"Ṿ"==="ẞ".toLowerCase()&&(t=t.replace(/ẞ/g,"ß")),t.toLowerCase().toUpperCase()}var Hl=Object.freeze({__proto__:null,arrayReplaceAt:Al,assign:Cl,escapeHtml:Il,escapeRE:function(t){return t.replace(jl,"\\$&")},fromCodePoint:Ol,has:function(t,e){return Ml.call(t,e)},isMdAsciiPunct:Ul,isPunctChar:Jl,isSpace:Pl,isString:Fl,isValidEntityCode:Sl,isWhiteSpace:Ll,lib:{mdurl:wl,ucmicro:El},normalizeReference:Vl,unescapeAll:Nl,unescapeMd:function(t){return t.indexOf("\\")<0?t:t.replace($l,"$1")}}),Wl=Object.freeze({__proto__:null,parseLinkDestination:function(t,e,r){let i,n=e;const s={ok:!1,pos:0,str:""};if(60===t.charCodeAt(n)){for(n++;n<r;){if(i=t.charCodeAt(n),10===i)return s;if(60===i)return s;if(62===i)return s.pos=n+1,s.str=Nl(t.slice(e+1,n)),s.ok=!0,s;92===i&&n+1<r?n+=2:n++}return s}let o=0;for(;n<r&&(i=t.charCodeAt(n),32!==i)&&!(i<32||127===i);)if(92===i&&n+1<r){if(32===t.charCodeAt(n+1))break;n+=2}else{if(40===i&&(o++,o>32))return s;if(41===i){if(0===o)break;o--}n++}return e===n||0!==o||(s.str=Nl(t.slice(e,n)),s.pos=n,s.ok=!0),s},parseLinkLabel:function(t,e,r){let i,n,s,o;const l=t.posMax,u=t.pos;for(t.pos=e+1,i=1;t.pos<l;){if(s=t.src.charCodeAt(t.pos),93===s&&(i--,0===i)){n=!0;break}if(o=t.pos,t.md.inline.skipToken(t),91===s)if(o===t.pos-1)i++;else if(r)return t.pos=u,-1}let h=-1;return n&&(h=t.pos),t.pos=u,h},parseLinkTitle:function(t,e,r,i){let n,s=e;const o={ok:!1,can_continue:!1,pos:0,str:"",marker:0};if(i)o.str=i.str,o.marker=i.marker;else{if(s>=r)return o;let i=t.charCodeAt(s);if(34!==i&&39!==i&&40!==i)return o;e++,s++,40===i&&(i=41),o.marker=i}for(;s<r;){if(n=t.charCodeAt(s),n===o.marker)return o.pos=s+1,o.str+=Nl(t.slice(e,s)),o.ok=!0,o;if(40===n&&41===o.marker)return o;92===n&&s+1<r&&s++,s++}return o.can_continue=!0,o.str+=Nl(t.slice(e,s)),o}});const Gl={};function Zl(){this.rules=Cl({},Gl)}function Kl(){this.__rules__=[],this.__cache__=null}function Yl(t,e,r){this.type=t,this.tag=e,this.attrs=null,this.map=null,this.nesting=r,this.level=0,this.children=null,this.content="",this.markup="",this.info="",this.meta=null,this.block=!1,this.hidden=!1}function Xl(t,e,r){this.src=t,this.env=r,this.tokens=[],this.inlineMode=!1,this.md=e}Gl.code_inline=function(t,e,r,i,n){const s=t[e];return"<code"+n.renderAttrs(s)+">"+Il(s.content)+"</code>"},Gl.code_block=function(t,e,r,i,n){return"<pre"+n.renderAttrs(t[e])+"><code>"+Il(t[e].content)+"</code></pre>\n"},Gl.fence=function(t,e,r,i,n){const s=t[e],o=s.info?Nl(s.info).trim():"";let l,u="",h="";if(o){const t=o.split(/(\s+)/g);u=t[0],h=t.slice(2).join("")}if(l=r.highlight&&r.highlight(s.content,u,h)||Il(s.content),0===l.indexOf("<pre"))return l+"\n";if(o){const t=s.attrIndex("class"),e=s.attrs?s.attrs.slice():[];return t<0?e.push(["class",r.langPrefix+u]):(e[t]=e[t].slice(),e[t][1]+=" "+r.langPrefix+u),`<pre><code${n.renderAttrs({attrs:e})}>${l}</code></pre>\n`}return`<pre><code${n.renderAttrs(s)}>${l}</code></pre>\n`},Gl.image=function(t,e,r,i,n){const s=t[e];return s.attrs[s.attrIndex("alt")][1]=n.renderInlineAsText(s.children,r,i),n.renderToken(t,e,r)},Gl.hardbreak=function(t,e,r){return r.xhtmlOut?"<br />\n":"<br>\n"},Gl.softbreak=function(t,e,r){return r.breaks?r.xhtmlOut?"<br />\n":"<br>\n":"\n"},Gl.text=function(t,e){return Il(t[e].content)},Gl.html_block=function(t,e){return t[e].content},Gl.html_inline=function(t,e){return t[e].content},Zl.prototype.renderAttrs=function(t){let e,r,i;if(!t.attrs)return"";for(i="",e=0,r=t.attrs.length;e<r;e++)i+=" "+Il(t.attrs[e][0])+'="'+Il(t.attrs[e][1])+'"';return i},Zl.prototype.renderToken=function(t,e,r){const i=t[e];let n="";if(i.hidden)return"";i.block&&-1!==i.nesting&&e&&t[e-1].hidden&&(n+="\n"),n+=(-1===i.nesting?"</":"<")+i.tag,n+=this.renderAttrs(i),0===i.nesting&&r.xhtmlOut&&(n+=" /");let s=!1;if(i.block&&(s=!0,1===i.nesting&&e+1<t.length)){const r=t[e+1];("inline"===r.type||r.hidden||-1===r.nesting&&r.tag===i.tag)&&(s=!1)}return n+=s?">\n":">",n},Zl.prototype.renderInline=function(t,e,r){let i="";const n=this.rules;for(let s=0,o=t.length;s<o;s++){const o=t[s].type;i+=void 0!==n[o]?n[o](t,s,e,r,this):this.renderToken(t,s,e)}return i},Zl.prototype.renderInlineAsText=function(t,e,r){let i="";for(let n=0,s=t.length;n<s;n++)switch(t[n].type){case"text":case"html_inline":case"html_block":i+=t[n].content;break;case"image":i+=this.renderInlineAsText(t[n].children,e,r);break;case"softbreak":case"hardbreak":i+="\n"}return i},Zl.prototype.render=function(t,e,r){let i="";const n=this.rules;for(let s=0,o=t.length;s<o;s++){const o=t[s].type;i+="inline"===o?this.renderInline(t[s].children,e,r):void 0!==n[o]?n[o](t,s,e,r,this):this.renderToken(t,s,e,r)}return i},Kl.prototype.__find__=function(t){for(let e=0;e<this.__rules__.length;e++)if(this.__rules__[e].name===t)return e;return-1},Kl.prototype.__compile__=function(){const t=this,e=[""];t.__rules__.forEach((function(t){t.enabled&&t.alt.forEach((function(t){e.indexOf(t)<0&&e.push(t)}))})),t.__cache__={},e.forEach((function(e){t.__cache__[e]=[],t.__rules__.forEach((function(r){r.enabled&&(e&&r.alt.indexOf(e)<0||t.__cache__[e].push(r.fn))}))}))},Kl.prototype.at=function(t,e,r){const i=this.__find__(t),n=r||{};if(-1===i)throw new Error("Parser rule not found: "+t);this.__rules__[i].fn=e,this.__rules__[i].alt=n.alt||[],this.__cache__=null},Kl.prototype.before=function(t,e,r,i){const n=this.__find__(t),s=i||{};if(-1===n)throw new Error("Parser rule not found: "+t);this.__rules__.splice(n,0,{name:e,enabled:!0,fn:r,alt:s.alt||[]}),this.__cache__=null},Kl.prototype.after=function(t,e,r,i){const n=this.__find__(t),s=i||{};if(-1===n)throw new Error("Parser rule not found: "+t);this.__rules__.splice(n+1,0,{name:e,enabled:!0,fn:r,alt:s.alt||[]}),this.__cache__=null},Kl.prototype.push=function(t,e,r){this.__rules__.push({name:t,enabled:!0,fn:e,alt:(r||{}).alt||[]}),this.__cache__=null},Kl.prototype.enable=function(t,e){Array.isArray(t)||(t=[t]);const r=[];return t.forEach((function(t){const i=this.__find__(t);if(i<0){if(e)return;throw new Error("Rules manager: invalid rule name "+t)}this.__rules__[i].enabled=!0,r.push(t)}),this),this.__cache__=null,r},Kl.prototype.enableOnly=function(t,e){Array.isArray(t)||(t=[t]),this.__rules__.forEach((function(t){t.enabled=!1})),this.enable(t,e)},Kl.prototype.disable=function(t,e){Array.isArray(t)||(t=[t]);const r=[];return t.forEach((function(t){const i=this.__find__(t);if(i<0){if(e)return;throw new Error("Rules manager: invalid rule name "+t)}this.__rules__[i].enabled=!1,r.push(t)}),this),this.__cache__=null,r},Kl.prototype.getRules=function(t){return null===this.__cache__&&this.__compile__(),this.__cache__[t]||[]},Yl.prototype.attrIndex=function(t){if(!this.attrs)return-1;const e=this.attrs;for(let r=0,i=e.length;r<i;r++)if(e[r][0]===t)return r;return-1},Yl.prototype.attrPush=function(t){this.attrs?this.attrs.push(t):this.attrs=[t]},Yl.prototype.attrSet=function(t,e){const r=this.attrIndex(t),i=[t,e];r<0?this.attrPush(i):this.attrs[r]=i},Yl.prototype.attrGet=function(t){const e=this.attrIndex(t);let r=null;return e>=0&&(r=this.attrs[e][1]),r},Yl.prototype.attrJoin=function(t,e){const r=this.attrIndex(t);r<0?this.attrPush([t,e]):this.attrs[r][1]=this.attrs[r][1]+" "+e},Xl.prototype.Token=Yl;const Ql=/\r\n?|\n/g,tu=/\0/g;const eu=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,ru=/\((c|tm|r)\)/i,iu=/\((c|tm|r)\)/gi,nu={c:"©",r:"®",tm:"™"};function su(t,e){return nu[e.toLowerCase()]}function ou(t){let e=0;for(let r=t.length-1;r>=0;r--){const i=t[r];"text"!==i.type||e||(i.content=i.content.replace(iu,su)),"link_open"===i.type&&"auto"===i.info&&e--,"link_close"===i.type&&"auto"===i.info&&e++}}function lu(t){let e=0;for(let r=t.length-1;r>=0;r--){const i=t[r];"text"!==i.type||e||eu.test(i.content)&&(i.content=i.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–")),"link_open"===i.type&&"auto"===i.info&&e--,"link_close"===i.type&&"auto"===i.info&&e++}}const uu=/['"]/,hu=/['"]/g;function au(t,e,r){return t.slice(0,e)+r+t.slice(e+1)}function fu(t,e){let r;const i=[];for(let n=0;n<t.length;n++){const s=t[n],o=t[n].level;for(r=i.length-1;r>=0&&!(i[r].level<=o);r--);if(i.length=r+1,"text"!==s.type)continue;let l=s.content,u=0,h=l.length;t:for(;u<h;){hu.lastIndex=u;const a=hu.exec(l);if(!a)break;let f=!0,c=!0;u=a.index+1;const d="'"===a[0];let p=32;if(a.index-1>=0)p=l.charCodeAt(a.index-1);else for(r=n-1;r>=0&&"softbreak"!==t[r].type&&"hardbreak"!==t[r].type;r--)if(t[r].content){p=t[r].content.charCodeAt(t[r].content.length-1);break}let m=32;if(u<h)m=l.charCodeAt(u);else for(r=n+1;r<t.length&&"softbreak"!==t[r].type&&"hardbreak"!==t[r].type;r++)if(t[r].content){m=t[r].content.charCodeAt(0);break}const g=Ul(p)||Jl(String.fromCharCode(p)),w=Ul(m)||Jl(String.fromCharCode(m)),b=Ll(p),v=Ll(m);if(v?f=!1:w&&(b||g||(f=!1)),b?c=!1:g&&(v||w||(c=!1)),34===m&&'"'===a[0]&&p>=48&&p<=57&&(c=f=!1),f&&c&&(f=g,c=w),f||c){if(c)for(r=i.length-1;r>=0;r--){let f=i[r];if(i[r].level<o)break;if(f.single===d&&i[r].level===o){let o,c;f=i[r],d?(o=e.md.options.quotes[2],c=e.md.options.quotes[3]):(o=e.md.options.quotes[0],c=e.md.options.quotes[1]),s.content=au(s.content,a.index,c),t[f.token].content=au(t[f.token].content,f.pos,o),u+=c.length-1,f.token===n&&(u+=o.length-1),l=s.content,h=l.length,i.length=r;continue t}}f?i.push({token:n,pos:a.index,single:d,level:o}):c&&d&&(s.content=au(s.content,a.index,"’"))}else d&&(s.content=au(s.content,a.index,"’"))}}}const cu=[["normalize",function(t){let e;e=t.src.replace(Ql,"\n"),e=e.replace(tu,"�"),t.src=e}],["block",function(t){let e;t.inlineMode?(e=new t.Token("inline","",0),e.content=t.src,e.map=[0,1],e.children=[],t.tokens.push(e)):t.md.block.parse(t.src,t.md,t.env,t.tokens)}],["inline",function(t){const e=t.tokens;for(let r=0,i=e.length;r<i;r++){const i=e[r];"inline"===i.type&&t.md.inline.parse(i.content,t.md,t.env,i.children)}}],["linkify",function(t){const e=t.tokens;if(t.md.options.linkify)for(let r=0,i=e.length;r<i;r++){if("inline"!==e[r].type||!t.md.linkify.pretest(e[r].content))continue;let i=e[r].children,n=0;for(let s=i.length-1;s>=0;s--){const o=i[s];if("link_close"!==o.type){if("html_inline"===o.type&&(/^<a[>\s]/i.test(o.content)&&n>0&&n--,/^<\/a\s*>/i.test(o.content)&&n++),!(n>0)&&"text"===o.type&&t.md.linkify.test(o.content)){const n=o.content;let l=t.md.linkify.match(n);const u=[];let h=o.level,a=0;l.length>0&&0===l[0].index&&s>0&&"text_special"===i[s-1].type&&(l=l.slice(1));for(let e=0;e<l.length;e++){const r=t.md.normalizeLink(l[e].url);if(!t.md.validateLink(r))continue;let i=l[e].text;i=l[e].schema?"mailto:"!==l[e].schema||/^mailto:/i.test(i)?t.md.normalizeLinkText(i):t.md.normalizeLinkText("mailto:"+i).replace(/^mailto:/,""):t.md.normalizeLinkText("http://"+i).replace(/^http:\/\//,"");const s=l[e].index;if(s>a){const e=new t.Token("text","",0);e.content=n.slice(a,s),e.level=h,u.push(e)}const o=new t.Token("link_open","a",1);o.attrs=[["href",r]],o.level=h++,o.markup="linkify",o.info="auto",u.push(o);const f=new t.Token("text","",0);f.content=i,f.level=h,u.push(f);const c=new t.Token("link_close","a",-1);c.level=--h,c.markup="linkify",c.info="auto",u.push(c),a=l[e].lastIndex}if(a<n.length){const e=new t.Token("text","",0);e.content=n.slice(a),e.level=h,u.push(e)}e[r].children=i=Al(i,s,u)}}else for(s--;i[s].level!==o.level&&"link_open"!==i[s].type;)s--}}}],["replacements",function(t){let e;if(t.md.options.typographer)for(e=t.tokens.length-1;e>=0;e--)"inline"===t.tokens[e].type&&(ru.test(t.tokens[e].content)&&ou(t.tokens[e].children),eu.test(t.tokens[e].content)&&lu(t.tokens[e].children))}],["smartquotes",function(t){if(t.md.options.typographer)for(let e=t.tokens.length-1;e>=0;e--)"inline"===t.tokens[e].type&&uu.test(t.tokens[e].content)&&fu(t.tokens[e].children,t)}],["text_join",function(t){let e,r;const i=t.tokens,n=i.length;for(let t=0;t<n;t++){if("inline"!==i[t].type)continue;const n=i[t].children,s=n.length;for(e=0;e<s;e++)"text_special"===n[e].type&&(n[e].type="text");for(e=r=0;e<s;e++)"text"===n[e].type&&e+1<s&&"text"===n[e+1].type?n[e+1].content=n[e].content+n[e+1].content:(e!==r&&(n[r]=n[e]),r++);e!==r&&(n.length=r)}}]];function du(){this.ruler=new Kl;for(let t=0;t<cu.length;t++)this.ruler.push(cu[t][0],cu[t][1])}function pu(t,e,r,i){this.src=t,this.md=e,this.env=r,this.tokens=i,this.bMarks=[],this.eMarks=[],this.tShift=[],this.sCount=[],this.bsCount=[],this.blkIndent=0,this.line=0,this.lineMax=0,this.tight=!1,this.ddIndent=-1,this.listIndent=-1,this.parentType="root",this.level=0;const n=this.src;for(let t=0,e=0,r=0,i=0,s=n.length,o=!1;e<s;e++){const l=n.charCodeAt(e);if(!o){if(Pl(l)){r++,9===l?i+=4-i%4:i++;continue}o=!0}10!==l&&e!==s-1||(10!==l&&e++,this.bMarks.push(t),this.eMarks.push(e),this.tShift.push(r),this.sCount.push(i),this.bsCount.push(0),o=!1,r=0,i=0,t=e+1)}this.bMarks.push(n.length),this.eMarks.push(n.length),this.tShift.push(0),this.sCount.push(0),this.bsCount.push(0),this.lineMax=this.bMarks.length-1}function mu(t,e){return t.src.slice(t.bMarks[e]+t.tShift[e],t.eMarks[e])}function gu(t){const e=[],r=t.length;let i=0,n=t.charCodeAt(i),s=!1,o=0,l="";for(;i<r;)124===n&&(s?(l+=t.substring(o,i-1),o=i):(e.push(l+t.substring(o,i)),l="",o=i+1)),s=92===n,i++,n=t.charCodeAt(i);return e.push(l+t.substring(o)),e}function wu(t,e){const r=t.eMarks[e];let i=t.bMarks[e]+t.tShift[e];const n=t.src.charCodeAt(i++);return 42!==n&&45!==n&&43!==n||i<r&&!Pl(t.src.charCodeAt(i))?-1:i}function bu(t,e){const r=t.bMarks[e]+t.tShift[e],i=t.eMarks[e];let n=r;if(n+1>=i)return-1;let s=t.src.charCodeAt(n++);if(s<48||s>57)return-1;for(;;){if(n>=i)return-1;if(s=t.src.charCodeAt(n++),!(s>=48&&s<=57)){if(41===s||46===s)break;return-1}if(n-r>=10)return-1}return n<i&&(s=t.src.charCodeAt(n),!Pl(s))?-1:n}du.prototype.process=function(t){const e=this.ruler.getRules("");for(let r=0,i=e.length;r<i;r++)e[r](t)},du.prototype.State=Xl,pu.prototype.push=function(t,e,r){const i=new Yl(t,e,r);return i.block=!0,r<0&&this.level--,i.level=this.level,r>0&&this.level++,this.tokens.push(i),i},pu.prototype.isEmpty=function(t){return this.bMarks[t]+this.tShift[t]>=this.eMarks[t]},pu.prototype.skipEmptyLines=function(t){for(let e=this.lineMax;t<e&&!(this.bMarks[t]+this.tShift[t]<this.eMarks[t]);t++);return t},pu.prototype.skipSpaces=function(t){for(let e=this.src.length;t<e&&Pl(this.src.charCodeAt(t));t++);return t},pu.prototype.skipSpacesBack=function(t,e){if(t<=e)return t;for(;t>e;)if(!Pl(this.src.charCodeAt(--t)))return t+1;return t},pu.prototype.skipChars=function(t,e){for(let r=this.src.length;t<r&&this.src.charCodeAt(t)===e;t++);return t},pu.prototype.skipCharsBack=function(t,e,r){if(t<=r)return t;for(;t>r;)if(e!==this.src.charCodeAt(--t))return t+1;return t},pu.prototype.getLines=function(t,e,r,i){if(t>=e)return"";const n=new Array(e-t);for(let s=0,o=t;o<e;o++,s++){let t=0;const l=this.bMarks[o];let u,h=l;for(u=o+1<e||i?this.eMarks[o]+1:this.eMarks[o];h<u&&t<r;){const e=this.src.charCodeAt(h);if(Pl(e))9===e?t+=4-(t+this.bsCount[o])%4:t++;else{if(!(h-l<this.tShift[o]))break;t++}h++}n[s]=t>r?new Array(t-r+1).join(" ")+this.src.slice(h,u):this.src.slice(h,u)}return n.join("")},pu.prototype.Token=Yl;const vu="<[A-Za-z][A-Za-z0-9\\-]*(?:\\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\\s*=\\s*(?:[^\"'=<>`\\x00-\\x20]+|'[^']*'|\"[^\"]*\"))?)*\\s*\\/?>",ku="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",Du=new RegExp("^(?:"+vu+"|"+ku+"|\x3c!---?>|\x3c!--(?:[^-]|-[^-]|--[^>])*--\x3e|<[?][\\s\\S]*?[?]>|<![A-Za-z][^>]*>|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>)"),yu=new RegExp("^(?:"+vu+"|"+ku+")"),Eu=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^<!--/,/-->/,!0],[/^<\?/,/\?>/,!0],[/^<![A-Z]/,/>/,!0],[/^<!\[CDATA\[/,/\]\]>/,!0],[new RegExp("^</?("+["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"].join("|")+")(?=(\\s|/?>|$))","i"),/^$/,!0],[new RegExp(yu.source+"\\s*$"),/^$/,!1]],xu=[["table",function(t,e,r,i){if(e+2>r)return!1;let n=e+1;if(t.sCount[n]<t.blkIndent)return!1;if(t.sCount[n]-t.blkIndent>=4)return!1;let s=t.bMarks[n]+t.tShift[n];if(s>=t.eMarks[n])return!1;const o=t.src.charCodeAt(s++);if(124!==o&&45!==o&&58!==o)return!1;if(s>=t.eMarks[n])return!1;const l=t.src.charCodeAt(s++);if(124!==l&&45!==l&&58!==l&&!Pl(l))return!1;if(45===o&&Pl(l))return!1;for(;s<t.eMarks[n];){const e=t.src.charCodeAt(s);if(124!==e&&45!==e&&58!==e&&!Pl(e))return!1;s++}let u=mu(t,e+1),h=u.split("|");const a=[];for(let t=0;t<h.length;t++){const e=h[t].trim();if(!e){if(0===t||t===h.length-1)continue;return!1}if(!/^:?-+:?$/.test(e))return!1;58===e.charCodeAt(e.length-1)?a.push(58===e.charCodeAt(0)?"center":"right"):58===e.charCodeAt(0)?a.push("left"):a.push("")}if(u=mu(t,e).trim(),-1===u.indexOf("|"))return!1;if(t.sCount[e]-t.blkIndent>=4)return!1;h=gu(u),h.length&&""===h[0]&&h.shift(),h.length&&""===h[h.length-1]&&h.pop();const f=h.length;if(0===f||f!==a.length)return!1;if(i)return!0;const c=t.parentType;t.parentType="table";const d=t.md.block.ruler.getRules("blockquote"),p=[e,0];t.push("table_open","table",1).map=p,t.push("thead_open","thead",1).map=[e,e+1],t.push("tr_open","tr",1).map=[e,e+1];for(let e=0;e<h.length;e++){const r=t.push("th_open","th",1);a[e]&&(r.attrs=[["style","text-align:"+a[e]]]);const i=t.push("inline","",0);i.content=h[e].trim(),i.children=[],t.push("th_close","th",-1)}let m;t.push("tr_close","tr",-1),t.push("thead_close","thead",-1);let g=0;for(n=e+2;n<r&&!(t.sCount[n]<t.blkIndent);n++){let i=!1;for(let e=0,s=d.length;e<s;e++)if(d[e](t,n,r,!0)){i=!0;break}if(i)break;if(u=mu(t,n).trim(),!u)break;if(t.sCount[n]-t.blkIndent>=4)break;if(h=gu(u),h.length&&""===h[0]&&h.shift(),h.length&&""===h[h.length-1]&&h.pop(),g+=f-h.length,g>65536)break;n===e+2&&(t.push("tbody_open","tbody",1).map=m=[e+2,0]),t.push("tr_open","tr",1).map=[n,n+1];for(let e=0;e<f;e++){const r=t.push("td_open","td",1);a[e]&&(r.attrs=[["style","text-align:"+a[e]]]);const i=t.push("inline","",0);i.content=h[e]?h[e].trim():"",i.children=[],t.push("td_close","td",-1)}t.push("tr_close","tr",-1)}return m&&(t.push("tbody_close","tbody",-1),m[1]=n),t.push("table_close","table",-1),p[1]=n,t.parentType=c,t.line=n,!0},["paragraph","reference"]],["code",function(t,e,r){if(t.sCount[e]-t.blkIndent<4)return!1;let i=e+1,n=i;for(;i<r;)if(t.isEmpty(i))i++;else{if(!(t.sCount[i]-t.blkIndent>=4))break;i++,n=i}t.line=n;const s=t.push("code_block","code",0);return s.content=t.getLines(e,n,4+t.blkIndent,!1)+"\n",s.map=[e,t.line],!0}],["fence",function(t,e,r,i){let n=t.bMarks[e]+t.tShift[e],s=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4)return!1;if(n+3>s)return!1;const o=t.src.charCodeAt(n);if(126!==o&&96!==o)return!1;let l=n;n=t.skipChars(n,o);let u=n-l;if(u<3)return!1;const h=t.src.slice(l,n),a=t.src.slice(n,s);if(96===o&&a.indexOf(String.fromCharCode(o))>=0)return!1;if(i)return!0;let f=e,c=!1;for(;!(f++,f>=r||(n=l=t.bMarks[f]+t.tShift[f],s=t.eMarks[f],n<s&&t.sCount[f]<t.blkIndent));)if(t.src.charCodeAt(n)===o&&!(t.sCount[f]-t.blkIndent>=4||(n=t.skipChars(n,o),n-l<u||(n=t.skipSpaces(n),n<s)))){c=!0;break}u=t.sCount[e],t.line=f+(c?1:0);const d=t.push("fence","code",0);return d.info=a,d.content=t.getLines(e+1,f,u,!0),d.markup=h,d.map=[e,t.line],!0},["paragraph","reference","blockquote","list"]],["blockquote",function(t,e,r,i){let n=t.bMarks[e]+t.tShift[e],s=t.eMarks[e];const o=t.lineMax;if(t.sCount[e]-t.blkIndent>=4)return!1;if(62!==t.src.charCodeAt(n))return!1;if(i)return!0;const l=[],u=[],h=[],a=[],f=t.md.block.ruler.getRules("blockquote"),c=t.parentType;t.parentType="blockquote";let d,p=!1;for(d=e;d<r;d++){const e=t.sCount[d]<t.blkIndent;if(n=t.bMarks[d]+t.tShift[d],s=t.eMarks[d],n>=s)break;if(62===t.src.charCodeAt(n++)&&!e){let e,r,i=t.sCount[d]+1;32===t.src.charCodeAt(n)?(n++,i++,r=!1,e=!0):9===t.src.charCodeAt(n)?(e=!0,(t.bsCount[d]+i)%4==3?(n++,i++,r=!1):r=!0):e=!1;let o=i;for(l.push(t.bMarks[d]),t.bMarks[d]=n;n<s;){const e=t.src.charCodeAt(n);if(!Pl(e))break;9===e?o+=4-(o+t.bsCount[d]+(r?1:0))%4:o++,n++}p=n>=s,u.push(t.bsCount[d]),t.bsCount[d]=t.sCount[d]+1+(e?1:0),h.push(t.sCount[d]),t.sCount[d]=o-i,a.push(t.tShift[d]),t.tShift[d]=n-t.bMarks[d];continue}if(p)break;let i=!1;for(let e=0,n=f.length;e<n;e++)if(f[e](t,d,r,!0)){i=!0;break}if(i){t.lineMax=d,0!==t.blkIndent&&(l.push(t.bMarks[d]),u.push(t.bsCount[d]),a.push(t.tShift[d]),h.push(t.sCount[d]),t.sCount[d]-=t.blkIndent);break}l.push(t.bMarks[d]),u.push(t.bsCount[d]),a.push(t.tShift[d]),h.push(t.sCount[d]),t.sCount[d]=-1}const m=t.blkIndent;t.blkIndent=0;const g=t.push("blockquote_open","blockquote",1);g.markup=">";const w=[e,0];g.map=w,t.md.block.tokenize(t,e,d),t.push("blockquote_close","blockquote",-1).markup=">",t.lineMax=o,t.parentType=c,w[1]=t.line;for(let r=0;r<a.length;r++)t.bMarks[r+e]=l[r],t.tShift[r+e]=a[r],t.sCount[r+e]=h[r],t.bsCount[r+e]=u[r];return t.blkIndent=m,!0},["paragraph","reference","blockquote","list"]],["hr",function(t,e,r,i){const n=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4)return!1;let s=t.bMarks[e]+t.tShift[e];const o=t.src.charCodeAt(s++);if(42!==o&&45!==o&&95!==o)return!1;let l=1;for(;s<n;){const e=t.src.charCodeAt(s++);if(e!==o&&!Pl(e))return!1;e===o&&l++}if(l<3)return!1;if(i)return!0;t.line=e+1;const u=t.push("hr","hr",0);return u.map=[e,t.line],u.markup=Array(l+1).join(String.fromCharCode(o)),!0},["paragraph","reference","blockquote","list"]],["list",function(t,e,r,i){let n,s,o,l,u=e,h=!0;if(t.sCount[u]-t.blkIndent>=4)return!1;if(t.listIndent>=0&&t.sCount[u]-t.listIndent>=4&&t.sCount[u]<t.blkIndent)return!1;let a,f,c,d=!1;if(i&&"paragraph"===t.parentType&&t.sCount[u]>=t.blkIndent&&(d=!0),(c=bu(t,u))>=0){if(a=!0,o=t.bMarks[u]+t.tShift[u],f=Number(t.src.slice(o,c-1)),d&&1!==f)return!1}else{if(!((c=wu(t,u))>=0))return!1;a=!1}if(d&&t.skipSpaces(c)>=t.eMarks[u])return!1;if(i)return!0;const p=t.src.charCodeAt(c-1),m=t.tokens.length;a?(l=t.push("ordered_list_open","ol",1),1!==f&&(l.attrs=[["start",f]])):l=t.push("bullet_list_open","ul",1);const g=[u,0];l.map=g,l.markup=String.fromCharCode(p);let w=!1;const b=t.md.block.ruler.getRules("list"),v=t.parentType;for(t.parentType="list";u<r;){s=c,n=t.eMarks[u];const e=t.sCount[u]+c-(t.bMarks[u]+t.tShift[u]);let i=e;for(;s<n;){const e=t.src.charCodeAt(s);if(9===e)i+=4-(i+t.bsCount[u])%4;else{if(32!==e)break;i++}s++}const f=s;let d;d=f>=n?1:i-e,d>4&&(d=1);const m=e+d;l=t.push("list_item_open","li",1),l.markup=String.fromCharCode(p);const g=[u,0];l.map=g,a&&(l.info=t.src.slice(o,c-1));const v=t.tight,k=t.tShift[u],D=t.sCount[u],y=t.listIndent;if(t.listIndent=t.blkIndent,t.blkIndent=m,t.tight=!0,t.tShift[u]=f-t.bMarks[u],t.sCount[u]=i,f>=n&&t.isEmpty(u+1)?t.line=Math.min(t.line+2,r):t.md.block.tokenize(t,u,r,!0),t.tight&&!w||(h=!1),w=t.line-u>1&&t.isEmpty(t.line-1),t.blkIndent=t.listIndent,t.listIndent=y,t.tShift[u]=k,t.sCount[u]=D,t.tight=v,l=t.push("list_item_close","li",-1),l.markup=String.fromCharCode(p),u=t.line,g[1]=u,u>=r)break;if(t.sCount[u]<t.blkIndent)break;if(t.sCount[u]-t.blkIndent>=4)break;let E=!1;for(let e=0,i=b.length;e<i;e++)if(b[e](t,u,r,!0)){E=!0;break}if(E)break;if(a){if(c=bu(t,u),c<0)break;o=t.bMarks[u]+t.tShift[u]}else if(c=wu(t,u),c<0)break;if(p!==t.src.charCodeAt(c-1))break}return l=a?t.push("ordered_list_close","ol",-1):t.push("bullet_list_close","ul",-1),l.markup=String.fromCharCode(p),g[1]=u,t.line=u,t.parentType=v,h&&function(t,e){const r=t.level+2;for(let i=e+2,n=t.tokens.length-2;i<n;i++)t.tokens[i].level===r&&"paragraph_open"===t.tokens[i].type&&(t.tokens[i+2].hidden=!0,t.tokens[i].hidden=!0,i+=2)}(t,m),!0},["paragraph","reference","blockquote"]],["reference",function(t,e,r,i){let n=t.bMarks[e]+t.tShift[e],s=t.eMarks[e],o=e+1;if(t.sCount[e]-t.blkIndent>=4)return!1;if(91!==t.src.charCodeAt(n))return!1;function l(e){const r=t.lineMax;if(e>=r||t.isEmpty(e))return null;let i=!1;if(t.sCount[e]-t.blkIndent>3&&(i=!0),t.sCount[e]<0&&(i=!0),!i){const i=t.md.block.ruler.getRules("reference"),n=t.parentType;t.parentType="reference";let s=!1;for(let n=0,o=i.length;n<o;n++)if(i[n](t,e,r,!0)){s=!0;break}if(t.parentType=n,s)return null}return t.src.slice(t.bMarks[e]+t.tShift[e],t.eMarks[e]+1)}let u=t.src.slice(n,s+1);s=u.length;let h=-1;for(n=1;n<s;n++){const t=u.charCodeAt(n);if(91===t)return!1;if(93===t){h=n;break}if(10===t){const t=l(o);null!==t&&(u+=t,s=u.length,o++)}else if(92===t&&(n++,n<s&&10===u.charCodeAt(n))){const t=l(o);null!==t&&(u+=t,s=u.length,o++)}}if(h<0||58!==u.charCodeAt(h+1))return!1;for(n=h+2;n<s;n++){const t=u.charCodeAt(n);if(10===t){const t=l(o);null!==t&&(u+=t,s=u.length,o++)}else if(!Pl(t))break}const a=t.md.helpers.parseLinkDestination(u,n,s);if(!a.ok)return!1;const f=t.md.normalizeLink(a.str);if(!t.md.validateLink(f))return!1;n=a.pos;const c=n,d=o,p=n;for(;n<s;n++){const t=u.charCodeAt(n);if(10===t){const t=l(o);null!==t&&(u+=t,s=u.length,o++)}else if(!Pl(t))break}let m,g=t.md.helpers.parseLinkTitle(u,n,s);for(;g.can_continue;){const e=l(o);if(null===e)break;u+=e,n=s,s=u.length,o++,g=t.md.helpers.parseLinkTitle(u,n,s,g)}for(n<s&&p!==n&&g.ok?(m=g.str,n=g.pos):(m="",n=c,o=d);n<s&&Pl(u.charCodeAt(n));)n++;if(n<s&&10!==u.charCodeAt(n)&&m)for(m="",n=c,o=d;n<s&&Pl(u.charCodeAt(n));)n++;if(n<s&&10!==u.charCodeAt(n))return!1;const w=Vl(u.slice(1,h));return!!w&&(i||(void 0===t.env.references&&(t.env.references={}),void 0===t.env.references[w]&&(t.env.references[w]={title:m,href:f}),t.line=o),!0)}],["html_block",function(t,e,r,i){let n=t.bMarks[e]+t.tShift[e],s=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4)return!1;if(!t.md.options.html)return!1;if(60!==t.src.charCodeAt(n))return!1;let o=t.src.slice(n,s),l=0;for(;l<Eu.length&&!Eu[l][0].test(o);l++);if(l===Eu.length)return!1;if(i)return Eu[l][2];let u=e+1;if(!Eu[l][1].test(o))for(;u<r&&!(t.sCount[u]<t.blkIndent);u++)if(n=t.bMarks[u]+t.tShift[u],s=t.eMarks[u],o=t.src.slice(n,s),Eu[l][1].test(o)){0!==o.length&&u++;break}t.line=u;const h=t.push("html_block","",0);return h.map=[e,u],h.content=t.getLines(e,u,t.blkIndent,!0),!0},["paragraph","reference","blockquote"]],["heading",function(t,e,r,i){let n=t.bMarks[e]+t.tShift[e],s=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4)return!1;let o=t.src.charCodeAt(n);if(35!==o||n>=s)return!1;let l=1;for(o=t.src.charCodeAt(++n);35===o&&n<s&&l<=6;)l++,o=t.src.charCodeAt(++n);if(l>6||n<s&&!Pl(o))return!1;if(i)return!0;s=t.skipSpacesBack(s,n);const u=t.skipCharsBack(s,35,n);u>n&&Pl(t.src.charCodeAt(u-1))&&(s=u),t.line=e+1;const h=t.push("heading_open","h"+String(l),1);h.markup="########".slice(0,l),h.map=[e,t.line];const a=t.push("inline","",0);return a.content=t.src.slice(n,s).trim(),a.map=[e,t.line],a.children=[],t.push("heading_close","h"+String(l),-1).markup="########".slice(0,l),!0},["paragraph","reference","blockquote"]],["lheading",function(t,e,r){const i=t.md.block.ruler.getRules("paragraph");if(t.sCount[e]-t.blkIndent>=4)return!1;const n=t.parentType;t.parentType="paragraph";let s,o=0,l=e+1;for(;l<r&&!t.isEmpty(l);l++){if(t.sCount[l]-t.blkIndent>3)continue;if(t.sCount[l]>=t.blkIndent){let e=t.bMarks[l]+t.tShift[l];const r=t.eMarks[l];if(e<r&&(s=t.src.charCodeAt(e),(45===s||61===s)&&(e=t.skipChars(e,s),e=t.skipSpaces(e),e>=r))){o=61===s?1:2;break}}if(t.sCount[l]<0)continue;let e=!1;for(let n=0,s=i.length;n<s;n++)if(i[n](t,l,r,!0)){e=!0;break}if(e)break}if(!o)return!1;const u=t.getLines(e,l,t.blkIndent,!1).trim();t.line=l+1;const h=t.push("heading_open","h"+String(o),1);h.markup=String.fromCharCode(s),h.map=[e,t.line];const a=t.push("inline","",0);return a.content=u,a.map=[e,t.line-1],a.children=[],t.push("heading_close","h"+String(o),-1).markup=String.fromCharCode(s),t.parentType=n,!0}],["paragraph",function(t,e,r){const i=t.md.block.ruler.getRules("paragraph"),n=t.parentType;let s=e+1;for(t.parentType="paragraph";s<r&&!t.isEmpty(s);s++){if(t.sCount[s]-t.blkIndent>3)continue;if(t.sCount[s]<0)continue;let e=!1;for(let n=0,o=i.length;n<o;n++)if(i[n](t,s,r,!0)){e=!0;break}if(e)break}const o=t.getLines(e,s,t.blkIndent,!1).trim();t.line=s,t.push("paragraph_open","p",1).map=[e,t.line];const l=t.push("inline","",0);return l.content=o,l.map=[e,t.line],l.children=[],t.push("paragraph_close","p",-1),t.parentType=n,!0}]];function Fu(){this.ruler=new Kl;for(let t=0;t<xu.length;t++)this.ruler.push(xu[t][0],xu[t][1],{alt:(xu[t][2]||[]).slice()})}function Mu(t,e,r,i){this.src=t,this.env=r,this.md=e,this.tokens=i,this.tokens_meta=Array(i.length),this.pos=0,this.posMax=this.src.length,this.level=0,this.pending="",this.pendingLevel=0,this.cache={},this.delimiters=[],this._prev_delimiters=[],this.backticks={},this.backticksScanned=!1,this.linkLevel=0}function Cu(t){switch(t){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}}Fu.prototype.tokenize=function(t,e,r){const i=this.ruler.getRules(""),n=i.length,s=t.md.options.maxNesting;let o=e,l=!1;for(;o<r&&(t.line=o=t.skipEmptyLines(o),!(o>=r))&&!(t.sCount[o]<t.blkIndent);){if(t.level>=s){t.line=r;break}const e=t.line;let u=!1;for(let s=0;s<n;s++)if(u=i[s](t,o,r,!1),u){if(e>=t.line)throw new Error("block rule didn't increment state.line");break}if(!u)throw new Error("none of the block rules matched");t.tight=!l,t.isEmpty(t.line-1)&&(l=!0),o=t.line,o<r&&t.isEmpty(o)&&(l=!0,o++,t.line=o)}},Fu.prototype.parse=function(t,e,r,i){if(!t)return;const n=new this.State(t,e,r,i);this.tokenize(n,n.line,n.lineMax)},Fu.prototype.State=pu,Mu.prototype.pushPending=function(){const t=new Yl("text","",0);return t.content=this.pending,t.level=this.pendingLevel,this.tokens.push(t),this.pending="",t},Mu.prototype.push=function(t,e,r){this.pending&&this.pushPending();const i=new Yl(t,e,r);let n=null;return r<0&&(this.level--,this.delimiters=this._prev_delimiters.pop()),i.level=this.level,r>0&&(this.level++,this._prev_delimiters.push(this.delimiters),this.delimiters=[],n={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(i),this.tokens_meta.push(n),i},Mu.prototype.scanDelims=function(t,e){const r=this.posMax,i=this.src.charCodeAt(t),n=t>0?this.src.charCodeAt(t-1):32;let s=t;for(;s<r&&this.src.charCodeAt(s)===i;)s++;const o=s-t,l=s<r?this.src.charCodeAt(s):32,u=Ul(n)||Jl(String.fromCharCode(n)),h=Ul(l)||Jl(String.fromCharCode(l)),a=Ll(n),f=Ll(l),c=!f&&(!h||a||u),d=!a&&(!u||f||h);return{can_open:c&&(e||!d||u),can_close:d&&(e||!c||h),length:o}},Mu.prototype.Token=Yl;const Au=/(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i,Su=[];for(let t=0;t<256;t++)Su.push(0);function Ou(t,e){let r;const i=[],n=e.length;for(let s=0;s<n;s++){const n=e[s];if(126!==n.marker)continue;if(-1===n.end)continue;const o=e[n.end];r=t.tokens[n.token],r.type="s_open",r.tag="s",r.nesting=1,r.markup="~~",r.content="",r=t.tokens[o.token],r.type="s_close",r.tag="s",r.nesting=-1,r.markup="~~",r.content="","text"===t.tokens[o.token-1].type&&"~"===t.tokens[o.token-1].content&&i.push(o.token-1)}for(;i.length;){const e=i.pop();let n=e+1;for(;n<t.tokens.length&&"s_close"===t.tokens[n].type;)n++;n--,e!==n&&(r=t.tokens[n],t.tokens[n]=t.tokens[e],t.tokens[e]=r)}}"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach((function(t){Su[t.charCodeAt(0)]=1}));var $u={tokenize:function(t,e){const r=t.src.charCodeAt(t.pos);if(e)return!1;if(126!==r)return!1;const i=t.scanDelims(t.pos,!0);let n=i.length;const s=String.fromCharCode(r);if(n<2)return!1;let o;n%2&&(o=t.push("text","",0),o.content=s,n--);for(let e=0;e<n;e+=2)o=t.push("text","",0),o.content=s+s,t.delimiters.push({marker:r,length:0,token:t.tokens.length-1,end:-1,open:i.can_open,close:i.can_close});return t.pos+=i.length,!0},postProcess:function(t){const e=t.tokens_meta,r=t.tokens_meta.length;Ou(t,t.delimiters);for(let i=0;i<r;i++)e[i]&&e[i].delimiters&&Ou(t,e[i].delimiters)}};function Bu(t,e){for(let r=e.length-1;r>=0;r--){const i=e[r];if(95!==i.marker&&42!==i.marker)continue;if(-1===i.end)continue;const n=e[i.end],s=r>0&&e[r-1].end===i.end+1&&e[r-1].marker===i.marker&&e[r-1].token===i.token-1&&e[i.end+1].token===n.token+1,o=String.fromCharCode(i.marker),l=t.tokens[i.token];l.type=s?"strong_open":"em_open",l.tag=s?"strong":"em",l.nesting=1,l.markup=s?o+o:o,l.content="";const u=t.tokens[n.token];u.type=s?"strong_close":"em_close",u.tag=s?"strong":"em",u.nesting=-1,u.markup=s?o+o:o,u.content="",s&&(t.tokens[e[r-1].token].content="",t.tokens[e[i.end+1].token].content="",r--)}}var Ru={tokenize:function(t,e){const r=t.src.charCodeAt(t.pos);if(e)return!1;if(95!==r&&42!==r)return!1;const i=t.scanDelims(t.pos,42===r);for(let e=0;e<i.length;e++)t.push("text","",0).content=String.fromCharCode(r),t.delimiters.push({marker:r,length:i.length,token:t.tokens.length-1,end:-1,open:i.can_open,close:i.can_close});return t.pos+=i.length,!0},postProcess:function(t){const e=t.tokens_meta,r=t.tokens_meta.length;Bu(t,t.delimiters);for(let i=0;i<r;i++)e[i]&&e[i].delimiters&&Bu(t,e[i].delimiters)}};const Nu=/^([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])?)*)$/,_u=/^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/,Tu=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,zu=/^&([a-z][a-z0-9]{1,31});/i;function qu(t){const e={},r=t.length;if(!r)return;let i=0,n=-2;const s=[];for(let o=0;o<r;o++){const r=t[o];if(s.push(0),t[i].marker===r.marker&&n===r.token-1||(i=o),n=r.token,r.length=r.length||0,!r.close)continue;e.hasOwnProperty(r.marker)||(e[r.marker]=[-1,-1,-1,-1,-1,-1]);const l=e[r.marker][(r.open?3:0)+r.length%3];let u=i-s[i]-1,h=u;for(;u>l;u-=s[u]+1){const e=t[u];if(e.marker===r.marker&&e.open&&e.end<0){let i=!1;if((e.close||r.open)&&(e.length+r.length)%3==0&&(e.length%3==0&&r.length%3==0||(i=!0)),!i){const i=u>0&&!t[u-1].open?s[u-1]+1:0;s[o]=o-u+i,s[u]=i,r.open=!1,e.end=o,e.close=!1,h=-1,n=-2;break}}}-1!==h&&(e[r.marker][(r.open?3:0)+(r.length||0)%3]=h)}}const Iu=[["text",function(t,e){let r=t.pos;for(;r<t.posMax&&!Cu(t.src.charCodeAt(r));)r++;return r!==t.pos&&(e||(t.pending+=t.src.slice(t.pos,r)),t.pos=r,!0)}],["linkify",function(t,e){if(!t.md.options.linkify)return!1;if(t.linkLevel>0)return!1;const r=t.pos;if(r+3>t.posMax)return!1;if(58!==t.src.charCodeAt(r))return!1;if(47!==t.src.charCodeAt(r+1))return!1;if(47!==t.src.charCodeAt(r+2))return!1;const i=t.pending.match(Au);if(!i)return!1;const n=i[1],s=t.md.linkify.matchAtStart(t.src.slice(r-n.length));if(!s)return!1;let o=s.url;if(o.length<=n.length)return!1;let l=o.length;for(;l>0&&42===o.charCodeAt(l-1);)l--;l!==o.length&&(o=o.slice(0,l));const u=t.md.normalizeLink(o);if(!t.md.validateLink(u))return!1;if(!e){t.pending=t.pending.slice(0,-n.length);const e=t.push("link_open","a",1);e.attrs=[["href",u]],e.markup="linkify",e.info="auto",t.push("text","",0).content=t.md.normalizeLinkText(o);const r=t.push("link_close","a",-1);r.markup="linkify",r.info="auto"}return t.pos+=o.length-n.length,!0}],["newline",function(t,e){let r=t.pos;if(10!==t.src.charCodeAt(r))return!1;const i=t.pending.length-1,n=t.posMax;if(!e)if(i>=0&&32===t.pending.charCodeAt(i))if(i>=1&&32===t.pending.charCodeAt(i-1)){let e=i-1;for(;e>=1&&32===t.pending.charCodeAt(e-1);)e--;t.pending=t.pending.slice(0,e),t.push("hardbreak","br",0)}else t.pending=t.pending.slice(0,-1),t.push("softbreak","br",0);else t.push("softbreak","br",0);for(r++;r<n&&Pl(t.src.charCodeAt(r));)r++;return t.pos=r,!0}],["escape",function(t,e){let r=t.pos;const i=t.posMax;if(92!==t.src.charCodeAt(r))return!1;if(r++,r>=i)return!1;let n=t.src.charCodeAt(r);if(10===n){for(e||t.push("hardbreak","br",0),r++;r<i&&(n=t.src.charCodeAt(r),Pl(n));)r++;return t.pos=r,!0}let s=t.src[r];if(n>=55296&&n<=56319&&r+1<i){const e=t.src.charCodeAt(r+1);e>=56320&&e<=57343&&(s+=t.src[r+1],r++)}const o="\\"+s;if(!e){const e=t.push("text_special","",0);e.content=n<256&&0!==Su[n]?s:o,e.markup=o,e.info="escape"}return t.pos=r+1,!0}],["backticks",function(t,e){let r=t.pos;if(96!==t.src.charCodeAt(r))return!1;const i=r;r++;const n=t.posMax;for(;r<n&&96===t.src.charCodeAt(r);)r++;const s=t.src.slice(i,r),o=s.length;if(t.backticksScanned&&(t.backticks[o]||0)<=i)return e||(t.pending+=s),t.pos+=o,!0;let l,u=r;for(;-1!==(l=t.src.indexOf("`",u));){for(u=l+1;u<n&&96===t.src.charCodeAt(u);)u++;const i=u-l;if(i===o){if(!e){const e=t.push("code_inline","code",0);e.markup=s,e.content=t.src.slice(r,l).replace(/\n/g," ").replace(/^ (.+) $/,"$1")}return t.pos=u,!0}t.backticks[i]=l}return t.backticksScanned=!0,e||(t.pending+=s),t.pos+=o,!0}],["strikethrough",$u.tokenize],["emphasis",Ru.tokenize],["link",function(t,e){let r,i,n,s,o="",l="",u=t.pos,h=!0;if(91!==t.src.charCodeAt(t.pos))return!1;const a=t.pos,f=t.posMax,c=t.pos+1,d=t.md.helpers.parseLinkLabel(t,t.pos,!0);if(d<0)return!1;let p=d+1;if(p<f&&40===t.src.charCodeAt(p)){for(h=!1,p++;p<f&&(r=t.src.charCodeAt(p),Pl(r)||10===r);p++);if(p>=f)return!1;if(u=p,n=t.md.helpers.parseLinkDestination(t.src,p,t.posMax),n.ok){for(o=t.md.normalizeLink(n.str),t.md.validateLink(o)?p=n.pos:o="",u=p;p<f&&(r=t.src.charCodeAt(p),Pl(r)||10===r);p++);if(n=t.md.helpers.parseLinkTitle(t.src,p,t.posMax),p<f&&u!==p&&n.ok)for(l=n.str,p=n.pos;p<f&&(r=t.src.charCodeAt(p),Pl(r)||10===r);p++);}(p>=f||41!==t.src.charCodeAt(p))&&(h=!0),p++}if(h){if(void 0===t.env.references)return!1;if(p<f&&91===t.src.charCodeAt(p)?(u=p+1,p=t.md.helpers.parseLinkLabel(t,p),p>=0?i=t.src.slice(u,p++):p=d+1):p=d+1,i||(i=t.src.slice(c,d)),s=t.env.references[Vl(i)],!s)return t.pos=a,!1;o=s.href,l=s.title}if(!e){t.pos=c,t.posMax=d;const e=[["href",o]];t.push("link_open","a",1).attrs=e,l&&e.push(["title",l]),t.linkLevel++,t.md.inline.tokenize(t),t.linkLevel--,t.push("link_close","a",-1)}return t.pos=p,t.posMax=f,!0}],["image",function(t,e){let r,i,n,s,o,l,u,h,a="";const f=t.pos,c=t.posMax;if(33!==t.src.charCodeAt(t.pos))return!1;if(91!==t.src.charCodeAt(t.pos+1))return!1;const d=t.pos+2,p=t.md.helpers.parseLinkLabel(t,t.pos+1,!1);if(p<0)return!1;if(s=p+1,s<c&&40===t.src.charCodeAt(s)){for(s++;s<c&&(r=t.src.charCodeAt(s),Pl(r)||10===r);s++);if(s>=c)return!1;for(h=s,l=t.md.helpers.parseLinkDestination(t.src,s,t.posMax),l.ok&&(a=t.md.normalizeLink(l.str),t.md.validateLink(a)?s=l.pos:a=""),h=s;s<c&&(r=t.src.charCodeAt(s),Pl(r)||10===r);s++);if(l=t.md.helpers.parseLinkTitle(t.src,s,t.posMax),s<c&&h!==s&&l.ok)for(u=l.str,s=l.pos;s<c&&(r=t.src.charCodeAt(s),Pl(r)||10===r);s++);else u="";if(s>=c||41!==t.src.charCodeAt(s))return t.pos=f,!1;s++}else{if(void 0===t.env.references)return!1;if(s<c&&91===t.src.charCodeAt(s)?(h=s+1,s=t.md.helpers.parseLinkLabel(t,s),s>=0?n=t.src.slice(h,s++):s=p+1):s=p+1,n||(n=t.src.slice(d,p)),o=t.env.references[Vl(n)],!o)return t.pos=f,!1;a=o.href,u=o.title}if(!e){i=t.src.slice(d,p);const e=[];t.md.inline.parse(i,t.md,t.env,e);const r=t.push("image","img",0),n=[["src",a],["alt",""]];r.attrs=n,r.children=e,r.content=i,u&&n.push(["title",u])}return t.pos=s,t.posMax=c,!0}],["autolink",function(t,e){let r=t.pos;if(60!==t.src.charCodeAt(r))return!1;const i=t.pos,n=t.posMax;for(;;){if(++r>=n)return!1;const e=t.src.charCodeAt(r);if(60===e)return!1;if(62===e)break}const s=t.src.slice(i+1,r);if(_u.test(s)){const r=t.md.normalizeLink(s);if(!t.md.validateLink(r))return!1;if(!e){const e=t.push("link_open","a",1);e.attrs=[["href",r]],e.markup="autolink",e.info="auto",t.push("text","",0).content=t.md.normalizeLinkText(s);const i=t.push("link_close","a",-1);i.markup="autolink",i.info="auto"}return t.pos+=s.length+2,!0}if(Nu.test(s)){const r=t.md.normalizeLink("mailto:"+s);if(!t.md.validateLink(r))return!1;if(!e){const e=t.push("link_open","a",1);e.attrs=[["href",r]],e.markup="autolink",e.info="auto",t.push("text","",0).content=t.md.normalizeLinkText(s);const i=t.push("link_close","a",-1);i.markup="autolink",i.info="auto"}return t.pos+=s.length+2,!0}return!1}],["html_inline",function(t,e){if(!t.md.options.html)return!1;const r=t.posMax,i=t.pos;if(60!==t.src.charCodeAt(i)||i+2>=r)return!1;const n=t.src.charCodeAt(i+1);if(33!==n&&63!==n&&47!==n&&!function(t){const e=32|t;return e>=97&&e<=122}(n))return!1;const s=t.src.slice(i).match(Du);if(!s)return!1;if(!e){const e=t.push("html_inline","",0);e.content=s[0],/^<a[>\s]/i.test(e.content)&&t.linkLevel++,/^<\/a\s*>/i.test(e.content)&&t.linkLevel--}return t.pos+=s[0].length,!0}],["entity",function(t,e){const r=t.pos,i=t.posMax;if(38!==t.src.charCodeAt(r))return!1;if(r+1>=i)return!1;if(35===t.src.charCodeAt(r+1)){const i=t.src.slice(r).match(Tu);if(i){if(!e){const e="x"===i[1][0].toLowerCase()?parseInt(i[1].slice(1),16):parseInt(i[1],10),r=t.push("text_special","",0);r.content=Sl(e)?Ol(e):Ol(65533),r.markup=i[0],r.info="entity"}return t.pos+=i[0].length,!0}}else{const i=t.src.slice(r).match(zu);if(i){const r=d(i[0]);if(r!==i[0]){if(!e){const e=t.push("text_special","",0);e.content=r,e.markup=i[0],e.info="entity"}return t.pos+=i[0].length,!0}}}return!1}]],ju=[["balance_pairs",function(t){const e=t.tokens_meta,r=t.tokens_meta.length;qu(t.delimiters);for(let t=0;t<r;t++)e[t]&&e[t].delimiters&&qu(e[t].delimiters)}],["strikethrough",$u.postProcess],["emphasis",Ru.postProcess],["fragments_join",function(t){let e,r,i=0;const n=t.tokens,s=t.tokens.length;for(e=r=0;e<s;e++)n[e].nesting<0&&i--,n[e].level=i,n[e].nesting>0&&i++,"text"===n[e].type&&e+1<s&&"text"===n[e+1].type?n[e+1].content=n[e].content+n[e+1].content:(e!==r&&(n[r]=n[e]),r++);e!==r&&(n.length=r)}]];function Pu(){this.ruler=new Kl;for(let t=0;t<Iu.length;t++)this.ruler.push(Iu[t][0],Iu[t][1]);this.ruler2=new Kl;for(let t=0;t<ju.length;t++)this.ruler2.push(ju[t][0],ju[t][1])}function Lu(t){return Array.prototype.slice.call(arguments,1).forEach((function(e){e&&Object.keys(e).forEach((function(r){t[r]=e[r]}))})),t}function Ju(t){return Object.prototype.toString.call(t)}function Uu(t){return"[object Function]"===Ju(t)}function Vu(t){return t.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}Pu.prototype.skipToken=function(t){const e=t.pos,r=this.ruler.getRules(""),i=r.length,n=t.md.options.maxNesting,s=t.cache;if(void 0!==s[e])return void(t.pos=s[e]);let o=!1;if(t.level<n){for(let n=0;n<i;n++)if(t.level++,o=r[n](t,!0),t.level--,o){if(e>=t.pos)throw new Error("inline rule didn't increment state.pos");break}}else t.pos=t.posMax;o||t.pos++,s[e]=t.pos},Pu.prototype.tokenize=function(t){const e=this.ruler.getRules(""),r=e.length,i=t.posMax,n=t.md.options.maxNesting;for(;t.pos<i;){const s=t.pos;let o=!1;if(t.level<n)for(let i=0;i<r;i++)if(o=e[i](t,!1),o){if(s>=t.pos)throw new Error("inline rule didn't increment state.pos");break}if(o){if(t.pos>=i)break}else t.pending+=t.src[t.pos++]}t.pending&&t.pushPending()},Pu.prototype.parse=function(t,e,r,i){const n=new this.State(t,e,r,i);this.tokenize(n);const s=this.ruler2.getRules(""),o=s.length;for(let t=0;t<o;t++)s[t](n)},Pu.prototype.State=Mu;const Hu={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1},Wu={"http:":{validate:function(t,e,r){const i=t.slice(e);return r.re.http||(r.re.http=new RegExp("^\\/\\/"+r.re.src_auth+r.re.src_host_port_strict+r.re.src_path,"i")),r.re.http.test(i)?i.match(r.re.http)[0].length:0}},"https:":"http:","ftp:":"http:","//":{validate:function(t,e,r){const i=t.slice(e);return r.re.no_http||(r.re.no_http=new RegExp("^"+r.re.src_auth+"(?:localhost|(?:(?:"+r.re.src_domain+")\\.)+"+r.re.src_domain_root+")"+r.re.src_port+r.re.src_host_terminator+r.re.src_path,"i")),r.re.no_http.test(i)?e>=3&&":"===t[e-3]||e>=3&&"/"===t[e-3]?0:i.match(r.re.no_http)[0].length:0}},"mailto:":{validate:function(t,e,r){const i=t.slice(e);return r.re.mailto||(r.re.mailto=new RegExp("^"+r.re.src_email_name+"@"+r.re.src_host_strict,"i")),r.re.mailto.test(i)?i.match(r.re.mailto)[0].length:0}}},Gu="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function Zu(t){const e=t.re=function(t){const e={};t=t||{},e.src_Any=bl.source,e.src_Cc=vl.source,e.src_Z=yl.source,e.src_P=kl.source,e.src_ZPCc=[e.src_Z,e.src_P,e.src_Cc].join("|"),e.src_ZCc=[e.src_Z,e.src_Cc].join("|");return e.src_pseudo_letter="(?:(?![><|]|"+e.src_ZPCc+")"+e.src_Any+")",e.src_ip4="(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",e.src_auth="(?:(?:(?!"+e.src_ZCc+"|[@/\\[\\]()]).)+@)?",e.src_port="(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?",e.src_host_terminator="(?=$|[><|]|"+e.src_ZPCc+")(?!"+(t["---"]?"-(?!--)|":"-|")+"_|:\\d|\\.-|\\.(?!$|"+e.src_ZPCc+"))",e.src_path="(?:[/?#](?:(?!"+e.src_ZCc+"|[><|]|[()[\\]{}.,\"'?!\\-;]).|\\[(?:(?!"+e.src_ZCc+"|\\]).)*\\]|\\((?:(?!"+e.src_ZCc+"|[)]).)*\\)|\\{(?:(?!"+e.src_ZCc+'|[}]).)*\\}|\\"(?:(?!'+e.src_ZCc+'|["]).)+\\"|\\\'(?:(?!'+e.src_ZCc+"|[']).)+\\'|\\'(?="+e.src_pseudo_letter+"|[-])|\\.{2,}[a-zA-Z0-9%/&]|\\.(?!"+e.src_ZCc+"|[.]|$)|"+(t["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+",(?!"+e.src_ZCc+"|$)|;(?!"+e.src_ZCc+"|$)|\\!+(?!"+e.src_ZCc+"|[!]|$)|\\?(?!"+e.src_ZCc+"|[?]|$))+|\\/)?",e.src_email_name='[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*',e.src_xn="xn--[a-z0-9\\-]{1,59}",e.src_domain_root="(?:"+e.src_xn+"|"+e.src_pseudo_letter+"{1,63})",e.src_domain="(?:"+e.src_xn+"|(?:"+e.src_pseudo_letter+")|(?:"+e.src_pseudo_letter+"(?:-|"+e.src_pseudo_letter+"){0,61}"+e.src_pseudo_letter+"))",e.src_host="(?:(?:(?:(?:"+e.src_domain+")\\.)*"+e.src_domain+"))",e.tpl_host_fuzzy="(?:"+e.src_ip4+"|(?:(?:(?:"+e.src_domain+")\\.)+(?:%TLDS%)))",e.tpl_host_no_ip_fuzzy="(?:(?:(?:"+e.src_domain+")\\.)+(?:%TLDS%))",e.src_host_strict=e.src_host+e.src_host_terminator,e.tpl_host_fuzzy_strict=e.tpl_host_fuzzy+e.src_host_terminator,e.src_host_port_strict=e.src_host+e.src_port+e.src_host_terminator,e.tpl_host_port_fuzzy_strict=e.tpl_host_fuzzy+e.src_port+e.src_host_terminator,e.tpl_host_port_no_ip_fuzzy_strict=e.tpl_host_no_ip_fuzzy+e.src_port+e.src_host_terminator,e.tpl_host_fuzzy_test="localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:"+e.src_ZPCc+"|>|$))",e.tpl_email_fuzzy='(^|[><|]|"|\\(|'+e.src_ZCc+")("+e.src_email_name+"@"+e.tpl_host_fuzzy_strict+")",e.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+e.src_ZPCc+"))((?![$+<=>^`||])"+e.tpl_host_port_fuzzy_strict+e.src_path+")",e.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+e.src_ZPCc+"))((?![$+<=>^`||])"+e.tpl_host_port_no_ip_fuzzy_strict+e.src_path+")",e}(t.__opts__),r=t.__tlds__.slice();function i(t){return t.replace("%TLDS%",e.src_tlds)}t.onCompile(),t.__tlds_replaced__||r.push("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]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]"),r.push(e.src_xn),e.src_tlds=r.join("|"),e.email_fuzzy=RegExp(i(e.tpl_email_fuzzy),"i"),e.link_fuzzy=RegExp(i(e.tpl_link_fuzzy),"i"),e.link_no_ip_fuzzy=RegExp(i(e.tpl_link_no_ip_fuzzy),"i"),e.host_fuzzy_test=RegExp(i(e.tpl_host_fuzzy_test),"i");const n=[];function s(t,e){throw new Error('(LinkifyIt) Invalid schema "'+t+'": '+e)}t.__compiled__={},Object.keys(t.__schemas__).forEach((function(e){const r=t.__schemas__[e];if(null===r)return;const i={validate:null,link:null};if(t.__compiled__[e]=i,"[object Object]"===Ju(r))return"[object RegExp]"!==Ju(r.validate)?Uu(r.validate)?i.validate=r.validate:s(e,r):i.validate=function(t){return function(e,r){const i=e.slice(r);return t.test(i)?i.match(t)[0].length:0}}(r.validate),void(Uu(r.normalize)?i.normalize=r.normalize:r.normalize?s(e,r):i.normalize=function(t,e){e.normalize(t)});!function(t){return"[object String]"===Ju(t)}(r)?s(e,r):n.push(e)})),n.forEach((function(e){t.__compiled__[t.__schemas__[e]]&&(t.__compiled__[e].validate=t.__compiled__[t.__schemas__[e]].validate,t.__compiled__[e].normalize=t.__compiled__[t.__schemas__[e]].normalize)})),t.__compiled__[""]={validate:null,normalize:function(t,e){e.normalize(t)}};const o=Object.keys(t.__compiled__).filter((function(e){return e.length>0&&t.__compiled__[e]})).map(Vu).join("|");t.re.schema_test=RegExp("(^|(?!_)(?:[><|]|"+e.src_ZPCc+"))("+o+")","i"),t.re.schema_search=RegExp("(^|(?!_)(?:[><|]|"+e.src_ZPCc+"))("+o+")","ig"),t.re.schema_at_start=RegExp("^"+t.re.schema_search.source,"i"),t.re.pretest=RegExp("("+t.re.schema_test.source+")|("+t.re.host_fuzzy_test.source+")|@","i"),function(t){t.__index__=-1,t.__text_cache__=""}(t)}function Ku(t,e){const r=t.__index__,i=t.__last_index__,n=t.__text_cache__.slice(r,i);this.schema=t.__schema__.toLowerCase(),this.index=r+e,this.lastIndex=i+e,this.raw=n,this.text=n,this.url=n}function Yu(t,e){const r=new Ku(t,e);return t.__compiled__[r.schema].normalize(r,t),r}function Xu(t,e){if(!(this instanceof Xu))return new Xu(t,e);e||Object.keys(t||{}).reduce((function(t,e){return t||Hu.hasOwnProperty(e)}),!1)&&(e=t,t={}),this.__opts__=Lu({},Hu,e),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=Lu({},Wu,t),this.__compiled__={},this.__tlds__=Gu,this.__tlds_replaced__=!1,this.re={},Zu(this)}Xu.prototype.add=function(t,e){return this.__schemas__[t]=e,Zu(this),this},Xu.prototype.set=function(t){return this.__opts__=Lu(this.__opts__,t),this},Xu.prototype.test=function(t){if(this.__text_cache__=t,this.__index__=-1,!t.length)return!1;let e,r,i,n,s,o,l,u,h;if(this.re.schema_test.test(t))for(l=this.re.schema_search,l.lastIndex=0;null!==(e=l.exec(t));)if(n=this.testSchemaAt(t,e[2],l.lastIndex),n){this.__schema__=e[2],this.__index__=e.index+e[1].length,this.__last_index__=e.index+e[0].length+n;break}return this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&(u=t.search(this.re.host_fuzzy_test),u>=0&&(this.__index__<0||u<this.__index__)&&null!==(r=t.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy))&&(s=r.index+r[1].length,(this.__index__<0||s<this.__index__)&&(this.__schema__="",this.__index__=s,this.__last_index__=r.index+r[0].length))),this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]&&(h=t.indexOf("@"),h>=0&&null!==(i=t.match(this.re.email_fuzzy))&&(s=i.index+i[1].length,o=i.index+i[0].length,(this.__index__<0||s<this.__index__||s===this.__index__&&o>this.__last_index__)&&(this.__schema__="mailto:",this.__index__=s,this.__last_index__=o))),this.__index__>=0},Xu.prototype.pretest=function(t){return this.re.pretest.test(t)},Xu.prototype.testSchemaAt=function(t,e,r){return this.__compiled__[e.toLowerCase()]?this.__compiled__[e.toLowerCase()].validate(t,r,this):0},Xu.prototype.match=function(t){const e=[];let r=0;this.__index__>=0&&this.__text_cache__===t&&(e.push(Yu(this,r)),r=this.__last_index__);let i=r?t.slice(r):t;for(;this.test(i);)e.push(Yu(this,r)),i=i.slice(this.__last_index__),r+=this.__last_index__;return e.length?e:null},Xu.prototype.matchAtStart=function(t){if(this.__text_cache__=t,this.__index__=-1,!t.length)return null;const e=this.re.schema_at_start.exec(t);if(!e)return null;const r=this.testSchemaAt(t,e[2],e[0].length);return r?(this.__schema__=e[2],this.__index__=e.index+e[1].length,this.__last_index__=e.index+e[0].length+r,Yu(this,0)):null},Xu.prototype.tlds=function(t,e){return t=Array.isArray(t)?t:[t],e?(this.__tlds__=this.__tlds__.concat(t).sort().filter((function(t,e,r){return t!==r[e-1]})).reverse(),Zu(this),this):(this.__tlds__=t.slice(),this.__tlds_replaced__=!0,Zu(this),this)},Xu.prototype.normalize=function(t){t.schema||(t.url="http://"+t.url),"mailto:"!==t.schema||/^mailto:/i.test(t.url)||(t.url="mailto:"+t.url)},Xu.prototype.onCompile=function(){};const Qu=2147483647,th=36,eh=/^xn--/,rh=/[^\0-\x7F]/,ih=/[\x2E\u3002\uFF0E\uFF61]/g,nh={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},sh=Math.floor,oh=String.fromCharCode;function lh(t){throw new RangeError(nh[t])}function uh(t,e){const r=t.split("@");let i="";r.length>1&&(i=r[0]+"@",t=r[1]);const n=function(t,e){const r=[];let i=t.length;for(;i--;)r[i]=e(t[i]);return r}((t=t.replace(ih,".")).split("."),e).join(".");return i+n}const hh=function(t,e){return t+22+75*(t<26)-((0!=e)<<5)},ah=function(t,e,r){let i=0;for(t=r?sh(t/700):t>>1,t+=sh(t/e);t>455;i+=th)t=sh(t/35);return sh(i+36*t/(t+38))},fh=function(t){return uh(t,(function(t){return rh.test(t)?"xn--"+function(t){const e=[],r=(t=function(t){const e=[];let r=0;const i=t.length;for(;r<i;){const n=t.charCodeAt(r++);if(n>=55296&&n<=56319&&r<i){const i=t.charCodeAt(r++);56320==(64512&i)?e.push(((1023&n)<<10)+(1023&i)+65536):(e.push(n),r--)}else e.push(n)}return e}(t)).length;let i=128,n=0,s=72;for(const r of t)r<128&&e.push(oh(r));const o=e.length;let l=o;for(o&&e.push("-");l<r;){let r=Qu;for(const e of t)e>=i&&e<r&&(r=e);const u=l+1;r-i>sh((Qu-n)/u)&&lh("overflow"),n+=(r-i)*u,i=r;for(const r of t)if(r<i&&++n>Qu&&lh("overflow"),r===i){let t=n;for(let r=th;;r+=th){const i=r<=s?1:r>=s+26?26:r-s;if(t<i)break;const n=t-i,o=th-i;e.push(oh(hh(i+n%o,0))),t=sh(n/o)}e.push(oh(hh(t,0))),s=ah(n,u,l===o),n=0,++l}++n,++i}return e.join("")}(t):t}))},ch=function(t){return uh(t,(function(t){return eh.test(t)?function(t){const e=[],r=t.length;let i=0,n=128,s=72,o=t.lastIndexOf("-");o<0&&(o=0);for(let r=0;r<o;++r)t.charCodeAt(r)>=128&&lh("not-basic"),e.push(t.charCodeAt(r));for(let u=o>0?o+1:0;u<r;){const o=i;for(let e=1,n=th;;n+=th){u>=r&&lh("invalid-input");const o=(l=t.charCodeAt(u++))>=48&&l<58?l-48+26:l>=65&&l<91?l-65:l>=97&&l<123?l-97:th;o>=th&&lh("invalid-input"),o>sh((Qu-i)/e)&&lh("overflow"),i+=o*e;const h=n<=s?1:n>=s+26?26:n-s;if(o<h)break;const a=th-h;e>sh(Qu/a)&&lh("overflow"),e*=a}const h=e.length+1;s=ah(i-o,h,0==o),sh(i/h)>Qu-n&&lh("overflow"),n+=sh(i/h),i%=h,e.splice(i++,0,n)}var l;return String.fromCodePoint(...e)}(t.slice(4).toLowerCase()):t}))},dh={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","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","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"]}}}},ph=/^(vbscript|javascript|file|data):/,mh=/^data:image\/(gif|png|jpeg|webp);/;function gh(t){const e=t.trim().toLowerCase();return!ph.test(e)||mh.test(e)}const wh=["http:","https:","mailto:"];function bh(t){const e=pl(t,!0);if(e.hostname&&(!e.protocol||wh.indexOf(e.protocol)>=0))try{e.hostname=fh(e.hostname)}catch(t){}return tl(el(e))}function vh(t){const e=pl(t,!0);if(e.hostname&&(!e.protocol||wh.indexOf(e.protocol)>=0))try{e.hostname=ch(e.hostname)}catch(t){}return Xo(el(e),Xo.defaultChars+"%")}function kh(t,e){if(!(this instanceof kh))return new kh(t,e);e||Fl(t)||(e=t||{},t="default"),this.inline=new Pu,this.block=new Fu,this.core=new du,this.renderer=new Zl,this.linkify=new Xu,this.validateLink=gh,this.normalizeLink=bh,this.normalizeLinkText=vh,this.utils=Hl,this.helpers=Cl({},Wl),this.options={},this.configure(t),e&&this.set(e)}kh.prototype.set=function(t){return Cl(this.options,t),this},kh.prototype.configure=function(t){const e=this;if(Fl(t)){const e=t;if(!(t=dh[e]))throw new Error('Wrong `markdown-it` preset "'+e+'", check name')}if(!t)throw new Error("Wrong `markdown-it` preset, can't be empty");return t.options&&e.set(t.options),t.components&&Object.keys(t.components).forEach((function(r){t.components[r].rules&&e[r].ruler.enableOnly(t.components[r].rules),t.components[r].rules2&&e[r].ruler2.enableOnly(t.components[r].rules2)})),this},kh.prototype.enable=function(t,e){let r=[];Array.isArray(t)||(t=[t]),["core","block","inline"].forEach((function(e){r=r.concat(this[e].ruler.enable(t,!0))}),this),r=r.concat(this.inline.ruler2.enable(t,!0));const i=t.filter((function(t){return r.indexOf(t)<0}));if(i.length&&!e)throw new Error("MarkdownIt. Failed to enable unknown rule(s): "+i);return this},kh.prototype.disable=function(t,e){let r=[];Array.isArray(t)||(t=[t]),["core","block","inline"].forEach((function(e){r=r.concat(this[e].ruler.disable(t,!0))}),this),r=r.concat(this.inline.ruler2.disable(t,!0));const i=t.filter((function(t){return r.indexOf(t)<0}));if(i.length&&!e)throw new Error("MarkdownIt. Failed to disable unknown rule(s): "+i);return this},kh.prototype.use=function(t){const e=[this].concat(Array.prototype.slice.call(arguments,1));return t.apply(t,e),this},kh.prototype.parse=function(t,e){if("string"!=typeof t)throw new Error("Input data should be a String");const r=new this.core.State(t,this,e);return this.core.process(r),r.tokens},kh.prototype.render=function(t,e){return this.renderer.render(this.parse(t,e=e||{}),this.options,e)},kh.prototype.parseInline=function(t,e){const r=new this.core.State(t,this,e);return r.inlineMode=!0,this.core.process(r),r.tokens},kh.prototype.renderInline=function(t,e){return this.renderer.render(this.parseInline(t,e=e||{}),this.options,e)};const Dh=new ct({nodes:{doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:()=>["p",0]},blockquote:{content:"block+",group:"block",parseDOM:[{tag:"blockquote"}],toDOM:()=>["blockquote",0]},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:()=>["div",["hr"]]},heading:{attrs:{level:{default:1}},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:t=>["h"+t.attrs.level,0]},code_block:{content:"text*",group:"block",code:!0,defining:!0,marks:"",attrs:{params:{default:""}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:t=>({params:t.getAttribute("data-params")||""})}],toDOM:t=>["pre",t.attrs.params?{"data-params":t.attrs.params}:{},["code",0]]},ordered_list:{content:"list_item+",group:"block",attrs:{order:{default:1},tight:{default:!1}},parseDOM:[{tag:"ol",getAttrs:t=>({order:t.hasAttribute("start")?+t.getAttribute("start"):1,tight:t.hasAttribute("data-tight")})}],toDOM:t=>["ol",{start:1==t.attrs.order?null:t.attrs.order,"data-tight":t.attrs.tight?"true":null},0]},bullet_list:{content:"list_item+",group:"block",attrs:{tight:{default:!1}},parseDOM:[{tag:"ul",getAttrs:t=>({tight:t.hasAttribute("data-tight")})}],toDOM:t=>["ul",{"data-tight":t.attrs.tight?"true":null},0]},list_item:{content:"block+",defining:!0,parseDOM:[{tag:"li"}],toDOM:()=>["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:t=>({src:t.getAttribute("src"),title:t.getAttribute("title"),alt:t.getAttribute("alt")})}],toDOM:t=>["img",t.attrs]},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM:()=>["br"]}},marks:{em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:t=>"em"==t.type.name}],toDOM:()=>["em"]},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:t=>"normal"!=t.style.fontWeight&&null},{style:"font-weight=400",clearMark:t=>"strong"==t.type.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}],toDOM:()=>["strong"]},link:{attrs:{href:{},title:{default:null}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs:t=>({href:t.getAttribute("href"),title:t.getAttribute("title")})}],toDOM:t=>["a",t.attrs]},code:{code:!0,parseDOM:[{tag:"code"}],toDOM:()=>["code"]}}});class yh{constructor(t,e){this.schema=t,this.tokenHandlers=e,this.stack=[{type:t.topNodeType,attrs:null,content:[],marks:C.none}]}top(){return this.stack[this.stack.length-1]}push(t){this.stack.length&&this.top().content.push(t)}addText(t){if(!t)return;let e,r=this.top(),i=r.content,n=i[i.length-1],s=this.schema.text(t,r.marks);n&&(e=function(t,e){if(t.isText&&e.isText&&C.sameSet(t.marks,e.marks))return t.withText(t.text+e.text)}(n,s))?i[i.length-1]=e:i.push(s)}openMark(t){let e=this.top();e.marks=t.addToSet(e.marks)}closeMark(t){let e=this.top();e.marks=t.removeFromSet(e.marks)}parseTokens(t){for(let e=0;e<t.length;e++){let r=t[e],i=this.tokenHandlers[r.type];if(!i)throw new Error("Token type `"+r.type+"` not supported by Markdown parser");i(this,r,t,e)}}addNode(t,e,r){let i=this.top(),n=t.createAndFill(e,r,i?i.marks:[]);return n?(this.push(n),n):null}openNode(t,e){this.stack.push({type:t,attrs:e,content:[],marks:C.none})}closeNode(){let t=this.stack.pop();return this.addNode(t.type,t.attrs,t.content)}}function Eh(t,e,r,i){return t.getAttrs?t.getAttrs(e,r,i):t.attrs instanceof Function?t.attrs(e):t.attrs}function xh(t,e){return t.noCloseToken||"code_inline"==e||"code_block"==e||"fence"==e}function Fh(t){return"\n"==t[t.length-1]?t.slice(0,t.length-1):t}function Mh(){}function Ch(t,e){for(;++e<t.length;)if("list_item_open"!=t[e].type)return t[e].hidden;return!1}new class{constructor(t,e,r){this.schema=t,this.tokenizer=e,this.tokens=r,this.tokenHandlers=function(t,e){let r=Object.create(null);for(let i in e){let n=e[i];if(n.block){let e=t.nodeType(n.block);xh(n,i)?r[i]=(t,r,i,s)=>{t.openNode(e,Eh(n,r,i,s)),t.addText(Fh(r.content)),t.closeNode()}:(r[i+"_open"]=(t,r,i,s)=>t.openNode(e,Eh(n,r,i,s)),r[i+"_close"]=t=>t.closeNode())}else if(n.node){let e=t.nodeType(n.node);r[i]=(t,r,i,s)=>t.addNode(e,Eh(n,r,i,s))}else if(n.mark){let e=t.marks[n.mark];xh(n,i)?r[i]=(t,r,i,s)=>{t.openMark(e.create(Eh(n,r,i,s))),t.addText(Fh(r.content)),t.closeMark(e)}:(r[i+"_open"]=(t,r,i,s)=>t.openMark(e.create(Eh(n,r,i,s))),r[i+"_close"]=t=>t.closeMark(e))}else{if(!n.ignore)throw new RangeError("Unrecognized parsing spec "+JSON.stringify(n));xh(n,i)?r[i]=Mh:(r[i+"_open"]=Mh,r[i+"_close"]=Mh)}}return r.text=(t,e)=>t.addText(e.content),r.inline=(t,e)=>t.parseTokens(e.children),r.softbreak=r.softbreak||(t=>t.addText(" ")),r}(t,r)}parse(t,e={}){let r,i=new yh(this.schema,this.tokenHandlers);i.parseTokens(this.tokenizer.parse(t,e));do{r=i.closeNode()}while(i.stack.length);return r||this.schema.topNodeType.createAndFill()}}(Dh,kh("commonmark",{html:!1}),{blockquote:{block:"blockquote"},paragraph:{block:"paragraph"},list_item:{block:"list_item"},bullet_list:{block:"bullet_list",getAttrs:(t,e,r)=>({tight:Ch(e,r)})},ordered_list:{block:"ordered_list",getAttrs:(t,e,r)=>({order:+t.attrGet("start")||1,tight:Ch(e,r)})},heading:{block:"heading",getAttrs:t=>({level:+t.tag.slice(1)})},code_block:{block:"code_block",noCloseToken:!0},fence:{block:"code_block",getAttrs:t=>({params:t.info||""}),noCloseToken:!0},hr:{node:"horizontal_rule"},image:{node:"image",getAttrs:t=>({src:t.attrGet("src"),title:t.attrGet("title")||null,alt:t.children[0]&&t.children[0].content||null})},hardbreak:{node:"hard_break"},em:{mark:"em"},strong:{mark:"strong"},link:{mark:"link",getAttrs:t=>({href:t.attrGet("href"),title:t.attrGet("title")||null})},code_inline:{mark:"code",noCloseToken:!0}});const Ah={open:"",close:"",mixable:!0};class Sh{constructor(t,e,r={}){this.nodes=t,this.marks=e,this.options=r}serialize(t,e={}){e=Object.assign({},this.options,e);let r=new Bh(this.nodes,this.marks,e);return r.renderContent(t),r.out}}const Oh=new Sh({blockquote(t,e){t.wrapBlock("> ",null,e,(()=>t.renderContent(e)))},code_block(t,e){const r=e.textContent.match(/`{3,}/gm),i=r?r.sort().slice(-1)[0]+"`":"```";t.write(i+(e.attrs.params||"")+"\n"),t.text(e.textContent,!1),t.write("\n"),t.write(i),t.closeBlock(e)},heading(t,e){t.write(t.repeat("#",e.attrs.level)+" "),t.renderInline(e,!1),t.closeBlock(e)},horizontal_rule(t,e){t.write(e.attrs.markup||"---"),t.closeBlock(e)},bullet_list(t,e){t.renderList(e," ",(()=>(e.attrs.bullet||"*")+" "))},ordered_list(t,e){let r=e.attrs.order||1,i=String(r+e.childCount-1).length,n=t.repeat(" ",i+2);t.renderList(e,n,(e=>{let n=String(r+e);return t.repeat(" ",i-n.length)+n+". "}))},list_item(t,e){t.renderContent(e)},paragraph(t,e){t.renderInline(e),t.closeBlock(e)},image(t,e){t.write("!["+t.esc(e.attrs.alt||"")+"]("+e.attrs.src.replace(/[\(\)]/g,"\\$&")+(e.attrs.title?' "'+e.attrs.title.replace(/"/g,'\\"')+'"':"")+")")},hard_break(t,e,r,i){for(let n=i+1;n<r.childCount;n++)if(r.child(n).type!=e.type)return void t.write("\\\n")},text(t,e){t.text(e.text,!t.inAutolink)}},{em:{open:"*",close:"*",mixable:!0,expelEnclosingWhitespace:!0},strong:{open:"**",close:"**",mixable:!0,expelEnclosingWhitespace:!0},link:{open:(t,e,r,i)=>(t.inAutolink=function(t,e,r){if(t.attrs.title||!/^\w+:/.test(t.attrs.href))return!1;let i=e.child(r);return!(!i.isText||i.text!=t.attrs.href||i.marks[i.marks.length-1]!=t||r!=e.childCount-1&&t.isInSet(e.child(r+1).marks))}(e,r,i),t.inAutolink?"<":"["),close(t,e,r,i){let{inAutolink:n}=t;return t.inAutolink=void 0,n?">":"]("+e.attrs.href.replace(/[\(\)"]/g,"\\$&")+(e.attrs.title?` "${e.attrs.title.replace(/"/g,'\\"')}"`:"")+")"},mixable:!0},code:{open:(t,e,r,i)=>$h(r.child(i),-1),close:(t,e,r,i)=>$h(r.child(i-1),1),escape:!1}});function $h(t,e){let r,i=/`+/g,n=0;if(t.isText)for(;r=i.exec(t.text);)n=Math.max(n,r[0].length);let s=n>0&&e>0?" `":"`";for(let t=0;t<n;t++)s+="`";return n>0&&e<0&&(s+=" "),s}class Bh{constructor(t,e,r){this.nodes=t,this.marks=e,this.options=r,this.delim="",this.out="",this.closed=null,this.inAutolink=void 0,this.atBlockStart=!1,this.inTightList=!1,void 0===this.options.tightLists&&(this.options.tightLists=!1),void 0===this.options.hardBreakNodeName&&(this.options.hardBreakNodeName="hard_break")}flushClose(t=2){if(this.closed){if(this.atBlank()||(this.out+="\n"),t>1){let e=this.delim,r=/\s+$/.exec(e);r&&(e=e.slice(0,e.length-r[0].length));for(let r=1;r<t;r++)this.out+=e+"\n"}this.closed=null}}getMark(t){let e=this.marks[t];if(!e){if(!1!==this.options.strict)throw new Error(`Mark type \`${t}\` not supported by Markdown renderer`);e=Ah}return e}wrapBlock(t,e,r,i){let n=this.delim;this.write(null!=e?e:t),this.delim+=t,i(),this.delim=n,this.closeBlock(r)}atBlank(){return/(^|\n)$/.test(this.out)}ensureNewLine(){this.atBlank()||(this.out+="\n")}write(t){this.flushClose(),this.delim&&this.atBlank()&&(this.out+=this.delim),t&&(this.out+=t)}closeBlock(t){this.closed=t}text(t,e=!0){let r=t.split("\n");for(let t=0;t<r.length;t++)this.write(),!e&&"["==r[t][0]&&/(^|[^\\])\!$/.test(this.out)&&(this.out=this.out.slice(0,this.out.length-1)+"\\!"),this.out+=e?this.esc(r[t],this.atBlockStart):r[t],t!=r.length-1&&(this.out+="\n")}render(t,e,r){if(this.nodes[t.type.name])this.nodes[t.type.name](this,t,e,r);else{if(!1!==this.options.strict)throw new Error("Token type `"+t.type.name+"` not supported by Markdown renderer");t.type.isLeaf||(t.type.inlineContent?this.renderInline(t):this.renderContent(t),t.isBlock&&this.closeBlock(t))}}renderContent(t){t.forEach(((e,r,i)=>this.render(e,t,i)))}renderInline(t,e=!0){this.atBlockStart=e;let r=[],i="",n=(e,n,s)=>{let o=e?e.marks:[];e&&e.type.name===this.options.hardBreakNodeName&&(o=o.filter((e=>{if(s+1==t.childCount)return!1;let r=t.child(s+1);return e.isInSet(r.marks)&&(!r.isText||/\S/.test(r.text))})));let l=i;if(i="",e&&e.isText&&o.some((t=>{let e=this.getMark(t.type.name);return e&&e.expelEnclosingWhitespace&&!t.isInSet(r)}))){let[t,i,n]=/^(\s*)(.*)$/m.exec(e.text);i&&(l+=i,(e=n?e.withText(n):null)||(o=r))}if(e&&e.isText&&o.some((e=>{let r=this.getMark(e.type.name);return r&&r.expelEnclosingWhitespace&&(s==t.childCount-1||!e.isInSet(t.child(s+1).marks))}))){let[t,n,s]=/^(.*?)(\s*)$/m.exec(e.text);s&&(i=s,(e=n?e.withText(n):null)||(o=r))}let u=o.length?o[o.length-1]:null,h=u&&!1===this.getMark(u.type.name).escape,a=o.length-(h?1:0);t:for(let t=0;t<a;t++){let e=o[t];if(!this.getMark(e.type.name).mixable)break;for(let i=0;i<r.length;i++){let n=r[i];if(!this.getMark(n.type.name).mixable)break;if(e.eq(n)){t>i?o=o.slice(0,i).concat(e).concat(o.slice(i,t)).concat(o.slice(t+1,a)):i>t&&(o=o.slice(0,t).concat(o.slice(t+1,i)).concat(e).concat(o.slice(i,a)));continue t}}}let f=0;for(;f<Math.min(r.length,a)&&o[f].eq(r[f]);)++f;for(;f<r.length;)this.text(this.markString(r.pop(),!1,t,s),!1);if(l&&this.text(l),e){for(;r.length<a;){let e=o[r.length];r.push(e),this.text(this.markString(e,!0,t,s),!1),this.atBlockStart=!1}h&&e.isText?this.text(this.markString(u,!0,t,s)+e.text+this.markString(u,!1,t,s+1),!1):this.render(e,t,s),this.atBlockStart=!1}(null==e?void 0:e.isText)&&e.nodeSize>0&&(this.atBlockStart=!1)};t.forEach(n),n(null,0,t.childCount),this.atBlockStart=!1}renderList(t,e,r){this.closed&&this.closed.type==t.type?this.flushClose(3):this.inTightList&&this.flushClose(1);let i=void 0!==t.attrs.tight?t.attrs.tight:this.options.tightLists,n=this.inTightList;this.inTightList=i,t.forEach(((n,s,o)=>{o&&i&&this.flushClose(1),this.wrapBlock(e,r(o),t,(()=>this.render(n,t,o)))})),this.inTightList=n}esc(t,e=!1){return t=t.replace(/[`*\\~\[\]_]/g,((e,r)=>"_"==e&&r>0&&r+1<t.length&&t[r-1].match(/\w/)&&t[r+1].match(/\w/)?e:"\\"+e)),e&&(t=t.replace(/^(\+[ ]|[\-*>])/,"\\$&").replace(/^(\s*)(#{1,6})(\s|$)/,"$1\\$2$3").replace(/^(\s*\d+)\.\s/,"$1\\. ")),this.options.escapeExtraCharacters&&(t=t.replace(this.options.escapeExtraCharacters,"\\$&")),t}quote(t){let e=-1==t.indexOf('"')?'""':-1==t.indexOf("'")?"''":"()";return e[0]+t+e[1]}repeat(t,e){let r="";for(let i=0;i<e;i++)r+=t;return r}markString(t,e,r,i){let n=this.getMark(t.type.name),s=e?n.open:n.close;return"string"==typeof s?s:s(this,t,r,i)}getEnclosingWhitespace(t){return{leading:(t.match(/^(\s+)/)||[void 0])[0],trailing:(t.match(/(\s+)$/)||[void 0])[0]}}}const Rh=new Map;function Nh(t,e){t.style.height=e.attrs.height,t.style.width=e.attrs.width,t.style.minHeight=e.attrs.minHeight,t.style.minWidth=e.attrs.minWidth,t.style.maxWidth=e.attrs.maxWidth}function _h(t){if("image"===t.type.name)return!0;for(let e=0;e<t.childCount;e++)if(_h(t.child(e)))return!0;return!1}function Th(t){return(e,r)=>{const i=r.attrs.state;if(!zh(i))return;if("success"===i){const t=function(t){const e=[];t.height&&e.push(`height: ${t.height};`),t.width&&e.push(`width: ${t.width};`),t.minHeight&&e.push(`min-height: ${t.minHeight};`),t.minWidth&&e.push(`min-width: ${t.minWidth};`),t.maxWidth&&e.push(`max-width: ${t.maxWidth};`);const r=e.length>0?` style="${e.join("")}"`:"";return`<img src="${t.src}" alt="${t.alt}"${r} />`}(r.attrs);return void e.write(t)}const n=function(t,e,r){return`<span>${p.get(`editor-image-view.${"failed"===t?"failed":"loading"}`,r,{filename:e||"file"})}</span>`}(i,r.attrs.alt,t);e.write(n)}}function zh(t){return"loading"===t||"failed"===t||"success"===t}function qh(t,e){return Ih(t,new Set(e.map((t=>t.tagName))))}function Ih(t,e){if(e.has(t.type.name))return!0;for(let r=0;r<t.childCount;r++)if(Ih(t.child(r),e))return!0;return!1}const jh=t=>(e,r)=>{const i=`<${t.tagName}`+t.attributes.map((t=>` ${t}="${r.attrs[t]}"`)).join("")+">",n=`</${t.tagName}>`;e.write(i),e.renderContent(r),e.write(n)};class Ph{constructor(t,e){this.parseAsHTML=t=>a(t,{whitelist:this.customNodes}),this.serialize=t=>""!==t.state.doc.textContent.trim()||_h(t.state.doc)||qh(t.state.doc,this.customNodes)?this.markdownSerializer.serialize(t.state.doc):"",this.markdownSerializer=((t,e)=>{const r={};for(const e of t)r[e.tagName]=jh(e);const i=Object.assign(Object.assign(Object.assign({},Oh.nodes),function(t){return{image:Th(t)}}(e)),r),n=Object.assign(Object.assign({},Oh.marks),{strikethrough:{open:"~~",close:"~~",mixable:!0,expelEnclosingWhitespace:!0}});return new Sh(i,n)})(t,e),this.customNodes=t}}class Lh{constructor(t){this.parseAsHTML=t=>f(t,this.customNodes),this.serialize=t=>{if(""===t.state.doc.textContent.trim()&&!_h(t.state.doc)&&!qh(t.state.doc,this.customNodes))return"";const e=document.createElement("div");return e.append(xt.fromSchema(t.state.schema).serializeFragment(t.state.doc.content)),e.innerHTML},this.customNodes=t}}const Jh={parseDOM:[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration=line-through"}],toDOM:()=>["s",0]},Uh=new je("linkPlugin"),Vh=(t,e)=>{const r=t.posAtCoords({left:e.clientX,top:e.clientY}),i=t.state.doc.nodeAt(null==r?void 0:r.pos);if(!i)return null;const n=i.marks.find((t=>t.type.name===s.Link));if(!n)return null;const o=n.attrs.href,l=((t,e,r)=>{for(;e>0;){const i=t.nodeAt(e-1);if(!(null==i?void 0:i.isText)||!i.marks.some((t=>t.type.name===s.Link&&t.attrs.href===r)))break;e--}return e})(t.state.doc,r.pos,o),u=((t,e,r)=>{for(;e<t.content.size;){const i=t.nodeAt(e);if(!(null==i?void 0:i.isText)||!i.marks.some((t=>t.type.name===s.Link&&t.attrs.href===r)))break;e++}return e})(t.state.doc,r.pos,o);return{href:o,text:t.state.doc.textBetween(l,u," "),from:l,to:u}},Hh=/(https?:\/\/[^\s<>"']+|mailto:[^\s<>"']+|tel:[^\s<>"']+|www\.[^\s<>"']+)/g,Wh=(t,e)=>t.text(e),Gh=(t,e)=>{const r=(t=>{let e=t.trim();for(;e.endsWith("\\");)e=e.slice(0,-1);return e.toLowerCase().startsWith("www.")&&(e=`https://${e}`),e})(e),i=t.marks.link.create(h(r,r));return t.text(r,[i])},Zh=(t,e)=>{const r=[],i=(t=>{const e=[];let r;for(Hh.lastIndex=0;null!==(r=Hh.exec(t));)e.push({url:r[0],start:r.index,end:r.index+r[0].length});return e})(t);if(0===i.length)return[Wh(e,t)];let n=0;for(const s of i)s.start>n&&r.push(Wh(e,t.slice(n,s.start))),r.push(Gh(e,s.url)),n=s.end;return n<t.length&&r.push(Wh(e,t.slice(n))),r},Kh=(t,e)=>{var r;const i=null===(r=e.clipboardData)||void 0===r?void 0:r.getData("text/plain");if(!i||!(t=>(Hh.lastIndex=0,Hh.test(t)))(i))return!1;const n=((t,e)=>{const r=t.split(/\r\n|\r|\n/),i=[];for(const[t,n]of r.entries())if(n.length>0&&i.push(...Zh(n,e)),t<r.length-1){const t=e.nodes.hard_break;t?i.push(t.create()):console.warn("hard_break node not found in schema")}return i})(i,t.state.schema);return e.preventDefault(),((t,e)=>{0!==e.length&&((t=>{if(1!==t.length)return!1;const e=t[0];return!(!e.isText||!e.text||""===e.text.trim())&&e.marks.some((t=>"link"===t.type.name))})(e)?((t,e)=>{const{state:r,dispatch:i}=t,{from:n,to:s}=r.selection,o=e.marks.find((t=>"link"===t.type.name)),l=r.doc.textBetween(n,s," ")||o.attrs.href;i(r.tr.insertText(l,n,s).addMark(n,n+l.length,o))})(t,e[0]):((t,e)=>{const{state:r,dispatch:i}=t,{from:n,to:s}=r.selection,o=E.fromArray(e);i(r.tr.replaceWith(n,s,o))})(t,e))})(t,n),!0},Yh=t=>new ze({key:Uh,props:{handlePaste:(t,e)=>Kh(t,e),handleDOMEvents:{mousedown:(t,e)=>{if((e.metaKey||e.ctrlKey)&&0===e.button)return((t,e)=>{const r=Vh(t,e);if(!r.href)return!1;e.preventDefault();const{href:i}=r;return!!i&&(window.open(i,"_blank","noopener,noreferrer"),!0)})(t,e)},dblclick:(t,e)=>{if(e.button!==l.Right)return((t,e)=>{const r=Vh(t,e);if(!r)return!1;const{href:i,text:n,from:s,to:o}=r,l=t.state.tr.setSelection(ye.create(t.state.doc,s,o));return t.dispatch(l),((t,e,r)=>{const i=new CustomEvent("open-editor-link-menu",{detail:{href:e,text:r},bubbles:!0,composed:!0});t.dom.dispatchEvent(i)})(t,i,n),!0})(t,e)},click:(t,e)=>{e.target instanceof HTMLElement&&e.target.closest("a")&&(e.preventDefault(),e.stopPropagation())}}},view:()=>({update:e=>{((t,e)=>{const{from:r,to:i}=t.state.selection;let n="",s="";t.state.doc.nodesBetween(r,i,((t,e)=>{if("text"!==t.type.name)return;const o=Math.max(0,r-e),l=Math.min(t.text.length,i-e);n+=t.text.slice(o,l),t.marks.forEach((t=>{"link"===t.type.name&&(s=t.attrs.href)}))})),e&&e(n,s)})(e,t)}})}),Xh={attrs:{href:{default:""},title:{default:null},target:{default:null},rel:{default:null},referrerpolicy:{default:null}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs:t=>({href:t.getAttribute("href")||"",title:t.getAttribute("title"),target:t.getAttribute("target"),rel:t.getAttribute("rel"),referrerpolicy:t.getAttribute("referrerpolicy")})}],toDOM:t=>{const e=t.attrs.target||null,r={rel:"_blank"===e?"noopener noreferrer":null,referrerpolicy:"_blank"===e?"noreferrer":null};return["a",Object.assign(Object.assign({},t.attrs),r),0]}},Qh=new je("imageInserterPlugin"),ta=(t,e,r)=>({fileInfo:r,insertThumbnail:ea(t,e,r),insertImage:ra(t,r),insertFailedThumbnail:ia(t,r)}),ea=(t,e,r)=>()=>{const{state:i,dispatch:n}=t,{schema:s}=i,o=na(e,r,"loading"),l=s.nodes.image.create(o);n(i.tr.replaceSelectionWith(l))},ra=(t,e)=>r=>{const{state:i,dispatch:n}=t,{schema:s}=i,o=i.tr;i.doc.descendants(((t,i)=>{if(t.attrs.fileInfoId===e.id){const n=na(null!=r?r:t.attrs.src,e,"success"),l=s.nodes.image.create(n);return o.replaceWith(i,i+t.nodeSize,l),!1}})),n(o)},ia=(t,e)=>()=>{const{state:r,dispatch:i}=t,{schema:n}=r,s=r.tr;r.doc.descendants(((t,r)=>{if(t.attrs.fileInfoId===e.id){const i=na(t.attrs.src,e,"failed"),o=n.nodes.image.create(i);return s.replaceWith(r,r+t.nodeSize,o),!1}})),i(s)};function na(t,e,r){return{src:t,alt:e.filename,fileInfoId:e.id,state:r}}const sa=t=>{if(t instanceof W){if("image"===t.type.name)return!0;let e=!1;return t.content.forEach((t=>{sa(t)&&(e=!0)})),e}if(t instanceof E){let e=!1;return t.forEach((t=>{sa(t)&&(e=!0)})),e}return!1},oa=t=>{const e=[];return t.forEach((t=>{if(!sa(t))if(t.content.size>0){const r=oa(t.content),i=t.copy(r);e.push(i)}else e.push(t)})),E.fromArray(e)};function la(t,e){var r,i;if(!function(t){return!!(null==t?void 0:t.type)&&t.type.startsWith("image/")}(t))return!1;const n=null!==(i=null===(r=null==e?void 0:e.getData("text/html"))||void 0===r?void 0:r.toLowerCase())&&void 0!==i?i:"";return!function(t){return!!t&&(t.includes('name=generator content="microsoft excel"')||t.includes('xmlns:x="urn:schemas-microsoft-com:office:excel"'))}(n)&&!function(t){return!!t&&t.includes("<table")}(n)}class ua{constructor(t,e,r,i){this.createResizeHandle=t=>{const e=document.createElement("div");return e.className=`resize-handle ${t}`,e.setAttribute("role","slider"),e.setAttribute("aria-label",p.get("editor-image-view.resize-handle",this.language)),e.setAttribute("tabindex","0"),e.setAttribute("aria-valuemin",10..toString()),e.setAttribute("aria-valuenow",this.img.offsetWidth.toString()),e.setAttribute("aria-valuetext",`${this.img.offsetWidth} pixels`),e.setAttribute("aria-grabbed","false"),e.addEventListener("pointerdown",(r=>{e.setAttribute("aria-grabbed","true"),this.onResizeStart(r,t)})),e},this.onResizeStart=(t,e)=>{t.preventDefault();const r=t.target,i=t.clientX,n=this.img.offsetWidth;this.img.style.height="";const s=t=>{const r=t.clientX-i,s=Math.max(10,n+("top-left"===e?-r:r));this.img.style.width=`${s}px`;const o=this.dom.querySelectorAll(".resize-handle");for(const t of o)t.setAttribute("aria-valuenow",s.toString()),t.setAttribute("aria-valuetext",`${s} pixels`)},o=()=>{window.removeEventListener("pointermove",s),window.removeEventListener("pointerup",o),r.setAttribute("aria-grabbed","false"),this.persistDimensions()};window.addEventListener("pointermove",s),window.addEventListener("pointerup",o)},this.createLoadingState=()=>{this.dom.setAttribute("aria-live","polite"),this.dom.setAttribute("aria-busy","true"),this.dom.setAttribute("aria-label",p.get("editor-image-view.loading",this.language,{filename:this.node.attrs.alt||"file"}));const t=document.createElement("limel-linear-progress");t.setAttribute("indeterminate","true"),this.dom.append(t)},this.createSuccessState=()=>{this.dom.setAttribute("aria-live","polite"),this.dom.setAttribute("aria-busy","false"),this.dom.setAttribute("aria-label",p.get("editor-image-view.success",this.language,{filename:this.node.attrs.alt||"file"}));const t=this.createResizeHandle("bottom-right"),e=this.createResizeHandle("top-left");this.dom.append(t),this.dom.append(e)},this.createFailedState=()=>{this.dom.setAttribute("aria-live","assertive"),this.dom.setAttribute("aria-busy","false"),this.dom.setAttribute("aria-label",p.get("editor-image-view.failed",this.language,{filename:this.node.attrs.alt||"file"}))},this.cleanUpPreviousState=()=>{for(const t of this.dom.childNodes)t instanceof HTMLImageElement||t.remove()},this.transitionBetweenStates=()=>{var t;this.cleanUpPreviousState(),this.dom.className=`image-wrapper state-${this.node.attrs.state}`;const e={loading:this.createLoadingState,success:this.createSuccessState,failed:this.createFailedState};null===(t=e[this.node.attrs.state])||void 0===t||t.call(e)},this.transitioningBetweenSuccessStates=t=>"success"===this.node.attrs.state&&"success"===t.attrs.state,this.node=t,this.view=e,this.getPos=r,this.language=i,this.dom=document.createElement("div"),this.dom.className=`image-wrapper state-${t.attrs.state}`,this.img=document.createElement("img"),this.img.src=t.attrs.src,this.img.alt=t.attrs.alt,Nh(this.img,t),this.img.addEventListener("load",(()=>{this.persistDimensions()})),this.dom.append(this.img),this.transitionBetweenStates()}persistDimensions(){this.view.dispatch(this.view.state.tr.setNodeMarkup(this.getPos(),void 0,Object.assign(Object.assign({},this.node.attrs),{height:`${this.img.offsetHeight}px`,width:`${this.img.offsetWidth}px`,minHeight:`${this.img.offsetHeight}px`,minWidth:`${this.img.offsetWidth}px`})))}update(t){return this.transitioningBetweenSuccessStates(t)||(this.img.src=t.attrs.src,this.img.alt=t.attrs.alt,Nh(this.img,t)),this.node=t,this.transitionBetweenStates(),!0}}const ha=new je("actionBarPlugin"),aa=new je("actionBarInteractionPlugin"),fa=(t,e)=>{const{state:r}=e,i=r.selection;let n=r.tr;i.empty||n.setSelection(i),t(r,(t=>{n=t})),e.dispatch(n),e.focus()},ca=t=>new ze({key:aa,props:{handleDOMEvents:{actionBarItemClick:(e,r)=>{r.preventDefault(),r.stopPropagation();const{value:i}=r.detail;try{const r=t.getCommand(i);fa(r,e)}catch(t){console.error(`Error executing command: ${t}`)}return!0},saveLinkMenu:(e,r)=>{r.preventDefault(),r.stopPropagation();const{type:i,link:n}=r.detail;if(i===s.Link)try{const r=t.getCommand(i,n);fa(r,e)}catch(t){console.error(`Error executing command: ${t}`)}return!0}}}}),da=t=>{const e={};for(const r of t.attributes)e[r]={};return{group:"inline",content:"(text* | inline*)",inline:!0,atom:!0,selectable:!0,attrs:e,toDOM:e=>[t.tagName,e.attrs],parseDOM:[{tag:`${t.tagName}[${t.attributes.map((t=>t)).join("][")}]`,getAttrs:e=>{const r={};return t.attributes.forEach((t=>r[t]=e.getAttribute(t))),r}}]}},pa=(t,e,r,i)=>{const n=t.state.schema;return async s=>{const o=document.createElement("span");o.innerHTML=await e.parseAsHTML(s,n);const l=pt.fromSchema(n).parse(o).content;i(t,r.position,l)}},ma=(t,e,r)=>({insert:ga(t,r),insertHtml:pa(t,e,r,ba),stopTrigger:()=>wa(t)}),ga=(t,e)=>r=>{const i=t.state.schema;let n;try{n=va(r,i)}catch(t){return void console.error(t.message)}const s=i.text(" "),o=i.nodes.doc.create(null,[n,s]);ba(t,e.position,o)},wa=t=>{const{state:e,dispatch:r}=t,i=e.tr;i.setMeta("stopTrigger",!0),r(i)},ba=(t,e,r)=>{const i=t.state,n=t.dispatch,s=i.tr.replaceWith(e,i.selection.$from.pos,r);s.setMeta("stopTrigger",!0),n(s)},va=(t,e)=>{var r;if("string"==typeof t)return e.text(t);const i=t.node;if("string"==typeof i)return e.text(i);const n=ka(i.tagName,e),s=(null!==(r=t.children)&&void 0!==r?r:[]).map((t=>va(t,e))).filter(Boolean);return n.create(i.attributes,s)},ka=(t,e)=>{const r=Object.values(e.nodes).find((e=>e.name===t));if(!r)throw new Error(`No custom element has been registered for node ${t}`);return r},Da=(t,e,r,i)=>({trigger:r.character,textEditor:ma(t,e,r),value:i}),ya=(t,e,r,i,n)=>{const s=new CustomEvent(t,{detail:Da(e,r,i,n),bubbles:!0,composed:!0});e.dom.dispatchEvent(s)},Ea=(t,e)=>{let r=null,i=null;const n=()=>{i=null},s=((t,e)=>(r,n,s,o)=>{if(!e.includes(o))return!1;const l=r.state.doc.textBetween(n-1,n,"");if(/\s/.test(l)||""===l){const e={character:o,position:n};(t=>{i=t})(e),ya("triggerStart",r,t,e,o)}return!1})(e,t),o=((t,e,r,i)=>(n,s,o)=>{const l=e();if(!l)return;const u=((t,e,r,i,n)=>{if(!e||e.position<1)return!1;for(const s of t.steps)if(s instanceof Lt){const{from:t,to:o,slice:l}=s;if(t<=e.position&&o>=e.position&&!l.content.textBetween(0,l.content.size,"").includes(e.character))return r(),ya("triggerStop",n,i,e,""),!0}return!1})(n[0],l,r,i,t());if(u)r();else{for(const t of n)t.docChanged&&(l.position=t.mapping.map(l.position,-1));((t,e,r,i,n)=>{let s="";r>e.position&&(s=t.textBetween(e.position+1,r,"")),ya("triggerChange",n,i,e,s)})(o.doc,l,o.selection.from,i,t())}})((()=>r),(()=>i),n,e);return new ze({key:new je("triggerPlugin"),view:t=>(r=t,{}),state:{init:()=>({}),apply:t=>(t.getMeta("stopTrigger")&&(ya("triggerStop",r,e,i,""),n()),{})},props:{handleTextInput:s},appendTransaction:o})};var xa,Fa;if("undefined"!=typeof WeakMap){let t=new WeakMap;xa=e=>t.get(e),Fa=(e,r)=>(t.set(e,r),r)}else{const t=[],e=10;let r=0;xa=e=>{for(let r=0;r<t.length;r+=2)if(t[r]==e)return t[r+1]},Fa=(i,n)=>(r==e&&(r=0),t[r++]=i,t[r++]=n)}var Ma=class{constructor(t,e,r,i){this.width=t,this.height=e,this.map=r,this.problems=i}findCell(t){for(let e=0;e<this.map.length;e++){const r=this.map[e];if(r!=t)continue;const i=e%this.width,n=e/this.width|0;let s=i+1,o=n+1;for(let t=1;s<this.width&&this.map[e+t]==r;t++)s++;for(let t=1;o<this.height&&this.map[e+this.width*t]==r;t++)o++;return{left:i,top:n,right:s,bottom:o}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,r){const{left:i,right:n,top:s,bottom:o}=this.findCell(t);return"horiz"==e?(r<0?0==i:n==this.width)?null:this.map[s*this.width+(r<0?i-1:n)]:(r<0?0==s:o==this.height)?null:this.map[i+this.width*(r<0?s-1:o)]}rectBetween(t,e){const{left:r,right:i,top:n,bottom:s}=this.findCell(t),{left:o,right:l,top:u,bottom:h}=this.findCell(e);return{left:Math.min(r,o),top:Math.min(n,u),right:Math.max(i,l),bottom:Math.max(s,h)}}cellsInRect(t){const e=[],r={};for(let i=t.top;i<t.bottom;i++)for(let n=t.left;n<t.right;n++){const s=i*this.width+n,o=this.map[s];r[o]||(r[o]=!0,n==t.left&&n&&this.map[s-1]==o||i==t.top&&i&&this.map[s-this.width]==o||e.push(o))}return e}positionAt(t,e,r){for(let i=0,n=0;;i++){const s=n+r.child(i).nodeSize;if(i==t){let r=e+t*this.width;const i=(t+1)*this.width;for(;r<i&&this.map[r]<n;)r++;return r==i?s-1:this.map[r]}n=s}}static get(t){return xa(t)||Fa(t,function(t){if("table"!=t.type.spec.tableRole)throw new RangeError("Not a table node: "+t.type.name);const e=function(t){let e=-1,r=!1;for(let i=0;i<t.childCount;i++){const n=t.child(i);let s=0;if(r)for(let e=0;e<i;e++){const r=t.child(e);for(let t=0;t<r.childCount;t++){const n=r.child(t);e+n.attrs.rowspan>i&&(s+=n.attrs.colspan)}}for(let t=0;t<n.childCount;t++){const e=n.child(t);s+=e.attrs.colspan,e.attrs.rowspan>1&&(r=!0)}-1==e?e=s:e!=s&&(e=Math.max(e,s))}return e}(t),r=t.childCount,i=[];let n=0,s=null;const o=[];for(let t=0,n=e*r;t<n;t++)i[t]=0;for(let l=0,u=0;l<r;l++){const h=t.child(l);u++;for(let t=0;;t++){for(;n<i.length&&0!=i[n];)n++;if(t==h.childCount)break;const a=h.child(t),{colspan:f,rowspan:c,colwidth:d}=a.attrs;for(let t=0;t<c;t++){if(t+l>=r){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:c-t});break}const h=n+t*e;for(let t=0;t<f;t++){0==i[h+t]?i[h+t]=u:(s||(s=[])).push({type:"collision",row:l,pos:u,n:f-t});const r=d&&d[t];if(r){const i=(h+t)%e*2,n=o[i];null==n||n!=r&&1==o[i+1]?(o[i]=r,o[i+1]=1):n==r&&o[i+1]++}}}n+=f,u+=a.nodeSize}const a=(l+1)*e;let f=0;for(;n<a;)0==i[n++]&&f++;f&&(s||(s=[])).push({type:"missing",row:l,n:f}),u++}0!==e&&0!==r||(s||(s=[])).push({type:"zero_sized"});const l=new Ma(e,r,i,s);let u=!1;for(let t=0;!u&&t<o.length;t+=2)null!=o[t]&&o[t+1]<r&&(u=!0);return u&&function(t,e,r){t.problems||(t.problems=[]);const i={};for(let n=0;n<t.map.length;n++){const s=t.map[n];if(i[s])continue;i[s]=!0;const o=r.nodeAt(s);if(!o)throw new RangeError(`No cell with offset ${s} found`);let l=null;const u=o.attrs;for(let r=0;r<u.colspan;r++){const i=e[(n+r)%t.width*2];null==i||u.colwidth&&u.colwidth[r]==i||((l||(l=Ca(u)))[r]=i)}l&&t.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}(l,o,t),l}(t))}};function Ca(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let r=0;r<t.colspan;r++)e.push(0);return e}function Aa(t,e){if("string"==typeof t)return{};const r=t.getAttribute("data-colwidth"),i=r&&/^\d+(,\d+)*$/.test(r)?r.split(",").map((t=>Number(t))):null,n=Number(t.getAttribute("colspan")||1),s={colspan:n,rowspan:Number(t.getAttribute("rowspan")||1),colwidth:i&&i.length==n?i:null};for(const r in e){const i=e[r].getFromDOM,n=i&&i(t);null!=n&&(s[r]=n)}return s}function Sa(t,e){const r={};1!=t.attrs.colspan&&(r.colspan=t.attrs.colspan),1!=t.attrs.rowspan&&(r.rowspan=t.attrs.rowspan),t.attrs.colwidth&&(r["data-colwidth"]=t.attrs.colwidth.join(","));for(const i in e){const n=e[i].setDOMAttr;n&&n(t.attrs[i],r)}return r}function Oa(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const r in t.nodes){const i=t.nodes[r],n=i.spec.tableRole;n&&(e[n]=i)}}return e}var $a=new je("selectingCells");function Ba(t){for(let e=t.depth-1;e>0;e--)if("row"==t.node(e).type.spec.tableRole)return t.node(0).resolve(t.before(e+1));return null}function Ra(t){return"row"==t.parent.type.spec.tableRole&&!!t.nodeAfter}function Na(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function _a(t,e,r){const i=t.node(-1),n=Ma.get(i),s=t.start(-1),o=n.nextCell(t.pos-s,e,r);return null==o?null:t.node(0).resolve(s+o)}function Ta(t,e,r=1){const i={...t,colspan:t.colspan-r};return i.colwidth&&(i.colwidth=i.colwidth.slice(),i.colwidth.splice(e,r),i.colwidth.some((t=>t>0))||(i.colwidth=null)),i}var za=class t extends be{constructor(t,e=t){const r=t.node(-1),i=Ma.get(r),n=t.start(-1),s=i.rectBetween(t.pos-n,e.pos-n),o=t.node(0),l=i.cellsInRect(s).filter((t=>t!=e.pos-n));l.unshift(e.pos-n);const u=l.map((t=>{const e=r.nodeAt(t);if(!e)throw RangeError(`No cell with offset ${t} found`);const i=n+t+1;return new ve(o.resolve(i),o.resolve(i+e.content.size))}));super(u[0].$from,u[0].$to,u),this.$anchorCell=t,this.$headCell=e}map(e,r){const i=e.resolve(r.map(this.$anchorCell.pos)),n=e.resolve(r.map(this.$headCell.pos));if(Ra(i)&&Ra(n)&&Na(i,n)){const e=this.$anchorCell.node(-1)!=i.node(-1);return e&&this.isRowSelection()?t.rowSelection(i,n):e&&this.isColSelection()?t.colSelection(i,n):new t(i,n)}return ye.between(i,n)}content(){const t=this.$anchorCell.node(-1),e=Ma.get(t),r=this.$anchorCell.start(-1),i=e.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),n={},s=[];for(let r=i.top;r<i.bottom;r++){const o=[];for(let s=r*e.width+i.left,l=i.left;l<i.right;l++,s++){const r=e.map[s];if(n[r])continue;n[r]=!0;const l=e.findCell(r);let u=t.nodeAt(r);if(!u)throw RangeError(`No cell with offset ${r} found`);const h=i.left-l.left,a=l.right-i.right;if(h>0||a>0){let t=u.attrs;if(h>0&&(t=Ta(t,0,h)),a>0&&(t=Ta(t,t.colspan-a,a)),l.left<i.left){if(u=u.type.createAndFill(t),!u)throw RangeError(`Could not create cell with attrs ${JSON.stringify(t)}`)}else u=u.type.create(t,u.content)}if(l.top<i.top||l.bottom>i.bottom){const t={...u.attrs,rowspan:Math.min(l.bottom,i.bottom)-Math.max(l.top,i.top)};u=l.top<i.top?u.type.createAndFill(t):u.type.create(t,u.content)}o.push(u)}s.push(t.child(r).copy(E.from(o)))}const o=this.isColSelection()&&this.isRowSelection()?t:s;return new S(E.from(o),1,1)}replace(t,e=S.empty){const r=t.steps.length,i=this.ranges;for(let n=0;n<i.length;n++){const{$from:s,$to:o}=i[n],l=t.mapping.slice(r);t.replace(l.map(s.pos),l.map(o.pos),n?S.empty:e)}const n=be.findFrom(t.doc.resolve(t.mapping.slice(r).map(this.to)),-1);n&&t.setSelection(n)}replaceWith(t,e){this.replace(t,new S(E.from(e),0,0))}forEachCell(t){const e=this.$anchorCell.node(-1),r=Ma.get(e),i=this.$anchorCell.start(-1),n=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let r=0;r<n.length;r++)t(e.nodeAt(n[r]),i+n[r])}isColSelection(){const t=this.$anchorCell.index(-1),e=this.$headCell.index(-1);return!(Math.min(t,e)>0)&&Math.max(t+this.$anchorCell.nodeAfter.attrs.rowspan,e+this.$headCell.nodeAfter.attrs.rowspan)==this.$headCell.node(-1).childCount}static colSelection(e,r=e){const i=e.node(-1),n=Ma.get(i),s=e.start(-1),o=n.findCell(e.pos-s),l=n.findCell(r.pos-s),u=e.node(0);return o.top<=l.top?(o.top>0&&(e=u.resolve(s+n.map[o.left])),l.bottom<n.height&&(r=u.resolve(s+n.map[n.width*(n.height-1)+l.right-1]))):(l.top>0&&(r=u.resolve(s+n.map[l.left])),o.bottom<n.height&&(e=u.resolve(s+n.map[n.width*(n.height-1)+o.right-1]))),new t(e,r)}isRowSelection(){const t=this.$anchorCell.node(-1),e=Ma.get(t),r=this.$anchorCell.start(-1),i=e.colCount(this.$anchorCell.pos-r),n=e.colCount(this.$headCell.pos-r);return!(Math.min(i,n)>0)&&Math.max(i+this.$anchorCell.nodeAfter.attrs.colspan,n+this.$headCell.nodeAfter.attrs.colspan)==e.width}eq(e){return e instanceof t&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,r=e){const i=e.node(-1),n=Ma.get(i),s=e.start(-1),o=n.findCell(e.pos-s),l=n.findCell(r.pos-s),u=e.node(0);return o.left<=l.left?(o.left>0&&(e=u.resolve(s+n.map[o.top*n.width])),l.right<n.width&&(r=u.resolve(s+n.map[n.width*(l.top+1)-1]))):(l.left>0&&(r=u.resolve(s+n.map[l.top*n.width])),o.right<n.width&&(e=u.resolve(s+n.map[n.width*(o.top+1)-1]))),new t(e,r)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,r){return new t(e.resolve(r.anchor),e.resolve(r.head))}static create(e,r,i=r){return new t(e.resolve(r),e.resolve(i))}getBookmark(){return new qa(this.$anchorCell.pos,this.$headCell.pos)}};za.prototype.visible=!1,be.jsonID("cell",za);var qa=class t{constructor(t,e){this.anchor=t,this.head=e}map(e){return new t(e.map(this.anchor),e.map(this.head))}resolve(t){const e=t.resolve(this.anchor),r=t.resolve(this.head);return"row"==e.parent.type.spec.tableRole&&"row"==r.parent.type.spec.tableRole&&e.index()<e.parent.childCount&&r.index()<r.parent.childCount&&Na(e,r)?new za(e,r):be.near(r,1)}};function Ia(t){if(!(t.selection instanceof za))return null;const e=[];return t.selection.forEachCell(((t,r)=>{e.push(vn.node(r,r+t.nodeSize,{class:"selectedCell"}))})),yn.create(t.doc,e)}var ja=new je("fix-tables");function Pa(t,e,r,i){const n=t.childCount,s=e.childCount;t:for(let o=0,l=0;o<s;o++){const s=e.child(o);for(let e=l,i=Math.min(n,o+3);e<i;e++)if(t.child(e)==s){l=e+1,r+=s.nodeSize;continue t}i(s,r),l<n&&t.child(l).sameMarkup(s)?Pa(t.child(l),s,r+1,i):s.nodesBetween(0,s.content.size,i,r+1),r+=s.nodeSize}}function La(t,e){let r;const i=(e,i)=>{"table"==e.type.spec.tableRole&&(r=function(t,e,r,i){const n=Ma.get(e);if(!n.problems)return i;i||(i=t.tr);const s=[];for(let t=0;t<n.height;t++)s.push(0);for(let t=0;t<n.problems.length;t++){const o=n.problems[t];if("collision"==o.type){const t=e.nodeAt(o.pos);if(!t)continue;const n=t.attrs;for(let t=0;t<n.rowspan;t++)s[o.row+t]+=o.n;i.setNodeMarkup(i.mapping.map(r+1+o.pos),null,Ta(n,n.colspan-o.n,o.n))}else if("missing"==o.type)s[o.row]+=o.n;else if("overlong_rowspan"==o.type){const t=e.nodeAt(o.pos);if(!t)continue;i.setNodeMarkup(i.mapping.map(r+1+o.pos),null,{...t.attrs,rowspan:t.attrs.rowspan-o.n})}else if("colwidth mismatch"==o.type){const t=e.nodeAt(o.pos);if(!t)continue;i.setNodeMarkup(i.mapping.map(r+1+o.pos),null,{...t.attrs,colwidth:o.colwidth})}else if("zero_sized"==o.type){const t=i.mapping.map(r);i.delete(t,t+e.nodeSize)}}let o,l;for(let t=0;t<s.length;t++)s[t]&&(null==o&&(o=t),l=t);for(let u=0,h=r+1;u<n.height;u++){const r=e.child(u),n=h+r.nodeSize,a=s[u];if(a>0){let e="cell";r.firstChild&&(e=r.firstChild.type.spec.tableRole);const s=[];for(let r=0;r<a;r++){const r=Oa(t.schema)[e].createAndFill();r&&s.push(r)}i.insert(i.mapping.map(0!=u&&o!=u-1||l!=u?n-1:h+1),s)}h=n}return i.setMeta(ja,{fixTables:!0})}(t,e,i,r))};return e?e.doc!=t.doc&&Pa(e.doc,t.doc,0,i):t.doc.descendants(i),r}function Ja(t,e){const r=t.selection;if(!(r instanceof za))return!1;if(e){const i=t.tr,n=Oa(t.schema).cell.createAndFill().content;r.forEachCell(((t,e)=>{t.content.eq(n)||i.replace(i.mapping.map(e+1),i.mapping.map(e+t.nodeSize-1),new S(n,0,0))})),i.docChanged&&e(i)}return!0}function Ua(t,e){const r=t.createAndFill();return new ge(r).replace(0,r.content.size,e).doc}function Va(t,e,r,i,n,s,o,l){if(0==o||o==e.height)return!1;let u=!1;for(let h=n;h<s;h++){const n=o*e.width+h,s=e.map[n];if(e.map[n-e.width]==s){u=!0;const n=r.nodeAt(s),{top:a,left:f}=e.findCell(s);t.setNodeMarkup(t.mapping.slice(l).map(s+i),null,{...n.attrs,rowspan:o-a}),t.insert(t.mapping.slice(l).map(e.positionAt(o,f,r)),n.type.createAndFill({...n.attrs,rowspan:a+n.attrs.rowspan-o})),h+=n.attrs.colspan-1}}return u}function Ha(t,e,r,i,n,s,o,l){if(0==o||o==e.width)return!1;let u=!1;for(let h=n;h<s;h++){const n=h*e.width+o,s=e.map[n];if(e.map[n-1]==s){u=!0;const n=r.nodeAt(s),a=e.colCount(s),f=t.mapping.slice(l).map(s+i);t.setNodeMarkup(f,null,Ta(n.attrs,o-a,n.attrs.colspan-(o-a))),t.insert(f+n.nodeSize,n.type.createAndFill(Ta(n.attrs,0,o-a))),h+=n.attrs.rowspan-1}}return u}function Wa(t,e,r,i,n){let s=r?t.doc.nodeAt(r-1):t.doc;if(!s)throw new Error("No table found");let o=Ma.get(s);const{top:l,left:u}=i,h=u+n.width,a=l+n.height,f=t.tr;let c=0;function d(){if(s=r?f.doc.nodeAt(r-1):f.doc,!s)throw new Error("No table found");o=Ma.get(s),c=f.mapping.maps.length}(function(t,e,r,i,n,s,o){const l=Oa(t.doc.type.schema);let u,h;if(n>e.width)for(let s=0,a=0;s<e.height;s++){const f=r.child(s);a+=f.nodeSize;const c=[];let d;d=null==f.lastChild||f.lastChild.type==l.cell?u||(u=l.cell.createAndFill()):h||(h=l.header_cell.createAndFill());for(let t=e.width;t<n;t++)c.push(d);t.insert(t.mapping.slice(o).map(a-1+i),c)}if(s>e.height){const a=[];for(let t=0,i=(e.height-1)*e.width;t<Math.max(e.width,n);t++){const n=!(t>=e.width)&&r.nodeAt(e.map[i+t]).type==l.header_cell;a.push(n?h||(h=l.header_cell.createAndFill()):u||(u=l.cell.createAndFill()))}const f=l.row.create(null,E.from(a)),c=[];for(let t=e.height;t<s;t++)c.push(f);t.insert(t.mapping.slice(o).map(i+r.nodeSize-2),c)}return!(!u&&!h)})(f,o,s,r,h,a,c)&&d(),Va(f,o,s,r,u,h,l,c)&&d(),Va(f,o,s,r,u,h,a,c)&&d(),Ha(f,o,s,r,l,a,u,c)&&d(),Ha(f,o,s,r,l,a,h,c)&&d();for(let t=l;t<a;t++){const e=o.positionAt(t,u,s),i=o.positionAt(t,h,s);f.replace(f.mapping.slice(c).map(e+r),f.mapping.slice(c).map(i+r),new S(n.rows[t-l],0,0))}d(),f.setSelection(new za(f.doc.resolve(r+o.positionAt(l,u,s)),f.doc.resolve(r+o.positionAt(a-1,h-1,s)))),e(f)}var Ga=Ms({ArrowLeft:Ka("horiz",-1),ArrowRight:Ka("horiz",1),ArrowUp:Ka("vert",-1),ArrowDown:Ka("vert",1),"Shift-ArrowLeft":Ya("horiz",-1),"Shift-ArrowRight":Ya("horiz",1),"Shift-ArrowUp":Ya("vert",-1),"Shift-ArrowDown":Ya("vert",1),Backspace:Ja,"Mod-Backspace":Ja,Delete:Ja,"Mod-Delete":Ja});function Za(t,e,r){return!r.eq(t.selection)&&(e&&e(t.tr.setSelection(r).scrollIntoView()),!0)}function Ka(t,e){return(r,i,n)=>{if(!n)return!1;const s=r.selection;if(s instanceof za)return Za(r,i,be.near(s.$headCell,e));if("horiz"!=t&&!s.empty)return!1;const o=ef(n,t,e);if(null==o)return!1;if("horiz"==t)return Za(r,i,be.near(r.doc.resolve(s.head+e),e));{const n=r.doc.resolve(o),s=_a(n,t,e);let l;return l=s?be.near(s,1):e<0?be.near(r.doc.resolve(n.before(-1)),-1):be.near(r.doc.resolve(n.after(-1)),1),Za(r,i,l)}}}function Ya(t,e){return(r,i,n)=>{if(!n)return!1;const s=r.selection;let o;if(s instanceof za)o=s;else{const i=ef(n,t,e);if(null==i)return!1;o=new za(r.doc.resolve(i))}const l=_a(o.$headCell,t,e);return!!l&&Za(r,i,new za(o.$anchorCell,l))}}function Xa(t,e){const r=Ba(t.state.doc.resolve(e));return!!r&&(t.dispatch(t.state.tr.setSelection(new za(r))),!0)}function Qa(t,e,r){if(!function(t){const e=t.selection.$head;for(let t=e.depth;t>0;t--)if("row"==e.node(t).type.spec.tableRole)return!0;return!1}(t.state))return!1;let i=function(t){if(!t.size)return null;let{content:e,openStart:r,openEnd:i}=t;for(;1==e.childCount&&(r>0&&i>0||"table"==e.child(0).type.spec.tableRole);)r--,i--,e=e.child(0).content;const n=e.child(0),s=n.type.spec.tableRole,o=n.type.schema,l=[];if("row"==s)for(let t=0;t<e.childCount;t++){let n=e.child(t).content;const s=t?0:Math.max(0,r-1),u=t<e.childCount-1?0:Math.max(0,i-1);(s||u)&&(n=Ua(Oa(o).row,new S(n,s,u)).content),l.push(n)}else{if("cell"!=s&&"header_cell"!=s)return null;l.push(r||i?Ua(Oa(o).row,new S(e,r,i)).content:e)}return function(t,e){const r=[];for(let t=0;t<e.length;t++){const i=e[t];for(let e=i.childCount-1;e>=0;e--){const{rowspan:n,colspan:s}=i.child(e).attrs;for(let e=t;e<t+n;e++)r[e]=(r[e]||0)+s}}let i=0;for(let t=0;t<r.length;t++)i=Math.max(i,r[t]);for(let n=0;n<r.length;n++)if(n>=e.length&&e.push(E.empty),r[n]<i){const s=Oa(t).cell.createAndFill(),o=[];for(let t=r[n];t<i;t++)o.push(s);e[n]=e[n].append(E.from(o))}return{height:e.length,width:i,rows:e}}(o,l)}(r);const n=t.state.selection;if(n instanceof za){i||(i={width:1,height:1,rows:[E.from(Ua(Oa(t.state.schema).cell,r))]});const e=n.$anchorCell.node(-1),s=n.$anchorCell.start(-1),o=Ma.get(e).rectBetween(n.$anchorCell.pos-s,n.$headCell.pos-s);return i=function({width:t,height:e,rows:r},i,n){if(t!=i){const e=[],n=[];for(let t=0;t<r.length;t++){const s=r[t],o=[];for(let r=e[t]||0,n=0;r<i;n++){let l=s.child(n%s.childCount);r+l.attrs.colspan>i&&(l=l.type.createChecked(Ta(l.attrs,l.attrs.colspan,r+l.attrs.colspan-i),l.content)),o.push(l),r+=l.attrs.colspan;for(let r=1;r<l.attrs.rowspan;r++)e[t+r]=(e[t+r]||0)+l.attrs.colspan}n.push(E.from(o))}r=n,t=i}if(e!=n){const t=[];for(let i=0,s=0;i<n;i++,s++){const o=[],l=r[s%e];for(let t=0;t<l.childCount;t++){let e=l.child(t);i+e.attrs.rowspan>n&&(e=e.type.create({...e.attrs,rowspan:Math.max(1,n-e.attrs.rowspan)},e.content)),o.push(e)}t.push(E.from(o))}r=t,e=n}return{width:t,height:e,rows:r}}(i,o.right-o.left,o.bottom-o.top),Wa(t.state,t.dispatch,s,o,i),!0}if(i){const e=function(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&"cell"==e.node.type.spec.tableRole)return e.$anchor;const r=Ba(e.$head)||function(t){for(let e=t.nodeAfter,r=t.pos;e;e=e.firstChild,r++){const i=e.type.spec.tableRole;if("cell"==i||"header_cell"==i)return t.doc.resolve(r)}for(let e=t.nodeBefore,r=t.pos;e;e=e.lastChild,r--){const i=e.type.spec.tableRole;if("cell"==i||"header_cell"==i)return t.doc.resolve(r-e.nodeSize)}}(e.$head);if(r)return r;throw new RangeError(`No cell found around position ${e.head}`)}(t.state),r=e.start(-1);return Wa(t.state,t.dispatch,r,Ma.get(e.node(-1)).findCell(e.pos-r),i),!0}return!1}function tf(t,e){var r;if(e.ctrlKey||e.metaKey)return;const i=rf(t,e.target);let n;if(e.shiftKey&&t.state.selection instanceof za)s(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&i&&null!=(n=Ba(t.state.selection.$anchor))&&(null==(r=nf(t,e))?void 0:r.pos)!=n.pos)s(n,e),e.preventDefault();else if(!i)return;function s(e,r){let i=nf(t,r);const n=null==$a.getState(t.state);if(!i||!Na(e,i)){if(!n)return;i=e}const s=new za(e,i);if(n||!t.state.selection.eq(s)){const r=t.state.tr.setSelection(s);n&&r.setMeta($a,e.pos),t.dispatch(r)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",l),null!=$a.getState(t.state)&&t.dispatch(t.state.tr.setMeta($a,-1))}function l(r){const n=r,l=$a.getState(t.state);let u;if(null!=l)u=t.state.doc.resolve(l);else if(rf(t,n.target)!=i&&(u=nf(t,e),!u))return o();u&&s(u,n)}t.root.addEventListener("mouseup",o),t.root.addEventListener("dragstart",o),t.root.addEventListener("mousemove",l)}function ef(t,e,r){if(!(t.state.selection instanceof ye))return null;const{$head:i}=t.state.selection;for(let n=i.depth-1;n>=0;n--){const s=i.node(n);if((r<0?i.index(n):i.indexAfter(n))!=(r<0?0:s.childCount))return null;if("cell"==s.type.spec.tableRole||"header_cell"==s.type.spec.tableRole){const s=i.before(n);return t.endOfTextblock("vert"==e?r>0?"down":"up":r>0?"right":"left")?s:null}}return null}function rf(t,e){for(;e&&e!=t.dom;e=e.parentNode)if("TD"==e.nodeName||"TH"==e.nodeName)return e;return null}function nf(t,e){const r=t.posAtCoords({left:e.clientX,top:e.clientY});return r&&r?Ba(t.state.doc.resolve(r.pos)):null}function sf({allowTableNodeSelection:t=!1}={}){return new ze({key:$a,state:{init:()=>null,apply(t,e){const r=t.getMeta($a);if(null!=r)return-1==r?null:r;if(null==e||!t.docChanged)return e;const{deleted:i,pos:n}=t.mapping.mapResult(e);return i?null:n}},props:{decorations:Ia,handleDOMEvents:{mousedown:tf},createSelectionBetween:t=>null!=$a.getState(t.state)?t.state.selection:null,handleTripleClick:Xa,handleKeyDown:Ga,handlePaste:Qa},appendTransaction:(e,r,i)=>function(t,e,r){const i=(e||t).selection,n=(e||t).doc;let s,o;if(i instanceof xe&&(o=i.node.type.spec.tableRole)){if("cell"==o||"header_cell"==o)s=za.create(n,i.from);else if("row"==o){const t=n.resolve(i.from+1);s=za.rowSelection(t,t)}else if(!r){const t=Ma.get(i.node),e=i.from+1;s=za.create(n,e+1,e+t.map[t.width*t.height-1])}}else i instanceof ye&&function({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let r=t.pos,i=e.pos,n=t.depth;for(;n>=0&&!(t.after(n+1)<t.end(n));n--,r++);for(let t=e.depth;t>=0&&!(e.before(t+1)>e.start(t));t--,i--);return r==i&&/row|table/.test(t.node(n).type.spec.tableRole)}(i)?s=ye.create(n,i.from):i instanceof ye&&function({$from:t,$to:e}){let r,i;for(let e=t.depth;e>0;e--){const i=t.node(e);if("cell"===i.type.spec.tableRole||"header_cell"===i.type.spec.tableRole){r=i;break}}for(let t=e.depth;t>0;t--){const r=e.node(t);if("cell"===r.type.spec.tableRole||"header_cell"===r.type.spec.tableRole){i=r;break}}return r!==i&&0===e.parentOffset}(i)&&(s=ye.create(n,i.$from.start(),i.$from.end()));return s&&(e||(e=t.tr)).setSelection(s),e}(i,La(i,r),t)})}new je("tableColumnResizing");const of=t=>({default:null,getFromDOM:e=>e.style[t]||null,setDOMAttr:(e,r)=>{e&&(r.style=(r.style||"")+`${t}: ${e};`)}});function lf(t){const e={images:[],links:[]};return t.descendants((t=>{if(function(t){return"image"===t.type.name&&!!t.attrs}(t))e.images.push(function(t){return{src:t.attrs.src,state:t.attrs.state,fileInfoId:t.attrs.fileInfoId}}(t));else if(function(t){var e;return t.isText&&(null===(e=t.marks)||void 0===e?void 0:e.length)>0}(t))for(const r of function(t){return t.marks.filter((t=>"link"===t.type.name&&t.attrs)).map((e=>({href:e.attrs.href,text:t.text})))}(t))e.links.push(r);return!0})),e}function uf(t){const e=new Map;for(const r of t){const t=`${r.fileInfoId}|${r.state}|${r.src}`;e.set(t,(e.get(t)||0)+1)}return e}function hf(t){const e=new Map;for(const r of t){const t=`${r.href}|${r.text}`;e.set(t,(e.get(t)||0)+1)}return e}function af(t,e){if(t.size!==e.size)return!1;for(const[r,i]of t.entries())if(e.get(r)!==i)return!1;return!0}const ff=class{constructor(r){t(this,r),this.change=e(this,"change"),this.imagePasted=e(this,"imagePasted"),this.imageRemoved=e(this,"imageRemoved"),this.metadataChange=e(this,"metadataChange"),this.contentType="markdown",this.disabled=!1,this.customElements=[],this.triggerCharacters=[],this.ui="standard",this.actionBarItems=[],this.link={href:"https://"},this.isLinkMenuOpen=!1,this.changeWaiting=!1,this.transactionFired=!1,this.lastClickedPos=null,this.metadata={images:[],links:[]},this.suppressChangeEvent=!1,this.getActionBarItems=()=>{this.actionBarItems=Zo().map(this.getTranslatedItem)},this.getTranslatedItem=t=>{const e=c(t);if(g(t)){const r=Ko[t.value];r&&(e.text=p.get(r,this.language))}return e},this.updateActiveActionBarItems=(t,e)=>{const r=Zo().map((r=>g(r)?Object.assign(Object.assign({},r),{selected:t[r.value],allowed:e[r.value]}):r));this.actionBarItems=r.filter((t=>!g(t)||t.allowed))},this.handleTransaction=t=>{this.transactionFired=!0;const e=this.view.state.apply(t);if(this.view.updateState(e),this.suppressChangeEvent||t.getMeta("pointer"))return;const r=this.contentConverter.serialize(this.view,this.schema);if(r===this.lastEmittedValue)return;const i=lf(e.doc);this.metadataEmitter(i),this.lastEmittedValue=r,this.changeWaiting=!0,this.changeEmitter(r)},this.handleActionBarItem=t=>{t.preventDefault(),t.stopImmediatePropagation();const{value:e}=t.detail;if(e===s.Link)return void(this.isLinkMenuOpen=!0);const r=new CustomEvent("actionBarItemClick",{detail:t.detail});this.view.dom.dispatchEvent(r)},this.handleCancelLinkMenu=t=>{t.preventDefault(),t.stopPropagation(),this.isLinkMenuOpen=!1,this.link={text:"",href:"https://"}},this.handleSaveLinkMenu=()=>{this.isLinkMenuOpen=!1;const t=new CustomEvent("saveLinkMenu",{detail:{type:s.Link,link:this.link}});this.view.dom.dispatchEvent(t),this.link={href:"https://"}},this.handleLinkChange=t=>{this.link=t.detail},this.handleFocus=()=>{var t;this.disabled||(null===(t=this.view)||void 0===t||t.focus(),this.transactionFired=!1,setTimeout((()=>{if(!this.transactionFired&&this.lastClickedPos){const{doc:t,tr:e}=this.view.state,r=t.resolve(this.lastClickedPos),i=be.near(r);e.setMeta("pointer",!0),this.view.dispatch(e.setSelection(i))}}),0))},this.handleNewLinkSelection=(t,e)=>{this.link.text=t,this.link.href=e||"https://"},this.handleOpenLinkMenu=t=>{t.stopImmediatePropagation();const{href:e,text:r}=t.detail;this.link={href:e,text:r},this.isLinkMenuOpen=!0},this.handleMouseDown=t=>{var e;const r=this.view.posAtCoords({left:t.clientX,top:t.clientY});this.lastClickedPos=null!==(e=null==r?void 0:r.pos)&&void 0!==e?e:null},this.changeEmitter=v((t=>{this.change.emit(t),this.changeWaiting=!1}),300),this.handleBlur=()=>{this.changeEmitter.flush()},this.portalId=m()}watchValue(t){this.view&&(this.changeWaiting||t!==this.contentConverter.serialize(this.view,this.schema)&&this.updateView(t))}componentWillLoad(){this.getActionBarItems(),this.setupContentConverter()}componentDidLoad(){setTimeout((()=>{this.initializeTextEditor()}),0)}connectedCallback(){this.view&&this.initializeTextEditor(),this.host.addEventListener("open-editor-link-menu",this.handleOpenLinkMenu)}disconnectedCallback(){var t,e,r,i,n;Rh.clear(),this.host.removeEventListener("open-editor-link-menu",this.handleOpenLinkMenu),null===(e=null===(t=this.view)||void 0===t?void 0:t.dom)||void 0===e||e.removeEventListener("blur",this.handleBlur),null===(i=null===(r=this.view)||void 0===r?void 0:r.dom)||void 0===i||i.removeEventListener("mousedown",this.handleMouseDown),null===(n=this.view)||void 0===n||n.destroy()}render(){return r(i,{key:"b7dbbd5a73e68e2df2b52f36f6d57bc0885f87a3",onFocus:this.handleFocus},r("div",{key:"a630b7eacb1b5be9460b85944e2a3a5955661437",id:"editor"}),this.renderToolbar(),this.renderLinkMenu())}renderToolbar(){if(0!==this.actionBarItems.length&&"no-toolbar"!==this.ui)return r("div",{class:"toolbar"},r("limel-action-bar",{ref:t=>this.actionBarElement=t,accessibleLabel:"Toolbar",actions:this.actionBarItems,onItemSelected:this.handleActionBarItem}))}renderLinkMenu(){if(this.isLinkMenuOpen)return r("limel-portal",{containerId:this.portalId,visible:this.isLinkMenuOpen,openDirection:"top",inheritParentWidth:!0,anchor:this.actionBarElement},r("limel-text-editor-link-menu",{link:this.link,isOpen:this.isLinkMenuOpen,onLinkChange:this.handleLinkChange,onCancel:this.handleCancelLinkMenu,onSave:this.handleSaveLinkMenu}))}setupContentConverter(){if("markdown"===this.contentType)this.contentConverter=new Ph(this.customElements,this.language);else{if("html"!==this.contentType)throw new Error(`Unsupported content type: ${this.contentType}. Only 'markdown' and 'html' are supported.`);this.contentConverter=new Lh(this.customElements)}}async initializeTextEditor(){this.schema=this.initializeSchema();const t=await this.parseInitialContent();this.menuCommandFactory=new Vo(this.schema),this.view=new Hn(this.host.shadowRoot.querySelector("#editor"),{state:this.createEditorState(t),dispatchTransaction:this.handleTransaction}),this.view.dom.addEventListener("blur",this.handleBlur),this.view.dom.addEventListener("mousedown",this.handleMouseDown),this.value&&this.updateView(this.value),this.lastEmittedValue=this.contentConverter.serialize(this.view,this.schema)}initializeSchema(){let t=ls.spec.nodes;for(const e of this.customElements){const r=da(e),i=e.tagName;t=t.append({[i]:r})}return t=function(t,e,r){return t.append({ordered_list:ps(fs,{content:"list_item+",group:r}),bullet_list:ps(cs,{content:"list_item+",group:r}),list_item:ps(ds,{content:"paragraph block*"})})}(t,0,"block"),"html"===this.contentType&&(t=t.append(function(t){const e=t.cellAttributes||{},r={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(const t in e)r[t]={default:e[t].default};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:t.tableGroup,parseDOM:[{tag:"table"}],toDOM:()=>["table",["tbody",0]]},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM:()=>["tr",0]},table_cell:{content:t.cellContent,attrs:r,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:t=>Aa(t,e)}],toDOM:t=>["td",Sa(t,e),0]},table_header:{content:t.cellContent,attrs:r,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:t=>Aa(t,e)}],toDOM:t=>["th",Sa(t,e),0]}}}({tableGroup:"block",cellContent:"block+",cellAttributes:{background:of("background-color"),color:of("color")}}))),t=t.append({image:(e=this.language,{group:"inline",inline:!0,attrs:{src:{default:""},alt:{default:""},fileInfoId:{default:""},height:{default:""},width:{default:""},minHeight:{default:""},minWidth:{default:""},maxWidth:{default:"100%"},state:{default:"success"}},toDOM:t=>{if(zh(t.attrs.state))return"success"===t.attrs.state?function(t,e){let r=Rh.get(t);return r?function(t,e){t.alt=e.attrs.alt,Nh(t,e)}(r,e):(r=function(t){const e=document.createElement("img");return e.src=t.attrs.src,e.alt=t.attrs.alt,Nh(e,t),e}(e),Rh.set(t,r)),r}(t.attrs.fileInfoId,t):function(t,e,r){return function(t,e,r){const i=p.get(`editor-image-view.${t}`,r,{filename:e.attrs.alt||"file"}),n=document.createElement("span");return n.textContent=i,n}("failed"===t?"failed":"loading",e,r)}(t.attrs.state,t,e)},parseDOM:[{tag:"img",getAttrs:t=>({src:t.getAttribute("src")||"",alt:t.getAttribute("alt")||"file",width:t.style.width||"",height:t.style.height||"",maxWidth:"100%",state:"success",fileInfoId:crypto.randomUUID()})}]})}),new ct({nodes:t,marks:ls.spec.marks.append({strikethrough:Jh,link:Xh})});var e}async parseInitialContent(){const t=document.createElement("div");return t.innerHTML=this.value?await this.contentConverter.parseAsHTML(this.value,this.schema):"<p></p>",pt.fromSchema(this.schema).parse(t)}createEditorState(t){return _e.create({doc:t,plugins:[..._o({schema:this.schema}),Fs(this.menuCommandFactory.buildKeymap()),Ea(this.triggerCharacters,this.contentConverter),Yh(this.handleNewLinkSelection),(o=this.imagePasted.emit,new ze({key:Qh,props:{handlePaste:(t,e,r)=>((t,e,r)=>{const i=e.clipboardData;if(!i)return!1;const n=function(t,e){let r=!1;const i=[...e.files||[]];for(const n of i)if(la(n,e)){r=!0;const e=new FileReader;e.onloadend=()=>{t.dom.dispatchEvent(new CustomEvent("imagePasted",{detail:ta(t,e.result,w(n))}))},e.readAsDataURL(n)}return r}(t,i),s=new S(oa(r.content),r.openStart,r.openEnd);if(s.content.childCount<r.content.childCount){const{state:e,dispatch:r}=t;return r(e.tr.replaceSelection(s)),!0}return n})(t,e,r),handleDOMEvents:{imagePasted:(t,e)=>{o(e.detail)}}}})),(s=this.language,new ze({props:{nodeViews:{image:(t,e,r)=>new ua(t,e,r,s)}}})),(r=u,i=this.menuCommandFactory,n=this.updateActiveActionBarItems,new ze({key:ha,state:{init:()=>({active:{},allowed:{}}),apply:(t,e)=>{const r=t.getMeta(ha);return null!=r?r:e}},view:()=>({update:t=>{const e=ha.getState(t.state),s=((t,e,r)=>{var i,n,s;const o={},l={};for(const u of t){const t=e.getCommand(u);o[u]=!!(null===(i=null==t?void 0:t.active)||void 0===i?void 0:i.call(t,r.state))||!1,l[u]=!(null!==(s=null===(n=null==t?void 0:t.allowed)||void 0===n?void 0:n.call(t,r.state))&&void 0!==s&&!s)}return{active:o,allowed:l}})(r,i,t);if(!b(e,s)){const e=t.state.tr.setMeta(ha,s);t.dispatch(e),n(s.active,s.allowed)}}})})),ca(this.menuCommandFactory),...(e="html"===this.contentType,e?[sf()]:[])]});var e,r,i,n,s,o}async updateView(t){this.suppressChangeEvent=!0;const e=await this.contentConverter.parseAsHTML(t,this.schema),r=pt.fromSchema(this.view.state.schema),i=(new window.DOMParser).parseFromString(e,"text/html"),n=r.parse(i.body),s=this.view.state.tr;s.replaceWith(0,s.doc.content.size,n.content),this.view.dispatch(s);const o=lf(this.view.state.doc);this.metadataEmitter(o),this.suppressChangeEvent=!1}metadataEmitter(t){var e,r,i,n;(function(t,e){return t.images.length!==e.images.length||t.links.length!==e.links.length}(e=this.metadata,r=t)||(n=r.links,!af(hf(e.links),hf(n)))||(i=r.images,!af(uf(e.images),uf(i))))&&(this.removeImagesFromCache(this.metadata,t),this.metadata=t,this.metadataChange.emit(t))}removeImagesFromCache(t,e){const r=t.images.filter((t=>!e.images.some((e=>e.fileInfoId===t.fileInfoId))));for(const t of r)Rh.delete(t.fileInfoId),this.imageRemoved.emit(t)}static get delegatesFocus(){return!0}get host(){return n(this)}static get watchers(){return{value:[{watchValue:0}]}}};ff.style='@charset "UTF-8";blockquote{position:relative;max-width:100%;margin:0.75rem 0;padding:0.5rem;border-left:0.25rem solid rgb(var(--contrast-500));background-color:rgb(var(--contrast-200))}blockquote:before,blockquote:after{position:absolute;line-height:0;font-size:2rem;opacity:0.4}blockquote:before{content:"“";left:-0.5rem;top:0.5rem}blockquote:after{content:"”";right:-0.25rem;bottom:-0.25rem}blockquote blockquote{padding-top:0;padding-right:0;padding-bottom:0;padding-left:0.25rem;border-color:rgb(var(--contrast-700));border-left-width:1px}blockquote blockquote:before,blockquote blockquote:after{display:none}blockquote:has(>blockquote){padding-left:0.25rem;padding-bottom:0}:host(limel-markdown.truncate-paragraphs) p{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}p,li{font-size:var(--limel-theme-default-font-size);word-break:break-word}a{word-break:break-all}p{margin-top:0;margin-bottom:0.5rem}p:last-child{margin-bottom:0}a{transition:color 0.2s ease;color:var(--markdown-hyperlink-color, rgb(var(--color-blue-dark)));text-decoration:none}a:hover{color:var(--markdown-hyperlink-color--hovered, rgb(var(--color-blue-default)))}hr{margin:1.75rem 0 2rem 0;border-width:0;border-top:1px solid rgb(var(--contrast-500))}dl{display:grid;grid-template-columns:1fr 2fr;grid-template-rows:1fr;margin-bottom:2rem;border:1px solid rgb(var(--contrast-400));border-radius:0.375rem;background-color:rgb(var(--contrast-200))}dl dt,dl dd{padding:0.375rem 0.5rem;font-size:var(--limel-theme-default-font-size);margin:0}dl dt:nth-of-type(even),dl dd:nth-of-type(even){background-color:rgb(var(--contrast-300))}dl dt:first-child{border-top-left-radius:0.375rem}dl dt:last-child{border-bottom-left-radius:0.375rem}dl dd:first-child{border-top-right-radius:0.375rem}dl dd:last-child{border-bottom-right-radius:0.375rem}h1{font-size:1.5rem}h2{font-size:1.25rem}h3{font-size:1.125rem}h4{font-size:1rem}h5{font-size:var(--limel-theme-default-font-size)}h6{font-size:0.75rem}h1,h2{margin-top:0.5rem;margin-bottom:0.5rem;letter-spacing:-0.03125rem;font-weight:500}h3,h4{margin-top:0.75rem;margin-bottom:0.25rem;font-weight:600}h5,h6{margin-top:0.5rem;margin-bottom:0.125rem;font-weight:600}h1,h2,h3,h4,h5,h6{word-break:break-word;hyphens:auto;-webkit-hyphens:auto}h1 code,h2 code,h3 code,h4 code,h5 code,h6 code{font-size:inherit}:not([contenteditable=true]) h1,:not([contenteditable=true]) h2,:not([contenteditable=true]) h3,:not([contenteditable=true]) h4,:not([contenteditable=true]) h5,:not([contenteditable=true]) h6{text-wrap:balance}[contenteditable=true] h1,[contenteditable=true] h2,[contenteditable=true] h3,[contenteditable=true] h4,[contenteditable=true] h5,[contenteditable=true] h6{text-wrap:initial}ul{list-style:none}ul li{position:relative;margin-left:0.75rem}ul li:before{content:"";position:absolute;left:-0.5rem;top:0.5rem;width:0.25rem;height:0.25rem;border-radius:50%;background-color:rgb(var(--contrast-700));display:block}ol{margin-top:0.25rem;padding-left:1rem}ul{margin-top:0.25rem;padding-left:0}ul ul,ul ol,ol ol,ol ul{margin-left:0}li{margin-bottom:0.25rem}pre,pre p,code{font-family:ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, "DejaVu Sans Mono", monospace;font-size:0.75rem}pre{max-width:100%;white-space:pre-wrap;word-wrap:break-word}code{letter-spacing:-0.0125rem;color:rgb(var(--contrast-1300));tab-size:4;hyphens:none;display:inline;border-radius:0.25rem;padding:0.03125rem 0.25rem;background-color:rgb(var(--contrast-600))}pre>code{display:block;margin:0.5rem 0;padding:0.5rem 0.75rem}:host(limel-markdown:not(.no-table-styles)) table{table-layout:auto;min-width:100%;border-collapse:collapse;border-spacing:0;background:transparent;margin:0.75rem 0}:host(limel-markdown:not(.no-table-styles)) tbody{border:1px solid rgb(var(--contrast-400));border-radius:0.25rem}:host(limel-markdown:not(.no-table-styles)) th,:host(limel-markdown:not(.no-table-styles)) td{text-align:left;vertical-align:top;transition:background-color 0.2s ease;font-size:var(--limel-theme-default-font-size)}:host(limel-markdown:not(.no-table-styles)) th p,:host(limel-markdown:not(.no-table-styles)) th li,:host(limel-markdown:not(.no-table-styles)) th a,:host(limel-markdown:not(.no-table-styles)) td p,:host(limel-markdown:not(.no-table-styles)) td li,:host(limel-markdown:not(.no-table-styles)) td a{word-break:normal;overflow-wrap:normal}:host(limel-markdown:not(.no-table-styles)) td{padding:0.5rem 0.375rem 0.75rem 0.375rem}:host(limel-markdown:not(.no-table-styles)) tr th{background-color:rgb(var(--contrast-400));padding:0.25rem 0.375rem;font-weight:normal}:host(limel-markdown:not(.no-table-styles)) tr th:only-child{text-align:center}:host(limel-markdown:not(.no-table-styles)) tbody tr:nth-child(odd) td{background-color:rgb(var(--contrast-200))}:host(limel-markdown:not(.no-table-styles)) tbody tr:hover td{background-color:rgb(var(--contrast-300))}table{display:block;box-sizing:border-box;overflow-x:auto;-webkit-overflow-scrolling:touch;max-width:100%}kbd{display:inline-block;font-family:ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, "DejaVu Sans Mono", monospace;font-weight:600;color:rgb(var(--contrast-1100));white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:normal;border-radius:0.125rem;border-style:solid;border-color:rgb(var(--contrast-500));border-width:0 1px 0.1875rem 1px;padding:0.0625rem 0.375rem;margin:0 0.25rem;background-color:rgb(var(--contrast-200));box-shadow:var(--button-shadow-normal), 0 0.625rem 0.375rem -0.5rem rgb(var(--color-black), 0.02), 0 0.025rem 0.5rem 0 rgb(var(--contrast-100)) inset}img{max-width:100%;border-radius:0.25rem}.image-wrapper{display:inline-flex;position:relative}.image-wrapper limel-linear-progress{position:absolute;inset:0.25rem auto auto 0.25rem;width:calc(100% - 0.5rem)}.image-wrapper img{transition:opacity 0.2s ease, scale 0.6s ease}.image-wrapper.state-failed,.image-wrapper.state-loading{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns=\'http://www.w3.org/2000/svg\'%20viewBox=\'0%200%208%208\'%20style=\'fill-rule:evenodd;\'%3E%3Cpath%20fill=\'rgba(186,186,192,0.16)\'%20d=\'M0%200h4v4H0zM4%204h4v4H4z\'/%3E%3C/svg%3E");background-size:0.5rem}.image-wrapper.state-failed img,.image-wrapper.state-loading img{opacity:0.3;scale:0.98}.image-wrapper::before{pointer-events:none;content:"";display:block;position:absolute;inset:0;border-radius:0.25rem;transition:border-color 0.4s ease, opacity 0.2s ease, box-shadow 0.6s ease;border:1px dashed transparent;opacity:0.2}.image-wrapper.state-failed img{filter:grayscale(0.8)}.image-wrapper.state-failed:before{opacity:0.8;box-shadow:var(--shadow-error-state)}.image-wrapper:hover::before{opacity:0.8;box-shadow:var(--shadow-depth-8)}.image-wrapper:has(.resize-handle[aria-grabbed=true])::before{border-color:var(--lime-primary-color, var(--limel-theme-primary-color));opacity:0.8;box-shadow:var(--shadow-depth-16), var(--shadow-depth-8)}.resize-handle{transition:color var(--limel-clickable-transition-speed, 0.4s) ease, background-color var(--limel-clickable-transition-speed, 0.4s) ease, box-shadow var(--limel-clickable-transform-speed, 0.4s) ease, transform var(--limel-clickable-transform-speed, 0.4s) var(--limel-clickable-transform-timing-function, ease);cursor:pointer;color:var(--limel-theme-on-surface-color);background-color:rgb(var(--contrast-900));box-shadow:var(--button-shadow-normal)}.resize-handle:hover,.resize-handle:focus,.resize-handle:focus-visible{will-change:color, background-color, box-shadow, transform}.resize-handle:hover,.resize-handle:focus-visible{transform:translate3d(0, -0.04rem, 0);color:var(--limel-theme-on-surface-color);background-color:var(--lime-elevated-surface-background-color);box-shadow:var(--button-shadow-hovered)}.resize-handle:active{--limel-clickable-transform-timing-function:cubic-bezier( 0.83, -0.15, 0.49, 1.16 );transform:translate3d(0, 0.05rem, 0);box-shadow:var(--button-shadow-pressed)}.resize-handle:hover,.resize-handle:active{--limel-clickable-transition-speed:0.2s;--limel-clickable-transform-speed:0.16s}.resize-handle:focus{outline:none}.resize-handle:focus-visible{outline:none;box-shadow:var(--shadow-depth-8-focused)}.resize-handle{cursor:nwse-resize;position:absolute;display:flex;align-items:center;justify-content:center;width:0.5rem;height:0.5rem;border-radius:50%}.resize-handle.top-left{left:-0.25rem;top:-0.25rem;translate:-50%, -50%}.resize-handle.bottom-right{right:-0.25rem;bottom:-0.25rem;translate:50%, 50%}.resize-handle{opacity:0.6}.resize-wrapper:has(.resize-handle[aria-grabbed=true]) .resize-handle,.resize-wrapper:hover .resize-handle,.resize-handle:hover,.resize-handle:focus-visible{opacity:1}.resize-handle[aria-grabbed=true],.resize-handle:hover,.resize-handle:focus-visible{opacity:1;background-color:var(--lime-primary-color, var(--limel-theme-primary-color))}.resize-handle:hover,.resize-handle[aria-grabbed=true]{scale:1.4}.resize-handle:hover:before,.resize-handle[aria-grabbed=true]:before{background-color:rgb(var(--color-white))}.resize-handle:before{content:"";display:block;position:absolute;inset:0;margin:auto;border-radius:50%;width:0.25rem;height:0.25rem;background-color:rgb(var(--contrast-100))}:host(limel-prosemirror-adapter){display:flex;flex-direction:column}:host(limel-prosemirror-adapter) .toolbar{order:1}:host(limel-prosemirror-adapter) div#editor{order:2;height:100%;flex-grow:1}:host(limel-prosemirror-adapter) div[contenteditable=true]{height:100%}*{box-sizing:border-box}:host(limel-prosemirror-adapter:hover) .toolbar,:host(limel-prosemirror-adapter:focus-within) .toolbar{will-change:grid-template-rows}:host(limel-prosemirror-adapter:hover) limel-action-bar,:host(limel-prosemirror-adapter:focus-within) limel-action-bar{will-change:opacity, padding}.ProseMirror-menubar-wrapper{display:grid;grid-template-rows:auto 1fr}.ProseMirror-textblock-dropdown{min-width:3em}.ProseMirror-tooltip .ProseMirror-menu{width:-webkit-fit-content;width:fit-content;white-space:pre}.toolbar{--action-bar-border-radius:0.25rem;border-radius:var(--action-bar-border-radius);flex-shrink:0;position:sticky;z-index:1;top:0;width:100%;display:grid;grid-template-rows:var(--limel-prosemirror-adapter-toolbar-grid-template-rows);transition-property:grid-template-rows;transition-duration:var(--limel-prosemirror-adapter-toolbar-grid-template-rows-transition-duration);transition-timing-function:var(--limel-prosemirror-adapter-toolbar-transition-timing-function);background-color:rgba(var(--contrast-200), 0.5);backdrop-filter:blur(0.5rem);-webkit-backdrop-filter:blur(0.5rem)}limel-action-bar{min-width:0;transition-property:padding, opacity;transition-duration:var(--limel-prosemirror-adapter-toolbar-grid-template-rows-transition-duration);transition-timing-function:var(--limel-prosemirror-adapter-toolbar-transition-timing-function);opacity:var(--limel-prosemirror-adapter-toolbar-opacity);padding:var(--limel-prosemirror-adapter-action-bar-padding-top-bottom, 0.125rem) 0.25rem;background-color:transparent;overflow:hidden}.ProseMirror{position:relative;word-wrap:break-word;white-space:pre-wrap;white-space:break-spaces;-webkit-font-variant-ligatures:none;font-variant-ligatures:none;font-feature-settings:"liga" 0;padding:var(--limel-text-editor-padding)}.ProseMirror [draggable][contenteditable=false]{user-select:text}.ProseMirror:focus-visible{outline:none}.ProseMirror-hideselection *::selection{background:transparent}.ProseMirror-hideselection *::-moz-selection{background:transparent}.ProseMirror-hideselection{caret-color:transparent}.ProseMirror-selectednode{outline:0.125rem solid rgb(var(--color-sky-light))}li.ProseMirror-selectednode{outline:none}li.ProseMirror-selectednode:after{content:"";position:absolute;left:-2rem;right:-0.125rem;top:-0.125rem;bottom:-0.125rem;border:0.125rem solid rgb(var(--color-sky-light));pointer-events:none}img.ProseMirror-separator{display:inline !important;border:none !important;margin:0 !important}limel-portal{width:25rem}';export{ff as limel_prosemirror_adapter}