@aquera/nile-elements 1.9.9 → 1.9.11

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 (103) hide show
  1. package/README.md +7 -0
  2. package/dist/{index-d7e6f1c6.cjs.js → index-50880eb7.cjs.js} +2 -2
  3. package/dist/{index-d7e6f1c6.cjs.js.map → index-50880eb7.cjs.js.map} +1 -1
  4. package/dist/index-6832c52b.cjs.js +2 -0
  5. package/dist/index-6832c52b.cjs.js.map +1 -0
  6. package/dist/{index-289706c7.esm.js → index-7b1c9857.esm.js} +1 -1
  7. package/dist/index-802939a8.esm.js +1 -0
  8. package/dist/index-ba47645d.esm.js +1 -0
  9. package/dist/index-d37d33cb.cjs.js +2 -0
  10. package/dist/index-d37d33cb.cjs.js.map +1 -0
  11. package/dist/index.cjs.js +1 -1
  12. package/dist/index.esm.js +1 -1
  13. package/dist/index.js +74 -10
  14. package/dist/nile-checkbox/nile-checkbox.cjs.js +1 -1
  15. package/dist/nile-checkbox/nile-checkbox.cjs.js.map +1 -1
  16. package/dist/nile-checkbox/nile-checkbox.esm.js +1 -1
  17. package/dist/nile-combobox/index.cjs.js +1 -1
  18. package/dist/nile-combobox/index.esm.js +1 -1
  19. package/dist/nile-combobox/nile-combobox.cjs.js +1 -1
  20. package/dist/nile-combobox/nile-combobox.esm.js +1 -1
  21. package/dist/nile-detail/index.cjs.js +1 -1
  22. package/dist/nile-detail/index.esm.js +1 -1
  23. package/dist/nile-detail/nile-detail.cjs.js +1 -1
  24. package/dist/nile-detail/nile-detail.esm.js +1 -1
  25. package/dist/nile-drawer/nile-drawer.cjs.js +1 -1
  26. package/dist/nile-drawer/nile-drawer.cjs.js.map +1 -1
  27. package/dist/nile-drawer/nile-drawer.css.cjs.js +1 -1
  28. package/dist/nile-drawer/nile-drawer.css.cjs.js.map +1 -1
  29. package/dist/nile-drawer/nile-drawer.css.esm.js +54 -0
  30. package/dist/nile-drawer/nile-drawer.esm.js +6 -6
  31. package/dist/nile-nav-tab/nile-nav-tab.cjs.js +1 -1
  32. package/dist/nile-nav-tab/nile-nav-tab.cjs.js.map +1 -1
  33. package/dist/nile-nav-tab/nile-nav-tab.css.cjs.js +1 -1
  34. package/dist/nile-nav-tab/nile-nav-tab.css.cjs.js.map +1 -1
  35. package/dist/nile-nav-tab/nile-nav-tab.css.esm.js +11 -0
  36. package/dist/nile-nav-tab/nile-nav-tab.esm.js +1 -1
  37. package/dist/nile-nav-tab-group/nile-nav-tab-group.css.cjs.js +1 -1
  38. package/dist/nile-nav-tab-group/nile-nav-tab-group.css.cjs.js.map +1 -1
  39. package/dist/nile-nav-tab-group/nile-nav-tab-group.css.esm.js +1 -2
  40. package/dist/nile-wysiwyg-editor/engine/commands.cjs.js +1 -1
  41. package/dist/nile-wysiwyg-editor/engine/commands.esm.js +1 -1
  42. package/dist/nile-wysiwyg-editor/engine/create-state.cjs.js +1 -1
  43. package/dist/nile-wysiwyg-editor/engine/create-state.esm.js +1 -1
  44. package/dist/nile-wysiwyg-editor/engine/index.cjs.js +1 -1
  45. package/dist/nile-wysiwyg-editor/engine/index.esm.js +1 -1
  46. package/dist/nile-wysiwyg-editor/engine/keymap.cjs.js +1 -1
  47. package/dist/nile-wysiwyg-editor/engine/keymap.esm.js +1 -1
  48. package/dist/nile-wysiwyg-editor/engine/plugins/code-highlight.cjs.js +1 -1
  49. package/dist/nile-wysiwyg-editor/engine/plugins/code-highlight.esm.js +1 -1
  50. package/dist/nile-wysiwyg-editor/engine/plugins/find-replace.cjs.js +1 -1
  51. package/dist/nile-wysiwyg-editor/engine/plugins/find-replace.esm.js +1 -1
  52. package/dist/nile-wysiwyg-editor/engine/plugins/image.cjs.js +1 -1
  53. package/dist/nile-wysiwyg-editor/engine/plugins/image.esm.js +1 -1
  54. package/dist/nile-wysiwyg-editor/engine/plugins/placeholder.cjs.js +1 -1
  55. package/dist/nile-wysiwyg-editor/engine/plugins/placeholder.esm.js +1 -1
  56. package/dist/nile-wysiwyg-editor/engine/plugins/suggestions.cjs.js +1 -1
  57. package/dist/nile-wysiwyg-editor/engine/plugins/suggestions.esm.js +1 -1
  58. package/dist/nile-wysiwyg-editor/engine/plugins/tables.cjs.js +1 -1
  59. package/dist/nile-wysiwyg-editor/engine/plugins/tables.esm.js +1 -1
  60. package/dist/nile-wysiwyg-editor/engine/schema.cjs.js +1 -1
  61. package/dist/nile-wysiwyg-editor/engine/schema.esm.js +1 -1
  62. package/dist/nile-wysiwyg-editor/engine/selection-state.cjs.js +1 -1
  63. package/dist/nile-wysiwyg-editor/engine/selection-state.esm.js +1 -1
  64. package/dist/nile-wysiwyg-editor/index.cjs.js +1 -1
  65. package/dist/nile-wysiwyg-editor/index.esm.js +1 -1
  66. package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.cjs.js +1 -1
  67. package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.esm.js +1 -1
  68. package/dist/nile-wysiwyg-editor/ui/code-block-menu.cjs.js +1 -1
  69. package/dist/nile-wysiwyg-editor/ui/code-block-menu.esm.js +1 -1
  70. package/dist/src/nile-checkbox/nile-checkbox.js +1 -0
  71. package/dist/src/nile-checkbox/nile-checkbox.js.map +1 -1
  72. package/dist/src/nile-drawer/nile-drawer.css.js +54 -0
  73. package/dist/src/nile-drawer/nile-drawer.css.js.map +1 -1
  74. package/dist/src/nile-drawer/nile-drawer.d.ts +4 -0
  75. package/dist/src/nile-drawer/nile-drawer.js +83 -38
  76. package/dist/src/nile-drawer/nile-drawer.js.map +1 -1
  77. package/dist/src/nile-drawer/nile-drawer.test.js +71 -0
  78. package/dist/src/nile-drawer/nile-drawer.test.js.map +1 -1
  79. package/dist/src/nile-nav-tab/nile-nav-tab.css.js +11 -0
  80. package/dist/src/nile-nav-tab/nile-nav-tab.css.js.map +1 -1
  81. package/dist/src/nile-nav-tab/nile-nav-tab.d.ts +2 -0
  82. package/dist/src/nile-nav-tab/nile-nav-tab.js +13 -0
  83. package/dist/src/nile-nav-tab/nile-nav-tab.js.map +1 -1
  84. package/dist/src/nile-nav-tab-group/nile-nav-tab-group.css.js +1 -2
  85. package/dist/src/nile-nav-tab-group/nile-nav-tab-group.css.js.map +1 -1
  86. package/dist/src/version.js +1 -1
  87. package/dist/src/version.js.map +1 -1
  88. package/dist/tsconfig.tsbuildinfo +1 -1
  89. package/package.json +1 -1
  90. package/src/nile-checkbox/nile-checkbox.ts +1 -0
  91. package/src/nile-drawer/nile-drawer.css.ts +54 -0
  92. package/src/nile-drawer/nile-drawer.test.ts +73 -0
  93. package/src/nile-drawer/nile-drawer.ts +58 -11
  94. package/src/nile-nav-tab/nile-nav-tab.css.ts +11 -0
  95. package/src/nile-nav-tab/nile-nav-tab.ts +17 -0
  96. package/src/nile-nav-tab-group/nile-nav-tab-group.css.ts +1 -2
  97. package/vscode-html-custom-data.json +11 -1
  98. package/dist/index-353172ed.esm.js +0 -1
  99. package/dist/index-b387a9f4.cjs.js +0 -2
  100. package/dist/index-b387a9f4.cjs.js.map +0 -1
  101. package/dist/index-cc1385e0.cjs.js +0 -2
  102. package/dist/index-cc1385e0.cjs.js.map +0 -1
  103. package/dist/index-dedc38a6.esm.js +0 -1
package/dist/index.js CHANGED
@@ -2931,6 +2931,56 @@ const Ie=1,je=2,ze=3,me=4,Te=e=>(...t)=>({_$litDirective$:e,values:t});let xe=cl
2931
2931
  z-index: 700;
2932
2932
  }
2933
2933
 
2934
+ .drawer--push {
2935
+ position: relative;
2936
+ z-index: initial;
2937
+ }
2938
+ :host([push]) {
2939
+ display: block;
2940
+ flex: 0 0 auto;
2941
+ overflow: hidden;
2942
+ transition: inline-size var(--push-duration, 250ms) var(--push-easing, ease),
2943
+ block-size var(--push-duration, 250ms) var(--push-easing, ease);
2944
+ }
2945
+
2946
+ :host([push][placement='start']),
2947
+ :host([push][placement='end']) {
2948
+ inline-size: 0;
2949
+ max-inline-size: 100%;
2950
+ align-self: stretch;
2951
+ }
2952
+
2953
+ :host([push][placement='top']),
2954
+ :host([push][placement='bottom']) {
2955
+ block-size: 0;
2956
+ max-block-size: 100%;
2957
+ }
2958
+
2959
+ :host([push][open][placement='start']),
2960
+ :host([push][open][placement='end']) {
2961
+ inline-size: var(--size);
2962
+ }
2963
+
2964
+ :host([push][open][placement='top']),
2965
+ :host([push][open][placement='bottom']) {
2966
+ block-size: var(--size);
2967
+ }
2968
+
2969
+ @media (prefers-reduced-motion: reduce) {
2970
+ :host([push]) {
2971
+ transition: none;
2972
+ }
2973
+ }
2974
+
2975
+ .drawer--push .drawer__overlay {
2976
+ display: none;
2977
+ }
2978
+
2979
+ .drawer--push .drawer__panel {
2980
+ max-inline-size: none;
2981
+ max-block-size: none;
2982
+ }
2983
+
2934
2984
  .drawer__panel {
2935
2985
  position: absolute;
2936
2986
  display: flex;
@@ -3051,6 +3101,10 @@ const Ie=1,je=2,ze=3,me=4,Te=e=>(...t)=>({_$litDirective$:e,values:t});let xe=cl
3051
3101
  display: none;
3052
3102
  }
3053
3103
 
3104
+ :host([nooverlay]) .drawer__overlay {
3105
+ background-color: transparent;
3106
+ }
3107
+
3054
3108
  .drawer__close:hover {
3055
3109
  cursor:pointer;
3056
3110
  }
@@ -3060,10 +3114,10 @@ const Ie=1,je=2,ze=3,me=4,Te=e=>(...t)=>({_$litDirective$:e,values:t});let xe=cl
3060
3114
  border: solid 1px var(--nile-colors-white-base, var(--ng-colors-border-tertiary));
3061
3115
  }
3062
3116
  }
3063
- `];let ii=class extends Ge{constructor(){super(...arguments),this.hasSlotController=new Ze(this,"footer"),this.open=!1,this.closeOnEscape=!0,this.label="",this.placement="end",this.contained=!1,this.preventOverlayClose=!1,this.noHeader=!1}connectedCallback(){super.connectedCallback(),this.handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this.modal=new ei(this)}firstUpdated(){this.drawer.hidden=!this.open,this.open&&(this.addOpenListeners(),this.contained||(this.modal.activate(),$t(this)))}disconnectedCallback(){super.disconnectedCallback(),Gt(this)}requestClose(e){if(("overlay"==e||"keyboard"==e)&&this.preventOverlayClose)return;if(this.emit("nile-request-close",{cancelable:!0,detail:{source:e}}).defaultPrevented){const e=Wt(this,"drawer.denyClose",{dir:""});Ct(this.panel,e.keyframes,e.options)}else this.hide()}addOpenListeners(){this.closeOnEscape&&document.addEventListener("keydown",this.handleDocumentKeyDown)}removeOpenListeners(){this.closeOnEscape&&document.removeEventListener("keydown",this.handleDocumentKeyDown)}handleDocumentKeyDown(e){this.open&&!this.contained&&"Escape"===e.key&&(e.stopPropagation(),this.requestClose("keyboard"))}async handleOpenChange(){if(this.open){this.emit("nile-show"),this.addOpenListeners(),this.originalTrigger=document.activeElement,this.contained||(this.modal.activate(),$t(this));const e=this.querySelector("[autofocus]");e&&e.removeAttribute("autofocus"),await Promise.all([Yt(this.drawer),Yt(this.overlay)]),this.drawer.hidden=!1,requestAnimationFrame((()=>{this.emit("nile-initial-focus",{cancelable:!0}).defaultPrevented||(e?e.focus({preventScroll:!0}):this.panel.focus({preventScroll:!0})),e&&e.setAttribute("autofocus","")}));const t=Wt(this,`drawer.show${Ht(this.placement)}`,{dir:""}),i=Wt(this,"drawer.overlay.show",{dir:""});await Promise.all([Ct(this.panel,t.keyframes,t.options),Ct(this.overlay,i.keyframes,i.options)]),this.emit("nile-after-show")}else{this.emit("nile-hide"),this.removeOpenListeners(),this.contained||(this.modal.deactivate(),Gt(this)),await Promise.all([Yt(this.drawer),Yt(this.overlay)]);const e=Wt(this,`drawer.hide${Ht(this.placement)}`,{dir:""}),t=Wt(this,"drawer.overlay.hide",{dir:""});await Promise.all([Ct(this.overlay,t.keyframes,t.options).then((()=>{this.overlay.hidden=!0})),Ct(this.panel,e.keyframes,e.options).then((()=>{this.panel.hidden=!0}))]),this.drawer.hidden=!0,this.overlay.hidden=!1,this.panel.hidden=!1;const i=this.originalTrigger;"function"==typeof i?.focus&&setTimeout((()=>i.focus())),this.emit("nile-after-hide")}}handleNoModalChange(){this.open&&!this.contained&&(this.modal.activate(),$t(this)),this.open&&this.contained&&(this.modal.deactivate(),Gt(this))}async show(){if(!this.open)return this.open=!0,Jt(this,"nile-after-show")}async hide(){if(this.open)return this.open=!1,Jt(this,"nile-after-hide")}render(){return R`
3117
+ `];let ii=class extends Ge{constructor(){super(...arguments),this.hasSlotController=new Ze(this,"footer"),this.open=!1,this.closeOnEscape=!0,this.label="",this.placement="end",this.contained=!1,this.push=!1,this.preventOverlayClose=!1,this.noHeader=!1,this.noOverlay=!1}get isNonModal(){return this.contained||this.push}connectedCallback(){super.connectedCallback(),this.handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this.modal=new ei(this)}firstUpdated(){this.drawer.hidden=!this.open,this.open&&(this.addOpenListeners(),this.isNonModal||(this.modal.activate(),$t(this)))}disconnectedCallback(){super.disconnectedCallback(),Gt(this)}requestClose(e){if(("overlay"==e||"keyboard"==e)&&this.preventOverlayClose)return;if(this.emit("nile-request-close",{cancelable:!0,detail:{source:e}}).defaultPrevented){const e=Wt(this,"drawer.denyClose",{dir:""});Ct(this.panel,e.keyframes,e.options)}else this.hide()}addOpenListeners(){this.closeOnEscape&&document.addEventListener("keydown",this.handleDocumentKeyDown)}removeOpenListeners(){this.closeOnEscape&&document.removeEventListener("keydown",this.handleDocumentKeyDown)}handleDocumentKeyDown(e){this.open&&!this.isNonModal&&"Escape"===e.key&&(e.stopPropagation(),this.requestClose("keyboard"))}async waitForPushTransition(){await this.updateComplete;const e=getComputedStyle(this),t=Qt(e.transitionDuration.split(",")[0])+Qt(e.transitionDelay.split(",")[0]);if(t)return new Promise((e=>{const i=()=>{this.removeEventListener("transitionend",n),clearTimeout(o),e()},n=e=>{e.target===this&&i()},o=setTimeout(i,t+50);this.addEventListener("transitionend",n)}))}async handleOpenChange(){if(this.open){this.emit("nile-show"),this.addOpenListeners(),this.originalTrigger=document.activeElement,this.isNonModal||(this.modal.activate(),$t(this));const e=this.querySelector("[autofocus]");if(e&&e.removeAttribute("autofocus"),await Promise.all([Yt(this.drawer),Yt(this.overlay)]),this.drawer.hidden=!1,requestAnimationFrame((()=>{this.emit("nile-initial-focus",{cancelable:!0}).defaultPrevented||(e?e.focus({preventScroll:!0}):this.panel.focus({preventScroll:!0})),e&&e.setAttribute("autofocus","")})),this.push)await this.waitForPushTransition();else{const e=Wt(this,`drawer.show${Ht(this.placement)}`,{dir:""}),t=Wt(this,"drawer.overlay.show",{dir:""});await Promise.all([Ct(this.panel,e.keyframes,e.options),Ct(this.overlay,t.keyframes,t.options)])}this.emit("nile-after-show")}else{if(this.emit("nile-hide"),this.removeOpenListeners(),this.isNonModal||(this.modal.deactivate(),Gt(this)),await Promise.all([Yt(this.drawer),Yt(this.overlay)]),this.push)await this.waitForPushTransition(),this.drawer.hidden=!0;else{const e=Wt(this,`drawer.hide${Ht(this.placement)}`,{dir:""}),t=Wt(this,"drawer.overlay.hide",{dir:""});await Promise.all([Ct(this.overlay,t.keyframes,t.options).then((()=>{this.overlay.hidden=!0})),Ct(this.panel,e.keyframes,e.options).then((()=>{this.panel.hidden=!0}))]),this.drawer.hidden=!0,this.overlay.hidden=!1,this.panel.hidden=!1}const e=this.originalTrigger;"function"==typeof e?.focus&&setTimeout((()=>e.focus())),this.emit("nile-after-hide")}}handleNoModalChange(){this.open&&!this.isNonModal&&(this.modal.activate(),$t(this)),this.open&&this.isNonModal&&(this.modal.deactivate(),Gt(this))}async show(){if(!this.open)return this.open=!0,Jt(this,"nile-after-show")}async hide(){if(this.open)return this.open=!1,Jt(this,"nile-after-hide")}render(){return R`
3064
3118
  <div
3065
3119
  part="base"
3066
- class=${Ae({drawer:!0,"drawer--open":this.open,"drawer--top":"top"===this.placement,"drawer--end":"end"===this.placement,"drawer--bottom":"bottom"===this.placement,"drawer--start":"start"===this.placement,"drawer--contained":this.contained,"drawer--fixed":!this.contained,"drawer--rtl":"rtl","drawer--has-footer":this.hasSlotController.test("footer")})}
3120
+ class=${Ae({drawer:!0,"drawer--open":this.open,"drawer--top":"top"===this.placement,"drawer--end":"end"===this.placement,"drawer--bottom":"bottom"===this.placement,"drawer--start":"start"===this.placement,"drawer--contained":this.contained&&!this.push,"drawer--push":this.push,"drawer--fixed":!this.contained&&!this.push,"drawer--rtl":"rtl","drawer--has-footer":this.hasSlotController.test("footer")})}
3067
3121
  >
3068
3122
  <div
3069
3123
  part="overlay"
@@ -3113,7 +3167,7 @@ const Ie=1,je=2,ze=3,me=4,Te=e=>(...t)=>({_$litDirective$:e,values:t});let xe=cl
3113
3167
  </footer>
3114
3168
  </div>
3115
3169
  </div>
3116
- `}};ii.styles=ti,e([pe(".drawer")],ii.prototype,"drawer",void 0),e([pe(".drawer__panel")],ii.prototype,"panel",void 0),e([pe(".drawer__overlay")],ii.prototype,"overlay",void 0),e([de({type:Boolean,reflect:!0})],ii.prototype,"open",void 0),e([de({type:Boolean,reflect:!0})],ii.prototype,"closeOnEscape",void 0),e([de({reflect:!0})],ii.prototype,"label",void 0),e([de({reflect:!0})],ii.prototype,"placement",void 0),e([de({type:Boolean,reflect:!0})],ii.prototype,"contained",void 0),e([de({type:Boolean,reflect:!0})],ii.prototype,"preventOverlayClose",void 0),e([de({attribute:"no-header",type:Boolean,reflect:!0})],ii.prototype,"noHeader",void 0),e([Ve("open",{waitUntilFirstUpdate:!0})],ii.prototype,"handleOpenChange",null),e([Ve("contained",{waitUntilFirstUpdate:!0})],ii.prototype,"handleNoModalChange",null),ii=e([ce("nile-drawer")],ii),Rt("drawer.showTop",{keyframes:[{opacity:0,translate:"0 -100%"},{opacity:1,translate:"0 0"}],options:{duration:250,easing:"ease"}}),Rt("drawer.hideTop",{keyframes:[{opacity:1,translate:"0 0"},{opacity:0,translate:"0 -100%"}],options:{duration:250,easing:"ease"}}),Rt("drawer.showEnd",{keyframes:[{opacity:0,translate:"100%"},{opacity:1,translate:"0"}],rtlKeyframes:[{opacity:0,translate:"-100%"},{opacity:1,translate:"0"}],options:{duration:250,easing:"ease"}}),Rt("drawer.hideEnd",{keyframes:[{opacity:1,translate:"0"},{opacity:0,translate:"100%"}],rtlKeyframes:[{opacity:1,translate:"0"},{opacity:0,translate:"-100%"}],options:{duration:250,easing:"ease"}}),Rt("drawer.showBottom",{keyframes:[{opacity:0,translate:"0 100%"},{opacity:1,translate:"0 0"}],options:{duration:250,easing:"ease"}}),Rt("drawer.hideBottom",{keyframes:[{opacity:1,translate:"0 0"},{opacity:0,translate:"0 100%"}],options:{duration:250,easing:"ease"}}),Rt("drawer.showStart",{keyframes:[{opacity:0,translate:"-100%"},{opacity:1,translate:"0"}],rtlKeyframes:[{opacity:0,translate:"100%"},{opacity:1,translate:"0"}],options:{duration:250,easing:"ease"}}),Rt("drawer.hideStart",{keyframes:[{opacity:1,translate:"0"},{opacity:0,translate:"-100%"}],rtlKeyframes:[{opacity:1,translate:"0"},{opacity:0,translate:"100%"}],options:{duration:250,easing:"ease"}}),Rt("drawer.denyClose",{keyframes:[{scale:1},{scale:1.01},{scale:1}],options:{duration:250}}),Rt("drawer.overlay.show",{keyframes:[{opacity:0},{opacity:1}],options:{duration:250}}),Rt("drawer.overlay.hide",{keyframes:[{opacity:1},{opacity:0}],options:{duration:250}});const ni=s`
3170
+ `}};ii.styles=ti,e([pe(".drawer")],ii.prototype,"drawer",void 0),e([pe(".drawer__panel")],ii.prototype,"panel",void 0),e([pe(".drawer__overlay")],ii.prototype,"overlay",void 0),e([de({type:Boolean,reflect:!0})],ii.prototype,"open",void 0),e([de({type:Boolean,reflect:!0})],ii.prototype,"closeOnEscape",void 0),e([de({reflect:!0})],ii.prototype,"label",void 0),e([de({reflect:!0})],ii.prototype,"placement",void 0),e([de({type:Boolean,reflect:!0})],ii.prototype,"contained",void 0),e([de({type:Boolean,reflect:!0})],ii.prototype,"push",void 0),e([de({type:Boolean,reflect:!0})],ii.prototype,"preventOverlayClose",void 0),e([de({attribute:"no-header",type:Boolean,reflect:!0})],ii.prototype,"noHeader",void 0),e([de({type:Boolean,reflect:!0})],ii.prototype,"noOverlay",void 0),e([Ve("open",{waitUntilFirstUpdate:!0})],ii.prototype,"handleOpenChange",null),e([Ve(["contained","push"],{waitUntilFirstUpdate:!0})],ii.prototype,"handleNoModalChange",null),ii=e([ce("nile-drawer")],ii),Rt("drawer.showTop",{keyframes:[{opacity:0,translate:"0 -100%"},{opacity:1,translate:"0 0"}],options:{duration:250,easing:"ease"}}),Rt("drawer.hideTop",{keyframes:[{opacity:1,translate:"0 0"},{opacity:0,translate:"0 -100%"}],options:{duration:250,easing:"ease"}}),Rt("drawer.showEnd",{keyframes:[{opacity:0,translate:"100%"},{opacity:1,translate:"0"}],rtlKeyframes:[{opacity:0,translate:"-100%"},{opacity:1,translate:"0"}],options:{duration:250,easing:"ease"}}),Rt("drawer.hideEnd",{keyframes:[{opacity:1,translate:"0"},{opacity:0,translate:"100%"}],rtlKeyframes:[{opacity:1,translate:"0"},{opacity:0,translate:"-100%"}],options:{duration:250,easing:"ease"}}),Rt("drawer.showBottom",{keyframes:[{opacity:0,translate:"0 100%"},{opacity:1,translate:"0 0"}],options:{duration:250,easing:"ease"}}),Rt("drawer.hideBottom",{keyframes:[{opacity:1,translate:"0 0"},{opacity:0,translate:"0 100%"}],options:{duration:250,easing:"ease"}}),Rt("drawer.showStart",{keyframes:[{opacity:0,translate:"-100%"},{opacity:1,translate:"0"}],rtlKeyframes:[{opacity:0,translate:"100%"},{opacity:1,translate:"0"}],options:{duration:250,easing:"ease"}}),Rt("drawer.hideStart",{keyframes:[{opacity:1,translate:"0"},{opacity:0,translate:"-100%"}],rtlKeyframes:[{opacity:1,translate:"0"},{opacity:0,translate:"100%"}],options:{duration:250,easing:"ease"}}),Rt("drawer.denyClose",{keyframes:[{scale:1},{scale:1.01},{scale:1}],options:{duration:250}}),Rt("drawer.overlay.show",{keyframes:[{opacity:0},{opacity:1}],options:{duration:250}}),Rt("drawer.overlay.hide",{keyframes:[{opacity:1},{opacity:0}],options:{duration:250}});const ni=s`
3117
3171
  :host {
3118
3172
  display: inline-block;
3119
3173
  -webkit-font-smoothing: var(--nile-webkit-font-smoothing, var(--ng-webkit-font-smoothing));
@@ -3319,7 +3373,7 @@ const Ie=1,je=2,ze=3,me=4,Te=e=>(...t)=>({_$litDirective$:e,values:t});let xe=cl
3319
3373
  cursor: pointer;
3320
3374
  margin-right: var(--nile-spacing-lg);
3321
3375
  }
3322
- `;let oi=class extends Ge{constructor(){super(),this.hasFocus=!1,this.title="",this.name="",this.size="medium",this.disabled=!1,this.checked=!1,this.label="",this.indeterminate=!1,this.defaultChecked=!1,this.helpText="",this.errorMessage="",this.showHelpText=!1,this.form="",this.group="",this.required=!1}toggleHelpText(){this.showHelpText=!this.showHelpText}handleClick(){this.checked=!this.checked,this.indeterminate=!1,this.emit("nile-change",{checked:this.checked}),this.emit("valueChange",{checked:this.checked})}handleBlur(){this.hasFocus=!1,this.emit("blur")}handleInput(){this.emit("input")}handleFocus(){this.hasFocus=!0,this.emit("focus")}handleStateChange(){this.input.checked=this.checked,this.input.indeterminate=this.indeterminate}click(){this.input.click()}focus(e){this.input.focus(e)}blur(){this.input.blur()}connectedCallback(){super.connectedCallback(),this.updateHostClass(),this.emit("nile-init")}disconnectedCallback(){super.disconnectedCallback(),this.emit("nile-destroy")}updated(e){super.updated(e),e.has("helpText")&&this.updateHostClass()}updateHostClass(){this.helpText?this.classList.add("full-width"):this.classList.remove("full-width")}render(){const e=!!this.helpText,t=!!this.errorMessage;return R`
3376
+ `;let oi=class extends Ge{constructor(){super(),this.hasFocus=!1,this.title="",this.name="",this.size="medium",this.disabled=!1,this.checked=!1,this.label="",this.indeterminate=!1,this.defaultChecked=!1,this.helpText="",this.errorMessage="",this.showHelpText=!1,this.form="",this.group="",this.required=!1}toggleHelpText(){this.showHelpText=!this.showHelpText}handleClick(){this.checked=!this.checked,this.indeterminate=!1,this.input.focus(),this.emit("nile-change",{checked:this.checked}),this.emit("valueChange",{checked:this.checked})}handleBlur(){this.hasFocus=!1,this.emit("blur")}handleInput(){this.emit("input")}handleFocus(){this.hasFocus=!0,this.emit("focus")}handleStateChange(){this.input.checked=this.checked,this.input.indeterminate=this.indeterminate}click(){this.input.click()}focus(e){this.input.focus(e)}blur(){this.input.blur()}connectedCallback(){super.connectedCallback(),this.updateHostClass(),this.emit("nile-init")}disconnectedCallback(){super.disconnectedCallback(),this.emit("nile-destroy")}updated(e){super.updated(e),e.has("helpText")&&this.updateHostClass()}updateHostClass(){this.helpText?this.classList.add("full-width"):this.classList.remove("full-width")}render(){const e=!!this.helpText,t=!!this.errorMessage;return R`
3323
3377
  <label
3324
3378
  part="base"
3325
3379
  class=${Ae({checkbox:!0,"checkbox--checked":this.checked,"checkbox--disabled":this.disabled,"checkbox--focused":this.hasFocus,"checkbox--indeterminate":this.indeterminate,"checkbox--medium":"medium"===this.size})}
@@ -7607,7 +7661,7 @@ const Po=()=>new Vo;class Vo{}const Ro=new WeakMap,Wo=Te(class extends Xn{render
7607
7661
  margin-top: var(--nile-spacing-lg, var(--ng-spacing-lg));
7608
7662
  font-size: var(--nile-type-scale-3, var(--ng-font-size-text-sm));
7609
7663
  }
7610
- `;function $o(e,t,i){let n,o=i.initialDeps??[],r=!0;function s(){var s;const a="production"!==process.env.NODE_ENV&&!!i.key&&!!(null==(s=i.debug)?void 0:s.call(i));let l=0;a&&(l=Date.now());const M=e();if(!(M.length!==o.length||M.some(((e,t)=>o[t]!==e))))return n;o=M;let c=0;if(a&&(c=Date.now()),n=t(...M),a){const e=Math.round(100*(Date.now()-l))/100,t=Math.round(100*(Date.now()-c))/100,n=t/16,o=(e,t)=>{for(e=String(e);e.length<t;)e=" "+e;return e};console.info(`%c⏱ ${o(t,5)} /${o(e,5)} ms`,`\n font-size: .6rem;\n font-weight: bold;\n color: hsl(${Math.max(0,Math.min(120-120*n,120))}deg 100% 31%);`,null==i?void 0:i.key)}return!(null==i?void 0:i.onChange)||r&&i.skipInitialOnChange||i.onChange(n),r=!1,n}return s.updateDeps=e=>{o=e},s}function Go(e,t){if(void 0===e)throw new Error("Unexpected undefined"+(t?`: ${t}`:""));return e}const Fo=(e,t,i)=>{let n;return function(...o){e.clearTimeout(n),n=e.setTimeout((()=>t.apply(this,o)),i)}};let Ho;const Jo=()=>{if(void 0!==Ho)return Ho;if("undefined"==typeof navigator)return Ho=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Ho=!0;const e=navigator.maxTouchPoints;return Ho="MacIntel"===navigator.platform&&void 0!==e&&e>0},Xo=e=>{const{offsetWidth:t,offsetHeight:i}=e;return{width:t,height:i}},qo=e=>e,Ko=e=>{const t=Math.max(e.startIndex-e.overscan,0),i=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,n=new Array(i);for(let e=0;e<i;e++)n[e]=t+e;return n},er=(e,t)=>{const i=e.scrollElement;if(!i)return;const n=e.targetWindow;if(!n)return;const o=e=>{const{width:i,height:n}=e;t({width:Math.round(i),height:Math.round(n)})};if(o(Xo(i)),!n.ResizeObserver)return()=>{};const r=new n.ResizeObserver((t=>{const n=()=>{const e=t[0];if(null==e?void 0:e.borderBoxSize){const t=e.borderBoxSize[0];if(t)return void o({width:t.inlineSize,height:t.blockSize})}o(Xo(i))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(n):n()}));return r.observe(i,{box:"border-box"}),()=>{r.unobserve(i)}},tr={passive:!0},ir="undefined"==typeof window||"onscrollend"in window,nr=(e,t)=>((e,t,i)=>{const n=e.scrollElement;if(!n)return;const o=e.targetWindow;if(!o)return;const r=e.options.useScrollendEvent&&ir;let s=0;const a=r?null:Fo(o,(()=>t(s,!1)),e.options.isScrollingResetDelay),l=e=>()=>{s=i(n),null==a||a(),t(s,e)},M=l(!0),c=l(!1);return n.addEventListener("scroll",M,tr),r&&n.addEventListener("scrollend",c,tr),()=>{n.removeEventListener("scroll",M),r&&n.removeEventListener("scrollend",c)}})(e,t,(t=>{const{horizontal:i,isRtl:n}=e.options;return i?t.scrollLeft*(n?-1:1):t.scrollTop})),or=(e,t,i)=>{if(i.options.useCachedMeasurements){const t=i.indexFromElement(e),n=i.options.getItemKey(t);return i.itemSizeCache.get(n)??i.options.estimateSize(t)}if(null==t?void 0:t.borderBoxSize){const e=t.borderBoxSize[0];if(e){return Math.round(e[i.options.horizontal?"inlineSize":"blockSize"])}}if(!t){const t=i.indexFromElement(e),n=i.options.getItemKey(t),o=i.itemSizeCache.get(n);if(void 0!==o)return o}return e[i.options.horizontal?"offsetWidth":"offsetHeight"]},rr=(e,{adjustments:t=0,behavior:i},n)=>{var o,r;null==(r=null==(o=n.scrollElement)?void 0:o.scrollTo)||r.call(o,{[n.options.horizontal?"left":"top"]:e+t,behavior:i})};class sr{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e,t,i;return(null==(i=null==(t=null==(e=this.targetWindow)?void 0:e.performance)?void 0:t.now)?void 0:i.call(t))??Date.now()},this.observer=(()=>{let e=null;const t=()=>e||(this.targetWindow&&this.targetWindow.ResizeObserver?e=new this.targetWindow.ResizeObserver((e=>{e.forEach((e=>{const t=()=>{const t=e.target,i=this.indexFromElement(t);if(t.isConnected)this.shouldMeasureDuringScroll(i)&&this.resizeItem(i,this.options.measureElement(t,e,this));else{this.observer.unobserve(t);for(const[e,i]of this.elementsCache)if(i===t){this.elementsCache.delete(e);break}}};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()}))})):null);return{disconnect:()=>{var i;null==(i=t())||i.disconnect(),e=null},observe:e=>{var i;return null==(i=t())?void 0:i.observe(e,{box:"border-box"})},unobserve:e=>{var i;return null==(i=t())?void 0:i.unobserve(e)}}})(),this.range=null,this.setOptions=e=>{var t,i;const n={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:qo,rangeExtractor:Ko,onChange:()=>{},measureElement:or,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const t in e){const i=e[t];void 0!==i&&(n[t]=i)}const o=this.options;let r=null,s=null,a=!1;if(void 0!==o&&o.enabled&&n.enabled&&"end"===n.anchorTo&&null!==this.scrollElement){const e=o.count,l=n.count,M=this.getMeasurements(),c=e>0?(null==(t=M[0])?void 0:t.key)??o.getItemKey(0):null,u=e>0?(null==(i=M[e-1])?void 0:i.key)??o.getItemKey(e-1):null;if(l!==e||e>0&&l>0&&(n.getItemKey(0)!==c||n.getItemKey(l-1)!==u)){a=!0;const t=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??M[0]:null;t&&(r=[t.key,this.getScrollOffset()-t.start]);const i=!0===n.followOnAppend?"auto":n.followOnAppend||null;i&&l>e&&this.isAtEnd(o.scrollEndThreshold)&&(0===e||n.getItemKey(l-1)!==u)&&(s=i)}}this.options=n,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let l=!1,M=0;if(r&&null!==this.scrollOffset){const[e,t]=r,i=this.getMeasurements(),{count:n,getItemKey:o}=this.options;let s=0;for(;s<n&&o(s)!==e;)s++;if(s<n){const e=i[s];if(e){const i=e.start+t;i!==this.scrollOffset&&(M=i-this.scrollOffset,this.scrollOffset=i,l=!0)}}}(l||s)&&(this.pendingScrollAnchor=[l?r[0]:null,l?r[1]:0,s,M])},this.notify=e=>{var t,i;null==(i=(t=this.options).onChange)||i.call(t,this,e)},this.maybeNotify=$o((()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null])),(e=>{this.notify(e)}),{key:"production"!==process.env.NODE_ENV&&"maybeNotify",debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach((e=>e())),this.unsubs=[],this.observer.disconnect(),null!=this.rafId&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var e;const t=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==t){if(this.cleanup(),!t)return void this.maybeNotify();if(this.scrollElement=t,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=(null==(e=this.scrollElement)?void 0:e.window)??null,this.elementsCache.forEach((e=>{this.observer.observe(e)})),this.unsubs.push(this.options.observeElementRect(this,(e=>{this.scrollRect=e,this.maybeNotify()}))),this.unsubs.push(this.options.observeElementOffset(this,((e,t)=>{if(t&&null===this._intendedScrollOffset&&e===this.scrollOffset)return;null!==this._intendedScrollOffset&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const i=this.getScrollOffset();this.scrollDirection=t?i===e?this.scrollDirection:i<e?"forward":"backward":null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()}))),"addEventListener"in this.scrollElement){const e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,null!==this._iosTouchEndTimerId&&null!=this.targetWindow&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},i=()=>{this._iosTouching=!1,Jo()&&null!=this.targetWindow&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout((()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()}),150))};e.addEventListener("touchstart",t,tr),e.addEventListener("touchend",i,tr),this.unsubs.push((()=>{e.removeEventListener("touchstart",t),e.removeEventListener("touchend",i),null!==this._iosTouchEndTimerId&&null!=this.targetWindow&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)}))}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const i=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,i&&this.scrollElement&&this.options.enabled){const[e,t,n,o]=i;null===e||n||(Jo()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?0!==o&&(this._iosDeferredAdjustment+=o):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),n&&this.scrollToEnd({behavior:n})}},this._flushIosDeferredIfReady=()=>{if(0===this._iosDeferredAdjustment)return;if(this.isScrolling)return;if(this._iosTouching)return;if(this._iosJustTouchEnded)return;const e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;const i=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=i,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??("function"==typeof this.options.initialOffset?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=$o((()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap]),((e,t,i,n,o,r,s,a)=>(void 0!==this.prevLanes&&this.prevLanes!==r&&(this.lanesChangedFlag=!0),this.prevLanes=r,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:i,getItemKey:n,enabled:o,lanes:r,laneAssignmentMode:s,gap:a})),{key:!1}),this.getMeasurements=$o((()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion]),(({count:e,paddingStart:t,scrollMargin:i,getItemKey:n,enabled:o,lanes:r,laneAssignmentMode:s,gap:a},l)=>{const M=this.itemSizeCache;if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(const t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),0!==this.measurementsCache.length||this.lanesSettling||(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach((e=>{this.itemSizeCache.set(e.key,e.size)})));const c=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),1===r){const o=2*e;let r,s=this._flatMeasurements;if(!s||s.length<o){const e=new Float64Array(o);s&&c>0&&e.set(s.subarray(0,2*c)),s=e,this._flatMeasurements=s}if(0===c)r=t+i;else{const e=c-1;r=s[2*e]+s[2*e+1]+a}for(let t=c;t<e;t++){const e=n(t),i=M.get(e),o="number"==typeof i?i:this.options.estimateSize(t);s[2*t]=r,s[2*t+1]=o,r+=o+a}const l=function(e,t,i){const n=new Array(e);return new Proxy(n,{get(n,o,r){if("string"==typeof o){const r=o.charCodeAt(0);if(r>=48&&r<=57){const r=+o;if(Number.isInteger(r)&&r>=0&&r<e){let e=n[r];if(!e){const o=t[2*r];e=n[r]={index:r,key:i(r),start:o,size:t[2*r+1],end:o+t[2*r+1],lane:0}}return e}}if("length"===o)return e}return Reflect.get(n,o,r)}})}(e,s,n);return this.measurementsCache=l,l}const u=this.measurementsCache.slice(0,c),g=new Array(r).fill(void 0),d=new Float64Array(r);let h=0;for(let e=0;e<c;e++){const t=u[e];t&&(void 0===g[t.lane]&&h++,g[t.lane]=e,d[t.lane]=t.end)}for(let o=c;o<e;o++){const e=n(o),l=this.laneAssignments.get(o);let c,N;const p="estimate"===s||M.has(e);if(void 0!==l&&this.options.lanes>1){c=l;const e=g[c],n=void 0!==e?u[e]:void 0;N=n?n.end+a:t+i}else if(h===r){let e=0,t=d[0],i=g[0];for(let n=1;n<r;n++){const o=d[n];(o<t||o===t&&g[n]<i)&&(e=n,t=o,i=g[n])}c=e,N=t+a,p&&this.laneAssignments.set(o,c)}else c=o%this.options.lanes,N=t+i,p&&this.laneAssignments.set(o,c);const D=M.get(e),y="number"==typeof D?D:this.options.estimateSize(o),I=N+y;u[o]={index:o,start:N,size:y,end:I,key:e,lane:c},void 0===g[c]&&h++,g[c]=o,d[c]=I}return this.measurementsCache=u,u}),{key:"production"!==process.env.NODE_ENV&&"getMeasurements",debug:()=>this.options.debug}),this.calculateRange=$o((()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes]),((e,t,i,n)=>0===e.length||0===t?(this.range=null,null):(this.range=function(e,t,i,n,o){const r=e.length-1;if(e.length<=n)return{startIndex:0,endIndex:r};if(1===n&&null!==o){const e=function(e,t,i){let n=0;for(;n<=t;){const o=(n+t)/2|0,r=e[2*o];if(r<i)n=o+1;else{if(!(r>i))return o;t=o-1}}return n>0?n-1:0}(o,r,i);let n=e;const s=i+t;for(;n<r&&o[2*n]+o[2*n+1]<s;)n++;return{startIndex:e,endIndex:n}}const s=t=>e[t].start;let a=ar(0,r,s,i),l=a;if(1===n)for(;l<r&&e[l].end<i+t;)l++;else if(n>1){const o=Array(n).fill(0);for(;l<r&&o.some((e=>e<i+t));){const t=e[l];o[t.lane]=t.end,l++}const s=Array(n).fill(i+t);for(;a>=0&&s.some((e=>e>=i));){const t=e[a];s[t.lane]=t.start,a--}a=Math.max(0,a-a%n),l=Math.min(r,l+(n-1-l%n))}return{startIndex:a,endIndex:l}}(e,t,i,n,1===n&&null!=this._flatMeasurements?this._flatMeasurements:null),this.range)),{key:"production"!==process.env.NODE_ENV&&"calculateRange",debug:()=>this.options.debug}),this.getVirtualIndexes=$o((()=>{let e=null,t=null;const i=this.calculateRange();return i&&(e=i.startIndex,t=i.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]}),((e,t,i,n,o)=>null===n||null===o?[]:e({startIndex:n,endIndex:o,overscan:t,count:i})),{key:"production"!==process.env.NODE_ENV&&"getVirtualIndexes",debug:()=>this.options.debug}),this.indexFromElement=e=>{const t=this.options.indexAttribute,i=e.getAttribute(t);return i?parseInt(i,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{var t;if(!this.scrollState||"smooth"!==this.scrollState.behavior)return!0;const i=this.scrollState.index??(null==(t=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))?void 0:t.index);if(void 0!==i&&this.range){const t=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),n=Math.max(0,i-t),o=Math.min(this.options.count-1,i+t);return e>=n&&e<=o}return!0},this.measureElement=e=>{if(!e)return void this.elementsCache.forEach(((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))}));const t=this.indexFromElement(e),i=this.options.getItemKey(t),n=this.elementsCache.get(i);n!==e&&(n&&this.observer.unobserve(n),this.observer.observe(e),this.elementsCache.set(i,e)),this.isScrolling&&!this.scrollState||!this.shouldMeasureDuringScroll(t)||this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{var i,n;if(e<0||e>=this.options.count)return;let o,r,s;const a=this._flatMeasurements;if(1===this.options.lanes&&null!==a)s=this.options.getItemKey(e),r=a[2*e],o=a[2*e+1];else{const t=this.measurementsCache[e];if(!t)return;s=t.key,r=t.start,o=t.size}const l=t-(this.itemSizeCache.get(s)??o);if(0!==l){const a="end"===this.options.anchorTo&&"smooth"!==(null==(i=this.scrollState)?void 0:i.behavior)&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,M=a?this.getTotalSize():0,c="smooth"!==(null==(n=this.scrollState)?void 0:n.behavior)&&(void 0!==this.shouldAdjustScrollPositionOnItemSizeChange?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:s,start:r,size:o,end:r+o,lane:0},l,this):r<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(s)||"backward"!==this.scrollDirection));(null===this.pendingMin||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(s,t),this.itemSizeCacheVersion++,a?this.applyScrollAdjustment(this.getTotalSize()-M):c&&this.applyScrollAdjustment(l),this.notify(!1)}},this.getVirtualItems=$o((()=>[this.getVirtualIndexes(),this.getMeasurements()]),((e,t)=>{const i=[];for(let n=0,o=e.length;n<o;n++){const o=t[e[n]];i.push(o)}return i}),{key:"production"!==process.env.NODE_ENV&&"getVirtualItems",debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{const t=this.getMeasurements();if(0===t.length)return;const i=this._flatMeasurements,n=1===this.options.lanes&&null!=i,o=ar(0,t.length-1,n?e=>i[2*e]:e=>Go(t[e]).start,e);return Go(t[o])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,i=0)=>{if(!this.scrollElement)return 0;const n=this.getSize(),o=this.getScrollOffset();"auto"===t&&(t=e>=o+n?"end":"start"),"center"===t?e+=(i-n)/2:"end"===t&&(e-=n);const r=this.getMaxScrollOffset();return Math.max(Math.min(r,e),0)},this.getOffsetForIndex=(e,t="auto")=>{e=Math.max(0,Math.min(e,this.options.count-1));const i=this.getSize(),n=this.getScrollOffset(),o=this.measurementsCache[e];if(!o)return;if("auto"===t)if(o.end>=n+i-this.options.scrollPaddingEnd)t="end";else{if(!(o.start<=n+this.options.scrollPaddingStart))return[n,t];t="start"}if("end"===t&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];const r="end"===t?o.end+this.options.scrollPaddingEnd:o.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(r,t,o.size),t]},this.scrollToOffset=(e,{align:t="start",behavior:i="auto"}={})=>{const n=this.getOffsetForAlignment(e,t),o=this.now();this.scrollState={index:null,align:t,behavior:i,startedAt:o,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t="auto",behavior:i="auto"}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));const n=this.getOffsetForIndex(e,t);if(!n)return;const[o,r]=n,s=this.now();this.scrollState={index:e,align:r,behavior:i,startedAt:s,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t="auto"}={})=>{const i=this.getScrollOffset()+e,n=this.now();this.scrollState={index:null,align:"start",behavior:t,startedAt:n,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e="auto"}={})=>{this.options.count>0?this.scrollToIndex(this.options.count-1,{align:"end",behavior:e}):this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{var e;const t=this.getMeasurements();let i;if(0===t.length)i=this.options.paddingStart;else if(1===this.options.lanes){const n=t.length-1,o=this._flatMeasurements;i=null!=o?o[2*n]+o[2*n+1]:(null==(e=t[n])?void 0:e.end)??0}else{const e=Array(this.options.lanes).fill(null);let n=t.length-1;for(;n>=0&&e.some((e=>null===e));){const i=t[n];null===e[i.lane]&&(e[i.lane]=i.end),n--}i=Math.max(...e.filter((e=>null!==e)))}return Math.max(i-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const e=[];if(0===this.itemSizeCache.size)return e;const t=this.getMeasurements();for(const i of t)i&&this.itemSizeCache.has(i.key)&&e.push({index:i.index,key:i.key,start:i.start,size:i.size,end:i.end,lane:i.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:i})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:i,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){0!==e&&("production"!==process.env.NODE_ENV&&this.options.debug&&console.info("correction",e),Jo()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=e:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),null!==this.scrollOffset&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){this.targetWindow?null==this.rafId&&(this.rafId=this.targetWindow.requestAnimationFrame((()=>{this.rafId=null,this.reconcileScroll()}))):this.scrollState=null}reconcileScroll(){if(!this.scrollState)return;if(!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3)return void(this.scrollState=null);const e=null!=this.scrollState.index?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,t=e?e[0]:this.scrollState.lastTargetOffset,i=t!==this.scrollState.lastTargetOffset;if(!i&&((e,t)=>Math.abs(e-t)<1.01)(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1)return this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:"auto"}),void(this.scrollState=null)}else if(this.scrollState.stableFrames=0,i){const e=this.getSize()||600,i=Math.abs(t-this.getScrollOffset()),n="smooth"===this.scrollState.behavior&&i>e;this.scrollState.lastTargetOffset=t,n||(this.scrollState.behavior="auto"),this._scrollToOffset(t,{adjustments:void 0,behavior:n?"smooth":"auto"})}this.scheduleScrollReconcile()}}const ar=(e,t,i,n)=>{for(;e<=t;){const o=(e+t)/2|0,r=i(o);if(r<n)e=o+1;else{if(!(r>n))return o;t=o-1}}return e>0?e-1:0};class lr{constructor(e,t){this.cleanup=()=>{};const i={...t,onChange:(e,i)=>{var n;this.host.updateComplete.then((()=>this.host.requestUpdate())),null==(n=t.onChange)||n.call(t,e,i)}};this.virtualizer=new sr(i),(this.host=e).addController(this)}getVirtualizer(){return this.virtualizer}hostConnected(){this.cleanup=this.virtualizer._didMount()}hostUpdated(){this.virtualizer._willUpdate()}hostDisconnected(){this.cleanup()}}class Mr extends lr{constructor(e,t){super(e,{observeElementRect:er,observeElementOffset:nr,scrollToFn:rr,...t})}}class cr{static createOptionsFromValues(e,t,i,n){if(!e||Array.isArray(e)&&0===e.length)return[];const o=Array.isArray(e)?e:[e],r=n||(e=>e?.value??e);return o.map((e=>{const n=t.find((t=>{const i=r(t);return String(i)===String(e)})),o=n?i(n):e;return{value:e,selected:!0,getTextLabel:()=>{if("string"==typeof o&&/<[^>]+>/.test(o)){const e=document.createElement("div");return e.innerHTML=o,e.textContent||e.innerText||""}return o}}}))}static toggleMultiValue(e,t){return e.includes(t)?e.filter((e=>e!==t)):[...e,t]}static removeValue(e,t){return e.filter((e=>e!==t))}}class ur{constructor(){this.debounceTimer=null}filter(e,t,i){if(!t||0===t.length)return{filteredItems:[],showNoResults:!0};if(!e||""===e.trim())return{filteredItems:[...t],showNoResults:!1};const n=e.toLowerCase(),o=t.filter((e=>i(e).toLowerCase().includes(n)));return{filteredItems:o,showNoResults:0===o.length}}debounceSearch(e,t,i){this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout((()=>{e(t),this.debounceTimer=null}),i)}cancelDebounce(){this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null)}}class gr{static renderGroupHeader(e){return R`
7664
+ `;function $o(e,t,i){let n,o=i.initialDeps??[],r=!0;function s(){var s;const a="production"!==process.env.NODE_ENV&&!!i.key&&!!(null==(s=i.debug)?void 0:s.call(i));let l=0;a&&(l=Date.now());const M=e();if(!(M.length!==o.length||M.some(((e,t)=>o[t]!==e))))return n;o=M;let c=0;if(a&&(c=Date.now()),n=t(...M),a){const e=Math.round(100*(Date.now()-l))/100,t=Math.round(100*(Date.now()-c))/100,n=t/16,o=(e,t)=>{for(e=String(e);e.length<t;)e=" "+e;return e};console.info(`%c⏱ ${o(t,5)} /${o(e,5)} ms`,`\n font-size: .6rem;\n font-weight: bold;\n color: hsl(${Math.max(0,Math.min(120-120*n,120))}deg 100% 31%);`,null==i?void 0:i.key)}return!(null==i?void 0:i.onChange)||r&&i.skipInitialOnChange||i.onChange(n),r=!1,n}return s.updateDeps=e=>{o=e},s}function Go(e,t){if(void 0===e)throw new Error("Unexpected undefined"+(t?`: ${t}`:""));return e}const Fo=(e,t,i)=>{let n;return function(...o){e.clearTimeout(n),n=e.setTimeout((()=>t.apply(this,o)),i)}};let Ho;const Jo=()=>{if(void 0!==Ho)return Ho;if("undefined"==typeof navigator)return Ho=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Ho=!0;const e=navigator.maxTouchPoints;return Ho="MacIntel"===navigator.platform&&void 0!==e&&e>0},Xo=e=>{const{offsetWidth:t,offsetHeight:i}=e;return{width:t,height:i}},qo=e=>e,Ko=e=>{const t=Math.max(e.startIndex-e.overscan,0),i=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,n=new Array(i);for(let e=0;e<i;e++)n[e]=t+e;return n},er=(e,t)=>{const i=e.scrollElement;if(!i)return;const n=e.targetWindow;if(!n)return;const o=e=>{const{width:i,height:n}=e;t({width:Math.round(i),height:Math.round(n)})};if(o(Xo(i)),!n.ResizeObserver)return()=>{};const r=new n.ResizeObserver((t=>{const n=()=>{const e=t[0];if(null==e?void 0:e.borderBoxSize){const t=e.borderBoxSize[0];if(t)return void o({width:t.inlineSize,height:t.blockSize})}o(Xo(i))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(n):n()}));return r.observe(i,{box:"border-box"}),()=>{r.unobserve(i)}},tr={passive:!0},ir="undefined"==typeof window||"onscrollend"in window,nr=(e,t)=>((e,t,i)=>{const n=e.scrollElement;if(!n)return;const o=e.targetWindow;if(!o)return;const r=e.options.useScrollendEvent&&ir;let s=0;const a=r?null:Fo(o,(()=>t(s,!1)),e.options.isScrollingResetDelay),l=e=>()=>{s=i(n),null==a||a(),t(s,e)},M=l(!0),c=l(!1);return n.addEventListener("scroll",M,tr),r&&n.addEventListener("scrollend",c,tr),()=>{n.removeEventListener("scroll",M),r&&n.removeEventListener("scrollend",c)}})(e,t,(t=>{const{horizontal:i,isRtl:n}=e.options;return i?t.scrollLeft*(n?-1:1):t.scrollTop})),or=(e,t,i)=>{if(i.options.useCachedMeasurements){const t=i.indexFromElement(e),n=i.options.getItemKey(t);return i.itemSizeCache.get(n)??i.options.estimateSize(t)}if(null==t?void 0:t.borderBoxSize){const e=t.borderBoxSize[0];if(e){return Math.round(e[i.options.horizontal?"inlineSize":"blockSize"])}}if(!t){const t=i.indexFromElement(e),n=i.options.getItemKey(t),o=i.itemSizeCache.get(n);if(void 0!==o)return o}return e[i.options.horizontal?"offsetWidth":"offsetHeight"]},rr=(e,{adjustments:t=0,behavior:i},n)=>{var o,r;null==(r=null==(o=n.scrollElement)?void 0:o.scrollTo)||r.call(o,{[n.options.horizontal?"left":"top"]:e+t,behavior:i})};class sr{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e,t,i;return(null==(i=null==(t=null==(e=this.targetWindow)?void 0:e.performance)?void 0:t.now)?void 0:i.call(t))??Date.now()},this.observer=(()=>{let e=null;const t=()=>e||(this.targetWindow&&this.targetWindow.ResizeObserver?e=new this.targetWindow.ResizeObserver((e=>{e.forEach((e=>{const t=()=>{const t=e.target,i=this.indexFromElement(t);if(t.isConnected)this.shouldMeasureDuringScroll(i)&&this.resizeItem(i,this.options.measureElement(t,e,this));else{this.observer.unobserve(t);for(const[e,i]of this.elementsCache)if(i===t){this.elementsCache.delete(e);break}}};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()}))})):null);return{disconnect:()=>{var i;null==(i=t())||i.disconnect(),e=null},observe:e=>{var i;return null==(i=t())?void 0:i.observe(e,{box:"border-box"})},unobserve:e=>{var i;return null==(i=t())?void 0:i.unobserve(e)}}})(),this.range=null,this.setOptions=e=>{var t,i;const n={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:qo,rangeExtractor:Ko,onChange:()=>{},measureElement:or,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const t in e){const i=e[t];void 0!==i&&(n[t]=i)}const o=this.options;let r=null,s=null,a=!1;if(void 0!==o&&o.enabled&&n.enabled&&"end"===n.anchorTo&&null!==this.scrollElement){const e=o.count,l=n.count,M=this.getMeasurements(),c=e>0?(null==(t=M[0])?void 0:t.key)??o.getItemKey(0):null,u=e>0?(null==(i=M[e-1])?void 0:i.key)??o.getItemKey(e-1):null;if(l!==e||e>0&&l>0&&(n.getItemKey(0)!==c||n.getItemKey(l-1)!==u)){a=!0;const t=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??M[0]:null;t&&(r=[t.key,this.getScrollOffset()-t.start]);const i=!0===n.followOnAppend?"auto":n.followOnAppend||null;i&&l>e&&this.isAtEnd(o.scrollEndThreshold)&&(0===e||n.getItemKey(l-1)!==u)&&(s=i)}}this.options=n,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let l=!1,M=0;if(r&&null!==this.scrollOffset){const[e,t]=r,i=this.getMeasurements(),{count:n,getItemKey:o}=this.options;let s=0;for(;s<n&&o(s)!==e;)s++;if(s<n){const e=i[s];if(e){const i=Math.max(0,e.start+t);i!==this.scrollOffset&&(M=i-this.scrollOffset,this.scrollOffset=i,l=!0)}}}(l||s)&&(this.pendingScrollAnchor=[l?r[0]:null,l?r[1]:0,s,M])},this.notify=e=>{var t,i;null==(i=(t=this.options).onChange)||i.call(t,this,e)},this.maybeNotify=$o((()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null])),(e=>{this.notify(e)}),{key:"production"!==process.env.NODE_ENV&&"maybeNotify",debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach((e=>e())),this.unsubs=[],this.observer.disconnect(),null!=this.rafId&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var e;const t=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==t){if(this.cleanup(),!t)return void this.maybeNotify();if(this.scrollElement=t,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=(null==(e=this.scrollElement)?void 0:e.window)??null,this.elementsCache.forEach((e=>{this.observer.observe(e)})),this.unsubs.push(this.options.observeElementRect(this,(e=>{this.scrollRect=e,this.maybeNotify()}))),this.unsubs.push(this.options.observeElementOffset(this,((e,t)=>{if(t&&null===this._intendedScrollOffset&&e===this.scrollOffset)return;null!==this._intendedScrollOffset&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const i=this.getScrollOffset();this.scrollDirection=t?i===e?this.scrollDirection:i<e?"forward":"backward":null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()}))),"addEventListener"in this.scrollElement){const e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,null!==this._iosTouchEndTimerId&&null!=this.targetWindow&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},i=()=>{this._iosTouching=!1,Jo()&&null!=this.targetWindow&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout((()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()}),150))};e.addEventListener("touchstart",t,tr),e.addEventListener("touchend",i,tr),this.unsubs.push((()=>{e.removeEventListener("touchstart",t),e.removeEventListener("touchend",i),null!==this._iosTouchEndTimerId&&null!=this.targetWindow&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)}))}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const i=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,i&&this.scrollElement&&this.options.enabled){const[e,t,n,o]=i;null===e||n||(Jo()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?0!==o&&(this._iosDeferredAdjustment+=o):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),n&&this.scrollToEnd({behavior:n})}},this._flushIosDeferredIfReady=()=>{if(0===this._iosDeferredAdjustment)return;if(this.isScrolling)return;if(this._iosTouching)return;if(this._iosJustTouchEnded)return;const e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;if(this._iosDeferredAdjustment<0&&e>=t-1)return void(this._iosDeferredAdjustment=0);const i=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=i,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??("function"==typeof this.options.initialOffset?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=$o((()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap]),((e,t,i,n,o,r,s,a)=>(void 0!==this.prevLanes&&this.prevLanes!==r&&(this.lanesChangedFlag=!0),this.prevLanes=r,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:i,getItemKey:n,enabled:o,lanes:r,laneAssignmentMode:s,gap:a})),{key:!1}),this.getMeasurements=$o((()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion]),(({count:e,paddingStart:t,scrollMargin:i,getItemKey:n,enabled:o,lanes:r,laneAssignmentMode:s,gap:a},l)=>{const M=this.itemSizeCache;if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(const t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),0!==this.measurementsCache.length||this.lanesSettling||(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach((e=>{this.itemSizeCache.set(e.key,e.size)})));const c=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),1===r){const o=2*e;let r,s=this._flatMeasurements;if(!s||s.length<o){const e=new Float64Array(o);s&&c>0&&e.set(s.subarray(0,2*c)),s=e,this._flatMeasurements=s}if(0===c)r=t+i;else{const e=c-1;r=s[2*e]+s[2*e+1]+a}for(let t=c;t<e;t++){const e=n(t),i=M.get(e),o="number"==typeof i?i:this.options.estimateSize(t);s[2*t]=r,s[2*t+1]=o,r+=o+a}const l=function(e,t,i){const n=new Array(e);return new Proxy(n,{get(n,o,r){if("string"==typeof o){const r=o.charCodeAt(0);if(r>=48&&r<=57){const r=+o;if(Number.isInteger(r)&&r>=0&&r<e){let e=n[r];if(!e){const o=t[2*r];e=n[r]={index:r,key:i(r),start:o,size:t[2*r+1],end:o+t[2*r+1],lane:0}}return e}}if("length"===o)return e}return Reflect.get(n,o,r)}})}(e,s,n);return this.measurementsCache=l,l}const u=this.measurementsCache.slice(0,c),g=new Array(r).fill(void 0),d=new Float64Array(r);let h=0;for(let e=0;e<c;e++){const t=u[e];t&&(void 0===g[t.lane]&&h++,g[t.lane]=e,d[t.lane]=t.end)}for(let o=c;o<e;o++){const e=n(o),l=this.laneAssignments.get(o);let c,N;const p="estimate"===s||M.has(e);if(void 0!==l&&this.options.lanes>1){c=l;const e=g[c],n=void 0!==e?u[e]:void 0;N=n?n.end+a:t+i}else if(h===r){let e=0,t=d[0],i=g[0];for(let n=1;n<r;n++){const o=d[n];(o<t||o===t&&g[n]<i)&&(e=n,t=o,i=g[n])}c=e,N=t+a,p&&this.laneAssignments.set(o,c)}else c=o%this.options.lanes,N=t+i,p&&this.laneAssignments.set(o,c);const D=M.get(e),y="number"==typeof D?D:this.options.estimateSize(o),I=N+y;u[o]={index:o,start:N,size:y,end:I,key:e,lane:c},void 0===g[c]&&h++,g[c]=o,d[c]=I}return this.measurementsCache=u,u}),{key:"production"!==process.env.NODE_ENV&&"getMeasurements",debug:()=>this.options.debug}),this.calculateRange=$o((()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes]),((e,t,i,n)=>0===e.length||0===t?(this.range=null,null):(this.range=function(e,t,i,n,o){const r=e.length-1;if(e.length<=n)return{startIndex:0,endIndex:r};if(1===n&&null!==o){const e=function(e,t,i){let n=0;for(;n<=t;){const o=(n+t)/2|0,r=e[2*o];if(r<i)n=o+1;else{if(!(r>i))return o;t=o-1}}return n>0?n-1:0}(o,r,i);let n=e;const s=i+t;for(;n<r&&o[2*n]+o[2*n+1]<s;)n++;return{startIndex:e,endIndex:n}}const s=t=>e[t].start;let a=ar(0,r,s,i),l=a;if(1===n)for(;l<r&&e[l].end<i+t;)l++;else if(n>1){const o=Array(n).fill(0);for(;l<r&&o.some((e=>e<i+t));){const t=e[l];o[t.lane]=t.end,l++}const s=Array(n).fill(i+t);for(;a>=0&&s.some((e=>e>=i));){const t=e[a];s[t.lane]=t.start,a--}a=Math.max(0,a-a%n),l=Math.min(r,l+(n-1-l%n))}return{startIndex:a,endIndex:l}}(e,t,i,n,1===n&&null!=this._flatMeasurements?this._flatMeasurements:null),this.range)),{key:"production"!==process.env.NODE_ENV&&"calculateRange",debug:()=>this.options.debug}),this.getVirtualIndexes=$o((()=>{let e=null,t=null;const i=this.calculateRange();return i&&(e=i.startIndex,t=i.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]}),((e,t,i,n,o)=>null===n||null===o?[]:e({startIndex:n,endIndex:o,overscan:t,count:i})),{key:"production"!==process.env.NODE_ENV&&"getVirtualIndexes",debug:()=>this.options.debug}),this.indexFromElement=e=>{const t=this.options.indexAttribute,i=e.getAttribute(t);return i?parseInt(i,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{var t;if(!this.scrollState||"smooth"!==this.scrollState.behavior)return!0;const i=this.scrollState.index??(null==(t=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))?void 0:t.index);if(void 0!==i&&this.range){const t=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),n=Math.max(0,i-t),o=Math.min(this.options.count-1,i+t);return e>=n&&e<=o}return!0},this.measureElement=e=>{if(!e)return void this.elementsCache.forEach(((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))}));const t=this.indexFromElement(e),i=this.options.getItemKey(t),n=this.elementsCache.get(i);n!==e&&(n&&this.observer.unobserve(n),this.observer.observe(e),this.elementsCache.set(i,e)),this.isScrolling&&!this.scrollState||!this.shouldMeasureDuringScroll(t)||this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{var i,n;if(e<0||e>=this.options.count)return;let o,r,s;const a=this._flatMeasurements;if(1===this.options.lanes&&null!==a)s=this.options.getItemKey(e),r=a[2*e],o=a[2*e+1];else{const t=this.measurementsCache[e];if(!t)return;s=t.key,r=t.start,o=t.size}const l=this.itemSizeCache.get(s)??o,M=t-l;if(0!==M){const a="end"===this.options.anchorTo&&"smooth"!==(null==(i=this.scrollState)?void 0:i.behavior)&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,c=a?this.getTotalSize():0,u=this.getScrollOffset()+this.scrollAdjustments,g=!this.itemSizeCache.has(s)?r<u:r+l<=u&&"backward"!==this.scrollDirection,d="smooth"!==(null==(n=this.scrollState)?void 0:n.behavior)&&(void 0!==this.shouldAdjustScrollPositionOnItemSizeChange?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:s,start:r,size:o,end:r+o,lane:0},M,this):g);(null===this.pendingMin||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(s,t),this.itemSizeCacheVersion++;let h=!1;a?h=this.applyScrollAdjustment(this.getTotalSize()-c):d&&(h=this.applyScrollAdjustment(M)),this.notify(h)}},this.getVirtualItems=$o((()=>[this.getVirtualIndexes(),this.getMeasurements()]),((e,t)=>{const i=[];for(let n=0,o=e.length;n<o;n++){const o=t[e[n]];i.push(o)}return i}),{key:"production"!==process.env.NODE_ENV&&"getVirtualItems",debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{const t=this.getMeasurements();if(0===t.length)return;const i=this._flatMeasurements,n=1===this.options.lanes&&null!=i,o=ar(0,t.length-1,n?e=>i[2*e]:e=>Go(t[e]).start,e);return Go(t[o])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,i=0)=>{if(!this.scrollElement)return 0;const n=this.getSize(),o=this.getScrollOffset();"auto"===t&&(t=e>=o+n?"end":"start"),"center"===t?e+=(i-n)/2:"end"===t&&(e-=n);const r=this.getMaxScrollOffset();return Math.max(Math.min(r,e),0)},this.getOffsetForIndex=(e,t="auto")=>{e=Math.max(0,Math.min(e,this.options.count-1));const i=this.getSize(),n=this.getScrollOffset(),o=this.measurementsCache[e];if(!o)return;if("auto"===t)if(o.end>=n+i-this.options.scrollPaddingEnd)t="end";else{if(!(o.start<=n+this.options.scrollPaddingStart))return[n,t];t="start"}if("end"===t&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];const r="end"===t?o.end+this.options.scrollPaddingEnd:o.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(r,t,o.size),t]},this.scrollToOffset=(e,{align:t="start",behavior:i="auto"}={})=>{this._iosDeferredAdjustment=0;const n=this.getOffsetForAlignment(e,t),o=this.now();this.scrollState={index:null,align:t,behavior:i,startedAt:o,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t="auto",behavior:i="auto"}={})=>{this._iosDeferredAdjustment=0,e=Math.max(0,Math.min(e,this.options.count-1));const n=this.getOffsetForIndex(e,t);if(!n)return;const[o,r]=n,s=this.now();this.scrollState={index:e,align:r,behavior:i,startedAt:s,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t="auto"}={})=>{const i=this.getScrollOffset()+e,n=this.now();this.scrollState={index:null,align:"start",behavior:t,startedAt:n,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e="auto"}={})=>{this.options.count>0?this.scrollToIndex(this.options.count-1,{align:"end",behavior:e}):this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{var e;const t=this.getMeasurements();let i;if(0===t.length)i=this.options.paddingStart;else if(1===this.options.lanes){const n=t.length-1,o=this._flatMeasurements;i=null!=o?o[2*n]+o[2*n+1]:(null==(e=t[n])?void 0:e.end)??0}else{const e=Array(this.options.lanes).fill(null);let n=t.length-1;for(;n>=0&&e.some((e=>null===e));){const i=t[n];null===e[i.lane]&&(e[i.lane]=i.end),n--}i=Math.max(...e.filter((e=>null!==e)))}return Math.max(i-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const e=[];if(0===this.itemSizeCache.size)return e;const t=this.getMeasurements();for(const i of t)i&&this.itemSizeCache.has(i.key)&&e.push({index:i.index,key:i.key,start:i.start,size:i.size,end:i.end,lane:i.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:i})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:i,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){return 0!==e&&("production"!==process.env.NODE_ENV&&this.options.debug&&console.info("correction",e),Jo()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?(this._iosDeferredAdjustment+=e,!1):(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),null!==this.scrollOffset&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0))}scheduleScrollReconcile(){this.targetWindow?null==this.rafId&&(this.rafId=this.targetWindow.requestAnimationFrame((()=>{this.rafId=null,this.reconcileScroll()}))):this.scrollState=null}reconcileScroll(){if(!this.scrollState)return;if(!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3)return void(this.scrollState=null);const e=null!=this.scrollState.index?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,t=e?e[0]:this.scrollState.lastTargetOffset,i=t!==this.scrollState.lastTargetOffset;if(!i&&((e,t)=>Math.abs(e-t)<1.01)(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1)return this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:"auto"}),void(this.scrollState=null)}else if(this.scrollState.stableFrames=0,i){const e=this.getSize()||600,i=Math.abs(t-this.getScrollOffset()),n="smooth"===this.scrollState.behavior&&i>e;this.scrollState.lastTargetOffset=t,n||(this.scrollState.behavior="auto"),this._scrollToOffset(t,{adjustments:void 0,behavior:n?"smooth":"auto"})}this.scheduleScrollReconcile()}}const ar=(e,t,i,n)=>{for(;e<=t;){const o=(e+t)/2|0,r=i(o);if(r<n)e=o+1;else{if(!(r>n))return o;t=o-1}}return e>0?e-1:0};class lr{constructor(e,t){this.cleanup=()=>{};const i={...t,onChange:(e,i)=>{var n;this.host.updateComplete.then((()=>this.host.requestUpdate())),null==(n=t.onChange)||n.call(t,e,i)}};this.virtualizer=new sr(i),(this.host=e).addController(this)}getVirtualizer(){return this.virtualizer}hostConnected(){this.cleanup=this.virtualizer._didMount()}hostUpdated(){this.virtualizer._willUpdate()}hostDisconnected(){this.cleanup()}}class Mr extends lr{constructor(e,t){super(e,{observeElementRect:er,observeElementOffset:nr,scrollToFn:rr,...t})}}class cr{static createOptionsFromValues(e,t,i,n){if(!e||Array.isArray(e)&&0===e.length)return[];const o=Array.isArray(e)?e:[e],r=n||(e=>e?.value??e);return o.map((e=>{const n=t.find((t=>{const i=r(t);return String(i)===String(e)})),o=n?i(n):e;return{value:e,selected:!0,getTextLabel:()=>{if("string"==typeof o&&/<[^>]+>/.test(o)){const e=document.createElement("div");return e.innerHTML=o,e.textContent||e.innerText||""}return o}}}))}static toggleMultiValue(e,t){return e.includes(t)?e.filter((e=>e!==t)):[...e,t]}static removeValue(e,t){return e.filter((e=>e!==t))}}class ur{constructor(){this.debounceTimer=null}filter(e,t,i){if(!t||0===t.length)return{filteredItems:[],showNoResults:!0};if(!e||""===e.trim())return{filteredItems:[...t],showNoResults:!1};const n=e.toLowerCase(),o=t.filter((e=>i(e).toLowerCase().includes(n)));return{filteredItems:o,showNoResults:0===o.length}}debounceSearch(e,t,i){this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout((()=>{e(t),this.debounceTimer=null}),i)}cancelDebounce(){this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null)}}class gr{static renderGroupHeader(e){return R`
7611
7665
  <div
7612
7666
  part="group-header"
7613
7667
  class="combobox__group-header"
@@ -18288,7 +18342,7 @@ nile-rich-text-editor[disabled] .editor figure.rte-image {
18288
18342
  ${this._renderTrigger()}
18289
18343
  ${e}
18290
18344
  </nile-popover>
18291
- `:e}};e([de({type:String,attribute:!0,reflect:!0})],rL.prototype,"type",void 0),e([de({type:String,attribute:!0,reflect:!0})],rL.prototype,"value",void 0),e([de({type:String,reflect:!0})],rL.prototype,"swatchTooltip",void 0),e([de({type:Number,reflect:!0})],rL.prototype,"recentColorsCount",void 0),e([de({type:Boolean,reflect:!0})],rL.prototype,"noFill",void 0),e([de({type:String,reflect:!0})],rL.prototype,"mode",void 0),e([de({type:Boolean,reflect:!0})],rL.prototype,"showCanvas",void 0),e([de({type:Boolean,reflect:!0})],rL.prototype,"showHue",void 0),e([de({type:Boolean,reflect:!0})],rL.prototype,"showInputs",void 0),e([de({type:Boolean,reflect:!0})],rL.prototype,"showActions",void 0),e([de({type:Boolean,reflect:!0,attribute:!0})],rL.prototype,"open",void 0),e([de({attribute:"palette",converter:{fromAttribute:e=>{try{const t=JSON.parse(e);return Array.isArray(t)?t.map((e=>"string"==typeof e?{color:e,name:e}:e&&"string"==typeof e.color?{color:e.color,name:e.name||e.color}:null)).filter(Boolean):[]}catch{return[]}},toAttribute:e=>JSON.stringify(e)}})],rL.prototype,"palette",void 0),e([he()],rL.prototype,"_view",void 0),e([he()],rL.prototype,"_recentColors",void 0),e([he()],rL.prototype,"_hue",void 0),e([he()],rL.prototype,"_sat",void 0),e([he()],rL.prototype,"_val",void 0),e([he()],rL.prototype,"_colorMode",void 0),e([he()],rL.prototype,"_hexInput",void 0),e([he()],rL.prototype,"_r",void 0),e([he()],rL.prototype,"_g",void 0),e([he()],rL.prototype,"_b",void 0),rL=e([ce("nile-color-picker")],rL);"undefined"!=typeof window&&(window.nileElementsVersion='"1.9.9"',window.nileVersion="__NILE_VERSION__",window.process=window.process||{env:{NODE_ENV:"production"}});const sL=s`
18345
+ `:e}};e([de({type:String,attribute:!0,reflect:!0})],rL.prototype,"type",void 0),e([de({type:String,attribute:!0,reflect:!0})],rL.prototype,"value",void 0),e([de({type:String,reflect:!0})],rL.prototype,"swatchTooltip",void 0),e([de({type:Number,reflect:!0})],rL.prototype,"recentColorsCount",void 0),e([de({type:Boolean,reflect:!0})],rL.prototype,"noFill",void 0),e([de({type:String,reflect:!0})],rL.prototype,"mode",void 0),e([de({type:Boolean,reflect:!0})],rL.prototype,"showCanvas",void 0),e([de({type:Boolean,reflect:!0})],rL.prototype,"showHue",void 0),e([de({type:Boolean,reflect:!0})],rL.prototype,"showInputs",void 0),e([de({type:Boolean,reflect:!0})],rL.prototype,"showActions",void 0),e([de({type:Boolean,reflect:!0,attribute:!0})],rL.prototype,"open",void 0),e([de({attribute:"palette",converter:{fromAttribute:e=>{try{const t=JSON.parse(e);return Array.isArray(t)?t.map((e=>"string"==typeof e?{color:e,name:e}:e&&"string"==typeof e.color?{color:e.color,name:e.name||e.color}:null)).filter(Boolean):[]}catch{return[]}},toAttribute:e=>JSON.stringify(e)}})],rL.prototype,"palette",void 0),e([he()],rL.prototype,"_view",void 0),e([he()],rL.prototype,"_recentColors",void 0),e([he()],rL.prototype,"_hue",void 0),e([he()],rL.prototype,"_sat",void 0),e([he()],rL.prototype,"_val",void 0),e([he()],rL.prototype,"_colorMode",void 0),e([he()],rL.prototype,"_hexInput",void 0),e([he()],rL.prototype,"_r",void 0),e([he()],rL.prototype,"_g",void 0),e([he()],rL.prototype,"_b",void 0),rL=e([ce("nile-color-picker")],rL);"undefined"!=typeof window&&(window.nileElementsVersion='"1.9.11"',window.nileVersion="__NILE_VERSION__",window.process=window.process||{env:{NODE_ENV:"production"}});const sL=s`
18292
18346
  :host {
18293
18347
 
18294
18348
  top: 0;
@@ -20462,6 +20516,17 @@ a {
20462
20516
  cursor: pointer;
20463
20517
  }
20464
20518
 
20519
+ :host([data-has-label]:focus-visible) {
20520
+ outline: none;
20521
+ }
20522
+
20523
+ :host([data-has-label]:focus-visible:not([disabled])) [part~='name'] {
20524
+ outline: var(--nile-border-width-2, var(--ng-border-width-2)) var(--nile-border-style-solid, var(--ng-border-style-solid))
20525
+ var(--nile-colors-primary-600, var(--ng-colors-text-brand-secondary-700));
20526
+ outline-offset: var(--nile-spacing-1px, var(--ng-outline-offset-1, 1px));
20527
+ border-radius: var(--nile-radius-radius-xs, var(--ng-radius-xxs));
20528
+ }
20529
+
20465
20530
  :host([centered]) {
20466
20531
  flex: 1;
20467
20532
  text-align: center;
@@ -20637,7 +20702,7 @@ a {
20637
20702
  }
20638
20703
 
20639
20704
 
20640
- `;let ok=0,rk=class extends Ge{constructor(){super(...arguments),this.attrId=++ok,this.componentId=`nile-nav-tab-${this.attrId}`,this.panel="",this.active=!1,this.closable=!1,this.disabled=!1,this.centered=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","tab"),this.syncA11yState()}firstUpdated(){this.syncA11yState(),this.updateAccessibleName()}updated(){this.syncA11yState(),this.updateAccessibleName()}syncA11yState(){this.id=this.id||this.componentId,this.tabIndex=this.disabled?-1:this.active?0:-1,this.setAttribute("aria-selected",this.active?"true":"false"),this.setAttribute("aria-disabled",this.disabled?"true":"false"),this.disabled?this.setAttribute("aria-hidden","true"):this.removeAttribute("aria-hidden")}updateAccessibleName(){if(this.hasAttribute("aria-label")&&"true"!==this.getAttribute("data-auto-aria-label"))return;const e=(this.textContent||"").replace(/\s+/g," ").trim();e?(this.setAttribute("aria-label",e),this.setAttribute("data-auto-aria-label","true")):(this.removeAttribute("aria-label"),this.removeAttribute("data-auto-aria-label"))}handleCloseClick(e){e.preventDefault(),e.stopPropagation(),this.emit("nile-close")}handleTabClick(e){if(this.disabled)return e.preventDefault(),void e.stopPropagation();Object.values(dt).some((t=>e[t]))||0!==e.button||e.preventDefault()}handleActiveChange(){this.syncA11yState()}handleDisabledChange(){this.syncA11yState()}focus(e){super.focus(e)}blur(){super.blur()}render(){return this.id=this.id||this.componentId,R`
20705
+ `;let ok=0,rk=class extends Ge{constructor(){super(...arguments),this.attrId=++ok,this.componentId=`nile-nav-tab-${this.attrId}`,this.panel="",this.active=!1,this.closable=!1,this.disabled=!1,this.centered=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","tab"),this.syncA11yState()}firstUpdated(){this.syncA11yState(),this.updateAccessibleName()}updated(){this.syncA11yState(),this.updateAccessibleName()}syncA11yState(){this.id=this.id||this.componentId,this.tabIndex=this.disabled?-1:this.active?0:-1,this.setAttribute("aria-selected",this.active?"true":"false"),this.setAttribute("aria-disabled",this.disabled?"true":"false"),this.disabled?this.setAttribute("aria-hidden","true"):this.removeAttribute("aria-hidden")}hasLabelText(){const e=this.shadowRoot?.querySelector("slot:not([name])");return!!e&&""!==e.assignedNodes({flatten:!0}).map((e=>e.textContent??"")).join("").trim()}updateAccessibleName(){this.toggleAttribute("data-has-label",this.hasLabelText());if(this.hasAttribute("aria-label")&&"true"!==this.getAttribute("data-auto-aria-label"))return;const e=(this.textContent||"").replace(/\s+/g," ").trim();e?(this.setAttribute("aria-label",e),this.setAttribute("data-auto-aria-label","true")):(this.removeAttribute("aria-label"),this.removeAttribute("data-auto-aria-label"))}handleCloseClick(e){e.preventDefault(),e.stopPropagation(),this.emit("nile-close")}handleTabClick(e){if(this.disabled)return e.preventDefault(),void e.stopPropagation();Object.values(dt).some((t=>e[t]))||0!==e.button||e.preventDefault()}handleActiveChange(){this.syncA11yState()}handleDisabledChange(){this.syncA11yState()}focus(e){super.focus(e)}blur(){super.blur()}render(){return this.id=this.id||this.componentId,R`
20641
20706
  <li part="base tab" class="nav-tab-container" role="presentation">
20642
20707
  <nile-link
20643
20708
  class=${Ae({"nav-tab":!0,"tab--centered":this.centered,"nav-tab--active":this.active,"nav-tab--closable":this.closable,"nav-tab--disabled":this.disabled})}
@@ -20693,8 +20758,7 @@ const sk="important",ak=" !"+sk,lk=Te(class extends xe{constructor(e){if(super(e
20693
20758
  -moz-osx-font-smoothing: var(--nile-moz-osx-font-smoothing, var(--ng-moz-osx-font-smoothing));
20694
20759
  text-rendering: var(--nile-text-rendering, var(--ng-text-rendering));
20695
20760
  display: block;
20696
-
20697
- --nile-nav-tab-padding: var(--nile-spacing-none, var(--ng-spacing-none)) var(--nile-spacing-none, var(--ng-spacing-none)) var(--nile-spacing-lg, var(--ng-spacing-lg)) var(--nile-spacing-none, var(--ng-spacing-none)) ;
20761
+ --nile-nav-tab-padding: var(--nile-spacing-xs, var(--ng-spacing-xs)) var(--nile-spacing-xs, var(--ng-spacing-xs)) var(--nile-spacing-lg, var(--ng-spacing-lg)) var(--nile-spacing-xs, var(--ng-spacing-xs));
20698
20762
  }
20699
20763
 
20700
20764
 
@@ -22888,7 +22952,7 @@ const sk="important",ak=" !"+sk,lk=Te(class extends xe{constructor(e){if(super(e
22888
22952
  `:B}
22889
22953
  </div>
22890
22954
  </div>
22891
- `}};function hC(e){this.content=e}function NC(e,t,i){for(let n=0;;n++){if(n==e.childCount||n==t.childCount)return e.childCount==t.childCount?null:i;let o=e.child(n),r=t.child(n);if(o!=r){if(!o.sameMarkup(r))return i;if(o.isText&&o.text!=r.text){let e=o.text,t=r.text,n=0;for(;e[n]==t[n];n++)i++;return n&&n<e.length&&n<t.length&&yC(e.charCodeAt(n-1))&&DC(e.charCodeAt(n))&&i--,i}if(o.content.size||r.content.size){let e=NC(o.content,r.content,i+1);if(null!=e)return e}i+=o.nodeSize}else i+=o.nodeSize}}function pC(e,t,i,n){for(let o=e.childCount,r=t.childCount;;){if(0==o||0==r)return o==r?null:{a:i,b:n};let s=e.child(--o),a=t.child(--r),l=s.nodeSize;if(s!=a){if(!s.sameMarkup(a))return{a:i,b:n};if(s.isText&&s.text!=a.text){let e=s.text,t=a.text,o=e.length,r=t.length;for(;o>0&&r>0&&e[o-1]==t[r-1];)o--,r--,i--,n--;return o&&r&&o<e.length&&yC(e.charCodeAt(o-1))&&DC(e.charCodeAt(o))&&(i++,n++),{a:i,b:n}}if(s.content.size||a.content.size){let e=pC(s.content,a.content,i-1,n-1);if(e)return e}i-=l,n-=l}else i-=l,n-=l}}function DC(e){return e>=56320&&e<57344}function yC(e){return e>=55296&&e<56320}dC.styles=MC,e([de()],dC.prototype,"value",void 0),e([de()],dC.prototype,"placeholder",void 0),e([de({type:Boolean,reflect:!0})],dC.prototype,"disabled",void 0),e([de({type:Boolean,reflect:!0})],dC.prototype,"readonly",void 0),e([de({type:Number})],dC.prototype,"rows",void 0),e([de({reflect:!0})],dC.prototype,"mode",void 0),e([de({type:Boolean,attribute:"hide-toolbar"})],dC.prototype,"hideToolbar",void 0),e([de({converter:{fromAttribute:e=>{if(!e)return[];try{const t=JSON.parse(e);if(Array.isArray(t))return t.map((e=>String(e).trim())).filter(Boolean)}catch{}return e.split(",").map((e=>e.trim())).filter(Boolean)},toAttribute:e=>JSON.stringify(e??[])}})],dC.prototype,"tools",void 0),e([pe("textarea")],dC.prototype,"textarea",void 0),e([pe(".body")],dC.prototype,"bodyEl",void 0),e([he()],dC.prototype,"splitRatio",void 0),e([he()],dC.prototype,"splitDragging",void 0),dC=e([ce("nile-markdown-editor")],dC),hC.prototype={constructor:hC,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return-1==t?void 0:this.content[t+1]},update:function(e,t,i){var n=i&&i!=e?this.remove(i):this,o=n.find(e),r=n.content.slice();return-1==o?r.push(i||e,t):(r[o+1]=t,i&&(r[o]=i)),new hC(r)},remove:function(e){var t=this.find(e);if(-1==t)return this;var i=this.content.slice();return i.splice(t,2),new hC(i)},addToStart:function(e,t){return new hC([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var i=this.remove(e).content.slice();return i.push(e,t),new hC(i)},addBefore:function(e,t,i){var n=this.remove(t),o=n.content.slice(),r=n.find(e);return o.splice(-1==r?o.length:r,0,t,i),new hC(o)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=hC.from(e)).size?new hC(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=hC.from(e)).size?new hC(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=hC.from(e);for(var i=0;i<e.content.length;i+=2)t=t.remove(e.content[i]);return t},toObject:function(){var e={};return this.forEach((function(t,i){e[t]=i})),e},get size(){return this.content.length>>1}},hC.from=function(e){if(e instanceof hC)return e;var t=[];if(e)for(var i in e)t.push(i,e[i]);return new hC(t)};class IC{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,i,n=0,o){for(let r=0,s=0;s<t;r++){let a=this.content[r],l=s+a.nodeSize;if(l>e&&!1!==i(a,n+s,o||null,r)&&a.content.size){let o=s+1;a.nodesBetween(Math.max(0,e-o),Math.min(a.content.size,t-o),i,n+o)}s=l}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,i,n){let o="",r=!0;return this.nodesBetween(e,t,((s,a)=>{let l=s.isText?s.text.slice(Math.max(e,a)-a,t-a):s.isLeaf?n?"function"==typeof n?n(s):n:s.type.spec.leafText?s.type.spec.leafText(s):"":"";s.isBlock&&(s.isLeaf&&l||s.isTextblock)&&i&&(r?r=!1:o+=i),o+=l}),0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,i=e.firstChild,n=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(i)&&(n[n.length-1]=t.withText(t.text+i.text),o=1);o<e.content.length;o++)n.push(e.content[o]);return new IC(n,this.size+e.size)}cut(e,t=this.size){if(0==e&&t==this.size)return this;let i=[],n=0;if(t>e)for(let o=0,r=0;r<t;o++){let s=this.content[o],a=r+s.nodeSize;a>e&&((r<e||a>t)&&(s=s.isText?s.cut(Math.max(0,e-r),Math.min(s.text.length,t-r)):s.cut(Math.max(0,e-r-1),Math.min(s.content.size,t-r-1))),i.push(s),n+=s.nodeSize),r=a}return new IC(i,n)}cutByIndex(e,t){return e==t?IC.empty:0==e&&t==this.content.length?this:new IC(this.content.slice(e,t))}replaceChild(e,t){let i=this.content[e];if(i==t)return this;let n=this.content.slice(),o=this.size+t.nodeSize-i.nodeSize;return n[e]=t,new IC(n,o)}addToStart(e){return new IC([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new IC(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,i=0;t<this.content.length;t++){let n=this.content[t];e(n,i,t),i+=n.nodeSize}}findDiffStart(e,t=0){return NC(this,e,t)}findDiffEnd(e,t=this.size,i=e.size){return pC(this,e,t,i)}findIndex(e){if(0==e)return zC(0,e);if(e==this.size)return zC(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,i=0;;t++){let n=i+this.child(t).nodeSize;if(n>=e)return n==e?zC(t+1,n):zC(t,i);i=n}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((e=>e.toJSON())):null}static fromJSON(e,t){if(!t)return IC.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return IC.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return IC.empty;let t,i=0;for(let n=0;n<e.length;n++){let o=e[n];i+=o.nodeSize,n&&o.isText&&e[n-1].sameMarkup(o)?(t||(t=e.slice(0,n)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new IC(t||e,i)}static from(e){if(!e)return IC.empty;if(e instanceof IC)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new IC([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}IC.empty=new IC([],0);const jC={index:0,offset:0};function zC(e,t){return jC.index=e,jC.offset=t,jC}function mC(e,t){if(e===t)return!0;if(!e||"object"!=typeof e||!t||"object"!=typeof t)return!1;let i=Array.isArray(e);if(Array.isArray(t)!=i)return!1;if(i){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(!mC(e[i],t[i]))return!1}else{for(let i in e)if(!(i in t)||!mC(e[i],t[i]))return!1;for(let i in t)if(!(i in e))return!1}return!0}class TC{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,i=!1;for(let n=0;n<e.length;n++){let o=e[n];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,n));else{if(o.type.excludes(this.type))return e;!i&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,n)),t.push(this),i=!0),t&&t.push(o)}}return t||(t=e.slice()),i||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&mC(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let i=e.marks[t.type];if(!i)throw new RangeError(`There is no mark type ${t.type} in this schema`);let n=i.create(t.attrs);return i.checkAttrs(n.attrs),n}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(!e[i].eq(t[i]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return TC.none;if(e instanceof TC)return[e];let t=e.slice();return t.sort(((e,t)=>e.type.rank-t.type.rank)),t}}TC.none=[];class xC extends Error{}class AC{constructor(e,t,i){this.content=e,this.openStart=t,this.openEnd=i}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let i=fC(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return i&&new AC(i,this.openStart,this.openEnd)}removeBetween(e,t){return new AC(OC(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return AC.empty;let i=t.openStart||0,n=t.openEnd||0;if("number"!=typeof i||"number"!=typeof n)throw new RangeError("Invalid input for Slice.fromJSON");return new AC(IC.fromJSON(e,t.content),i,n)}static maxOpen(e,t=!0){let i=0,n=0;for(let n=e.firstChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.firstChild)i++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)n++;return new AC(e,i,n)}}function OC(e,t,i){let{index:n,offset:o}=e.findIndex(t),r=e.maybeChild(n),{index:s,offset:a}=e.findIndex(i);if(o==t||r.isText){if(a!=i&&!e.child(s).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(i))}if(n!=s)throw new RangeError("Removing non-flat range");return e.replaceChild(n,r.copy(OC(r.content,t-o-1,i-o-1)))}function fC(e,t,i,n,o,r){let{index:s,offset:a}=e.findIndex(t),l=e.maybeChild(s);if(a==t||l.isText)return r&&n<=0&&o<=0&&!r.canReplace(s,s,i)?null:e.cut(0,t).append(i).append(e.cut(t));let M=fC(l.content,t-a-1,i,0==s?n-1:0,s==e.childCount-1?o-1:0,l);return M&&e.replaceChild(s,l.copy(M))}function bC(e,t,i){if(i.openStart>e.depth)throw new xC("Inserted content deeper than insertion position");if(e.depth-i.openStart!=t.depth-i.openEnd)throw new xC("Inconsistent open depths");return LC(e,t,i,0)}function LC(e,t,i,n){let o=e.index(n),r=e.node(n);if(o==t.index(n)&&n<e.depth-i.openStart){let s=LC(e,t,i,n+1);return r.copy(r.content.replaceChild(o,s))}if(i.content.size){if(i.openStart||i.openEnd||e.depth!=n||t.depth!=n){let{start:o,end:s}=function(e,t){let i=t.depth-e.openStart,n=t.node(i).copy(e.content);for(let e=i-1;e>=0;e--)n=t.node(e).copy(IC.from(n));return{start:n.resolveNoCache(e.openStart+i),end:n.resolveNoCache(n.content.size-e.openEnd-i)}}(i,e);return EC(r,CC(e,o,s,t,n))}{let n=e.parent,o=n.content;return EC(n,o.cut(0,e.parentOffset).append(i.content).append(o.cut(t.parentOffset)))}}return EC(r,QC(e,t,n))}function wC(e,t){if(!t.type.compatibleContent(e.type))throw new xC("Cannot join "+t.type.name+" onto "+e.type.name)}function vC(e,t,i){let n=e.node(i);return wC(n,t.node(i)),n}function SC(e,t){let i=t.length-1;i>=0&&e.isText&&e.sameMarkup(t[i])?t[i]=e.withText(t[i].text+e.text):t.push(e)}function kC(e,t,i,n){let o=(t||e).node(i),r=0,s=t?t.index(i):o.childCount;e&&(r=e.index(i),e.depth>i?r++:e.textOffset&&(SC(e.nodeAfter,n),r++));for(let e=r;e<s;e++)SC(o.child(e),n);t&&t.depth==i&&t.textOffset&&SC(t.nodeBefore,n)}function EC(e,t){if(!e.type.validContent(t))throw new xC("Invalid content for node "+e.type.name);return e.copy(t)}function CC(e,t,i,n,o){let r=e.depth>o&&vC(e,t,o+1),s=n.depth>o&&vC(i,n,o+1),a=[];return kC(null,e,o,a),r&&s&&t.index(o)==i.index(o)?(wC(r,s),SC(EC(r,CC(e,t,i,n,o+1)),a)):(r&&SC(EC(r,QC(e,t,o+1)),a),kC(t,i,o,a),s&&SC(EC(s,QC(i,n,o+1)),a)),kC(n,null,o,a),new IC(a)}function QC(e,t,i){let n=[];if(kC(null,e,i,n),e.depth>i){SC(EC(vC(e,t,i+1),QC(e,t,i+1)),n)}return kC(t,null,i,n),new IC(n)}AC.empty=new AC(IC.empty,0,0);class UC{constructor(e,t,i){this.pos=e,this.path=t,this.parentOffset=i,this.depth=t.length/3-1}resolveDepth(e){return null==e?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let i=this.pos-this.path[this.path.length-1],n=e.child(t);return i?e.child(t).cut(i):n}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let i=this.path[3*t],n=0==t?0:this.path[3*t-1]+1;for(let t=0;t<e;t++)n+=i.child(t).nodeSize;return n}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return TC.none;if(this.textOffset)return e.child(t).marks;let i=e.maybeChild(t-1),n=e.maybeChild(t);if(!i){let e=i;i=n,n=e}let o=i.marks;for(var r=0;r<o.length;r++)!1!==o[r].type.spec.inclusive||n&&o[r].isInSet(n.marks)||(o=o[r--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let i=t.marks,n=e.parent.maybeChild(e.index());for(var o=0;o<i.length;o++)!1!==i[o].type.spec.inclusive||n&&i[o].isInSet(n.marks)||(i=i[o--].removeFromSet(i));return i}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let i=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);i>=0;i--)if(e.pos<=this.end(i)&&(!t||t(this.node(i))))return new PC(this,e,i);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let i=[],n=0,o=t;for(let t=e;;){let{index:e,offset:r}=t.content.findIndex(o),s=o-r;if(i.push(t,e,n+r),!s)break;if(t=t.child(e),t.isText)break;o=s-1,n+=r+1}return new UC(t,i,o)}static resolveCached(e,t){let i=_C.get(e);if(i)for(let e=0;e<i.elts.length;e++){let n=i.elts[e];if(n.pos==t)return n}else _C.set(e,i=new YC);let n=i.elts[i.i]=UC.resolve(e,t);return i.i=(i.i+1)%ZC,n}}class YC{constructor(){this.elts=[],this.i=0}}const ZC=12,_C=new WeakMap;class PC{constructor(e,t,i){this.$from=e,this.$to=t,this.depth=i}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 VC=Object.create(null);let RC=class e{constructor(e,t,i,n=TC.none){this.type=e,this.attrs=t,this.marks=n,this.content=i||IC.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,i,n=0){this.content.nodesBetween(e,t,i,n,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,i,n){return this.content.textBetween(e,t,i,n)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,i){return this.type==e&&mC(this.attrs,t||e.defaultAttrs||VC)&&TC.sameSet(this.marks,i||TC.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,i=!1){if(e==t)return AC.empty;let n=this.resolve(e),o=this.resolve(t),r=i?0:n.sharedDepth(t),s=n.start(r),a=n.node(r).content.cut(n.pos-s,o.pos-s);return new AC(a,n.depth-r,o.depth-r)}replace(e,t,i){return bC(this.resolve(e),this.resolve(t),i)}nodeAt(e){for(let t=this;;){let{index:i,offset:n}=t.content.findIndex(e);if(t=t.maybeChild(i),!t)return null;if(n==e||t.isText)return t;e-=n+1}}childAfter(e){let{index:t,offset:i}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:i}}childBefore(e){if(0==e)return{node:null,index:0,offset:0};let{index:t,offset:i}=this.content.findIndex(e);if(i<e)return{node:this.content.child(t),index:t,offset:i};let n=this.content.child(t-1);return{node:n,index:t-1,offset:i-n.nodeSize}}resolve(e){return UC.resolveCached(this,e)}resolveNoCache(e){return UC.resolve(this,e)}rangeHasMark(e,t,i){let n=!1;return t>e&&this.nodesBetween(e,t,(e=>(i.isInSet(e.marks)&&(n=!0),!n))),n}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),BC(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,i=IC.empty,n=0,o=i.childCount){let r=this.contentMatchAt(e).matchFragment(i,n,o),s=r&&r.matchFragment(this.content,t);if(!s||!s.validEnd)return!1;for(let e=n;e<o;e++)if(!this.type.allowsMarks(i.child(e).marks))return!1;return!0}canReplaceWith(e,t,i,n){if(n&&!this.type.allowsMarks(n))return!1;let o=this.contentMatchAt(e).matchType(i),r=o&&o.matchFragment(this.content,t);return!!r&&r.validEnd}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=TC.none;for(let t=0;t<this.marks.length;t++){let i=this.marks[t];i.type.checkAttrs(i.attrs),e=i.addToSet(e)}if(!TC.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((e=>e.type.name))}`);this.content.forEach((e=>e.check()))}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map((e=>e.toJSON()))),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let i;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");i=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,i)}let n=IC.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,n,i);return o.type.checkAttrs(o.attrs),o}};RC.prototype.text=void 0;let WC=class e extends RC{constructor(e,t,i,n){if(super(e,t,null,n),!i)throw new RangeError("Empty text nodes are not allowed");this.text=i}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):BC(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return 0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function BC(e,t){for(let i=e.length-1;i>=0;i--)t=e[i].type.name+"("+t+")";return t}class $C{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let i=new GC(e,t);if(null==i.next)return $C.empty;let n=FC(i);i.next&&i.err("Unexpected trailing text");let o=function(e){let t=Object.create(null);return i(eQ(e,0));function i(n){let o=[];n.forEach((t=>{e[t].forEach((({term:t,to:i})=>{if(!t)return;let n;for(let e=0;e<o.length;e++)o[e][0]==t&&(n=o[e][1]);eQ(e,i).forEach((e=>{n||o.push([t,n=[]]),-1==n.indexOf(e)&&n.push(e)}))}))}));let r=t[n.join(",")]=new $C(n.indexOf(e.length-1)>-1);for(let e=0;e<o.length;e++){let n=o[e][1].sort(KC);r.next.push({type:o[e][0],next:t[n.join(",")]||i(n)})}return r}}(function(e){let t=[[]];return o(r(e,0),i()),t;function i(){return t.push([])-1}function n(e,i,n){let o={term:n,to:i};return t[e].push(o),o}function o(e,t){e.forEach((e=>e.to=t))}function r(e,t){if("choice"==e.type)return e.exprs.reduce(((e,i)=>e.concat(r(i,t))),[]);if("seq"!=e.type){if("star"==e.type){let s=i();return n(t,s),o(r(e.expr,s),s),[n(s)]}if("plus"==e.type){let s=i();return o(r(e.expr,t),s),o(r(e.expr,s),s),[n(s)]}if("opt"==e.type)return[n(t)].concat(r(e.expr,t));if("range"==e.type){let s=t;for(let t=0;t<e.min;t++){let t=i();o(r(e.expr,s),t),s=t}if(-1==e.max)o(r(e.expr,s),s);else for(let t=e.min;t<e.max;t++){let t=i();n(s,t),o(r(e.expr,s),t),s=t}return[n(s)]}if("name"==e.type)return[n(t,void 0,e.value)];throw new Error("Unknown expr type")}for(let n=0;;n++){let s=r(e.exprs[n],t);if(n==e.exprs.length-1)return s;o(s,t=i())}}}(n));return function(e,t){for(let i=0,n=[e];i<n.length;i++){let e=n[i],o=!e.validEnd,r=[];for(let t=0;t<e.next.length;t++){let{type:i,next:s}=e.next[t];r.push(i.name),!o||i.isText||i.hasRequiredAttrs()||(o=!1),-1==n.indexOf(s)&&n.push(s)}o&&t.err("Only non-generatable nodes ("+r.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(o,i),o}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,i=e.childCount){let n=this;for(let o=t;n&&o<i;o++)n=n.matchType(e.child(o).type);return n}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!t.isText&&!t.hasRequiredAttrs())return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let i=0;i<e.next.length;i++)if(this.next[t].type==e.next[i].type)return!0;return!1}fillBefore(e,t=!1,i=0){let n=[this];return function o(r,s){let a=r.matchFragment(e,i);if(a&&(!t||a.validEnd))return IC.from(s.map((e=>e.createAndFill())));for(let e=0;e<r.next.length;e++){let{type:t,next:i}=r.next[e];if(!t.isText&&!t.hasRequiredAttrs()&&-1==n.indexOf(i)){n.push(i);let e=o(i,s.concat(t));if(e)return e}}return null}(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),i=[{match:this,type:null,via:null}];for(;i.length;){let n=i.shift(),o=n.match;if(o.matchType(e)){let e=[];for(let t=n;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<o.next.length;e++){let{type:r,next:s}=o.next[e];r.isLeaf||r.hasRequiredAttrs()||r.name in t||n.type&&!s.validEnd||(i.push({match:r.contentMatch,type:r,via:n}),t[r.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];return function t(i){e.push(i);for(let n=0;n<i.next.length;n++)-1==e.indexOf(i.next[n].next)&&t(i.next[n].next)}(this),e.map(((t,i)=>{let n=i+(t.validEnd?"*":" ")+" ";for(let i=0;i<t.next.length;i++)n+=(i?", ":"")+t.next[i].type.name+"->"+e.indexOf(t.next[i].next);return n})).join("\n")}}$C.empty=new $C(!0);class GC{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function FC(e){let t=[];do{t.push(HC(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function HC(e){let t=[];do{t.push(JC(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function JC(e){let t=function(e){if(e.eat("(")){let t=FC(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){let t=function(e,t){let i=e.nodeTypes,n=i[t];if(n)return[n];let o=[];for(let e in i){let n=i[e];n.isInGroup(t)&&o.push(n)}0==o.length&&e.err("No node type or group '"+t+"' found");return o}(e,e.next).map((t=>(null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t})));return e.pos++,1==t.length?t[0]:{type:"choice",exprs:t}}e.err("Unexpected token '"+e.next+"'")}(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=qC(e,t)}return t}function XC(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function qC(e,t){let i=XC(e),n=i;return e.eat(",")&&(n="}"!=e.next?XC(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:i,max:n,expr:t}}function KC(e,t){return t-e}function eQ(e,t){let i=[];return function t(n){let o=e[n];if(1==o.length&&!o[0].term)return t(o[0].to);i.push(n);for(let e=0;e<o.length;e++){let{term:n,to:r}=o[e];n||-1!=i.indexOf(r)||t(r)}}(t),i.sort(KC)}function tQ(e){let t=Object.create(null);for(let i in e){let n=e[i];if(!n.hasDefault)return null;t[i]=n.default}return t}function iQ(e,t){let i=Object.create(null);for(let n in e){let o=t&&t[n];if(void 0===o){let t=e[n];if(!t.hasDefault)throw new RangeError("No value supplied for attribute "+n);o=t.default}i[n]=o}return i}function nQ(e,t,i,n){for(let o in t)if(!(o in e))throw new RangeError(`Unsupported attribute ${o} for ${i} of type ${n}`);for(let i in e)e[i].validate&&e[i].validate(t[i])}function oQ(e,t){let i=Object.create(null);if(t)for(let n in t)i[n]=new sQ(e,n,t[n]);return i}let rQ=class e{constructor(e,t,i){this.name=e,this.schema=t,this.spec=i,this.markSet=null,this.groups=i.group?i.group.split(" "):[],this.attrs=oQ(e,i.attrs),this.defaultAttrs=tQ(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(i.inline||"text"==e),this.isText="text"==e}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==$C.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:iQ(this.attrs,e)}create(e=null,t,i){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new RC(this,this.computeAttrs(e),IC.from(t),TC.setFrom(i))}createChecked(e=null,t,i){return t=IC.from(t),this.checkContent(t),new RC(this,this.computeAttrs(e),t,TC.setFrom(i))}createAndFill(e=null,t,i){if(e=this.computeAttrs(e),(t=IC.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let n=this.contentMatch.matchFragment(t),o=n&&n.fillBefore(IC.empty,!0);return o?new RC(this,e,t.append(o),TC.setFrom(i)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){nQ(this.attrs,e,"node",this.name)}allowsMarkType(e){return null==this.markSet||this.markSet.indexOf(e)>-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(null==this.markSet)return e;let t;for(let i=0;i<e.length;i++)this.allowsMarkType(e[i].type)?t&&t.push(e[i]):t||(t=e.slice(0,i));return t?t.length?t:TC.none:e}static compile(t,i){let n=Object.create(null);t.forEach(((t,o)=>n[t]=new e(t,i,o)));let o=i.spec.topNode||"doc";if(!n[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let e in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}};class sQ{constructor(e,t,i){this.hasDefault=Object.prototype.hasOwnProperty.call(i,"default"),this.default=i.default,this.validate="string"==typeof i.validate?function(e,t,i){let n=i.split("|");return i=>{let o=null===i?"null":typeof i;if(n.indexOf(o)<0)throw new RangeError(`Expected value of type ${n} for attribute ${t} on type ${e}, got ${o}`)}}(e,t,i.validate):i.validate}get isRequired(){return!this.hasDefault}}class aQ{constructor(e,t,i,n){this.name=e,this.rank=t,this.schema=i,this.spec=n,this.attrs=oQ(e,n.attrs),this.excluded=null;let o=tQ(this.attrs);this.instance=o?new TC(this,o):null}create(e=null){return!e&&this.instance?this.instance:new TC(this,iQ(this.attrs,e))}static compile(e,t){let i=Object.create(null),n=0;return e.forEach(((e,o)=>i[e]=new aQ(e,n++,t,o))),i}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){nQ(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class lQ{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=hC.from(e.nodes),t.marks=hC.from(e.marks||{}),this.nodes=rQ.compile(this.spec.nodes,this),this.marks=aQ.compile(this.spec.marks,this);let i=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw new RangeError(e+" can not be both a node and a mark");let t=this.nodes[e],n=t.spec.content||"",o=t.spec.marks;if(t.contentMatch=i[n]||(i[n]=$C.parse(n,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!t.isInline||!t.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=t}t.markSet="_"==o?null:o?MQ(this,o.split(" ")):""!=o&&t.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],i=t.spec.excludes;t.excluded=null==i?[t]:""==i?[]:MQ(this,i.split(" "))}this.nodeFromJSON=e=>RC.fromJSON(this,e),this.markFromJSON=e=>TC.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,i,n){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof rQ))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,i,n)}text(e,t){let i=this.nodes.text;return new WC(i,i.defaultAttrs,e,TC.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function MQ(e,t){let i=[];for(let n=0;n<t.length;n++){let o=t[n],r=e.marks[o],s=r;if(r)i.push(r);else for(let t in e.marks){let n=e.marks[t];("_"==o||n.spec.group&&n.spec.group.split(" ").indexOf(o)>-1)&&i.push(s=n)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[n]+"'")}return i}let cQ=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let i=this.matchedStyles=[];t.forEach((e=>{if(function(e){return null!=e.tag}(e))this.tags.push(e);else if(function(e){return null!=e.style}(e)){let t=/[^=]*/.exec(e.style)[0];i.indexOf(t)<0&&i.push(t),this.styles.push(e)}})),this.normalizeLists=!this.tags.some((t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let i=e.nodes[t.node];return i.contentMatch.matchType(i)}))}parse(e,t={}){let i=new pQ(this,t,!1);return i.addAll(e,TC.none,t.from,t.to),i.finish()}parseSlice(e,t={}){let i=new pQ(this,t,!0);return i.addAll(e,TC.none,t.from,t.to),AC.maxOpen(i.finish())}matchTag(e,t,i){for(let n=i?this.tags.indexOf(i)+1:0;n<this.tags.length;n++){let i=this.tags[n];if(DQ(e,i.tag)&&(void 0===i.namespace||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs){let t=i.getAttrs(e);if(!1===t)continue;i.attrs=t||void 0}return i}}}matchStyle(e,t,i,n){for(let o=n?this.styles.indexOf(n)+1:0;o<this.styles.length;o++){let n=this.styles[o],r=n.style;if(!(0!=r.indexOf(e)||n.context&&!i.matchesContext(n.context)||r.length>e.length&&(61!=r.charCodeAt(e.length)||r.slice(e.length+1)!=t))){if(n.getAttrs){let e=n.getAttrs(t);if(!1===e)continue;n.attrs=e||void 0}return n}}}static schemaRules(e){let t=[];function i(e){let i=null==e.priority?50:e.priority,n=0;for(;n<t.length;n++){let e=t[n];if((null==e.priority?50:e.priority)<i)break}t.splice(n,0,e)}for(let t in e.marks){let n=e.marks[t].spec.parseDOM;n&&n.forEach((e=>{i(e=yQ(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)}))}for(let t in e.nodes){let n=e.nodes[t].spec.parseDOM;n&&n.forEach((e=>{i(e=yQ(e)),e.node||e.ignore||e.mark||(e.node=t)}))}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}};const uQ={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},gQ={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},dQ={ol:!0,ul:!0};function hQ(e,t,i){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&i}class NQ{constructor(e,t,i,n,o,r){this.type=e,this.attrs=t,this.marks=i,this.solid=n,this.options=r,this.content=[],this.activeMarks=TC.none,this.match=o||(4&r?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(IC.from(e));if(!t){let t,i=this.type.contentMatch;return(t=i.findWrapping(e.type))?(this.match=i,t):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e,t=this.content[this.content.length-1];if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let i=t;t.text.length==e[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-e[0].length))}}let t=IC.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(IC.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!uQ.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class pQ{constructor(e,t,i){this.parser=e,this.options=t,this.isOpen=i,this.open=0,this.localPreserveWS=!1;let n,o=t.topNode,r=hQ(null,t.preserveWhitespace,0)|(i?4:0);n=o?new NQ(o.type,o.attrs,TC.none,!0,t.topMatch||o.type.contentMatch,r):new NQ(i?null:e.schema.topNodeType,null,TC.none,!0,null,r),this.nodes=[n],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){3==e.nodeType?this.addTextNode(e,t):1==e.nodeType&&this.addElement(e,t)}addTextNode(e,t){let i=e.nodeValue,n=this.top,o=2&n.options?"full":this.localPreserveWS||(1&n.options)>0,{schema:r}=this.parser;if("full"===o||n.inlineContext(e)||/[^ \t\r\n\u000c]/.test(i)){if(o)if("full"===o)i=i.replace(/\r\n?/g,"\n");else if(r.linebreakReplacement&&/[\r\n]/.test(i)&&this.top.findWrapping(r.linebreakReplacement.create())){let e=i.split(/\r?\n|\r/);for(let i=0;i<e.length;i++)i&&this.insertNode(r.linebreakReplacement.create(),t,!0),e[i]&&this.insertNode(r.text(e[i]),t,!/\S/.test(e[i]));i=""}else i=i.replace(/\r?\n|\r/g," ");else if(i=i.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(i)&&this.open==this.nodes.length-1){let t=n.content[n.content.length-1],o=e.previousSibling;(!t||o&&"BR"==o.nodeName||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(i=i.slice(1))}i&&this.insertNode(r.text(i),t,!/\S/.test(i)),this.findInText(e)}else this.findInside(e)}addElement(e,t,i){let n=this.localPreserveWS,o=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let r,s=e.nodeName.toLowerCase();dQ.hasOwnProperty(s)&&this.parser.normalizeLists&&function(e){for(let t=e.firstChild,i=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&dQ.hasOwnProperty(e)&&i?(i.appendChild(t),t=i):"li"==e?i=t:e&&(i=null)}}(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(r=this.parser.matchTag(e,this,i));e:if(a?a.ignore:gQ.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let i,n=this.needsBlock;if(uQ.hasOwnProperty(s))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),i=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let r=a&&a.skip?t:this.readStyles(e,t);r&&this.addAll(e,r),i&&this.sync(o),this.needsBlock=n}else{let i=this.readStyles(e,t);i&&this.addElementByRule(e,a,i,!1===a.consuming?r:void 0)}this.localPreserveWS=n}leafFallback(e,t){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),t)}ignoreFallback(e,t){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let i=e.style;if(i&&i.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let n=this.parser.matchedStyles[e],o=i.getPropertyValue(n);if(o)for(let e;;){let i=this.parser.matchStyle(n,o,this,e);if(!i)break;if(i.ignore)return null;if(t=i.clearMark?t.filter((e=>!i.clearMark(e))):t.concat(this.parser.schema.marks[i.mark].create(i.attrs)),!1!==i.consuming)break;e=i}}return t}addElementByRule(e,t,i,n){let o,r;if(t.node)if(r=this.parser.schema.nodes[t.node],r.isLeaf)this.insertNode(r.create(t.attrs),i,"BR"==e.nodeName)||this.leafFallback(e,i);else{let e=this.enter(r,t.attrs||null,i,t.preserveWhitespace);e&&(o=!0,i=e)}else{let e=this.parser.schema.marks[t.mark];i=i.concat(e.create(t.attrs))}let s=this.top;if(r&&r.isLeaf)this.findInside(e);else if(n)this.addElement(e,i,n);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach((e=>this.insertNode(e,i,!1)));else{let n=e;"string"==typeof t.contentElement?n=e.querySelector(t.contentElement):"function"==typeof t.contentElement?n=t.contentElement(e):t.contentElement&&(n=t.contentElement),this.findAround(e,n,!0),this.addAll(n,i),this.findAround(e,n,!1)}o&&this.sync(s)&&this.open--}addAll(e,t,i,n){let o=i||0;for(let r=i?e.childNodes[i]:e.firstChild,s=null==n?null:e.childNodes[n];r!=s;r=r.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(r,t);this.findAtPoint(e,o)}findPlace(e,t,i){let n,o;for(let t=this.open,r=0;t>=0;t--){let s=this.nodes[t],a=s.findWrapping(e);if(a&&(!n||n.length>a.length+r)&&(n=a,o=s,!a.length))break;if(s.solid){if(i)break;r+=2}}if(!n)return null;this.sync(o);for(let e=0;e<n.length;e++)t=this.enterInner(n[e],null,t,!1);return t}insertNode(e,t,i){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let n=this.findPlace(e,t,i);if(n){this.closeExtra();let t=this.top;t.match&&(t.match=t.match.matchType(e.type));let i=TC.none;for(let o of n.concat(e.marks))(t.type?t.type.allowsMarkType(o.type):IQ(o.type,e.type))&&(i=o.addToSet(i));return t.content.push(e.mark(i)),!0}return!1}enter(e,t,i,n){let o=this.findPlace(e.create(t),i,!1);return o&&(o=this.enterInner(e,t,i,!0,n)),o}enterInner(e,t,i,n=!1,o){this.closeExtra();let r=this.top;r.match=r.match&&r.match.matchType(e);let s=hQ(e,o,r.options);4&r.options&&0==r.content.length&&(s|=4);let a=TC.none;return i=i.filter((t=>!(r.type?r.type.allowsMarkType(t.type):IQ(t.type,e))||(a=t.addToSet(a),!1))),this.nodes.push(new NQ(e,t,a,n,null,s)),this.open++,i}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!(!this.isOpen&&!this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=1)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let i=this.nodes[t].content;for(let t=i.length-1;t>=0;t--)e+=i[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let i=0;i<this.find.length;i++)this.find[i].node==e&&this.find[i].offset==t&&(this.find[i].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,i){if(e!=t&&this.find)for(let n=0;n<this.find.length;n++)if(null==this.find[n].pos&&1==e.nodeType&&e.contains(this.find[n].node)){t.compareDocumentPosition(this.find[n].node)&(i?2:4)&&(this.find[n].pos=this.currentPos)}}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),i=this.options.context,n=!(this.isOpen||i&&i.parent.type!=this.nodes[0].type),o=-(i?i.depth+1:0)+(n?0:1),r=(e,s)=>{for(;e>=0;e--){let a=t[e];if(""==a){if(e==t.length-1||0==e)continue;for(;s>=o;s--)if(r(e-1,s))return!0;return!1}{let e=s>0||0==s&&n?this.nodes[s].type:i&&s>=o?i.node(s-o).type:null;if(!e||e.name!=a&&!e.isInGroup(a))return!1;s--}}return!0};return r(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(i&&i.isTextblock&&i.defaultAttrs)return i}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}}function DQ(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function yQ(e){let t={};for(let i in e)t[i]=e[i];return t}function IQ(e,t){let i=t.schema.nodes;for(let n in i){let o=i[n];if(!o.allowsMarkType(e))continue;let r=[],s=e=>{r.push(e);for(let i=0;i<e.edgeCount;i++){let{type:n,next:o}=e.edge(i);if(n==t)return!0;if(r.indexOf(o)<0&&s(o))return!0}};if(s(o.contentMatch))return!0}}class jQ{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},i){i||(i=mQ(t).createDocumentFragment());let n=i,o=[];return e.forEach((e=>{if(o.length||e.marks.length){let i=0,r=0;for(;i<o.length&&r<e.marks.length;){let t=e.marks[r];if(this.marks[t.type.name]){if(!t.eq(o[i][0])||!1===t.type.spec.spanning)break;i++,r++}else r++}for(;i<o.length;)n=o.pop()[1];for(;r<e.marks.length;){let i=e.marks[r++],s=this.serializeMark(i,e.isInline,t);s&&(o.push([i,n]),n.appendChild(s.dom),n=s.contentDOM||s.dom)}}n.appendChild(this.serializeNodeInner(e,t))})),i}serializeNodeInner(e,t){if(e.isText)return mQ(t).createTextNode(e.text);let{dom:i,contentDOM:n}=AQ(mQ(t),this.nodes[e.type.name](e),null,e.attrs);if(n){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,n)}return i}serializeNode(e,t={}){let i=this.serializeNodeInner(e,t);for(let n=e.marks.length-1;n>=0;n--){let o=this.serializeMark(e.marks[n],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(i),i=o.dom)}return i}serializeMark(e,t,i={}){let n=this.marks[e.type.name];return n&&AQ(mQ(i),n(e,t),null,e.attrs)}static renderSpec(e,t,i=null,n){return"string"==typeof t?{dom:e.createTextNode(t)}:AQ(e,t,i,n)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new jQ(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=zQ(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return zQ(e.marks)}}function zQ(e){let t={};for(let i in e){let n=e[i].spec.toDOM;n&&(t[i]=n)}return t}function mQ(e){return e.document||window.document}const TQ=new WeakMap;function xQ(e){let t=TQ.get(e);return void 0===t&&TQ.set(e,t=function(e){let t=null;function i(e){if(e&&"object"==typeof e)if(Array.isArray(e))if("string"==typeof e[0])t||(t=[]),t.push(e);else for(let t=0;t<e.length;t++)i(e[t]);else for(let t in e)i(e[t])}return i(e),t}(e)),t}function AQ(e,t,i,n){if(1==t.nodeType)return{dom:t};if(t.dom&&1==t.dom.nodeType)return t;let o,r=t[0];if("string"!=typeof r)throw new RangeError("Invalid array passed to renderSpec");if(n&&(o=xQ(n))&&o.indexOf(t)>-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 s,a=r.indexOf(" ");a>0&&(i=r.slice(0,a),r=r.slice(a+1));let l=i?e.createElementNS(i,r):e.createElement(r),M=t[1],c=1;if(M&&"object"==typeof M&&null==M.nodeType&&!Array.isArray(M)){c=2;for(let e in M)if(null!=M[e]){let t=e.indexOf(" ");t>0?l.setAttributeNS(e.slice(0,t),e.slice(t+1),M[e]):"style"==e&&l.style?l.style.cssText=M[e]:l.setAttribute(e,M[e])}}for(let o=c;o<t.length;o++){let r=t[o];if(0===r){if(o<t.length-1||o>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}if("string"==typeof r)l.appendChild(e.createTextNode(r));else{let{dom:t,contentDOM:o}=AQ(e,r,i,n);if(l.appendChild(t),o){if(s)throw new RangeError("Multiple content holes");s=o}}}return{dom:l,contentDOM:s}}const OQ=Math.pow(2,16);function fQ(e,t){return e+t*OQ}function bQ(e){return 65535&e}class LQ{constructor(e,t,i){this.pos=e,this.delInfo=t,this.recover=i}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 wQ{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&wQ.empty)return wQ.empty}recover(e){let t=0,i=bQ(e);if(!this.inverted)for(let e=0;e<i;e++)t+=this.ranges[3*e+2]-this.ranges[3*e+1];return this.ranges[3*i]+t+function(e){return(e-(65535&e))/OQ}(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,i){let n=0,o=this.inverted?2:1,r=this.inverted?1:2;for(let s=0;s<this.ranges.length;s+=3){let a=this.ranges[s]-(this.inverted?n:0);if(a>e)break;let l=this.ranges[s+o],M=this.ranges[s+r],c=a+l;if(e<=c){let o=a+n+((l?e==a?-1:e==c?1:t:t)<0?0:M);if(i)return o;let r=e==(t<0?a:c)?null:fQ(s/3,e-a),u=e==a?2:e==c?1:4;return(t<0?e!=a:e!=c)&&(u|=8),new LQ(o,u,r)}n+=M-l}return i?e+n:new LQ(e+n,0,null)}touches(e,t){let i=0,n=bQ(t),o=this.inverted?2:1,r=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let s=this.ranges[t]-(this.inverted?i:0);if(s>e)break;let a=this.ranges[t+o];if(e<=s+a&&t==3*n)return!0;i+=this.ranges[t+r]-a}return!1}forEach(e){let t=this.inverted?2:1,i=this.inverted?1:2;for(let n=0,o=0;n<this.ranges.length;n+=3){let r=this.ranges[n],s=r-(this.inverted?o:0),a=r+(this.inverted?0:o),l=this.ranges[n+t],M=this.ranges[n+i];e(s,s+l,a,a+M),o+=M-l}}invert(){return new wQ(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?wQ.empty:new wQ(e<0?[0,-e,0]:[0,0,e])}}wQ.empty=new wQ([]);class vQ{constructor(e,t,i=0,n=(e?e.length:0)){this.mirror=t,this.from=i,this.to=n,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new vQ(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),null!=t&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,i=this._maps.length;t<e._maps.length;t++){let n=e.getMirror(t);this.appendMap(e._maps[t],null!=n&&n<t?i+n:void 0)}}getMirror(e){if(this.mirror)for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,i=this._maps.length+e._maps.length;t>=0;t--){let n=e.getMirror(t);this.appendMap(e._maps[t].invert(),null!=n&&n>t?i-n-1:void 0)}}invert(){let e=new vQ;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let i=this.from;i<this.to;i++)e=this._maps[i].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,i){let n=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i].mapResult(e,t);if(null!=o.recover){let t=this.getMirror(i);if(null!=t&&t>i&&t<this.to){i=t,e=this._maps[t].recover(o.recover);continue}}n|=o.delInfo,e=o.pos}return i?e:new LQ(e,n,null)}}const SQ=Object.create(null);class kQ{getMap(){return wQ.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let i=SQ[t.stepType];if(!i)throw new RangeError(`No step type ${t.stepType} defined`);return i.fromJSON(e,t)}static jsonID(e,t){if(e in SQ)throw new RangeError("Duplicate use of step JSON ID "+e);return SQ[e]=t,t.prototype.jsonID=e,t}}class EQ{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new EQ(e,null)}static fail(e){return new EQ(null,e)}static fromReplace(e,t,i,n){try{return EQ.ok(e.replace(t,i,n))}catch(e){if(e instanceof xC)return EQ.fail(e.message);throw e}}}function CQ(e,t,i){let n=[];for(let o=0;o<e.childCount;o++){let r=e.child(o);r.content.size&&(r=r.copy(CQ(r.content,t,r))),r.isInline&&(r=t(r,i,o)),n.push(r)}return IC.fromArray(n)}class QQ extends kQ{constructor(e,t,i){super(),this.from=e,this.to=t,this.mark=i}apply(e){let t=e.slice(this.from,this.to),i=e.resolve(this.from),n=i.node(i.sharedDepth(this.to)),o=new AC(CQ(t.content,((e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e),n),t.openStart,t.openEnd);return EQ.fromReplace(e,this.from,this.to,o)}invert(){return new UQ(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return t.deleted&&i.deleted||t.pos>=i.pos?null:new QQ(t.pos,i.pos,this.mark)}merge(e){return e instanceof QQ&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new QQ(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new QQ(t.from,t.to,e.markFromJSON(t.mark))}}kQ.jsonID("addMark",QQ);class UQ extends kQ{constructor(e,t,i){super(),this.from=e,this.to=t,this.mark=i}apply(e){let t=e.slice(this.from,this.to),i=new AC(CQ(t.content,(e=>e.mark(this.mark.removeFromSet(e.marks))),e),t.openStart,t.openEnd);return EQ.fromReplace(e,this.from,this.to,i)}invert(){return new QQ(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return t.deleted&&i.deleted||t.pos>=i.pos?null:new UQ(t.pos,i.pos,this.mark)}merge(e){return e instanceof UQ&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new UQ(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new UQ(t.from,t.to,e.markFromJSON(t.mark))}}kQ.jsonID("removeMark",UQ);class YQ extends kQ{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return EQ.fail("No node at mark step's position");let i=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return EQ.fromReplace(e,this.pos,this.pos+1,new AC(IC.from(i),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let e=this.mark.addToSet(t.marks);if(e.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(e))return new YQ(this.pos,t.marks[i]);return new YQ(this.pos,this.mark)}}return new ZQ(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new YQ(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new YQ(t.pos,e.markFromJSON(t.mark))}}kQ.jsonID("addNodeMark",YQ);class ZQ extends kQ{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return EQ.fail("No node at mark step's position");let i=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return EQ.fromReplace(e,this.pos,this.pos+1,new AC(IC.from(i),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new YQ(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ZQ(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new ZQ(t.pos,e.markFromJSON(t.mark))}}kQ.jsonID("removeNodeMark",ZQ);class _Q extends kQ{constructor(e,t,i,n=!1){super(),this.from=e,this.to=t,this.slice=i,this.structure=n}apply(e){return this.structure&&VQ(e,this.from,this.to)?EQ.fail("Structure replace would overwrite content"):EQ.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new wQ([this.from,this.to-this.from,this.slice.size])}invert(e){return new _Q(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),i=this.from==this.to&&_Q.MAP_BIAS<0?t:e.mapResult(this.from,1);return i.deletedAcross&&t.deletedAcross?null:new _Q(i.pos,Math.max(i.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof _Q)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;{let t=this.slice.size+e.slice.size==0?AC.empty:new AC(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new _Q(e.from,this.to,t,this.structure)}}{let t=this.slice.size+e.slice.size==0?AC.empty:new AC(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new _Q(this.from,this.to+(e.to-e.from),t,this.structure)}}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new _Q(t.from,t.to,AC.fromJSON(e,t.slice),!!t.structure)}}_Q.MAP_BIAS=1,kQ.jsonID("replace",_Q);class PQ extends kQ{constructor(e,t,i,n,o,r,s=!1){super(),this.from=e,this.to=t,this.gapFrom=i,this.gapTo=n,this.slice=o,this.insert=r,this.structure=s}apply(e){if(this.structure&&(VQ(e,this.from,this.gapFrom)||VQ(e,this.gapTo,this.to)))return EQ.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return EQ.fail("Gap is not a flat range");let i=this.slice.insertAt(this.insert,t.content);return i?EQ.fromReplace(e,this.from,this.to,i):EQ.fail("Content does not fit in gap")}getMap(){return new wQ([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new PQ(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),i=e.mapResult(this.to,-1),n=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?i.pos:e.map(this.gapTo,1);return t.deletedAcross&&i.deletedAcross||n<t.pos||o>i.pos?null:new PQ(t.pos,i.pos,n,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new PQ(t.from,t.to,t.gapFrom,t.gapTo,AC.fromJSON(e,t.slice),t.insert,!!t.structure)}}function VQ(e,t,i){let n=e.resolve(t),o=i-t,r=n.depth;for(;o>0&&r>0&&n.indexAfter(r)==n.node(r).childCount;)r--,o--;if(o>0){let e=n.node(r).maybeChild(n.indexAfter(r));for(;o>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,o--}}return!1}function RQ(e,t,i,n=i.contentMatch,o=!0){let r=e.doc.nodeAt(t),s=[],a=t+1;for(let t=0;t<r.childCount;t++){let l=r.child(t),M=a+l.nodeSize,c=n.matchType(l.type);if(c){n=c;for(let t=0;t<l.marks.length;t++)i.allowsMarkType(l.marks[t].type)||e.step(new UQ(a,M,l.marks[t]));if(o&&l.isText&&"pre"!=i.whitespace){let e,t,n=/\r?\n|\r/g;for(;e=n.exec(l.text);)t||(t=new AC(IC.from(i.schema.text(" ",i.allowedMarks(l.marks))),0,0)),s.push(new _Q(a+e.index,a+e.index+e[0].length,t))}}else s.push(new _Q(a,M,AC.empty));a=M}if(!n.validEnd){let t=n.fillBefore(IC.empty,!0);e.replace(a,a,new AC(t,0,0))}for(let t=s.length-1;t>=0;t--)e.step(s[t])}function WQ(e,t,i){return(0==t||e.canReplace(t,e.childCount))&&(i==e.childCount||e.canReplace(0,i))}function BQ(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let i=e.depth,n=0,o=0;;--i){let r=e.$from.node(i),s=e.$from.index(i)+n,a=e.$to.indexAfter(i)-o;if(i<e.depth&&r.canReplace(s,a,t))return i;if(0==i||r.type.spec.isolating||!WQ(r,s,a))break;s&&(n=1),a<r.childCount&&(o=1)}return null}function $Q(e,t,i=null,n=e){let o=function(e,t){let{parent:i,startIndex:n,endIndex:o}=e,r=i.contentMatchAt(n).findWrapping(t);if(!r)return null;let s=r.length?r[0]:t;return i.canReplaceWith(n,o,s)?r:null}(e,t),r=o&&function(e,t){let{parent:i,startIndex:n,endIndex:o}=e,r=i.child(n),s=t.contentMatch.findWrapping(r.type);if(!s)return null;let a=s.length?s[s.length-1]:t,l=a.contentMatch;for(let e=n;l&&e<o;e++)l=l.matchType(i.child(e).type);return l&&l.validEnd?s:null}(n,t);return r?o.map(GQ).concat({type:t,attrs:i}).concat(r.map(GQ)):null}function GQ(e){return{type:e,attrs:null}}function FQ(e,t,i,n){t.forEach(((o,r)=>{if(o.isText){let s,a=/\r?\n|\r/g;for(;s=a.exec(o.text);){let o=e.mapping.slice(n).map(i+1+r+s.index);e.replaceWith(o,o+1,t.type.schema.linebreakReplacement.create())}}}))}function HQ(e,t,i,n){t.forEach(((o,r)=>{if(o.type==o.type.schema.linebreakReplacement){let o=e.mapping.slice(n).map(i+1+r);e.replaceWith(o,o+1,t.type.schema.text("\n"))}}))}function JQ(e,t,i=1,n){let o=e.resolve(t),r=o.depth-i,s=n&&n[n.length-1]||o.parent;if(r<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let e=o.depth-1,t=i-2;e>r;e--,t--){let i=o.node(e),r=o.index(e);if(i.type.spec.isolating)return!1;let s=i.content.cutByIndex(r,i.childCount),a=n&&n[t+1];a&&(s=s.replaceChild(0,a.type.create(a.attrs)));let l=n&&n[t]||i;if(!i.canReplace(r+1,i.childCount)||!l.type.validContent(s))return!1}let a=o.indexAfter(r),l=n&&n[0];return o.node(r).canReplaceWith(a,a,l?l.type:o.node(r+1).type)}function XQ(e,t){let i=e.resolve(t),n=i.index();return function(e,t){return!(!e||!t||e.isLeaf||!function(e,t){t.content.size||e.type.compatibleContent(t.type);let i=e.contentMatchAt(e.childCount),{linebreakReplacement:n}=e.type.schema;for(let o=0;o<t.childCount;o++){let r=t.child(o),s=r.type==n?e.type.schema.nodes.text:r.type;if(i=i.matchType(s),!i)return!1;if(!e.type.allowsMarks(r.marks))return!1}return i.validEnd}(e,t))}(i.nodeBefore,i.nodeAfter)&&i.parent.canReplace(n,n+1)}function qQ(e,t,i){let n=e.resolve(t);if(!i.content.size)return t;let o=i.content;for(let e=0;e<i.openStart;e++)o=o.firstChild.content;for(let e=1;e<=(0==i.openStart&&i.size?2:1);e++)for(let t=n.depth;t>=0;t--){let i=t==n.depth?0:n.pos<=(n.start(t+1)+n.end(t+1))/2?-1:1,r=n.index(t)+(i>0?1:0),s=n.node(t),a=!1;if(1==e)a=s.canReplace(r,r,o);else{let e=s.contentMatchAt(r).findWrapping(o.firstChild.type);a=e&&s.canReplaceWith(r,r,e[0])}if(a)return 0==i?n.pos:i<0?n.before(t+1):n.after(t+1)}return null}function KQ(e,t,i=t,n=AC.empty){if(t==i&&!n.size)return null;let o=e.resolve(t),r=e.resolve(i);return eU(o,r,n)?new _Q(t,i,n):new tU(o,r,n).fit()}function eU(e,t,i){return!i.openStart&&!i.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),i.content)}kQ.jsonID("replaceAround",PQ);class tU{constructor(e,t,i){this.$from=e,this.$to=t,this.unplaced=i,this.frontier=[],this.placed=IC.empty;for(let t=0;t<=e.depth;t++){let i=e.node(t);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=IC.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,i=this.$from,n=this.close(e<0?this.$to:i.doc.resolve(e));if(!n)return null;let o=this.placed,r=i.depth,s=n.depth;for(;r&&s&&1==o.childCount;)o=o.firstChild.content,r--,s--;let a=new AC(o,r,s);return e>-1?new PQ(i.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||i.pos!=this.$to.pos?new _Q(i.pos,n.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,i=0,n=this.unplaced.openEnd;i<e;i++){let o=t.firstChild;if(t.childCount>1&&(n=0),o.type.spec.isolating&&n<=i){e=i;break}t=o.content}for(let t=1;t<=2;t++)for(let i=1==t?e:this.unplaced.openStart;i>=0;i--){let e,n=null;i?(n=oU(this.unplaced.content,i-1).firstChild,e=n.content):e=this.unplaced.content;let o=e.firstChild;for(let e=this.depth;e>=0;e--){let r,{type:s,match:a}=this.frontier[e],l=null;if(1==t&&(o?a.matchType(o.type)||(l=a.fillBefore(IC.from(o),!1)):n&&s.compatibleContent(n.type)))return{sliceDepth:i,frontierDepth:e,parent:n,inject:l};if(2==t&&o&&(r=a.findWrapping(o.type)))return{sliceDepth:i,frontierDepth:e,parent:n,wrap:r};if(n&&a.matchType(n.type))break}}}openMore(){let{content:e,openStart:t,openEnd:i}=this.unplaced,n=oU(e,t);return!(!n.childCount||n.firstChild.isLeaf)&&(this.unplaced=new AC(e,t+1,Math.max(i,n.size+t>=e.size-i?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:i}=this.unplaced,n=oU(e,t);if(n.childCount<=1&&t>0){let o=e.size-t<=t+n.size;this.unplaced=new AC(iU(e,t-1,1),t-1,o?t-1:i)}else this.unplaced=new AC(iU(e,t,1),t,i)}placeNodes({sliceDepth:e,frontierDepth:t,parent:i,inject:n,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let e=0;e<o.length;e++)this.openFrontierNode(o[e]);let r=this.unplaced,s=i?i.content:r.content,a=r.openStart-e,l=0,M=[],{match:c,type:u}=this.frontier[t];if(n){for(let e=0;e<n.childCount;e++)M.push(n.child(e));c=c.matchFragment(n)}let g=s.size+e-(r.content.size-r.openEnd);for(;l<s.childCount;){let e=s.child(l),t=c.matchType(e.type);if(!t)break;l++,(l>1||0==a||e.content.size)&&(c=t,M.push(rU(e.mark(u.allowedMarks(e.marks)),1==l?a:0,l==s.childCount?g:-1)))}let d=l==s.childCount;d||(g=-1),this.placed=nU(this.placed,t,IC.from(M)),this.frontier[t].match=c,d&&g<0&&i&&i.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=s;e<g;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=d?0==e?AC.empty:new AC(iU(r.content,e-1,1),e-1,g<0?r.openEnd:e-1):new AC(iU(r.content,e,l),r.openStart,r.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e,t=this.frontier[this.depth];if(!t.type.isTextblock||!sU(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:i}=this.$to,n=this.$to.after(i);for(;i>1&&n==this.$to.end(--i);)++n;return n}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:i,type:n}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),r=sU(e,t,n,i,o);if(r){for(let i=t-1;i>=0;i--){let{match:t,type:n}=this.frontier[i],o=sU(e,i,n,t,!0);if(!o||o.childCount)continue e}return{depth:t,fit:r,move:o?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=nU(this.placed,t.depth,t.fit)),e=t.move;for(let i=t.depth+1;i<=e.depth;i++){let t=e.node(i),n=t.type.contentMatch.fillBefore(t.content,!0,e.index(i));this.openFrontierNode(t.type,t.attrs,n)}return e}openFrontierNode(e,t=null,i){let n=this.frontier[this.depth];n.match=n.match.matchType(e),this.placed=nU(this.placed,this.depth,IC.from(e.create(t,i))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(IC.empty,!0);e.childCount&&(this.placed=nU(this.placed,this.frontier.length,e))}}function iU(e,t,i){return 0==t?e.cutByIndex(i,e.childCount):e.replaceChild(0,e.firstChild.copy(iU(e.firstChild.content,t-1,i)))}function nU(e,t,i){return 0==t?e.append(i):e.replaceChild(e.childCount-1,e.lastChild.copy(nU(e.lastChild.content,t-1,i)))}function oU(e,t){for(let i=0;i<t;i++)e=e.firstChild.content;return e}function rU(e,t,i){if(t<=0)return e;let n=e.content;return t>1&&(n=n.replaceChild(0,rU(n.firstChild,t-1,1==n.childCount?i-1:0))),t>0&&(n=e.type.contentMatch.fillBefore(n).append(n),i<=0&&(n=n.append(e.type.contentMatch.matchFragment(n).fillBefore(IC.empty,!0)))),e.copy(n)}function sU(e,t,i,n,o){let r=e.node(t),s=o?e.indexAfter(t):e.index(t);if(s==r.childCount&&!i.compatibleContent(r.type))return null;let a=n.fillBefore(r.content,!0,s);return a&&!function(e,t,i){for(let n=i;n<t.childCount;n++)if(!e.allowsMarks(t.child(n).marks))return!0;return!1}(i,r.content,s)?a:null}function aU(e,t,i,n,o){if(t<i){let o=e.firstChild;e=e.replaceChild(0,o.copy(aU(o.content,t+1,i,n,o)))}if(t>n){let t=o.contentMatchAt(0),i=t.fillBefore(e).append(e);e=i.append(t.matchFragment(i).fillBefore(IC.empty,!0))}return e}function lU(e,t){let i=[];for(let n=Math.min(e.depth,t.depth);n>=0;n--){let o=e.start(n);if(o<e.pos-(e.depth-n)||t.end(n)>t.pos+(t.depth-n)||e.node(n).type.spec.isolating||t.node(n).type.spec.isolating)break;(o==t.start(n)||n==e.depth&&n==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&n&&t.start(n-1)==o-1)&&i.push(n)}return i}class MU extends kQ{constructor(e,t,i){super(),this.pos=e,this.attr=t,this.value=i}apply(e){let t=e.nodeAt(this.pos);if(!t)return EQ.fail("No node at attribute step's position");let i=Object.create(null);for(let e in t.attrs)i[e]=t.attrs[e];i[this.attr]=this.value;let n=t.type.create(i,null,t.marks);return EQ.fromReplace(e,this.pos,this.pos+1,new AC(IC.from(n),0,t.isLeaf?0:1))}getMap(){return wQ.empty}invert(e){return new MU(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new MU(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if("number"!=typeof t.pos||"string"!=typeof t.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new MU(t.pos,t.attr,t.value)}}kQ.jsonID("attr",MU);class cU extends kQ{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let i=e.type.create(t,e.content,e.marks);return EQ.ok(i)}getMap(){return wQ.empty}invert(e){return new cU(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if("string"!=typeof t.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new cU(t.attr,t.value)}}kQ.jsonID("docAttr",cU);let uU=class extends Error{};uU=function e(t){let i=Error.call(this,t);return i.__proto__=e.prototype,i},(uU.prototype=Object.create(Error.prototype)).constructor=uU,uU.prototype.name="TransformError";class gU{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new vQ}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new uU(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let i=0;i<this.mapping.maps.length;i++){let n=this.mapping.maps[i];i&&(e=n.map(e,1),t=n.map(t,-1)),n.forEach(((i,n,o,r)=>{e=Math.min(e,o),t=Math.max(t,r)}))}return 1e9==e?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,i=AC.empty){let n=KQ(this.doc,e,t,i);return n&&this.step(n),this}replaceWith(e,t,i){return this.replace(e,t,new AC(IC.from(i),0,0))}delete(e,t){return this.replace(e,t,AC.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,i){return function(e,t,i,n){if(!n.size)return e.deleteRange(t,i);let o=e.doc.resolve(t),r=e.doc.resolve(i);if(eU(o,r,n))return e.step(new _Q(t,i,n));let s=lU(o,r);0==s[s.length-1]&&s.pop();let a=-(o.depth+1);s.unshift(a);for(let e=o.depth,t=o.pos-1;e>0;e--,t--){let i=o.node(e).type.spec;if(i.defining||i.definingAsContext||i.isolating)break;s.indexOf(e)>-1?a=e:o.before(e)==t&&s.splice(1,0,-e)}let l=s.indexOf(a),M=[],c=n.openStart;for(let e=n.content,t=0;;t++){let i=e.firstChild;if(M.push(i),t==n.openStart)break;e=i.content}for(let e=c-1;e>=0;e--){let t=M[e],i=(u=t.type).spec.defining||u.spec.definingForContent;if(i&&!t.sameMarkup(o.node(Math.abs(a)-1)))c=e;else if(i||!t.type.isTextblock)break}var u;for(let t=n.openStart;t>=0;t--){let a=(t+c+1)%(n.openStart+1),u=M[a];if(u)for(let t=0;t<s.length;t++){let M=s[(t+l)%s.length],c=!0;M<0&&(c=!1,M=-M);let g=o.node(M-1),d=o.index(M-1);if(g.canReplaceWith(d,d,u.type,u.marks))return e.replace(o.before(M),c?r.after(M):i,new AC(aU(n.content,0,n.openStart,a),a,n.openEnd))}}let g=e.steps.length;for(let a=s.length-1;a>=0&&(e.replace(t,i,n),!(e.steps.length>g));a--){let e=s[a];e<0||(t=o.before(e),i=r.after(e))}}(this,e,t,i),this}replaceRangeWith(e,t,i){return function(e,t,i,n){if(!n.isInline&&t==i&&e.doc.resolve(t).parent.content.size){let o=function(e,t,i){let n=e.resolve(t);if(n.parent.canReplaceWith(n.index(),n.index(),i))return t;if(0==n.parentOffset)for(let e=n.depth-1;e>=0;e--){let t=n.index(e);if(n.node(e).canReplaceWith(t,t,i))return n.before(e+1);if(t>0)return null}if(n.parentOffset==n.parent.content.size)for(let e=n.depth-1;e>=0;e--){let t=n.indexAfter(e);if(n.node(e).canReplaceWith(t,t,i))return n.after(e+1);if(t<n.node(e).childCount)return null}return null}(e.doc,t,n.type);null!=o&&(t=i=o)}e.replaceRange(t,i,new AC(IC.from(n),0,0))}(this,e,t,i),this}deleteRange(e,t){return function(e,t,i){let n=e.doc.resolve(t),o=e.doc.resolve(i);if(n.parent.isTextblock&&o.parent.isTextblock&&n.start()!=o.start()&&0==n.parentOffset&&0==o.parentOffset){let r=n.sharedDepth(i),s=!1;for(let e=n.depth;e>r;e--)n.node(e).type.spec.isolating&&(s=!0);for(let e=o.depth;e>r;e--)o.node(e).type.spec.isolating&&(s=!0);if(!s){for(let e=n.depth;e>0&&t==n.start(e);e--)t=n.before(e);for(let e=o.depth;e>0&&i==o.start(e);e--)i=o.before(e);n=e.doc.resolve(t),o=e.doc.resolve(i)}}let r=lU(n,o);for(let t=0;t<r.length;t++){let i=r[t],s=t==r.length-1;if(s&&0==i||n.node(i).type.contentMatch.validEnd)return e.delete(n.start(i),o.end(i));if(i>0&&(s||n.node(i-1).canReplace(n.index(i-1),o.indexAfter(i-1))))return e.delete(n.before(i),o.after(i))}for(let r=1;r<=n.depth&&r<=o.depth;r++)if(t-n.start(r)==n.depth-r&&i>n.end(r)&&o.end(r)-i!=o.depth-r&&n.start(r-1)==o.start(r-1)&&n.node(r-1).canReplace(n.index(r-1),o.index(r-1)))return e.delete(n.before(r),i);e.delete(t,i)}(this,e,t),this}lift(e,t){return function(e,t,i){let{$from:n,$to:o,depth:r}=t,s=n.before(r+1),a=o.after(r+1),l=s,M=a,c=IC.empty,u=0;for(let e=r,t=!1;e>i;e--)t||n.index(e)>0?(t=!0,c=IC.from(n.node(e).copy(c)),u++):l--;let g=IC.empty,d=0;for(let e=r,t=!1;e>i;e--)t||o.after(e+1)<o.end(e)?(t=!0,g=IC.from(o.node(e).copy(g)),d++):M++;e.step(new PQ(l,M,s,a,new AC(c.append(g),u,d),c.size-u,!0))}(this,e,t),this}join(e,t=1){return function(e,t,i){let n=null,{linebreakReplacement:o}=e.doc.type.schema,r=e.doc.resolve(t-i),s=r.node().type;if(o&&s.inlineContent){let e="pre"==s.whitespace,t=!!s.contentMatch.matchType(o);e&&!t?n=!1:!e&&t&&(n=!0)}let a=e.steps.length;if(!1===n){let n=e.doc.resolve(t+i);HQ(e,n.node(),n.before(),a)}s.inlineContent&&RQ(e,t+i-1,s,r.node().contentMatchAt(r.index()),null==n);let l=e.mapping.slice(a),M=l.map(t-i);if(e.step(new _Q(M,l.map(t+i,-1),AC.empty,!0)),!0===n){let t=e.doc.resolve(M);FQ(e,t.node(),t.before(),e.steps.length)}}(this,e,t),this}wrap(e,t){return function(e,t,i){let n=IC.empty;for(let e=i.length-1;e>=0;e--){if(n.size){let t=i[e].type.contentMatch.matchFragment(n);if(!t||!t.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=IC.from(i[e].type.create(i[e].attrs,n))}let o=t.start,r=t.end;e.step(new PQ(o,r,o,r,new AC(n,0,0),i.length,!0))}(this,e,t),this}setBlockType(e,t=e,i,n=null){return function(e,t,i,n,o){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let r=e.steps.length;e.doc.nodesBetween(t,i,((t,i)=>{let s="function"==typeof o?o(t):o;if(t.isTextblock&&!t.hasMarkup(n,s)&&function(e,t,i){let n=e.resolve(t),o=n.index();return n.parent.canReplaceWith(o,o+1,i)}(e.doc,e.mapping.slice(r).map(i),n)){let o=null;if(n.schema.linebreakReplacement){let e="pre"==n.whitespace,t=!!n.contentMatch.matchType(n.schema.linebreakReplacement);e&&!t?o=!1:!e&&t&&(o=!0)}!1===o&&HQ(e,t,i,r),RQ(e,e.mapping.slice(r).map(i,1),n,void 0,null===o);let a=e.mapping.slice(r),l=a.map(i,1),M=a.map(i+t.nodeSize,1);return e.step(new PQ(l,M,l+1,M-1,new AC(IC.from(n.create(s,null,t.marks)),0,0),1,!0)),!0===o&&FQ(e,t,i,r),!1}}))}(this,e,t,i,n),this}setNodeMarkup(e,t,i=null,n){return function(e,t,i,n,o){let r=e.doc.nodeAt(t);if(!r)throw new RangeError("No node at given position");i||(i=r.type);let s=i.create(n,null,o||r.marks);if(r.isLeaf)return e.replaceWith(t,t+r.nodeSize,s);if(!i.validContent(r.content))throw new RangeError("Invalid content for node type "+i.name);e.step(new PQ(t,t+r.nodeSize,t+1,t+r.nodeSize-1,new AC(IC.from(s),0,0),1,!0))}(this,e,t,i,n),this}setNodeAttribute(e,t,i){return this.step(new MU(e,t,i)),this}setDocAttribute(e,t){return this.step(new cU(e,t)),this}addNodeMark(e,t){return this.step(new YQ(e,t)),this}removeNodeMark(e,t){let i=this.doc.nodeAt(e);if(!i)throw new RangeError("No node at position "+e);if(t instanceof TC)t.isInSet(i.marks)&&this.step(new ZQ(e,t));else{let n,o=i.marks,r=[];for(;n=t.isInSet(o);)r.push(new ZQ(e,n)),o=n.removeFromSet(o);for(let e=r.length-1;e>=0;e--)this.step(r[e])}return this}split(e,t=1,i){return function(e,t,i=1,n){let o=e.doc.resolve(t),r=IC.empty,s=IC.empty;for(let e=o.depth,t=o.depth-i,a=i-1;e>t;e--,a--){r=IC.from(o.node(e).copy(r));let t=n&&n[a];s=IC.from(t?t.type.create(t.attrs,s):o.node(e).copy(s))}e.step(new _Q(t,t,new AC(r.append(s),i,i),!0))}(this,e,t,i),this}addMark(e,t,i){return function(e,t,i,n){let o,r,s=[],a=[];e.doc.nodesBetween(t,i,((e,l,M)=>{if(!e.isInline)return;let c=e.marks;if(!n.isInSet(c)&&M.type.allowsMarkType(n.type)){let M=Math.max(l,t),u=Math.min(l+e.nodeSize,i),g=n.addToSet(c);for(let e=0;e<c.length;e++)c[e].isInSet(g)||(o&&o.to==M&&o.mark.eq(c[e])?o.to=u:s.push(o=new UQ(M,u,c[e])));r&&r.to==M?r.to=u:a.push(r=new QQ(M,u,n))}})),s.forEach((t=>e.step(t))),a.forEach((t=>e.step(t)))}(this,e,t,i),this}removeMark(e,t,i){return function(e,t,i,n){let o=[],r=0;e.doc.nodesBetween(t,i,((e,s)=>{if(!e.isInline)return;r++;let a=null;if(n instanceof aQ){let t,i=e.marks;for(;t=n.isInSet(i);)(a||(a=[])).push(t),i=t.removeFromSet(i)}else n?n.isInSet(e.marks)&&(a=[n]):a=e.marks;if(a&&a.length){let n=Math.min(s+e.nodeSize,i);for(let e=0;e<a.length;e++){let i,l=a[e];for(let e=0;e<o.length;e++){let t=o[e];t.step==r-1&&l.eq(o[e].style)&&(i=t)}i?(i.to=n,i.step=r):o.push({style:l,from:Math.max(s,t),to:n,step:r})}}})),o.forEach((t=>e.step(new UQ(t.from,t.to,t.style))))}(this,e,t,i),this}clearIncompatible(e,t,i){return RQ(this,e,t,i),this}}const dU=Object.create(null);class hU{constructor(e,t,i){this.$anchor=e,this.$head=t,this.ranges=i||[new NU(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=AC.empty){let i=t.content.lastChild,n=null;for(let e=0;e<t.openEnd;e++)n=i,i=i.lastChild;let o=e.steps.length,r=this.ranges;for(let s=0;s<r.length;s++){let{$from:a,$to:l}=r[s],M=e.mapping.slice(o);e.replaceRange(M.map(a.pos),M.map(l.pos),s?AC.empty:t),0==s&&AU(e,o,(i?i.isInline:n&&n.isTextblock)?-1:1)}}replaceWith(e,t){let i=e.steps.length,n=this.ranges;for(let o=0;o<n.length;o++){let{$from:r,$to:s}=n[o],a=e.mapping.slice(i),l=a.map(r.pos),M=a.map(s.pos);o?e.deleteRange(l,M):(e.replaceRangeWith(l,M,t),AU(e,i,t.isInline?-1:1))}}static findFrom(e,t,i=!1){let n=e.parent.inlineContent?new yU(e):xU(e.node(0),e.parent,e.pos,e.index(),t,i);if(n)return n;for(let n=e.depth-1;n>=0;n--){let o=t<0?xU(e.node(0),e.node(n),e.before(n+1),e.index(n),t,i):xU(e.node(0),e.node(n),e.after(n+1),e.index(n)+1,t,i);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new mU(e.node(0))}static atStart(e){return xU(e,e,0,0,1)||new mU(e)}static atEnd(e){return xU(e,e,e.content.size,e.childCount,-1)||new mU(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let i=dU[t.type];if(!i)throw new RangeError(`No selection type ${t.type} defined`);return i.fromJSON(e,t)}static jsonID(e,t){if(e in dU)throw new RangeError("Duplicate use of selection JSON ID "+e);return dU[e]=t,t.prototype.jsonID=e,t}getBookmark(){return yU.between(this.$anchor,this.$head).getBookmark()}}hU.prototype.visible=!0;class NU{constructor(e,t){this.$from=e,this.$to=t}}let pU=!1;function DU(e){pU||e.parent.inlineContent||(pU=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class yU extends hU{constructor(e,t=e){DU(e),DU(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let i=e.resolve(t.map(this.head));if(!i.parent.inlineContent)return hU.near(i);let n=e.resolve(t.map(this.anchor));return new yU(n.parent.inlineContent?n:i,i)}replace(e,t=AC.empty){if(super.replace(e,t),t==AC.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof yU&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new IU(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new yU(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,i=t){let n=e.resolve(t);return new this(n,i==t?n:e.resolve(i))}static between(e,t,i){let n=e.pos-t.pos;if(i&&!n||(i=n>=0?1:-1),!t.parent.inlineContent){let e=hU.findFrom(t,i,!0)||hU.findFrom(t,-i,!0);if(!e)return hU.near(t,i);t=e.$head}return e.parent.inlineContent||(0==n||(e=(hU.findFrom(e,-i,!0)||hU.findFrom(e,i,!0)).$anchor).pos<t.pos!=n<0)&&(e=t),new yU(e,t)}}hU.jsonID("text",yU);class IU{constructor(e,t){this.anchor=e,this.head=t}map(e){return new IU(e.map(this.anchor),e.map(this.head))}resolve(e){return yU.between(e.resolve(this.anchor),e.resolve(this.head))}}class jU extends hU{constructor(e){let t=e.nodeAfter,i=e.node(0).resolve(e.pos+t.nodeSize);super(e,i),this.node=t}map(e,t){let{deleted:i,pos:n}=t.mapResult(this.anchor),o=e.resolve(n);return i?hU.near(o):new jU(o)}content(){return new AC(IC.from(this.node),0,0)}eq(e){return e instanceof jU&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new zU(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new jU(e.resolve(t.anchor))}static create(e,t){return new jU(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}jU.prototype.visible=!1,hU.jsonID("node",jU);class zU{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:i}=e.mapResult(this.anchor);return t?new IU(i,i):new zU(i)}resolve(e){let t=e.resolve(this.anchor),i=t.nodeAfter;return i&&jU.isSelectable(i)?new jU(t):hU.near(t)}}class mU extends hU{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=AC.empty){if(t==AC.empty){e.delete(0,e.doc.content.size);let t=hU.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new mU(e)}map(e){return new mU(e)}eq(e){return e instanceof mU}getBookmark(){return TU}}hU.jsonID("all",mU);const TU={map(){return this},resolve:e=>new mU(e)};function xU(e,t,i,n,o,r=!1){if(t.inlineContent)return yU.create(e,i);for(let s=n-(o>0?0:1);o>0?s<t.childCount:s>=0;s+=o){let n=t.child(s);if(n.isAtom){if(!r&&jU.isSelectable(n))return jU.create(e,i-(o<0?n.nodeSize:0))}else{let t=xU(e,n,i+o,o<0?n.childCount:0,o,r);if(t)return t}i+=n.nodeSize*o}return null}function AU(e,t,i){let n=e.steps.length-1;if(n<t)return;let o,r=e.steps[n];(r instanceof _Q||r instanceof PQ)&&(e.mapping.maps[n].forEach(((e,t,i,n)=>{null==o&&(o=n)})),e.setSelection(hU.near(e.doc.resolve(o),i)))}class OU extends gU{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=-3&this.updated|1,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return TC.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(e,t){super.addStep(e,t),this.updated=-3&this.updated,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let i=this.selection;return t&&(e=e.mark(this.storedMarks||(i.empty?i.$from.marks():i.$from.marksAcross(i.$to)||TC.none))),i.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,i){let n=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(n.text(e),!0):this.deleteSelection();{if(null==i&&(i=t),!e)return this.deleteRange(t,i);let o=this.storedMarks;if(!o){let e=this.doc.resolve(t);o=i==t?e.marks():e.marksAcross(this.doc.resolve(i))}return this.replaceRangeWith(t,i,n.text(e,o)),this.selection.empty||this.selection.to!=t+e.length||this.setSelection(hU.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function fU(e,t){return t&&e?e.bind(t):e}class bU{constructor(e,t,i){this.name=e,this.init=fU(t.init,i),this.apply=fU(t.apply,i)}}const LU=[new bU("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new bU("selection",{init:(e,t)=>e.selection||hU.atStart(t.doc),apply:e=>e.selection}),new bU("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,i,n)=>n.selection.$cursor?e.storedMarks:null}),new bU("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class wU{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=LU.slice(),t&&t.forEach((e=>{if(this.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new bU(e.key,e.spec.state,e))}))}}class vU{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let i=0;i<this.config.plugins.length;i++)if(i!=t){let t=this.config.plugins[i];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],i=this.applyInner(e),n=null;for(;;){let o=!1;for(let r=0;r<this.config.plugins.length;r++){let s=this.config.plugins[r];if(s.spec.appendTransaction){let a=n?n[r].n:0,l=n?n[r].state:this,M=a<t.length&&s.spec.appendTransaction.call(s,a?t.slice(a):t,l,i);if(M&&i.filterTransaction(M,r)){if(M.setMeta("appendedTransaction",e),!n){n=[];for(let e=0;e<this.config.plugins.length;e++)n.push(e<r?{state:i,n:t.length}:{state:this,n:0})}t.push(M),i=i.applyInner(M),o=!0}n&&(n[r]={state:i,n:t.length})}}if(!o)return{state:i,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new vU(this.config),i=this.config.fields;for(let n=0;n<i.length;n++){let o=i[n];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new OU(this)}static create(e){let t=new wU(e.doc?e.doc.type.schema:e.schema,e.plugins),i=new vU(t);for(let n=0;n<t.fields.length;n++)i[t.fields[n].name]=t.fields[n].init(e,i);return i}reconfigure(e){let t=new wU(this.schema,e.plugins),i=t.fields,n=new vU(t);for(let t=0;t<i.length;t++){let o=i[t].name;n[o]=this.hasOwnProperty(o)?this[o]:i[t].init(e,n)}return n}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map((e=>e.toJSON()))),e&&"object"==typeof e)for(let i in e){if("doc"==i||"selection"==i)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let n=e[i],o=n.spec.state;o&&o.toJSON&&(t[i]=o.toJSON.call(n,this[n.key]))}return t}static fromJSON(e,t,i){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let n=new wU(e.schema,e.plugins),o=new vU(n);return n.fields.forEach((n=>{if("doc"==n.name)o.doc=RC.fromJSON(e.schema,t.doc);else if("selection"==n.name)o.selection=hU.fromJSON(o.doc,t.selection);else if("storedMarks"==n.name)t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(i)for(let r in i){let s=i[r],a=s.spec.state;if(s.key==n.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(t,r))return void(o[n.name]=a.fromJSON.call(s,e,t[r],o))}o[n.name]=n.init(e,o)}})),o}}function SU(e,t,i){for(let n in e){let o=e[n];o instanceof Function?o=o.bind(t):"handleDOMEvents"==n&&(o=SU(o,t,{})),i[n]=o}return i}class kU{constructor(e){this.spec=e,this.props={},e.props&&SU(e.props,this,this.props),this.key=e.key?e.key.key:CU("plugin")}getState(e){return e[this.key]}}const EU=Object.create(null);function CU(e){return e in EU?e+"$"+ ++EU[e]:(EU[e]=0,e+"$")}class QU{constructor(e="key"){this.key=CU(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const UU=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},YU=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t};let ZU=null;const _U=function(e,t,i){let n=ZU||(ZU=document.createRange());return n.setEnd(e,null==i?e.nodeValue.length:i),n.setStart(e,t||0),n},PU=function(e,t,i,n){return i&&(RU(e,t,i,n,-1)||RU(e,t,i,n,1))},VU=/^(img|br|input|textarea|hr)$/i;function RU(e,t,i,n,o){for(var r;;){if(e==i&&t==n)return!0;if(t==(o<0?0:WU(e))){let i=e.parentNode;if(!i||1!=i.nodeType||BU(e)||VU.test(e.nodeName)||"false"==e.contentEditable)return!1;t=UU(e)+(o<0?0:1),e=i}else{if(1!=e.nodeType)return!1;{let i=e.childNodes[t+(o<0?-1:0)];if(1==i.nodeType&&"false"==i.contentEditable){if(!(null===(r=i.pmViewDesc)||void 0===r?void 0:r.ignoreForSelection))return!1;t+=o}else e=i,t=o<0?WU(e):0}}}}function WU(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function BU(e){let t;for(let i=e;i&&!(t=i.pmViewDesc);i=i.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const $U=function(e){return e.focusNode&&PU(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function GU(e,t){let i=document.createEvent("Event");return i.initEvent("keydown",!0,!0),i.keyCode=e,i.key=i.code=t,i}const FU="undefined"!=typeof navigator?navigator:null,HU="undefined"!=typeof document?document:null,JU=FU&&FU.userAgent||"",XU=/Edge\/(\d+)/.exec(JU),qU=/MSIE \d/.exec(JU),KU=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(JU),eY=!!(qU||KU||XU),tY=qU?document.documentMode:KU?+KU[1]:XU?+XU[1]:0,iY=!eY&&/gecko\/(\d+)/i.test(JU);iY&&(/Firefox\/(\d+)/.exec(JU)||[0,0])[1];const nY=!eY&&/Chrome\/(\d+)/.exec(JU),oY=!!nY,rY=nY?+nY[1]:0,sY=!eY&&!!FU&&/Apple Computer/.test(FU.vendor),aY=sY&&(/Mobile\/\w+/.test(JU)||!!FU&&FU.maxTouchPoints>2),lY=aY||!!FU&&/Mac/.test(FU.platform),MY=!!FU&&/Win/.test(FU.platform),cY=/Android \d/.test(JU),uY=!!HU&&"webkitFontSmoothing"in HU.documentElement.style,gY=uY?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function dY(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function hY(e,t){return"number"==typeof e?e:e[t]}function NY(e){let t=e.getBoundingClientRect(),i=t.width/e.offsetWidth||1,n=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*i,top:t.top,bottom:t.top+e.clientHeight*n}}function pY(e,t,i){if(!xY(t)&&0==t.left)return;let n=e.someProp("scrollThreshold")||0,o=e.someProp("scrollMargin")||5,r=e.dom.ownerDocument;for(let s=i||e.dom;s;){if(1!=s.nodeType){s=YU(s);continue}let e=s,i=e==r.body,a=i?dY(r):NY(e),l=0,M=0;if(t.top<a.top+hY(n,"top")?M=-(a.top-t.top+hY(o,"top")):t.bottom>a.bottom-hY(n,"bottom")&&(M=t.bottom-t.top>a.bottom-a.top?t.top+hY(o,"top")-a.top:t.bottom-a.bottom+hY(o,"bottom")),t.left<a.left+hY(n,"left")?l=-(a.left-t.left+hY(o,"left")):t.right>a.right-hY(n,"right")&&(l=t.right-a.right+hY(o,"right")),l||M)if(i)r.defaultView.scrollBy(l,M);else{let i=e.scrollLeft,n=e.scrollTop;M&&(e.scrollTop+=M),l&&(e.scrollLeft+=l);let o=e.scrollLeft-i,r=e.scrollTop-n;t={left:t.left-o,top:t.top-r,right:t.right-o,bottom:t.bottom-r}}let c=i?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(c))break;s="absolute"==c?s.offsetParent:YU(s)}}function DY(e){let t=[],i=e.ownerDocument;for(let n=e;n&&(t.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),e!=i);n=YU(n));return t}function yY(e,t){for(let i=0;i<e.length;i++){let{dom:n,top:o,left:r}=e[i];n.scrollTop!=o+t&&(n.scrollTop=o+t),n.scrollLeft!=r&&(n.scrollLeft=r)}}let IY=null;function jY(e,t){let i,n,o,r,s=2e8,a=0,l=t.top,M=t.top;for(let c=e.firstChild,u=0;c;c=c.nextSibling,u++){let e;if(1==c.nodeType)e=c.getClientRects();else{if(3!=c.nodeType)continue;e=_U(c).getClientRects()}for(let g=0;g<e.length;g++){let d=e[g];if(d.top<=l&&d.bottom>=M){l=Math.max(d.bottom,l),M=Math.min(d.top,M);let e=d.left>t.left?d.left-t.left:d.right<t.left?t.left-d.right:0;if(e<s){i=c,s=e,n=e&&3==i.nodeType?{left:d.right<t.left?d.right:d.left,top:t.top}:t,1==c.nodeType&&e&&(a=u+(t.left>=(d.left+d.right)/2?1:0));continue}}else d.top>t.top&&!o&&d.left<=t.left&&d.right>=t.left&&(o=c,r={left:Math.max(d.left,Math.min(d.right,t.left)),top:d.top});!i&&(t.left>=d.right&&t.top>=d.top||t.left>=d.left&&t.top>=d.bottom)&&(a=u+1)}}return!i&&o&&(i=o,n=r,s=0),i&&3==i.nodeType?function(e,t){let i,n=e.nodeValue.length,o=document.createRange();for(let r=0;r<n;r++){o.setEnd(e,r+1),o.setStart(e,r);let n=AY(o,1);if(n.top!=n.bottom&&zY(t,n)){i={node:e,offset:r+(t.left>=(n.left+n.right)/2?1:0)};break}}return o.detach(),i||{node:e,offset:0}}(i,n):!i||s&&1==i.nodeType?{node:e,offset:a}:jY(i,n)}function zY(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function mY(e,t,i){let n=e.childNodes.length;if(n&&i.top<i.bottom)for(let o=Math.max(0,Math.min(n-1,Math.floor(n*(t.top-i.top)/(i.bottom-i.top))-2)),r=o;;){let i=e.childNodes[r];if(1==i.nodeType){let e=i.getClientRects();for(let n=0;n<e.length;n++){let o=e[n];if(zY(t,o))return mY(i,t,o)}}if((r=(r+1)%n)==o)break}return e}function TY(e,t){let i,n=e.dom.ownerDocument,o=0,r=function(e,t,i){if(e.caretPositionFromPoint)try{let n=e.caretPositionFromPoint(t,i);if(n)return{node:n.offsetNode,offset:Math.min(WU(n.offsetNode),n.offset)}}catch(e){}if(e.caretRangeFromPoint){let n=e.caretRangeFromPoint(t,i);if(n)return{node:n.startContainer,offset:Math.min(WU(n.startContainer),n.startOffset)}}}(n,t.left,t.top);r&&({node:i,offset:o}=r);let s,a=(e.root.elementFromPoint?e.root:n).elementFromPoint(t.left,t.top);if(!a||!e.dom.contains(1!=a.nodeType?a.parentNode:a)){let i=e.dom.getBoundingClientRect();if(!zY(t,i))return null;if(a=mY(e.dom,t,i),!a)return null}if(sY)for(let e=a;i&&e;e=YU(e))e.draggable&&(i=void 0);if(a=function(e,t){let i=e.parentNode;return i&&/^li$/i.test(i.nodeName)&&t.left<e.getBoundingClientRect().left?i:e}(a,t),i){if(iY&&1==i.nodeType&&(o=Math.min(o,i.childNodes.length),o<i.childNodes.length)){let e,n=i.childNodes[o];"IMG"==n.nodeName&&(e=n.getBoundingClientRect()).right<=t.left&&e.bottom>t.top&&o++}let n;uY&&o&&1==i.nodeType&&1==(n=i.childNodes[o-1]).nodeType&&"false"==n.contentEditable&&n.getBoundingClientRect().top>=t.top&&o--,i==e.dom&&o==i.childNodes.length-1&&1==i.lastChild.nodeType&&t.top>i.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:0!=o&&1==i.nodeType&&"BR"==i.childNodes[o-1].nodeName||(s=function(e,t,i,n){let o=-1;for(let i=t,r=!1;i!=e.dom;){let t,s=e.docView.nearestDesc(i,!0);if(!s)return null;if(1==s.dom.nodeType&&(s.node.isBlock&&s.parent||!s.contentDOM)&&((t=s.dom.getBoundingClientRect()).width||t.height)&&(s.node.isBlock&&s.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(s.dom.nodeName)&&(!r&&t.left>n.left||t.top>n.top?o=s.posBefore:(!r&&t.right<n.left||t.bottom<n.top)&&(o=s.posAfter),r=!0),!s.contentDOM&&o<0&&!s.node.isText))return(s.node.isBlock?n.top<(t.top+t.bottom)/2:n.left<(t.left+t.right)/2)?s.posBefore:s.posAfter;i=s.dom.parentNode}return o>-1?o:e.docView.posFromDOM(t,i,-1)}(e,i,o,t))}null==s&&(s=function(e,t,i){let{node:n,offset:o}=jY(t,i),r=-1;if(1==n.nodeType&&!n.firstChild){let e=n.getBoundingClientRect();r=e.left!=e.right&&i.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(n,o,r)}(e,a,t));let l=e.docView.nearestDesc(a,!0);return{pos:s,inside:l?l.posAtStart-l.border:-1}}function xY(e){return e.top<e.bottom||e.left<e.right}function AY(e,t){let i=e.getClientRects();if(i.length){let e=i[t<0?0:i.length-1];if(xY(e))return e}return Array.prototype.find.call(i,xY)||e.getBoundingClientRect()}const OY=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function fY(e,t,i){let{node:n,offset:o,atom:r}=e.docView.domFromPos(t,i<0?-1:1),s=uY||iY;if(3==n.nodeType){if(!s||!OY.test(n.nodeValue)&&(i<0?o:o!=n.nodeValue.length)){let e=o,t=o,r=i<0?1:-1;return i<0&&!o?(t++,r=-1):i>=0&&o==n.nodeValue.length?(e--,r=1):i<0?e--:t++,bY(AY(_U(n,e,t),r),r<0)}{let e=AY(_U(n,o,o),i);if(iY&&o&&/\s/.test(n.nodeValue[o-1])&&o<n.nodeValue.length){let t=AY(_U(n,o-1,o-1),-1);if(t.top==e.top){let i=AY(_U(n,o,o+1),-1);if(i.top!=e.top)return bY(i,i.left<t.left)}}return e}}if(!e.state.doc.resolve(t-(r||0)).parent.inlineContent){if(null==r&&o&&(i<0||o==WU(n))){let e=n.childNodes[o-1];if(1==e.nodeType)return LY(e.getBoundingClientRect(),!1)}if(null==r&&o<WU(n)){let e=n.childNodes[o];if(1==e.nodeType)return LY(e.getBoundingClientRect(),!0)}return LY(n.getBoundingClientRect(),i>=0)}if(null==r&&o&&(i<0||o==WU(n))){let e=n.childNodes[o-1],t=3==e.nodeType?_U(e,WU(e)-(s?0:1)):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return bY(AY(t,1),!1)}if(null==r&&o<WU(n)){let e=n.childNodes[o];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?_U(e,0,s?0:1):1==e.nodeType?e:null:null;if(t)return bY(AY(t,-1),!0)}return bY(AY(3==n.nodeType?_U(n):n,-i),i>=0)}function bY(e,t){if(0==e.width)return e;let i=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:i,right:i}}function LY(e,t){if(0==e.height)return e;let i=t?e.top:e.bottom;return{top:i,bottom:i,left:e.left,right:e.right}}function wY(e,t,i){let n=e.state,o=e.root.activeElement;n!=t&&e.updateState(t),o!=e.dom&&e.focus();try{return i()}finally{n!=t&&e.updateState(n),o!=e.dom&&o&&o.focus()}}const vY=/[\u0590-\u08ac]/;let SY=null,kY=null,EY=!1;function CY(e,t,i){return SY==t&&kY==i?EY:(SY=t,kY=i,EY="up"==i||"down"==i?function(e,t,i){let n=t.selection,o="up"==i?n.$from:n.$to;return wY(e,t,(()=>{let{node:t}=e.docView.domFromPos(o.pos,"up"==i?-1:1);for(;;){let i=e.docView.nearestDesc(t,!0);if(!i)break;if(i.node.isBlock){t=i.contentDOM||i.dom;break}t=i.dom.parentNode}let n=fY(e,o.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=_U(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let o=t[e];if(o.bottom>o.top+1&&("up"==i?n.top-o.top>2*(o.bottom-n.top):o.bottom-n.bottom>2*(n.bottom-o.top)))return!1}}return!0}))}(e,t,i):function(e,t,i){let{$head:n}=t.selection;if(!n.parent.isTextblock)return!1;let o=n.parentOffset,r=!o,s=o==n.parent.content.size,a=e.domSelection();return a?vY.test(n.parent.textContent)&&a.modify?wY(e,t,(()=>{let{focusNode:t,focusOffset:o,anchorNode:r,anchorOffset:s}=e.domSelectionRange(),l=a.caretBidiLevel;a.modify("move",i,"character");let M=n.depth?e.docView.domAfterPos(n.before()):e.dom,{focusNode:c,focusOffset:u}=e.domSelectionRange(),g=c&&!M.contains(1==c.nodeType?c:c.parentNode)||t==c&&o==u;try{a.collapse(r,s),t&&(t!=r||o!=s)&&a.extend&&a.extend(t,o)}catch(e){}return null!=l&&(a.caretBidiLevel=l),g})):"left"==i||"backward"==i?r:s:n.pos==n.start()||n.pos==n.end()}(e,t,i))}class QY{constructor(e,t,i,n){this.parent=e,this.children=t,this.dom=i,this.contentDOM=n,this.dirty=0,i.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,i){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,i=this.posAtStart;;t++){let n=this.children[t];if(n==e)return i;i+=n.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,i){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(i<0){let i,n;if(e==this.contentDOM)i=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&(!(n=i.pmViewDesc)||n.parent!=this);)i=i.previousSibling;return i?this.posBeforeChild(n)+n.size:this.posAtStart}{let i,n;if(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&(!(n=i.pmViewDesc)||n.parent!=this);)i=i.nextSibling;return i?this.posBeforeChild(n):this.posAtEnd}}let n;if(e==this.dom&&this.contentDOM)n=t>UU(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))n=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){n=!1;break}if(t.previousSibling)break}if(null==n&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){n=!0;break}if(t.nextSibling)break}}return(null==n?i>0:n)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let i=!0,n=e;n;n=n.parentNode){let o,r=this.getDesc(n);if(r&&(!t||r.node)){if(!i||!(o=r.nodeDOM)||(1==o.nodeType?o.contains(1==e.nodeType?e:e.parentNode):o==e))return r;i=!1}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,i){for(let n=e;n;n=n.parentNode){let o=this.getDesc(n);if(o)return o.localPosFromDOM(e,t,i)}return-1}descAt(e){for(let t=0,i=0;t<this.children.length;t++){let n=this.children[t],o=i+n.size;if(i==e&&o!=i){for(;!n.border&&n.children.length;)for(let e=0;e<n.children.length;e++){let t=n.children[e];if(t.size){n=t;break}}return n}if(e<o)return n.descAt(e-i-n.border);i=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let i=0,n=0;for(let t=0;i<this.children.length;i++){let o=this.children[i],r=t+o.size;if(r>e||o instanceof RY){n=e-t;break}t=r}if(n)return this.children[i].domFromPos(n-this.children[i].border,t);for(let e;i&&!(e=this.children[i-1]).size&&e instanceof UY&&e.side>=0;i--);if(t<=0){let e,n=!0;for(;e=i?this.children[i-1]:null,e&&e.dom.parentNode!=this.contentDOM;i--,n=!1);return e&&t&&n&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?UU(e.dom)+1:0}}{let e,n=!0;for(;e=i<this.children.length?this.children[i]:null,e&&e.dom.parentNode!=this.contentDOM;i++,n=!1);return e&&n&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?UU(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,i=0){if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let n=-1,o=-1;for(let r=i,s=0;;s++){let i=this.children[s],a=r+i.size;if(-1==n&&e<=a){let o=r+i.border;if(e>=o&&t<=a-i.border&&i.node&&i.contentDOM&&this.contentDOM.contains(i.contentDOM))return i.parseRange(e,t,o);e=r;for(let t=s;t>0;t--){let i=this.children[t-1];if(i.size&&i.dom.parentNode==this.contentDOM&&!i.emptyChildAt(1)){n=UU(i.dom)+1;break}e-=i.size}-1==n&&(n=0)}if(n>-1&&(a>t||s==this.children.length-1)){t=a;for(let e=s+1;e<this.children.length;e++){let i=this.children[e];if(i.size&&i.dom.parentNode==this.contentDOM&&!i.emptyChildAt(-1)){o=UU(i.dom);break}t+=i.size}-1==o&&(o=this.contentDOM.childNodes.length);break}r=a}return{node:this.contentDOM,from:e,to:t,fromOffset:n,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:i}=this.domFromPos(e,0);if(1!=t.nodeType||i==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[i]}setSelection(e,t,i,n=!1){let o=Math.min(e,t),r=Math.max(e,t);for(let s=0,a=0;s<this.children.length;s++){let l=this.children[s],M=a+l.size;if(o>a&&r<M)return l.setSelection(e-a-l.border,t-a-l.border,i,n);a=M}let s=this.domFromPos(e,e?-1:1),a=t==e?s:this.domFromPos(t,t?-1:1),l=i.root.getSelection(),M=i.domSelectionRange(),c=!1;if((iY||sY)&&e==t){let{node:e,offset:t}=s;if(3==e.nodeType){if(c=!(!t||"\n"!=e.nodeValue[t-1]),c&&t==e.nodeValue.length)for(let t,i=e;i;i=i.parentNode){if(t=i.nextSibling){"BR"==t.nodeName&&(s=a={node:t.parentNode,offset:UU(t)+1});break}let e=i.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let i=e.childNodes[t-1];c=i&&("BR"==i.nodeName||"false"==i.contentEditable)}}if(iY&&M.focusNode&&M.focusNode!=a.node&&1==M.focusNode.nodeType){let e=M.focusNode.childNodes[M.focusOffset];e&&"false"==e.contentEditable&&(n=!0)}if(!(n||c&&sY)&&PU(s.node,s.offset,M.anchorNode,M.anchorOffset)&&PU(a.node,a.offset,M.focusNode,M.focusOffset))return;let u=!1;if((l.extend||e==t)&&(!c||!iY)){l.collapse(s.node,s.offset);try{e!=t&&l.extend(a.node,a.offset),u=!0}catch(e){}}if(!u){if(e>t){let e=s;s=a,a=e}let i=document.createRange();i.setEnd(a.node,a.offset),i.setStart(s.node,s.offset),l.removeAllRanges(),l.addRange(i)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let i=0,n=0;n<this.children.length;n++){let o=this.children[n],r=i+o.size;if(i==r?e<=r&&t>=i:e<r&&t>i){let n=i+o.border,s=r-o.border;if(e>=n&&t<=s)return this.dirty=e==i||t==r?2:1,void(e!=n||t!=s||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(e-n,t-n):o.dirty=3);o.dirty=o.dom!=o.contentDOM||o.dom.parentNode!=this.contentDOM||o.children.length?3:2}i=r}this.dirty=2}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let i=1==e?2:1;t.dirty<i&&(t.dirty=i)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class UY extends QY{constructor(e,t,i,n){let o,r=t.type.toDOM;if("function"==typeof r&&(r=r(i,(()=>o?o.parent?o.parent.posBeforeChild(o):void 0:n))),!t.type.spec.raw){if(1!=r.nodeType){let e=document.createElement("span");e.appendChild(r),r=e}r.contentEditable="false",r.classList.add("ProseMirror-widget")}super(e,[],r,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return 0==this.dirty&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return!!t&&t(e)}ignoreMutation(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class YY extends QY{constructor(e,t,i,n){super(e,[],t,null),this.textDOM=i,this.text=n}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue}}class ZY extends QY{constructor(e,t,i,n,o){super(e,[],i,n),this.mark=t,this.spec=o}static create(e,t,i,n){let o=n.nodeViews[t.type.name],r=o&&o(t,n,i);return r&&r.dom||(r=jQ.renderSpec(document,t.type.spec.toDOM(t,i),null,t.attrs)),new ZY(e,t,r.dom,r.contentDOM||r.dom,r)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return 3!=this.dirty&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),0!=this.dirty){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=0}}slice(e,t,i){let n=ZY.create(this.parent,this.mark,!0,i),o=this.children,r=this.size;t<r&&(o=iZ(o,t,r,i)),e>0&&(o=iZ(o,0,e,i));for(let e=0;e<o.length;e++)o[e].parent=n;return n.children=o,n}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class _Y extends QY{constructor(e,t,i,n,o,r,s){super(e,[],o,r),this.node=t,this.outerDeco=i,this.innerDeco=n,this.nodeDOM=s}static create(e,t,i,n,o,r){let s,a=o.nodeViews[t.type.name],l=a&&a(t,o,(()=>s?s.parent?s.parent.posBeforeChild(s):void 0:r),i,n),M=l&&l.dom,c=l&&l.contentDOM;if(t.isText)if(M){if(3!=M.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else M=document.createTextNode(t.text);else if(!M){let e=jQ.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs);({dom:M,contentDOM:c}=e)}c||t.isText||"BR"==M.nodeName||(M.hasAttribute("contenteditable")||(M.contentEditable="false"),t.type.spec.draggable&&(M.draggable=!0));let u=M;return M=XY(M,i,t),l?s=new WY(e,t,i,n,M,c||null,u,l):t.isText?new VY(e,t,i,n,M,u):new _Y(e,t,i,n,M,c||null,u)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let t=this.children.length-1;t>=0;t--){let i=this.children[t];if(this.dom.contains(i.dom.parentNode)){e.contentElement=i.dom.parentNode;break}}e.contentElement||(e.getContent=()=>IC.empty)}else e.contentElement=this.contentDOM;else e.getContent=()=>this.node.content;return e}matchesNode(e,t,i){return 0==this.dirty&&e.eq(this.node)&&qY(t,this.outerDeco)&&i.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let i=this.node.inlineContent,n=t,o=e.composing?this.localCompositionInfo(e,t):null,r=o&&o.pos>-1?o:null,s=o&&o.pos<0,a=new eZ(this,r&&r.node,e);!function(e,t,i,n){let o=t.locals(e),r=0;if(0==o.length){for(let i=0;i<e.childCount;i++){let s=e.child(i);n(s,o,t.forChild(r,s),i),r+=s.nodeSize}return}let s=0,a=[],l=null;for(let M=0;;){let c,u,g,d;for(;s<o.length&&o[s].to==r;){let e=o[s++];e.widget&&(c?(u||(u=[c])).push(e):c=e)}if(c)if(u){u.sort(tZ);for(let e=0;e<u.length;e++)i(u[e],M,!!l)}else i(c,M,!!l);if(l)d=-1,g=l,l=null;else{if(!(M<e.childCount))break;d=M,g=e.child(M++)}for(let e=0;e<a.length;e++)a[e].to<=r&&a.splice(e--,1);for(;s<o.length&&o[s].from<=r&&o[s].to>r;)a.push(o[s++]);let h=r+g.nodeSize;if(g.isText){let e=h;s<o.length&&o[s].from<e&&(e=o[s].from);for(let t=0;t<a.length;t++)a[t].to<e&&(e=a[t].to);e<h&&(l=g.cut(e-r),g=g.cut(0,e-r),h=e,d=-1)}else for(;s<o.length&&o[s].to<h;)s++;let N=g.isInline&&!g.isLeaf?a.filter((e=>!e.inline)):a.slice();n(g,N,t.forChild(r,g),d),r=h}}(this.node,this.innerDeco,((t,o,r)=>{t.spec.marks?a.syncToMarks(t.spec.marks,i,e,o):t.type.side>=0&&!r&&a.syncToMarks(o==this.node.childCount?TC.none:this.node.child(o).marks,i,e,o),a.placeWidget(t,e,n)}),((t,r,l,M)=>{let c;a.syncToMarks(t.marks,i,e,M),a.findNodeMatch(t,r,l,M)||s&&e.state.selection.from>n&&e.state.selection.to<n+t.nodeSize&&(c=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(t,r,l,c,e)||a.updateNextNode(t,r,l,e,M,n)||a.addNode(t,r,l,e,n),n+=t.nodeSize})),a.syncToMarks([],i,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||2==this.dirty)&&(r&&this.protectLocalComposition(e,r),BY(this.contentDOM,this.children,e),aY&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}localCompositionInfo(e,t){let{from:i,to:n}=e.state.selection;if(!(e.state.selection instanceof yU)||i<t||n>t+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let e=o.nodeValue,r=function(e,t,i,n){for(let o=0,r=0;o<e.childCount&&r<=n;){let s=e.child(o++),a=r;if(r+=s.nodeSize,!s.isText)continue;let l=s.text;for(;o<e.childCount;){let t=e.child(o++);if(r+=t.nodeSize,!t.isText)break;l+=t.text}if(r>=i){if(r>=n&&l.slice(n-t.length-a,n-a)==t)return n-t.length;let e=a<n?l.lastIndexOf(t,n-a-1):-1;if(e>=0&&e+t.length+a>=i)return a+e;if(i==n&&l.length>=n+t.length-a&&l.slice(n-a,n-a+t.length)==t)return n}}return-1}(this.node.content,e,i-t,n-t);return r<0?null:{node:o,pos:r,text:e}}return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:i,text:n}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let r=new YY(this,o,t,n);e.input.compositionNodes.push(r),this.children=iZ(this.children,i,i+n.length,e,r)}update(e,t,i,n){return!(3==this.dirty||!e.sameMarkup(this.node))&&(this.updateInner(e,t,i,n),!0)}updateInner(e,t,i,n){this.updateOuterDeco(t),this.node=e,this.innerDeco=i,this.contentDOM&&this.updateChildren(n,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(qY(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,i=this.dom;this.dom=HY(this.dom,this.nodeDOM,FY(this.outerDeco,this.node,t),FY(e,this.node,t)),this.dom!=i&&(i.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.nodeDOM.draggable=!0))}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function PY(e,t,i,n,o){XY(n,t,e);let r=new _Y(void 0,e,t,i,n,n,n);return r.contentDOM&&r.updateChildren(o,0),r}class VY extends _Y{constructor(e,t,i,n,o,r){super(e,t,i,n,o,null,r)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,i,n){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!e.sameMarkup(this.node))&&(this.updateOuterDeco(t),0==this.dirty&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,n.trackWrites==this.nodeDOM&&(n.trackWrites=null)),this.node=e,this.dirty=0,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,i){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,i)}ignoreMutation(e){return"characterData"!=e.type&&"selection"!=e.type}slice(e,t,i){let n=this.node.cut(e,t),o=document.createTextNode(n.text);return new VY(this.parent,n,this.outerDeco,this.innerDeco,o,o)}markDirty(e,t){super.markDirty(e,t),this.dom==this.nodeDOM||0!=e&&t!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}isText(e){return this.node.text==e}}class RY extends QY{parseRule(){return{ignore:!0}}matchesHack(e){return 0==this.dirty&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class WY extends _Y{constructor(e,t,i,n,o,r,s,a){super(e,t,i,n,o,r,s),this.spec=a}update(e,t,i,n){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,i);return o&&this.updateInner(e,t,i,n),o}return!(!this.contentDOM&&!e.isLeaf)&&super.update(e,t,i,n)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,i,n){this.spec.setSelection?this.spec.setSelection(e,t,i.root):super.setSelection(e,t,i,n)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function BY(e,t,i){let n=e.firstChild,o=!1;for(let r=0;r<t.length;r++){let s=t[r],a=s.dom;if(a.parentNode==e){for(;a!=n;)n=KY(n),o=!0;n=n.nextSibling}else o=!0,e.insertBefore(a,n);if(s instanceof ZY){let t=n?n.previousSibling:e.lastChild;BY(s.contentDOM,s.children,i),n=t?t.nextSibling:e.firstChild}}for(;n;)n=KY(n),o=!0;o&&i.trackWrites==e&&(i.trackWrites=null)}const $Y=function(e){e&&(this.nodeName=e)};$Y.prototype=Object.create(null);const GY=[new $Y];function FY(e,t,i){if(0==e.length)return GY;let n=i?GY[0]:new $Y,o=[n];for(let r=0;r<e.length;r++){let s=e[r].type.attrs;if(s){s.nodeName&&o.push(n=new $Y(s.nodeName));for(let e in s){let r=s[e];null!=r&&(i&&1==o.length&&o.push(n=new $Y(t.isInline?"span":"div")),"class"==e?n.class=(n.class?n.class+" ":"")+r:"style"==e?n.style=(n.style?n.style+";":"")+r:"nodeName"!=e&&(n[e]=r))}}}return o}function HY(e,t,i,n){if(i==GY&&n==GY)return t;let o=t;for(let t=0;t<n.length;t++){let r=n[t],s=i[t];if(t){let t;s&&s.nodeName==r.nodeName&&o!=e&&(t=o.parentNode)&&t.nodeName.toLowerCase()==r.nodeName||(t=document.createElement(r.nodeName),t.pmIsDeco=!0,t.appendChild(o),s=GY[0]),o=t}JY(o,s||GY[0],r)}return o}function JY(e,t,i){for(let n in t)"class"==n||"style"==n||"nodeName"==n||n in i||e.removeAttribute(n);for(let n in i)"class"!=n&&"style"!=n&&"nodeName"!=n&&i[n]!=t[n]&&e.setAttribute(n,i[n]);if(t.class!=i.class){let n=t.class?t.class.split(" ").filter(Boolean):[],o=i.class?i.class.split(" ").filter(Boolean):[];for(let t=0;t<n.length;t++)-1==o.indexOf(n[t])&&e.classList.remove(n[t]);for(let t=0;t<o.length;t++)-1==n.indexOf(o[t])&&e.classList.add(o[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=i.style){if(t.style){let i,n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;i=n.exec(t.style);)e.style.removeProperty(i[1])}i.style&&(e.style.cssText+=i.style)}}function XY(e,t,i){return HY(e,e,GY,FY(t,i,1!=e.nodeType))}function qY(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(!e[i].type.eq(t[i].type))return!1;return!0}function KY(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class eZ{constructor(e,t,i){this.lock=t,this.view=i,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=function(e,t){let i=t,n=i.children.length,o=e.childCount,r=new Map,s=[];e:for(;o>0;){let a;for(;;)if(n){let e=i.children[n-1];if(!(e instanceof ZY)){a=e,n--;break}i=e,n=e.children.length}else{if(i==t)break e;n=i.parent.children.indexOf(i),i=i.parent}let l=a.node;if(l){if(l!=e.child(o-1))break;--o,r.set(a,o),s.push(a)}}return{index:o,matched:r,matches:s.reverse()}}(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let i=e;i<t;i++)this.top.children[i].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,i,n){let o=0,r=this.stack.length>>1,s=Math.min(r,e.length);for(;o<s&&(o==r-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&!1!==e[o].type.spec.spanning;)o++;for(;o<r;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),r--;for(;r<e.length;){this.stack.push(this.top,this.index+1);let o=-1,s=this.top.children.length;n<this.preMatch.index&&(s=Math.min(this.index+3,s));for(let t=this.index;t<s;t++){let i=this.top.children[t];if(i.matchesMark(e[r])&&!this.isLocked(i.dom)){o=t;break}}if(o<0&&this.index<this.top.children.length){let t=this.top.children[this.index];t instanceof ZY&&3!=t.dirty&&t.mark.type==e[r].type&&t.spec.update&&!this.isLocked(t.dom)&&t.spec.update(e[r])&&(t.mark=e[r],o=this.index,this.changed=!0)}if(o>-1)o>this.index&&(this.changed=!0,this.destroyBetween(this.index,o)),this.top=this.top.children[this.index];else{let n=ZY.create(this.top,e[r],t,i);this.top.children.splice(this.index,0,n),this.top=n,this.changed=!0}this.index=0,r++}}findNodeMatch(e,t,i,n){let o,r=-1;if(n>=this.preMatch.index&&(o=this.preMatch.matches[n-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,i))r=this.top.children.indexOf(o,this.index);else for(let n=this.index,o=Math.min(this.top.children.length,n+5);n<o;n++){let o=this.top.children[n];if(o.matchesNode(e,t,i)&&!this.preMatch.matched.has(o)){r=n;break}}return!(r<0)&&(this.destroyBetween(this.index,r),this.index++,!0)}updateNodeAt(e,t,i,n,o){let r=this.top.children[n];return 3==r.dirty&&r.dom==r.contentDOM&&(r.dirty=2),!!r.update(e,t,i,o)&&(this.destroyBetween(this.index,n),this.index++,!0)}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t)for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e;return-1}e=t}}updateNextNode(e,t,i,n,o,r){for(let s=this.index;s<this.top.children.length;s++){let a=this.top.children[s];if(a instanceof _Y){let l=this.preMatch.matched.get(a);if(null!=l&&l!=o)return!1;let M,c=a.dom,u=this.isLocked(c)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&3!=a.dirty&&qY(t,a.outerDeco));if(!u&&a.update(e,t,i,n))return this.destroyBetween(this.index,s),a.dom!=c&&(this.changed=!0),this.index++,!0;if(!u&&(M=this.recreateWrapper(a,e,t,i,n,r)))return this.destroyBetween(this.index,s),this.top.children[this.index]=M,M.contentDOM&&(M.dirty=2,M.updateChildren(n,r+1),M.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,i,n,o,r){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!qY(i,e.outerDeco)||!n.eq(e.innerDeco))return null;let s=_Y.create(this.top,t,i,n,o,r);if(s.contentDOM){s.children=e.children,e.children=[];for(let e of s.children)e.parent=s}return e.destroy(),s}addNode(e,t,i,n,o){let r=_Y.create(this.top,e,t,i,n,o);r.contentDOM&&r.updateChildren(n,o+1),this.top.children.splice(this.index++,0,r),this.changed=!0}placeWidget(e,t,i){let n=this.index<this.top.children.length?this.top.children[this.index]:null;if(!n||!n.matchesWidget(e)||e!=n.widget&&n.widget.type.toDOM.parentNode){let n=new UY(this.top,e,t,i);this.top.children.splice(this.index++,0,n),this.changed=!0}else this.index++}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof ZY;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof VY)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((sY||oY)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let i=document.createElement(e);"IMG"==e&&(i.className="ProseMirror-separator",i.alt=""),"BR"==e&&(i.className="ProseMirror-trailingBreak");let n=new RY(this.top,[],i,null);t!=this.top?t.children.push(n):t.children.splice(this.index++,0,n),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}}function tZ(e,t){return e.type.side-t.type.side}function iZ(e,t,i,n,o){let r=[];for(let s=0,a=0;s<e.length;s++){let l=e[s],M=a,c=a+=l.size;M>=i||c<=t?r.push(l):(M<t&&r.push(l.slice(0,t-M,n)),o&&(r.push(o),o=void 0),c>i&&r.push(l.slice(i-M,l.size,n)))}return r}function nZ(e,t=null){let i=e.domSelectionRange(),n=e.state.doc;if(!i.focusNode)return null;let o=e.docView.nearestDesc(i.focusNode),r=o&&0==o.size,s=e.docView.posFromDOM(i.focusNode,i.focusOffset,1);if(s<0)return null;let a,l,M=n.resolve(s);if($U(i)){for(a=s;o&&!o.node;)o=o.parent;let e=o.node;if(o&&e.isAtom&&jU.isSelectable(e)&&o.parent&&(!e.isInline||!function(e,t,i){for(let n=0==t,o=t==WU(e);n||o;){if(e==i)return!0;let t=UU(e);if(!(e=e.parentNode))return!1;n=n&&0==t,o=o&&t==WU(e)}}(i.focusNode,i.focusOffset,o.dom))){let e=o.posBefore;l=new jU(s==e?M:n.resolve(e))}}else{if(i instanceof e.dom.ownerDocument.defaultView.Selection&&i.rangeCount>1){let t=s,o=s;for(let n=0;n<i.rangeCount;n++){let r=i.getRangeAt(n);t=Math.min(t,e.docView.posFromDOM(r.startContainer,r.startOffset,1)),o=Math.max(o,e.docView.posFromDOM(r.endContainer,r.endOffset,-1))}if(t<0)return null;[a,s]=o==e.state.selection.anchor?[o,t]:[t,o],M=n.resolve(s)}else a=e.docView.posFromDOM(i.anchorNode,i.anchorOffset,1);if(a<0)return null}let c=n.resolve(a);if(!l){l=gZ(e,c,M,"pointer"==t||e.state.selection.head<M.pos&&!r?1:-1)}return l}function oZ(e){return e.editable?e.hasFocus():hZ(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function rZ(e,t=!1){let i=e.state.selection;if(cZ(e,i),!oZ(e))return;let n=e.input.mouseDown;if(!t&&oY&&n){let t=e.domSelectionRange(),i=e.domObserver.currentSelection;if(t.anchorNode&&i.anchorNode&&PU(t.anchorNode,t.anchorOffset,i.anchorNode,i.anchorOffset)&&n.delaySelUpdate())return void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){let t=e.domSelection();if(!t)return;let i=e.cursorWrapper.dom,n="IMG"==i.nodeName;n?t.collapse(i.parentNode,UU(i)+1):t.collapse(i,0);!n&&!e.state.selection.visible&&eY&&tY<=11&&(i.disabled=!0,i.disabled=!1)}(e);else{let n,o,{anchor:r,head:s}=i;!sZ||i instanceof yU||(i.$from.parent.inlineContent||(n=aZ(e,i.from)),i.empty||i.$from.parent.inlineContent||(o=aZ(e,i.to))),e.docView.setSelection(r,s,e,t),sZ&&(n&&MZ(n),o&&MZ(o)),i.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let i=e.domSelectionRange(),n=i.anchorNode,o=i.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{i.anchorNode==n&&i.anchorOffset==o||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout((()=>{oZ(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")}),20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}const sZ=sY||oY&&rY<63;function aZ(e,t){let{node:i,offset:n}=e.docView.domFromPos(t,0),o=n<i.childNodes.length?i.childNodes[n]:null,r=n?i.childNodes[n-1]:null;if(sY&&o&&"false"==o.contentEditable)return lZ(o);if(!(o&&"false"!=o.contentEditable||r&&"false"!=r.contentEditable)){if(o)return lZ(o);if(r)return lZ(r)}}function lZ(e){return e.contentEditable="true",sY&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function MZ(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function cZ(e,t){if(t instanceof jU){let i=e.docView.descAt(t.from);i!=e.lastSelectedViewDesc&&(uZ(e),i&&i.selectNode(),e.lastSelectedViewDesc=i)}else uZ(e)}function uZ(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function gZ(e,t,i,n){return e.someProp("createSelectionBetween",(n=>n(e,t,i)))||yU.between(t,i,n)}function dZ(e){return!(e.editable&&!e.hasFocus())&&hZ(e)}function hZ(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function NZ(e,t){let{$anchor:i,$head:n}=e.selection,o=t>0?i.max(n):i.min(n),r=o.parent.inlineContent?o.depth?e.doc.resolve(t>0?o.after():o.before()):null:o;return r&&hU.findFrom(r,t)}function pZ(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function DZ(e,t,i){let n=e.state.selection;if(!(n instanceof yU)){if(n instanceof jU&&n.node.isInline)return pZ(e,new yU(t>0?n.$to:n.$from));{let i=NZ(e.state,t);return!!i&&pZ(e,i)}}if(i.indexOf("s")>-1){let{$head:i}=n,o=i.textOffset?null:t<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let r=e.state.doc.resolve(i.pos+o.nodeSize*(t<0?-1:1));return pZ(e,new yU(n.$anchor,r))}if(!n.empty)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){let i=NZ(e.state,t);return!!(i&&i instanceof jU)&&pZ(e,i)}if(!(lY&&i.indexOf("m")>-1)){let i,o=n.$head,r=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter;if(!r||r.isText)return!1;let s=t<0?o.pos-r.nodeSize:o.pos;return!!(r.isAtom||(i=e.docView.descAt(s))&&!i.contentDOM)&&(jU.isSelectable(r)?pZ(e,new jU(t<0?e.state.doc.resolve(o.pos-r.nodeSize):o)):!!uY&&pZ(e,new yU(e.state.doc.resolve(t<0?s:s+r.nodeSize))))}}function yZ(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function IZ(e,t){let i=e.pmViewDesc;return i&&0==i.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function jZ(e,t){return t<0?function(e){let t=e.domSelectionRange(),i=t.focusNode,n=t.focusOffset;if(!i)return;let o,r,s=!1;iY&&1==i.nodeType&&n<yZ(i)&&IZ(i.childNodes[n],-1)&&(s=!0);for(;;)if(n>0){if(1!=i.nodeType)break;{let e=i.childNodes[n-1];if(IZ(e,-1))o=i,r=--n;else{if(3!=e.nodeType)break;i=e,n=i.nodeValue.length}}}else{if(zZ(i))break;{let t=i.previousSibling;for(;t&&IZ(t,-1);)o=i.parentNode,r=UU(t),t=t.previousSibling;if(t)i=t,n=yZ(i);else{if(i=i.parentNode,i==e.dom)break;n=0}}}s?mZ(e,i,n):o&&mZ(e,o,r)}(e):function(e){let t=e.domSelectionRange(),i=t.focusNode,n=t.focusOffset;if(!i)return;let o,r,s=yZ(i);for(;;)if(n<s){if(1!=i.nodeType)break;if(!IZ(i.childNodes[n],1))break;o=i,r=++n}else{if(zZ(i))break;{let t=i.nextSibling;for(;t&&IZ(t,1);)o=t.parentNode,r=UU(t)+1,t=t.nextSibling;if(t)i=t,n=0,s=yZ(i);else{if(i=i.parentNode,i==e.dom)break;n=s=0}}}o&&mZ(e,o,r)}(e)}function zZ(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function mZ(e,t,i){if(3!=t.nodeType){let e,n;(n=function(e,t){for(;e&&t==e.childNodes.length&&!BU(e);)t=UU(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let i=e.childNodes[t];if(3==i.nodeType)return i;if(1==i.nodeType&&"false"==i.contentEditable)break;e=i,t=0}}(t,i))?(t=n,i=0):(e=function(e,t){for(;e&&!t&&!BU(e);)t=UU(e),e=e.parentNode;for(;e&&t;){let i=e.childNodes[t-1];if(3==i.nodeType)return i;if(1==i.nodeType&&"false"==i.contentEditable)break;t=(e=i).childNodes.length}}(t,i))&&(t=e,i=e.nodeValue.length)}let n=e.domSelection();if(!n)return;if($U(n)){let e=document.createRange();e.setEnd(t,i),e.setStart(t,i),n.removeAllRanges(),n.addRange(e)}else n.extend&&n.extend(t,i);e.domObserver.setCurSelection();let{state:o}=e;setTimeout((()=>{e.state==o&&rZ(e)}),50)}function TZ(e,t){let i=e.state.doc.resolve(t);if(!oY&&!MY&&i.parent.inlineContent){let n=e.coordsAtPos(t);if(t>i.start()){let i=e.coordsAtPos(t-1),o=(i.top+i.bottom)/2;if(o>n.top&&o<n.bottom&&Math.abs(i.left-n.left)>1)return i.left<n.left?"ltr":"rtl"}if(t<i.end()){let i=e.coordsAtPos(t+1),o=(i.top+i.bottom)/2;if(o>n.top&&o<n.bottom&&Math.abs(i.left-n.left)>1)return i.left>n.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function xZ(e,t,i){let n=e.state.selection;if(n instanceof yU&&!n.empty||i.indexOf("s")>-1)return!1;if(lY&&i.indexOf("m")>-1)return!1;let{$from:o,$to:r}=n;if(!o.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let i=NZ(e.state,t);if(i&&i instanceof jU)return pZ(e,i)}if(!o.parent.inlineContent){let i=t<0?o:r,s=n instanceof mU?hU.near(i,t):hU.findFrom(i,t);return!!s&&pZ(e,s)}return!1}function AZ(e,t){if(!(e.state.selection instanceof yU))return!0;let{$head:i,$anchor:n,empty:o}=e.state.selection;if(!i.sameParent(n))return!0;if(!o)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let r=!i.textOffset&&(t<0?i.nodeBefore:i.nodeAfter);if(r&&!r.isText){let n=e.state.tr;return t<0?n.delete(i.pos-r.nodeSize,i.pos):n.delete(i.pos,i.pos+r.nodeSize),e.dispatch(n),!0}return!1}function OZ(e,t,i){e.domObserver.stop(),t.contentEditable=i,e.domObserver.start()}function fZ(e,t){let i=t.keyCode,n=function(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);if(8==i||lY&&72==i&&"c"==n)return AZ(e,-1)||jZ(e,-1);if(46==i&&!t.shiftKey||lY&&68==i&&"c"==n)return AZ(e,1)||jZ(e,1);if(13==i||27==i)return!0;if(37==i||lY&&66==i&&"c"==n){let t=37==i?"ltr"==TZ(e,e.state.selection.from)?-1:1:-1;return DZ(e,t,n)||jZ(e,t)}if(39==i||lY&&70==i&&"c"==n){let t=39==i?"ltr"==TZ(e,e.state.selection.from)?1:-1:1;return DZ(e,t,n)||jZ(e,t)}return 38==i||lY&&80==i&&"c"==n?xZ(e,-1,n)||jZ(e,-1):40==i||lY&&78==i&&"c"==n?function(e){if(!sY||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:i}=e.domSelectionRange();if(t&&1==t.nodeType&&0==i&&t.firstChild&&"false"==t.firstChild.contentEditable){let i=t.firstChild;OZ(e,i,"true"),setTimeout((()=>OZ(e,i,"false")),20)}return!1}(e)||xZ(e,1,n)||jZ(e,1):n==(lY?"m":"c")&&(66==i||73==i||89==i||90==i)}function bZ(e,t){e.someProp("transformCopied",(i=>{t=i(t,e)}));let i=[],{content:n,openStart:o,openEnd:r}=t;for(;o>1&&r>1&&1==n.childCount&&1==n.firstChild.childCount;){o--,r--;let e=n.firstChild;i.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),n=e.content}let s=e.someProp("clipboardSerializer")||jQ.fromSchema(e.state.schema),a=UZ(),l=a.createElement("div");l.appendChild(s.serializeFragment(n,{document:a}));let M,c=l.firstChild,u=0;for(;c&&1==c.nodeType&&(M=QZ[c.nodeName.toLowerCase()]);){for(let e=M.length-1;e>=0;e--){let t=a.createElement(M[e]);for(;l.firstChild;)t.appendChild(l.firstChild);l.appendChild(t),u++}c=l.firstChild}c&&1==c.nodeType&&c.setAttribute("data-pm-slice",`${o} ${r}${u?` -${u}`:""} ${JSON.stringify(i)}`);let g=e.someProp("clipboardTextSerializer",(i=>i(t,e)))||t.content.textBetween(0,t.content.size,"\n\n");return{dom:l,text:g,slice:t}}function LZ(e,t,i,n,o){let r,s,a=o.parent.type.spec.code;if(!i&&!t)return null;let l=!!t&&(n||a||!i);if(l){if(e.someProp("transformPastedText",(i=>{t=i(t,a||n,e)})),a)return s=new AC(IC.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0),e.someProp("transformPasted",(t=>{s=t(s,e,!0)})),s;let i=e.someProp("clipboardTextParser",(i=>i(t,o,n,e)));if(i)s=i;else{let i=o.marks(),{schema:n}=e.state,s=jQ.fromSchema(n);r=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach((e=>{let t=r.appendChild(document.createElement("p"));e&&t.appendChild(s.serializeNode(n.text(e,i)))}))}}else e.someProp("transformPastedHTML",(t=>{i=t(i,e)})),r=function(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let i,n=UZ(),o=n.body,r=/<([a-z][^>\s]+)/i.exec(e);(i=r&&QZ[r[1].toLowerCase()])&&(e=i.map((e=>"<"+e+">")).join("")+e+i.map((e=>"</"+e+">")).reverse().join(""));if(o.innerHTML=function(e){let t=window.trustedTypes;if(!t)return e;YZ||(YZ=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:e=>e}));return YZ.createHTML(e)}(e),i)for(let e=0;e<i.length;e++)o=o.querySelector(i[e])||o;for(let e=0;e<n.styleSheets.length;e++){let t=n.styleSheets[e];for(let e=0;e<t.rules.length;e++){let i=t.rules[e];if(i instanceof CSSStyleRule){let e=o.querySelectorAll(i.selectorText);for(let t=0;t<e.length;t++)e[t].style.cssText+=i.style.cssText}}}return o}(i),uY&&function(e){let t=e.querySelectorAll(oY?"span:not([class]):not([style])":"span.Apple-converted-space");for(let i=0;i<t.length;i++){let n=t[i];1==n.childNodes.length&&" "==n.textContent&&n.parentNode&&n.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),n)}}(r);let M=r&&r.querySelector("[data-pm-slice]"),c=M&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(M.getAttribute("data-pm-slice")||"");if(c&&c[3])for(let e=+c[3];e>0;e--){let e=r.firstChild;for(;e&&1!=e.nodeType;)e=e.nextSibling;if(!e)break;r=e}if(!s){let t=e.someProp("clipboardParser")||e.someProp("domParser")||cQ.fromSchema(e.state.schema);s=t.parseSlice(r,{preserveWhitespace:!(!l&&!c),context:o,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||wZ.test(e.parentNode.nodeName)?null:{ignore:!0}})}if(c)s=function(e,t){if(!e.size)return e;let i,n=e.content.firstChild.type.schema;try{i=JSON.parse(t)}catch(t){return e}let{content:o,openStart:r,openEnd:s}=e;for(let e=i.length-2;e>=0;e-=2){let t=n.nodes[i[e]];if(!t||t.hasRequiredAttrs())break;o=IC.from(t.create(i[e+1],o)),r++,s++}return new AC(o,r,s)}(CZ(s,+c[1],+c[2]),c[4]);else if(s=AC.maxOpen(function(e,t){if(e.childCount<2)return e;for(let i=t.depth;i>=0;i--){let n,o=t.node(i).contentMatchAt(t.index(i)),r=[];if(e.forEach((e=>{if(!r)return;let t,i=o.findWrapping(e.type);if(!i)return r=null;if(t=r.length&&n.length&&SZ(i,n,e,r[r.length-1],0))r[r.length-1]=t;else{r.length&&(r[r.length-1]=kZ(r[r.length-1],n.length));let t=vZ(e,i);r.push(t),o=o.matchType(t.type),n=i}})),r)return IC.from(r)}return e}(s.content,o),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=CZ(s,e,t)}return e.someProp("transformPasted",(t=>{s=t(s,e,l)})),s}const wZ=/^(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 vZ(e,t,i=0){for(let n=t.length-1;n>=i;n--)e=t[n].create(null,IC.from(e));return e}function SZ(e,t,i,n,o){if(o<e.length&&o<t.length&&e[o]==t[o]){let r=SZ(e,t,i,n.lastChild,o+1);if(r)return n.copy(n.content.replaceChild(n.childCount-1,r));if(n.contentMatchAt(n.childCount).matchType(o==e.length-1?i.type:e[o+1]))return n.copy(n.content.append(IC.from(vZ(i,e,o+1))))}}function kZ(e,t){if(0==t)return e;let i=e.content.replaceChild(e.childCount-1,kZ(e.lastChild,t-1)),n=e.contentMatchAt(e.childCount).fillBefore(IC.empty,!0);return e.copy(i.append(n))}function EZ(e,t,i,n,o,r){let s=t<0?e.firstChild:e.lastChild,a=s.content;return e.childCount>1&&(r=0),o<n-1&&(a=EZ(a,t,i,n,o+1,r)),o>=i&&(a=t<0?s.contentMatchAt(0).fillBefore(a,r<=o).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(IC.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,s.copy(a))}function CZ(e,t,i){return t<e.openStart&&(e=new AC(EZ(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),i<e.openEnd&&(e=new AC(EZ(e.content,1,i,e.openEnd,0,0),e.openStart,i)),e}const QZ={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function UZ(){return document.implementation.createHTMLDocument("title")}let YZ=null;const ZZ={},_Z={},PZ={touchstart:!0,touchmove:!0};class VZ{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function RZ(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function WZ(e){e.someProp("handleDOMEvents",(t=>{for(let i in t)e.input.eventHandlers[i]||e.dom.addEventListener(i,e.input.eventHandlers[i]=t=>BZ(e,t))}))}function BZ(e,t){return e.someProp("handleDOMEvents",(i=>{let n=i[t.type];return!!n&&(n(e,t)||t.defaultPrevented)}))}function $Z(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let i=t.target;i!=e.dom;i=i.parentNode)if(!i||11==i.nodeType||i.pmViewDesc&&i.pmViewDesc.stopEvent(t))return!1;return!0}function GZ(e){return{left:e.clientX,top:e.clientY}}function FZ(e,t,i,n,o){if(-1==n)return!1;let r=e.state.doc.resolve(n);for(let n=r.depth+1;n>0;n--)if(e.someProp(t,(t=>n>r.depth?t(e,i,r.nodeAfter,r.before(n),o,!0):t(e,i,r.node(n),r.before(n),o,!1))))return!0;return!1}function HZ(e,t,i){if(e.focused||e.focus(),e.state.selection.eq(t))return;let n=e.state.tr.setSelection(t);"pointer"==i&&n.setMeta("pointer",!0),e.dispatch(n)}function JZ(e,t,i,n,o){return FZ(e,"handleClickOn",t,i,n)||e.someProp("handleClick",(i=>i(e,t,n)))||(o?function(e,t){if(-1==t)return!1;let i,n,o=e.state.selection;o instanceof jU&&(i=o.node);let r=e.state.doc.resolve(t);for(let e=r.depth+1;e>0;e--){let t=e>r.depth?r.nodeAfter:r.node(e);if(jU.isSelectable(t)){n=i&&o.$from.depth>0&&e>=o.$from.depth&&r.before(o.$from.depth+1)==o.$from.pos?r.before(o.$from.depth):r.before(e);break}}return null!=n&&(HZ(e,jU.create(e.state.doc,n),"pointer"),!0)}(e,i):function(e,t){if(-1==t)return!1;let i=e.state.doc.resolve(t),n=i.nodeAfter;return!!(n&&n.isAtom&&jU.isSelectable(n))&&(HZ(e,new jU(i),"pointer"),!0)}(e,i))}function XZ(e,t,i,n){return FZ(e,"handleDoubleClickOn",t,i,n)||e.someProp("handleDoubleClick",(i=>i(e,t,n)))}function qZ(e,t,i,n){return FZ(e,"handleTripleClickOn",t,i,n)||e.someProp("handleTripleClick",(i=>i(e,t,n)))||function(e,t,i){if(0!=i.button)return!1;let n=KZ(e,t,!0),o=e.state.doc;if(!n)return!1;HZ(e,n,"pointer"),n instanceof yU&&o.eq(e.state.doc)&&(e.input.mouseDown=new o_(e,n));return!0}(e,i,n)}function KZ(e,t,i){let n=e.state.doc;if(-1==t)return n.inlineContent?yU.create(n,0,n.content.size):null;let o=n.resolve(t);for(let e=o.depth+1;e>0;e--){let t=e>o.depth?o.nodeAfter:o.node(e),r=o.before(e);if(t.inlineContent)return yU.create(n,r+1,r+1+t.content.size);if(i&&jU.isSelectable(t))return jU.create(n,r)}return null}function e_(e){return c_(e)}_Z.keydown=(e,t)=>{let i=t;if(e.input.shiftKey=16==i.keyCode||i.shiftKey,!r_(e)&&(e.input.lastKeyCode=i.keyCode,e.input.lastKeyCodeTime=Date.now(),!cY||!oY||13!=i.keyCode))if(229!=i.keyCode&&e.domObserver.forceFlush(),!aY||13!=i.keyCode||i.ctrlKey||i.altKey||i.metaKey)e.someProp("handleKeyDown",(t=>t(e,i)))||fZ(e,i)?i.preventDefault():RZ(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",(t=>t(e,GU(13,"Enter")))),e.input.lastIOSEnter=0)}),200)}},_Z.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},_Z.keypress=(e,t)=>{let i=t;if(r_(e)||!i.charCode||i.ctrlKey&&!i.altKey||lY&&i.metaKey)return;if(e.someProp("handleKeyPress",(t=>t(e,i))))return void i.preventDefault();let n=e.state.selection;if(!(n instanceof yU&&n.$from.sameParent(n.$to))){let t=String.fromCharCode(i.charCode),o=()=>e.state.tr.insertText(t).scrollIntoView();/[\r\n]/.test(t)||e.someProp("handleTextInput",(i=>i(e,n.$from.pos,n.$to.pos,t,o)))||e.dispatch(o()),i.preventDefault()}};const t_=lY?"metaKey":"ctrlKey";ZZ.mousedown=(e,t)=>{let i=t;e.input.shiftKey=i.shiftKey;let n=e_(e),o=Date.now(),r="singleClick";o-e.input.lastClick.time<500&&function(e,t){let i=t.x-e.clientX,n=t.y-e.clientY;return i*i+n*n<100}(i,e.input.lastClick)&&!i[t_]&&e.input.lastClick.button==i.button&&("singleClick"==e.input.lastClick.type?r="doubleClick":"doubleClick"==e.input.lastClick.type&&(r="tripleClick")),e.input.lastClick={time:o,x:i.clientX,y:i.clientY,type:r,button:i.button},e.input.mouseDown&&e.input.mouseDown.done();let s=e.posAtCoords(GZ(i));s&&("singleClick"==r?e.input.mouseDown=new n_(e,s,i,!!n):("doubleClick"==r?XZ:qZ)(e,s.pos,s.inside,i)?i.preventDefault():RZ(e,"pointer"))};class i_{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){0==e.buttons&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}}class n_ extends i_{constructor(e,t,i,n){let o,r;if(super(e),this.pos=t,this.event=i,this.flushed=n,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!i[t_],this.allowDefault=i.shiftKey,t.inside>-1)o=e.state.doc.nodeAt(t.inside),r=t.inside;else{let i=e.state.doc.resolve(t.pos);o=i.parent,r=i.depth?i.before():0}const s=n?null:i.target,a=s?e.docView.nearestDesc(s,!0):null;this.target=a&&1==a.nodeDOM.nodeType?a.nodeDOM:null;let{selection:l}=e.state;0==i.button&&(o.type.spec.draggable&&!1!==o.type.spec.selectable||l instanceof jU&&l.from<=r&&l.to>r)&&(this.mightDrag={node:o,pos:r,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!iY||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()),RZ(e,"pointer")}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout((()=>{this.view.isDestroyed||rZ(this.view)}))}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(GZ(e))),this.updateAllowDefault(e),this.allowDefault||!t?RZ(this.view,"pointer"):JZ(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||sY&&this.mightDrag&&!this.mightDrag.node.isAtom||oY&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(HZ(this.view,hU.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):RZ(this.view,"pointer")}move(e){this.updateAllowDefault(e),RZ(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return!!this.allowDefault&&(this.delayedSelectionSync=!0,!0)}}class o_ extends i_{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(0==e.buttons||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc))return void this.done();e.preventDefault(),RZ(this.view,"pointer");let t=this.view.posAtCoords(GZ(e)),i=t&&KZ(this.view,t.inside,!1);if(!i)return;let{doc:n}=this.view.state,o=this.startSelection,[r,s]=i.from<o.from?[o.to,i.from]:[o.from,i.to];HZ(this.view,yU.create(n,r,s),"pointer")}}function r_(e,t){return!!e.composing||!!(sY&&Math.abs(Date.now()-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}ZZ.touchstart=e=>{e.input.lastTouch=Date.now(),e_(e),RZ(e,"pointer")},ZZ.touchmove=e=>{e.input.lastTouch=Date.now(),RZ(e,"pointer")},ZZ.contextmenu=e=>e_(e);const s_=cY?5e3:-1;function a_(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout((()=>c_(e)),t))}function l_(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function M_(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let i=function(e,t){for(;;){if(3==e.nodeType&&t)return e;if(1==e.nodeType&&t>0){if("false"==e.contentEditable)return null;t=WU(e=e.childNodes[t-1])}else{if(!e.parentNode||BU(e))return null;t=UU(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),n=function(e,t){for(;;){if(3==e.nodeType&&t<e.nodeValue.length)return e;if(1==e.nodeType&&t<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[t],t=0}else{if(!e.parentNode||BU(e))return null;t=UU(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(i&&n&&i!=n){let t=n.pmViewDesc,o=e.domObserver.lastChangedTextNode;if(i==o||n==o)return o;if(!t||!t.isText(n.nodeValue))return n;if(e.input.compositionNode==n){let e=i.pmViewDesc;if(e&&e.isText(i.nodeValue))return n}}return i||n}function c_(e,t=!1){if(!(cY&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),l_(e),t||e.docView&&e.docView.dirty){let i=nZ(e),n=e.state.selection;return i&&!i.eq(n)?e.dispatch(e.state.tr.setSelection(i)):!e.markCursor&&!t||n.$from.node(n.$from.sharedDepth(n.to)).inlineContent?e.updateState(e.state):e.dispatch(e.state.tr.deleteSelection()),!0}return!1}}_Z.compositionstart=_Z.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,i=t.selection.$to;if(t.selection instanceof yU&&(t.storedMarks||!i.textOffset&&i.parentOffset&&i.nodeBefore.marks.some((e=>!1===e.type.spec.inclusive))||oY&&MY&&function(e){let{focusNode:t,focusOffset:i}=e.domSelectionRange();if(!t||1!=t.nodeType||i>=t.childNodes.length)return!1;let n=t.childNodes[i];return 1==n.nodeType&&"false"==n.contentEditable}(e)))e.markCursor=e.state.storedMarks||i.marks(),c_(e,!0),e.markCursor=null;else if(c_(e,!t.selection.empty),iY&&t.selection.empty&&i.parentOffset&&!i.textOffset&&i.nodeBefore.marks.length){let t=e.domSelectionRange();for(let i=t.focusNode,n=t.focusOffset;i&&1==i.nodeType&&0!=n;){let t=n<0?i.lastChild:i.childNodes[n-1];if(!t)break;if(3==t.nodeType){let i=e.domSelection();i&&i.collapse(t,t.nodeValue.length);break}i=t,n=-1}}e.input.composing=!0}a_(e,s_)},_Z.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now(),e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then((()=>e.domObserver.flush())),e.input.compositionID++,a_(e,20))};const u_=eY&&tY<15||aY&&gY<604;function g_(e,t,i,n,o){let r=LZ(e,t,i,n,e.state.selection.$from);if(e.someProp("handlePaste",(t=>t(e,o,r||AC.empty))))return!0;if(!r)return!1;let s=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(r),a=s?e.state.tr.replaceSelectionWith(s,n):e.state.tr.replaceSelection(r);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function d_(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let i=e.getData("text/uri-list");return i?i.replace(/\r?\n/g," "):""}ZZ.copy=_Z.cut=(e,t)=>{let i=t,n=e.state.selection,o="cut"==i.type;if(n.empty)return;let r=u_?null:i.clipboardData,s=n.content(),{dom:a,text:l}=bZ(e,s);r?(i.preventDefault(),r.clearData(),r.setData("text/html",a.innerHTML),r.setData("text/plain",l)):function(e,t){if(!e.dom.parentNode)return;let i=e.dom.parentNode.appendChild(document.createElement("div"));i.appendChild(t),i.style.cssText="position: fixed; left: -10000px; top: 10px";let n=getSelection(),o=document.createRange();o.selectNodeContents(t),e.dom.blur(),n.removeAllRanges(),n.addRange(o),setTimeout((()=>{i.parentNode&&i.parentNode.removeChild(i),e.focus()}),50)}(e,a),o&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},_Z.paste=(e,t)=>{let i=t;if(e.composing&&!cY)return;let n=u_?null:i.clipboardData,o=e.input.shiftKey&&45!=e.input.lastKeyCode;n&&g_(e,d_(n),n.getData("text/html"),o,i)?i.preventDefault():function(e,t){if(!e.dom.parentNode)return;let i=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,n=e.dom.parentNode.appendChild(document.createElement(i?"textarea":"div"));i||(n.contentEditable="true"),n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus();let o=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout((()=>{e.focus(),n.parentNode&&n.parentNode.removeChild(n),i?g_(e,n.value,null,o,t):g_(e,n.textContent,n.innerHTML,o,t)}),50)}(e,i)};class h_{constructor(e,t,i){this.slice=e,this.move=t,this.node=i}}const N_=lY?"altKey":"ctrlKey";function p_(e,t){let i;return e.someProp("dragCopies",(e=>{i=i||e(t)})),null!=i?!i:!t[N_]}ZZ.dragstart=(e,t)=>{let i=t,n=e.input.mouseDown;if(n&&n.done(),!i.dataTransfer)return;let o,r=e.state.selection,s=r.empty?null:e.posAtCoords(GZ(i));if(s&&s.pos>=r.from&&s.pos<=(r instanceof jU?r.to-1:r.to));else if(n&&n.mightDrag)o=jU.create(e.state.doc,n.mightDrag.pos);else if(i.target&&1==i.target.nodeType){let t=e.docView.nearestDesc(i.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=jU.create(e.state.doc,t.posBefore))}let a=(o||e.state.selection).content(),{dom:l,text:M,slice:c}=bZ(e,a);(!i.dataTransfer.files.length||!oY||rY>120)&&i.dataTransfer.clearData(),i.dataTransfer.setData(u_?"Text":"text/html",l.innerHTML),i.dataTransfer.effectAllowed="copyMove",u_||i.dataTransfer.setData("text/plain",M),e.dragging=new h_(c,p_(e,i),o)},ZZ.dragend=e=>{let t=e.dragging;window.setTimeout((()=>{e.dragging==t&&(e.dragging=null)}),50)},_Z.dragover=_Z.dragenter=(e,t)=>t.preventDefault(),_Z.drop=(e,t)=>{try{!function(e,t,i){if(!t.dataTransfer)return;let n=e.posAtCoords(GZ(t));if(!n)return;let o=e.state.doc.resolve(n.pos),r=i&&i.slice;r?e.someProp("transformPasted",(t=>{r=t(r,e,!1)})):r=LZ(e,d_(t.dataTransfer),u_?null:t.dataTransfer.getData("text/html"),!1,o);let s=!(!i||!p_(e,t));if(e.someProp("handleDrop",(i=>i(e,t,r||AC.empty,s))))return void t.preventDefault();if(!r)return;t.preventDefault();let a=r?qQ(e.state.doc,o.pos,r):o.pos;null==a&&(a=o.pos);let l=e.state.tr;if(s){let{node:e}=i;e?e.replace(l):l.deleteSelection()}let M=l.mapping.map(a),c=0==r.openStart&&0==r.openEnd&&1==r.content.childCount,u=l.doc;c?l.replaceRangeWith(M,M,r.content.firstChild):l.replaceRange(M,M,r);if(l.doc.eq(u))return;let g=l.doc.resolve(M);if(c&&jU.isSelectable(r.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(r.content.firstChild))l.setSelection(new jU(g));else{let t=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach(((e,i,n,o)=>t=o)),l.setSelection(gZ(e,g,l.doc.resolve(t)))}e.focus(),e.dispatch(l.setMeta("uiEvent","drop"))}(e,t,e.dragging)}finally{e.dragging=null}},ZZ.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout((()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&rZ(e)}),20))},ZZ.blur=(e,t)=>{let i=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),i.relatedTarget&&e.dom.contains(i.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},ZZ.beforeinput=(e,t)=>{if(oY&&cY&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout((()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",(t=>t(e,GU(8,"Backspace")))))return;let{$cursor:i}=e.state.selection;i&&i.pos>0&&e.dispatch(e.state.tr.delete(i.pos-1,i.pos).scrollIntoView())}),50)}};for(let e in _Z)ZZ[e]=_Z[e];function D_(e,t){if(e==t)return!0;for(let i in e)if(e[i]!==t[i])return!1;for(let i in t)if(!(i in e))return!1;return!0}class y_{constructor(e,t){this.toDOM=e,this.spec=t||T_,this.side=this.spec.side||0}map(e,t,i,n){let{pos:o,deleted:r}=e.mapResult(t.from+n,this.side<0?-1:1);return r?null:new z_(o-i,o-i,this)}valid(){return!0}eq(e){return this==e||e instanceof y_&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&D_(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class I_{constructor(e,t){this.attrs=e,this.spec=t||T_}map(e,t,i,n){let o=e.map(t.from+n,this.spec.inclusiveStart?-1:1)-i,r=e.map(t.to+n,this.spec.inclusiveEnd?1:-1)-i;return o>=r?null:new z_(o,r,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof I_&&D_(this.attrs,e.attrs)&&D_(this.spec,e.spec)}static is(e){return e.type instanceof I_}destroy(){}}class j_{constructor(e,t){this.attrs=e,this.spec=t||T_}map(e,t,i,n){let o=e.mapResult(t.from+n,1);if(o.deleted)return null;let r=e.mapResult(t.to+n,-1);return r.deleted||r.pos<=o.pos?null:new z_(o.pos-i,r.pos-i,this)}valid(e,t){let i,{index:n,offset:o}=e.content.findIndex(t.from);return o==t.from&&!(i=e.child(n)).isText&&o+i.nodeSize==t.to}eq(e){return this==e||e instanceof j_&&D_(this.attrs,e.attrs)&&D_(this.spec,e.spec)}destroy(){}}class z_{constructor(e,t,i){this.from=e,this.to=t,this.type=i}copy(e,t){return new z_(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,i){return this.type.map(e,this,t,i)}static widget(e,t,i){return new z_(e,e,new y_(t,i))}static inline(e,t,i,n){return new z_(e,t,new I_(i,n))}static node(e,t,i,n){return new z_(e,t,new j_(i,n))}get spec(){return this.type.spec}get inline(){return this.type instanceof I_}get widget(){return this.type instanceof y_}}const m_=[],T_={};class x_{constructor(e,t){this.local=e.length?e:m_,this.children=t.length?t:m_}static create(e,t){return t.length?w_(t,e,0,T_):A_}find(e,t,i){let n=[];return this.findInner(null==e?0:e,null==t?1e9:t,n,0,i),n}findInner(e,t,i,n,o){for(let r=0;r<this.local.length;r++){let s=this.local[r];s.from<=t&&s.to>=e&&(!o||o(s.spec))&&i.push(s.copy(s.from+n,s.to+n))}for(let r=0;r<this.children.length;r+=3)if(this.children[r]<t&&this.children[r+1]>e){let s=this.children[r]+1;this.children[r+2].findInner(e-s,t-s,i,n+s,o)}}map(e,t,i){return this==A_||0==e.maps.length?this:this.mapInner(e,t,0,0,i||T_)}mapInner(e,t,i,n,o){let r;for(let s=0;s<this.local.length;s++){let a=this.local[s].map(e,i,n);a&&a.type.valid(t,a)?(r||(r=[])).push(a):o.onRemove&&o.onRemove(this.local[s].spec)}return this.children.length?function(e,t,i,n,o,r,s){let a=e.slice();for(let e=0,t=r;e<i.maps.length;e++){let n=0;i.maps[e].forEach(((e,i,o,r)=>{let s=r-o-(i-e);for(let o=0;o<a.length;o+=3){let r=a[o+1];if(r<0||e>r+t-n)continue;let l=a[o]+t-n;i>=l?a[o+1]=e<=l?-2:-1:e>=t&&s&&(a[o]+=s,a[o+1]+=s)}n+=s})),t=i.maps[e].map(t,-1)}let l=!1;for(let t=0;t<a.length;t+=3)if(a[t+1]<0){if(-2==a[t+1]){l=!0,a[t+1]=-1;continue}let M=i.map(e[t]+r),c=M-o;if(c<0||c>=n.content.size){l=!0;continue}let u=i.map(e[t+1]+r,-1)-o,{index:g,offset:d}=n.content.findIndex(c),h=n.maybeChild(g);if(h&&d==c&&d+h.nodeSize==u){let n=a[t+2].mapInner(i,h,M+1,e[t]+r+1,s);n!=A_?(a[t]=c,a[t+1]=u,a[t+2]=n):(a[t+1]=-2,l=!0)}else l=!0}if(l){let l=function(e,t,i,n,o,r,s){function a(e,t){for(let r=0;r<e.local.length;r++){let a=e.local[r].map(n,o,t);a?i.push(a):s.onRemove&&s.onRemove(e.local[r].spec)}for(let i=0;i<e.children.length;i+=3)a(e.children[i+2],e.children[i]+t+1)}for(let i=0;i<e.length;i+=3)-1==e[i+1]&&a(e[i+2],t[i]+r+1);return i}(a,e,t,i,o,r,s),M=w_(l,n,0,s);t=M.local;for(let e=0;e<a.length;e+=3)a[e+1]<0&&(a.splice(e,3),e-=3);for(let e=0,t=0;e<M.children.length;e+=3){let i=M.children[e];for(;t<a.length&&a[t]<i;)t+=3;a.splice(t,0,M.children[e],M.children[e+1],M.children[e+2])}}return new x_(t.sort(v_),a)}(this.children,r||[],e,t,i,n,o):r?new x_(r.sort(v_),m_):A_}add(e,t){return t.length?this==A_?x_.create(e,t):this.addInner(e,t,0):this}addInner(e,t,i){let n,o=0;e.forEach(((e,r)=>{let s,a=r+i;if(s=b_(t,e,a)){for(n||(n=this.children.slice());o<n.length&&n[o]<r;)o+=3;n[o]==r?n[o+2]=n[o+2].addInner(e,s,a+1):n.splice(o,0,r,r+e.nodeSize,w_(s,e,a+1,T_)),o+=3}}));let r=f_(o?L_(t):t,-i);for(let t=0;t<r.length;t++)r[t].type.valid(e,r[t])||r.splice(t--,1);return new x_(r.length?this.local.concat(r).sort(v_):this.local,n||this.children)}remove(e){return 0==e.length||this==A_?this:this.removeInner(e,0)}removeInner(e,t){let i=this.children,n=this.local;for(let n=0;n<i.length;n+=3){let o,r=i[n]+t,s=i[n+1]+t;for(let t,i=0;i<e.length;i++)(t=e[i])&&t.from>r&&t.to<s&&(e[i]=null,(o||(o=[])).push(t));if(!o)continue;i==this.children&&(i=this.children.slice());let a=i[n+2].removeInner(o,r+1);a!=A_?i[n+2]=a:(i.splice(n,3),n-=3)}if(n.length)for(let i,o=0;o<e.length;o++)if(i=e[o])for(let e=0;e<n.length;e++)n[e].eq(i,t)&&(n==this.local&&(n=this.local.slice()),n.splice(e--,1));return i==this.children&&n==this.local?this:n.length||i.length?new x_(n,i):A_}forChild(e,t){if(this==A_)return this;if(t.isLeaf)return x_.empty;let i,n;for(let t=0;t<this.children.length;t+=3)if(this.children[t]>=e){this.children[t]==e&&(i=this.children[t+2]);break}let o=e+1,r=o+t.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<r&&t.to>o&&t.type instanceof I_){let e=Math.max(o,t.from)-o,i=Math.min(r,t.to)-o;e<i&&(n||(n=[])).push(t.copy(e,i))}}if(n){let e=new x_(n.sort(v_),m_);return i?new O_([e,i]):e}return i||A_}eq(e){if(this==e)return!0;if(!(e instanceof x_)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return S_(this.localsInner(e))}localsInner(e){if(this==A_)return m_;if(e.inlineContent||!this.local.some(I_.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof I_||t.push(this.local[e]);return t}forEachSet(e){e(this)}}x_.empty=new x_([],[]),x_.removeOverlap=S_;const A_=x_.empty;class O_{constructor(e){this.members=e}map(e,t){const i=this.members.map((i=>i.map(e,t,T_)));return O_.from(i)}forChild(e,t){if(t.isLeaf)return x_.empty;let i=[];for(let n=0;n<this.members.length;n++){let o=this.members[n].forChild(e,t);o!=A_&&(o instanceof O_?i=i.concat(o.members):i.push(o))}return O_.from(i)}eq(e){if(!(e instanceof O_)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,i=!0;for(let n=0;n<this.members.length;n++){let o=this.members[n].localsInner(e);if(o.length)if(t){i&&(t=t.slice(),i=!1);for(let e=0;e<o.length;e++)t.push(o[e])}else t=o}return t?S_(i?t:t.sort(v_)):m_}static from(e){switch(e.length){case 0:return A_;case 1:return e[0];default:return new O_(e.every((e=>e instanceof x_))?e:e.reduce(((e,t)=>e.concat(t instanceof x_?t:t.members)),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function f_(e,t){if(!t||!e.length)return e;let i=[];for(let n=0;n<e.length;n++){let o=e[n];i.push(new z_(o.from+t,o.to+t,o.type))}return i}function b_(e,t,i){if(t.isLeaf)return null;let n=i+t.nodeSize,o=null;for(let t,r=0;r<e.length;r++)(t=e[r])&&t.from>i&&t.to<n&&((o||(o=[])).push(t),e[r]=null);return o}function L_(e){let t=[];for(let i=0;i<e.length;i++)null!=e[i]&&t.push(e[i]);return t}function w_(e,t,i,n){let o=[],r=!1;t.forEach(((t,s)=>{let a=b_(e,t,s+i);if(a){r=!0;let e=w_(a,t,i+s+1,n);e!=A_&&o.push(s,s+t.nodeSize,e)}}));let s=f_(r?L_(e):e,-i).sort(v_);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||(n.onRemove&&n.onRemove(s[e].spec),s.splice(e--,1));return s.length||o.length?new x_(s,o):A_}function v_(e,t){return e.from-t.from||e.to-t.to}function S_(e){let t=e;for(let i=0;i<t.length-1;i++){let n=t[i];if(n.from!=n.to)for(let o=i+1;o<t.length;o++){let r=t[o];if(r.from!=n.from){r.from<n.to&&(t==e&&(t=e.slice()),t[i]=n.copy(n.from,r.from),k_(t,o,n.copy(r.from,n.to)));break}r.to!=n.to&&(t==e&&(t=e.slice()),t[o]=r.copy(r.from,n.to),k_(t,o+1,r.copy(n.to,r.to)))}}return t}function k_(e,t,i){for(;t<e.length&&v_(i,e[t])>0;)t++;e.splice(t,0,i)}function E_(e){let t=[];return e.someProp("decorations",(i=>{let n=i(e.state);n&&n!=A_&&t.push(n)})),e.cursorWrapper&&t.push(x_.create(e.state.doc,[e.cursorWrapper.deco])),O_.from(t)}const C_={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Q_=eY&&tY<=11;class U_{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Y_{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new U_,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]);eY&&tY<=11&&t.some((e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length))?this.flushSoon():sY&&e.composing&&t.some((e=>"childList"==e.type&&"TR"==e.target.nodeName))?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()})),Q_&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.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,C_)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout((()=>this.flush()),20)}this.observer.disconnect()}this.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(dZ(this.view)){if(this.suppressingSelectionUpdates)return rZ(this.view);if(eY&&tY<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&PU(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t,i=new Set;for(let t=e.focusNode;t;t=YU(t))i.add(t);for(let n=e.anchorNode;n;n=YU(n))if(i.has(n)){t=n;break}let n=t&&this.view.docView.nearestDesc(t);return n&&n.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let i=e.domSelectionRange(),n=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(i)&&dZ(e)&&!this.ignoreSelectionChange(i),o=-1,r=-1,s=!1,a=[];if(e.editable)for(let e=0;e<t.length;e++){let i=this.registerMutation(t[e],a);i&&(o=o<0?i.from:Math.min(i.from,o),r=r<0?i.to:Math.max(i.to,r),i.typeOver&&(s=!0))}if(a.some((e=>"BR"==e.nodeName))&&(8==e.input.lastKeyCode||46==e.input.lastKeyCode||oY&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some((e=>"childList"==e.type&&e.removedNodes.length)))){for(let e of a)if("BR"==e.nodeName&&e.parentNode){let t=e.nextSibling;for(;t&&1==t.nodeType;){if("false"==t.contentEditable){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(iY&&a.length){let t=a.filter((e=>"BR"==e.nodeName));if(2==t.length){let[e,i]=t;e.parentNode&&e.parentNode.parentNode==i.parentNode?i.remove():e.remove()}else{let{focusNode:i}=this.currentSelection;for(let n of t){let t=n.parentNode;!t||"LI"!=t.nodeName||i&&V_(e,i)==t||n.remove()}}}let l=null;o<0&&n&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&$U(i)&&(l=nZ(e))&&l.eq(hU.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,rZ(e),this.currentSelection.set(i),e.scrollToSelection()):(o>-1||n)&&(o>-1&&(e.docView.markDirty(o,r),function(e){if(Z_.has(e))return;if(Z_.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)){if(e.requiresGeckoHackNode=iY,__)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."),__=!0}}(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,function(e,t){var i;let{focusNode:n,focusOffset:o}=e.domSelectionRange();for(let r of t)if("TR"==(null===(i=r.parentNode)||void 0===i?void 0:i.nodeName)){let t=r.nextSibling;for(;t&&"TD"!=t.nodeName&&"TH"!=t.nodeName;)t=t.nextSibling;if(t){let i=t;for(;;){let e=i.firstChild;if(!e||1!=e.nodeType||"false"==e.contentEditable||/^(BR|IMG)$/.test(e.nodeName))break;i=e}i.insertBefore(r,i.firstChild),n==r&&e.domSelection().collapse(r,o)}else r.parentNode.removeChild(r)}}(e,a)),this.handleDOMChange(o,r,s,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(i)||rZ(e),this.currentSelection.set(i))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let i=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(i==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!i||i.ignoreMutation(e))return null;if("childList"==e.type){for(let i=0;i<e.addedNodes.length;i++){let n=e.addedNodes[i];t.push(n),3==n.nodeType&&(this.lastChangedTextNode=n)}if(i.contentDOM&&i.contentDOM!=i.dom&&!i.contentDOM.contains(e.target))return{from:i.posBefore,to:i.posAfter};let n=e.previousSibling,o=e.nextSibling;if(eY&&tY<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:i,nextSibling:r}=e.addedNodes[t];(!i||Array.prototype.indexOf.call(e.addedNodes,i)<0)&&(n=i),(!r||Array.prototype.indexOf.call(e.addedNodes,r)<0)&&(o=r)}let r=n&&n.parentNode==e.target?UU(n)+1:0,s=i.localPosFromDOM(e.target,r,-1),a=o&&o.parentNode==e.target?UU(o):e.target.childNodes.length;return{from:s,to:i.localPosFromDOM(e.target,a,1)}}return"attributes"==e.type?{from:i.posAtStart-i.border,to:i.posAtEnd+i.border}:(this.lastChangedTextNode=e.target,{from:i.posAtStart,to:i.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Z_=new WeakMap,__=!1;function P_(e,t){let i=t.startContainer,n=t.startOffset,o=t.endContainer,r=t.endOffset,s=e.domAtPos(e.state.selection.anchor);return PU(s.node,s.offset,o,r)&&([i,n,o,r]=[o,r,i,n]),{anchorNode:i,anchorOffset:n,focusNode:o,focusOffset:r}}function V_(e,t){for(let i=t.parentNode;i&&i!=e.dom;i=i.parentNode){let t=e.docView.nearestDesc(i,!0);if(t&&t.node.isBlock)return i}return null}function R_(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(sY&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}if(e.parentNode.lastChild==e||sY&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}const W_=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function B_(e,t,i,n,o){let r=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,i=nZ(e,t);if(i&&!e.state.selection.eq(i)){if(oY&&cY&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",(t=>t(e,GU(13,"Enter")))))return;let n=e.state.tr.setSelection(i);"pointer"==t?n.setMeta("pointer",!0):"key"==t&&n.scrollIntoView(),r&&n.setMeta("composition",r),e.dispatch(n)}return}let s=e.state.doc.resolve(t),a=s.sharedDepth(i);t=s.before(a+1),i=e.state.doc.resolve(i).after(a+1);let l,M,c=e.state.selection,u=function(e,t,i){let n,{node:o,fromOffset:r,toOffset:s,from:a,to:l}=e.docView.parseRange(t,i),M=e.domSelectionRange(),c=M.anchorNode;if(c&&e.dom.contains(1==c.nodeType?c:c.parentNode)&&(n=[{node:c,offset:M.anchorOffset}],$U(M)||n.push({node:M.focusNode,offset:M.focusOffset})),oY&&8===e.input.lastKeyCode)for(let e=s;e>r;e--){let t=o.childNodes[e-1],i=t.pmViewDesc;if("BR"==t.nodeName&&!i){s=e;break}if(!i||i.size)break}let u=e.state.doc,g=e.someProp("domParser")||cQ.fromSchema(e.state.schema),d=u.resolve(a),h=null,N=g.parse(o,{topNode:d.parent,topMatch:d.parent.contentMatchAt(d.index()),topOpen:!0,from:r,to:s,preserveWhitespace:"pre"!=d.parent.type.whitespace||"full",findPositions:n,ruleFromNode:R_,context:d});if(n&&null!=n[0].pos){let e=n[0].pos,t=n[1]&&n[1].pos;null==t&&(t=e),h={anchor:e+a,head:t+a}}return{doc:N,sel:h,from:a,to:l}}(e,t,i),g=e.state.doc,d=g.slice(u.from,u.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(l=e.state.selection.to,M="end"):(l=e.state.selection.from,M="start"),e.input.lastKeyCode=null;let h=function(e,t,i,n,o){let r=e.findDiffStart(t,i),s=i+e.size,a=i+t.size;if(null==r)return null;let{a:l,b:M}=e.findDiffEnd(t,s,a);if("end"==o){n-=l+Math.max(0,r-Math.min(l,M))-r}if(l<r&&s<a){r-=n<=r&&n>=l?r-n:0,M=r+(M-l),l=r}else if(M<r){r-=n<=r&&n>=M?r-n:0,l=r+(l-M),M=r}return{start:r,endA:l,endB:M}}(d.content,u.doc.content,u.from,l,M);if(h&&e.input.domChangeCount++,(aY&&e.input.lastIOSEnter>Date.now()-225||cY)&&o.some((e=>1==e.nodeType&&!W_.test(e.nodeName)))&&(!h||h.endA>=h.endB)&&e.someProp("handleKeyDown",(t=>t(e,GU(13,"Enter")))))return void(e.input.lastIOSEnter=0);if(!h){if(!(n&&c instanceof yU&&!c.empty&&c.$head.sameParent(c.$anchor))||e.composing||u.sel&&u.sel.anchor!=u.sel.head){if(u.sel){let t=$_(e,e.state.doc,u.sel);if(t&&!t.eq(e.state.selection)){let i=e.state.tr.setSelection(t);r&&i.setMeta("composition",r),e.dispatch(i)}}return}h={start:c.from,endA:c.to,endB:c.to}}e.state.selection.from<e.state.selection.to&&h.start==h.endB&&e.state.selection instanceof yU&&(h.start>e.state.selection.from&&h.start<=e.state.selection.from+2&&e.state.selection.from>=u.from?h.start=e.state.selection.from:h.endA<e.state.selection.to&&h.endA>=e.state.selection.to-2&&e.state.selection.to<=u.to&&(h.endB+=e.state.selection.to-h.endA,h.endA=e.state.selection.to)),eY&&tY<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>u.from&&"  "==u.doc.textBetween(h.start-u.from-1,h.start-u.from+1)&&(h.start--,h.endA--,h.endB--);let N=u.doc.resolveNoCache(h.start-u.from),p=u.doc.resolveNoCache(h.endB-u.from),D=g.resolve(h.start),y=N.sameParent(p)&&N.parent.inlineContent&&D.end()>=h.endA;if((aY&&e.input.lastIOSEnter>Date.now()-225&&(!y||o.some((e=>"DIV"==e.nodeName||"P"==e.nodeName)))||!y&&N.pos<u.doc.content.size&&(!N.sameParent(p)||!N.parent.inlineContent)&&N.pos<p.pos&&!/\S/.test(u.doc.textBetween(N.pos,p.pos,"","")))&&e.someProp("handleKeyDown",(t=>t(e,GU(13,"Enter")))))return void(e.input.lastIOSEnter=0);if(e.state.selection.anchor>h.start&&function(e,t,i,n,o){if(i-t<=o.pos-n.pos||G_(n,!0,!1)<o.pos)return!1;let r=e.resolve(t);if(!n.parent.isTextblock){let e=r.nodeAfter;return null!=e&&i==t+e.nodeSize}if(r.parentOffset<r.parent.content.size||!r.parent.isTextblock)return!1;let s=e.resolve(G_(r,!0,!0));return!(!s.parent.isTextblock||s.pos>i||G_(s,!0,!1)<i)&&n.parent.content.cut(n.parentOffset).eq(s.parent.content)}(g,h.start,h.endA,N,p)&&e.someProp("handleKeyDown",(t=>t(e,GU(8,"Backspace")))))return void(cY&&oY&&e.domObserver.suppressSelectionUpdates());oY&&h.endB==h.start&&(e.input.lastChromeDelete=Date.now()),cY&&!y&&N.start()!=p.start()&&0==p.parentOffset&&N.depth==p.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==h.endA&&(h.endB-=2,p=u.doc.resolveNoCache(h.endB-u.from),setTimeout((()=>{e.someProp("handleKeyDown",(function(t){return t(e,GU(13,"Enter"))}))}),20));let I,j=h.start,z=h.endA,m=t=>{let i=t||e.state.tr.replace(j,z,u.doc.slice(h.start-u.from,h.endB-u.from));if(u.sel){let t=$_(e,i.doc,u.sel);t&&!(oY&&e.composing&&t.empty&&(h.start!=h.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==j||t.head==i.mapping.map(z)-1)||eY&&t.empty&&t.head==j)&&i.setSelection(t)}return r&&i.setMeta("composition",r),i.scrollIntoView()};if(y)if(N.pos==p.pos){eY&&tY<=11&&0==N.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout((()=>rZ(e)),20));let t=m(e.state.tr.delete(j,z)),i=g.resolve(h.start).marksAcross(g.resolve(h.endA));i&&t.ensureMarks(i),e.dispatch(t)}else if(h.endA==h.endB&&(I=function(e,t){let i,n,o,r=e.firstChild.marks,s=t.firstChild.marks,a=r,l=s;for(let e=0;e<s.length;e++)a=s[e].removeFromSet(a);for(let e=0;e<r.length;e++)l=r[e].removeFromSet(l);if(1==a.length&&0==l.length)n=a[0],i="add",o=e=>e.mark(n.addToSet(e.marks));else{if(0!=a.length||1!=l.length)return null;n=l[0],i="remove",o=e=>e.mark(n.removeFromSet(e.marks))}let M=[];for(let e=0;e<t.childCount;e++)M.push(o(t.child(e)));if(IC.from(M).eq(e))return{mark:n,type:i}}(N.parent.content.cut(N.parentOffset,p.parentOffset),D.parent.content.cut(D.parentOffset,h.endA-D.start())))){let t=m(e.state.tr);"add"==I.type?t.addMark(j,z,I.mark):t.removeMark(j,z,I.mark),e.dispatch(t)}else if(N.parent.child(N.index()).isText&&N.index()==p.index()-(p.textOffset?0:1)){let t=N.parent.textBetween(N.parentOffset,p.parentOffset),i=()=>m(e.state.tr.insertText(t,j,z));e.someProp("handleTextInput",(n=>n(e,j,z,t,i)))||e.dispatch(i())}else e.dispatch(m());else e.dispatch(m())}function $_(e,t,i){return Math.max(i.anchor,i.head)>t.content.size?null:gZ(e,t.resolve(i.anchor),t.resolve(i.head))}function G_(e,t,i){let n=e.depth,o=t?e.end():e.pos;for(;n>0&&(t||e.indexAfter(n)==e.node(n).childCount);)n--,o++,t=!1;if(i){let t=e.node(n).maybeChild(e.indexAfter(n));for(;t&&!t.isLeaf;)t=t.firstChild,o++}return o}class F_{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new VZ,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(K_),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=X_(this),J_(this),this.nodeViews=q_(this),this.docView=PY(this.state.doc,H_(this),E_(this),this.dom,this),this.domObserver=new Y_(this,((e,t,i,n)=>B_(this,e,t,i,n))),this.domObserver.start(),function(e){for(let t in ZZ){let i=ZZ[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!$Z(e,t)||BZ(e,t)||!e.editable&&t.type in _Z||i(e,t)},PZ[t]?{passive:!0}:void 0)}sY&&e.dom.addEventListener("input",(()=>null)),WZ(e)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&WZ(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(K_),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let i in e)t[i]=e[i];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var i;let n=this.state,o=!1,r=!1;e.storedMarks&&this.composing&&(l_(this),r=!0),this.state=e;let s=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(s||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=q_(this);(function(e,t){let i=0,n=0;for(let n in e){if(e[n]!=t[n])return!0;i++}for(let e in t)n++;return i!=n})(e,this.nodeViews)&&(this.nodeViews=e,o=!0)}(s||t.handleDOMEvents!=this._props.handleDOMEvents)&&WZ(this),this.editable=X_(this),J_(this);let a=E_(this),l=H_(this),M=n.plugins==e.plugins||n.doc.eq(e.doc)?e.scrollToSelection>n.scrollToSelection?"to selection":"preserve":"reset",c=o||!this.docView.matchesNode(e.doc,l,a);!c&&e.selection.eq(n.selection)||(r=!0);let u="preserve"==M&&r&&null==this.dom.style.overflowAnchor&&function(e){let t,i,n=e.dom.getBoundingClientRect(),o=Math.max(0,n.top);for(let r=(n.left+n.right)/2,s=o+1;s<Math.min(innerHeight,n.bottom);s+=5){let n=e.root.elementFromPoint(r,s);if(!n||n==e.dom||!e.dom.contains(n))continue;let a=n.getBoundingClientRect();if(a.top>=o-20){t=n,i=a.top;break}}return{refDOM:t,refTop:i,stack:DY(e.dom)}}(this);if(r){this.domObserver.stop();let t=c&&(eY||oY)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&function(e,t){let i=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(i)!=t.$anchor.start(i)}(n.selection,e.selection);if(c){let i=oY?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=M_(this)),!o&&this.docView.update(e.doc,l,a,this)||(this.docView.updateOuterDeco(l),this.docView.destroy(),this.docView=PY(e.doc,l,a,this.dom,this)),!i||this.trackWrites&&this.dom.contains(this.trackWrites)||(t=!0)}let i=this.input.mouseDown;t||!(i&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),i=e.domSelectionRange();return PU(t.node,t.offset,i.anchorNode,i.anchorOffset)}(this)&&i.delaySelUpdate())?rZ(this,t):(cZ(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),(null===(i=this.dragging)||void 0===i?void 0:i.node)&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),"reset"==M?this.dom.scrollTop=0:"to selection"==M?this.scrollToSelection():u&&function({refDOM:e,refTop:t,stack:i}){let n=e?e.getBoundingClientRect().top:0;yY(i,0==n?0:n-t)}(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&this.dom.contains(1==e.nodeType?e:e.parentNode))if(this.someProp("handleScrollToSelection",(e=>e(this))));else if(this.state.selection instanceof jU){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&pY(this,t.getBoundingClientRect(),e)}else pY(this,this.coordsAtPos(this.state.selection.head,1),e);else;}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(e&&e.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let t=0;t<this.pluginViews.length;t++){let i=this.pluginViews[t];i.update&&i.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}}updateDraggedNode(e,t){let i=e.node,n=-1;if(i.from<this.state.doc.content.size&&this.state.doc.nodeAt(i.from)==i.node)n=i.from;else{let e=i.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==i.node&&(n=e)}this.dragging=new h_(e.slice,e.move,n<0?void 0:jU.create(this.state.doc,n))}someProp(e,t){let i,n=this._props&&this._props[e];if(null!=n&&(i=t?t(n):n))return i;for(let n=0;n<this.directPlugins.length;n++){let o=this.directPlugins[n].props[e];if(null!=o&&(i=t?t(o):o))return i}let o=this.state.plugins;if(o)for(let n=0;n<o.length;n++){let r=o[n].props[e];if(null!=r&&(i=t?t(r):r))return i}}hasFocus(){if(eY){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(IY)return e.focus(IY);let t=DY(e);e.focus(null==IY?{get preventScroll(){return IY={preventScroll:!0},!0}}:void 0),IY||(IY=!1,yY(t,0))}(this.dom),rZ(this),this.domObserver.start()}get root(){let e=this._root;if(null==e)for(let e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e;return e||document}updateRoot(){this._root=null}posAtCoords(e){return TY(this,e)}coordsAtPos(e,t=1){return fY(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,i=-1){let n=this.docView.posFromDOM(e,t,i);if(null==n)throw new RangeError("DOM position not inside the editor");return n}endOfTextblock(e,t){return CY(this,t||this.state,e)}pasteHTML(e,t){return g_(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return g_(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return bZ(this,e)}destroy(){this.docView&&(!function(e){e.input.mouseDown&&e.input.mouseDown.done(),e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],E_(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,ZU=null)}get isDestroyed(){return null==this.docView}dispatchEvent(e){return function(e,t){BZ(e,t)||!ZZ[t.type]||!e.editable&&t.type in _Z||ZZ[t.type](e,t)}(this,e)}domSelectionRange(){let e=this.domSelection();return e?sY&&11===this.root.nodeType&&function(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom&&function(e,t){if(t.getComposedRanges){let i=t.getComposedRanges(e.root)[0];if(i)return P_(e,i)}let i;function n(e){e.preventDefault(),e.stopImmediatePropagation(),i=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",n,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",n,!0),i?P_(e,i):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function H_(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",(i=>{if("function"==typeof i&&(i=i(e.state)),i)for(let e in i)"class"==e?t.class+=" "+i[e]:"style"==e?t.style=(t.style?t.style+";":"")+i[e]:t[e]||"contenteditable"==e||"nodeName"==e||(t[e]=String(i[e]))})),t.translate||(t.translate="no"),[z_.node(0,e.state.doc.content.size,t)]}function J_(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:z_.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function X_(e){return!e.someProp("editable",(t=>!1===t(e.state)))}function q_(e){let t=Object.create(null);function i(e){for(let i in e)Object.prototype.hasOwnProperty.call(t,i)||(t[i]=e[i])}return e.someProp("nodeViews",i),e.someProp("markViews",i),t}function K_(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}F_.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};const eP=s`
22955
+ `}};function hC(e){this.content=e}function NC(e,t,i){for(let n=0;;n++){if(n==e.childCount||n==t.childCount)return e.childCount==t.childCount?null:i;let o=e.child(n),r=t.child(n);if(o!=r){if(!o.sameMarkup(r))return i;if(o.isText&&o.text!=r.text){let e=o.text,t=r.text,n=0;for(;e[n]==t[n];n++)i++;return n&&n<e.length&&n<t.length&&yC(e.charCodeAt(n-1))&&DC(e.charCodeAt(n))&&i--,i}if(o.content.size||r.content.size){let e=NC(o.content,r.content,i+1);if(null!=e)return e}i+=o.nodeSize}else i+=o.nodeSize}}function pC(e,t,i,n){for(let o=e.childCount,r=t.childCount;;){if(0==o||0==r)return o==r?null:{a:i,b:n};let s=e.child(--o),a=t.child(--r),l=s.nodeSize;if(s!=a){if(!s.sameMarkup(a))return{a:i,b:n};if(s.isText&&s.text!=a.text){let e=s.text,t=a.text,o=e.length,r=t.length;for(;o>0&&r>0&&e[o-1]==t[r-1];)o--,r--,i--,n--;return o&&r&&o<e.length&&yC(e.charCodeAt(o-1))&&DC(e.charCodeAt(o))&&(i++,n++),{a:i,b:n}}if(s.content.size||a.content.size){let e=pC(s.content,a.content,i-1,n-1);if(e)return e}i-=l,n-=l}else i-=l,n-=l}}function DC(e){return e>=56320&&e<57344}function yC(e){return e>=55296&&e<56320}dC.styles=MC,e([de()],dC.prototype,"value",void 0),e([de()],dC.prototype,"placeholder",void 0),e([de({type:Boolean,reflect:!0})],dC.prototype,"disabled",void 0),e([de({type:Boolean,reflect:!0})],dC.prototype,"readonly",void 0),e([de({type:Number})],dC.prototype,"rows",void 0),e([de({reflect:!0})],dC.prototype,"mode",void 0),e([de({type:Boolean,attribute:"hide-toolbar"})],dC.prototype,"hideToolbar",void 0),e([de({converter:{fromAttribute:e=>{if(!e)return[];try{const t=JSON.parse(e);if(Array.isArray(t))return t.map((e=>String(e).trim())).filter(Boolean)}catch{}return e.split(",").map((e=>e.trim())).filter(Boolean)},toAttribute:e=>JSON.stringify(e??[])}})],dC.prototype,"tools",void 0),e([pe("textarea")],dC.prototype,"textarea",void 0),e([pe(".body")],dC.prototype,"bodyEl",void 0),e([he()],dC.prototype,"splitRatio",void 0),e([he()],dC.prototype,"splitDragging",void 0),dC=e([ce("nile-markdown-editor")],dC),hC.prototype={constructor:hC,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return-1==t?void 0:this.content[t+1]},update:function(e,t,i){var n=i&&i!=e?this.remove(i):this,o=n.find(e),r=n.content.slice();return-1==o?r.push(i||e,t):(r[o+1]=t,i&&(r[o]=i)),new hC(r)},remove:function(e){var t=this.find(e);if(-1==t)return this;var i=this.content.slice();return i.splice(t,2),new hC(i)},addToStart:function(e,t){return new hC([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var i=this.remove(e).content.slice();return i.push(e,t),new hC(i)},addBefore:function(e,t,i){var n=this.remove(t),o=n.content.slice(),r=n.find(e);return o.splice(-1==r?o.length:r,0,t,i),new hC(o)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=hC.from(e)).size?new hC(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=hC.from(e)).size?new hC(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=hC.from(e);for(var i=0;i<e.content.length;i+=2)t=t.remove(e.content[i]);return t},toObject:function(){var e={};return this.forEach((function(t,i){e[t]=i})),e},get size(){return this.content.length>>1}},hC.from=function(e){if(e instanceof hC)return e;var t=[];if(e)for(var i in e)t.push(i,e[i]);return new hC(t)};class IC{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,i,n=0,o){for(let r=0,s=0;s<t;r++){let a=this.content[r],l=s+a.nodeSize;if(l>e&&!1!==i(a,n+s,o||null,r)&&a.content.size){let o=s+1;a.nodesBetween(Math.max(0,e-o),Math.min(a.content.size,t-o),i,n+o)}s=l}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,i,n){let o="",r=!0;return this.nodesBetween(e,t,((s,a)=>{let l=s.isText?s.text.slice(Math.max(e,a)-a,t-a):s.isLeaf?n?"function"==typeof n?n(s):n:s.type.spec.leafText?s.type.spec.leafText(s):"":"";s.isBlock&&(s.isLeaf&&l||s.isTextblock)&&i&&(r?r=!1:o+=i),o+=l}),0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,i=e.firstChild,n=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(i)&&(n[n.length-1]=t.withText(t.text+i.text),o=1);o<e.content.length;o++)n.push(e.content[o]);return new IC(n,this.size+e.size)}cut(e,t=this.size){if(0==e&&t==this.size)return this;let i=[],n=0;if(t>e)for(let o=0,r=0;r<t;o++){let s=this.content[o],a=r+s.nodeSize;a>e&&((r<e||a>t)&&(s=s.isText?s.cut(Math.max(0,e-r),Math.min(s.text.length,t-r)):s.cut(Math.max(0,e-r-1),Math.min(s.content.size,t-r-1))),i.push(s),n+=s.nodeSize),r=a}return new IC(i,n)}cutByIndex(e,t){return e==t?IC.empty:0==e&&t==this.content.length?this:new IC(this.content.slice(e,t))}replaceChild(e,t){let i=this.content[e];if(i==t)return this;let n=this.content.slice(),o=this.size+t.nodeSize-i.nodeSize;return n[e]=t,new IC(n,o)}addToStart(e){return new IC([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new IC(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,i=0;t<this.content.length;t++){let n=this.content[t];e(n,i,t),i+=n.nodeSize}}findDiffStart(e,t=0){return NC(this,e,t)}findDiffEnd(e,t=this.size,i=e.size){return pC(this,e,t,i)}findIndex(e){if(0==e)return zC(0,e);if(e==this.size)return zC(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,i=0;;t++){let n=i+this.child(t).nodeSize;if(n>=e)return n==e?zC(t+1,n):zC(t,i);i=n}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((e=>e.toJSON())):null}static fromJSON(e,t){if(!t)return IC.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return IC.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return IC.empty;let t,i=0;for(let n=0;n<e.length;n++){let o=e[n];i+=o.nodeSize,n&&o.isText&&e[n-1].sameMarkup(o)?(t||(t=e.slice(0,n)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new IC(t||e,i)}static from(e){if(!e)return IC.empty;if(e instanceof IC)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new IC([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}IC.empty=new IC([],0);const jC={index:0,offset:0};function zC(e,t){return jC.index=e,jC.offset=t,jC}function mC(e,t){if(e===t)return!0;if(!e||"object"!=typeof e||!t||"object"!=typeof t)return!1;let i=Array.isArray(e);if(Array.isArray(t)!=i)return!1;if(i){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(!mC(e[i],t[i]))return!1}else{for(let i in e)if(!(i in t)||!mC(e[i],t[i]))return!1;for(let i in t)if(!(i in e))return!1}return!0}class TC{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,i=!1;for(let n=0;n<e.length;n++){let o=e[n];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,n));else{if(o.type.excludes(this.type))return e;!i&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,n)),t.push(this),i=!0),t&&t.push(o)}}return t||(t=e.slice()),i||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&mC(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let i=e.marks[t.type];if(!i)throw new RangeError(`There is no mark type ${t.type} in this schema`);let n=i.create(t.attrs);return i.checkAttrs(n.attrs),n}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(!e[i].eq(t[i]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return TC.none;if(e instanceof TC)return[e];let t=e.slice();return t.sort(((e,t)=>e.type.rank-t.type.rank)),t}}TC.none=[];class xC extends Error{}class AC{constructor(e,t,i){this.content=e,this.openStart=t,this.openEnd=i}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let i=fC(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return i&&new AC(i,this.openStart,this.openEnd)}removeBetween(e,t){return new AC(OC(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return AC.empty;let i=t.openStart||0,n=t.openEnd||0;if("number"!=typeof i||"number"!=typeof n)throw new RangeError("Invalid input for Slice.fromJSON");return new AC(IC.fromJSON(e,t.content),i,n)}static maxOpen(e,t=!0){let i=0,n=0;for(let n=e.firstChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.firstChild)i++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)n++;return new AC(e,i,n)}}function OC(e,t,i){let{index:n,offset:o}=e.findIndex(t),r=e.maybeChild(n),{index:s,offset:a}=e.findIndex(i);if(o==t||r.isText){if(a!=i&&!e.child(s).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(i))}if(n!=s)throw new RangeError("Removing non-flat range");return e.replaceChild(n,r.copy(OC(r.content,t-o-1,i-o-1)))}function fC(e,t,i,n,o,r){let{index:s,offset:a}=e.findIndex(t),l=e.maybeChild(s);if(a==t||l.isText)return r&&n<=0&&o<=0&&!r.canReplace(s,s,i)?null:e.cut(0,t).append(i).append(e.cut(t));let M=fC(l.content,t-a-1,i,0==s?n-1:0,s==e.childCount-1?o-1:0,l);return M&&e.replaceChild(s,l.copy(M))}function bC(e,t,i){if(i.openStart>e.depth)throw new xC("Inserted content deeper than insertion position");if(e.depth-i.openStart!=t.depth-i.openEnd)throw new xC("Inconsistent open depths");return LC(e,t,i,0)}function LC(e,t,i,n){let o=e.index(n),r=e.node(n);if(o==t.index(n)&&n<e.depth-i.openStart){let s=LC(e,t,i,n+1);return r.copy(r.content.replaceChild(o,s))}if(i.content.size){if(i.openStart||i.openEnd||e.depth!=n||t.depth!=n){let{start:o,end:s}=function(e,t){let i=t.depth-e.openStart,n=t.node(i).copy(e.content);for(let e=i-1;e>=0;e--)n=t.node(e).copy(IC.from(n));return{start:n.resolveNoCache(e.openStart+i),end:n.resolveNoCache(n.content.size-e.openEnd-i)}}(i,e);return EC(r,CC(e,o,s,t,n))}{let n=e.parent,o=n.content;return EC(n,o.cut(0,e.parentOffset).append(i.content).append(o.cut(t.parentOffset)))}}return EC(r,QC(e,t,n))}function wC(e,t){if(!t.type.compatibleContent(e.type))throw new xC("Cannot join "+t.type.name+" onto "+e.type.name)}function vC(e,t,i){let n=e.node(i);return wC(n,t.node(i)),n}function SC(e,t){let i=t.length-1;i>=0&&e.isText&&e.sameMarkup(t[i])?t[i]=e.withText(t[i].text+e.text):t.push(e)}function kC(e,t,i,n){let o=(t||e).node(i),r=0,s=t?t.index(i):o.childCount;e&&(r=e.index(i),e.depth>i?r++:e.textOffset&&(SC(e.nodeAfter,n),r++));for(let e=r;e<s;e++)SC(o.child(e),n);t&&t.depth==i&&t.textOffset&&SC(t.nodeBefore,n)}function EC(e,t){if(!e.type.validContent(t))throw new xC("Invalid content for node "+e.type.name);return e.copy(t)}function CC(e,t,i,n,o){let r=e.depth>o&&vC(e,t,o+1),s=n.depth>o&&vC(i,n,o+1),a=[];return kC(null,e,o,a),r&&s&&t.index(o)==i.index(o)?(wC(r,s),SC(EC(r,CC(e,t,i,n,o+1)),a)):(r&&SC(EC(r,QC(e,t,o+1)),a),kC(t,i,o,a),s&&SC(EC(s,QC(i,n,o+1)),a)),kC(n,null,o,a),new IC(a)}function QC(e,t,i){let n=[];if(kC(null,e,i,n),e.depth>i){SC(EC(vC(e,t,i+1),QC(e,t,i+1)),n)}return kC(t,null,i,n),new IC(n)}AC.empty=new AC(IC.empty,0,0);class UC{constructor(e,t,i){this.pos=e,this.path=t,this.parentOffset=i,this.depth=t.length/3-1}resolveDepth(e){return null==e?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let i=this.pos-this.path[this.path.length-1],n=e.child(t);return i?e.child(t).cut(i):n}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let i=this.path[3*t],n=0==t?0:this.path[3*t-1]+1;for(let t=0;t<e;t++)n+=i.child(t).nodeSize;return n}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return TC.none;if(this.textOffset)return e.child(t).marks;let i=e.maybeChild(t-1),n=e.maybeChild(t);if(!i){let e=i;i=n,n=e}let o=i.marks;for(var r=0;r<o.length;r++)!1!==o[r].type.spec.inclusive||n&&o[r].isInSet(n.marks)||(o=o[r--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let i=t.marks,n=e.parent.maybeChild(e.index());for(var o=0;o<i.length;o++)!1!==i[o].type.spec.inclusive||n&&i[o].isInSet(n.marks)||(i=i[o--].removeFromSet(i));return i}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let i=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);i>=0;i--)if(e.pos<=this.end(i)&&(!t||t(this.node(i))))return new PC(this,e,i);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let i=[],n=0,o=t;for(let t=e;;){let{index:e,offset:r}=t.content.findIndex(o),s=o-r;if(i.push(t,e,n+r),!s)break;if(t=t.child(e),t.isText)break;o=s-1,n+=r+1}return new UC(t,i,o)}static resolveCached(e,t){let i=_C.get(e);if(i)for(let e=0;e<i.elts.length;e++){let n=i.elts[e];if(n.pos==t)return n}else _C.set(e,i=new YC);let n=i.elts[i.i]=UC.resolve(e,t);return i.i=(i.i+1)%ZC,n}}class YC{constructor(){this.elts=[],this.i=0}}const ZC=12,_C=new WeakMap;class PC{constructor(e,t,i){this.$from=e,this.$to=t,this.depth=i}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 VC=Object.create(null);let RC=class e{constructor(e,t,i,n=TC.none){this.type=e,this.attrs=t,this.marks=n,this.content=i||IC.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,i,n=0){this.content.nodesBetween(e,t,i,n,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,i,n){return this.content.textBetween(e,t,i,n)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,i){return this.type==e&&mC(this.attrs,t||e.defaultAttrs||VC)&&TC.sameSet(this.marks,i||TC.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,i=!1){if(e==t)return AC.empty;let n=this.resolve(e),o=this.resolve(t),r=i?0:n.sharedDepth(t),s=n.start(r),a=n.node(r).content.cut(n.pos-s,o.pos-s);return new AC(a,n.depth-r,o.depth-r)}replace(e,t,i){return bC(this.resolve(e),this.resolve(t),i)}nodeAt(e){for(let t=this;;){let{index:i,offset:n}=t.content.findIndex(e);if(t=t.maybeChild(i),!t)return null;if(n==e||t.isText)return t;e-=n+1}}childAfter(e){let{index:t,offset:i}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:i}}childBefore(e){if(0==e)return{node:null,index:0,offset:0};let{index:t,offset:i}=this.content.findIndex(e);if(i<e)return{node:this.content.child(t),index:t,offset:i};let n=this.content.child(t-1);return{node:n,index:t-1,offset:i-n.nodeSize}}resolve(e){return UC.resolveCached(this,e)}resolveNoCache(e){return UC.resolve(this,e)}rangeHasMark(e,t,i){let n=!1;return t>e&&this.nodesBetween(e,t,(e=>(i.isInSet(e.marks)&&(n=!0),!n))),n}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),BC(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,i=IC.empty,n=0,o=i.childCount){let r=this.contentMatchAt(e).matchFragment(i,n,o),s=r&&r.matchFragment(this.content,t);if(!s||!s.validEnd)return!1;for(let e=n;e<o;e++)if(!this.type.allowsMarks(i.child(e).marks))return!1;return!0}canReplaceWith(e,t,i,n){if(n&&!this.type.allowsMarks(n))return!1;let o=this.contentMatchAt(e).matchType(i),r=o&&o.matchFragment(this.content,t);return!!r&&r.validEnd}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=TC.none;for(let t=0;t<this.marks.length;t++){let i=this.marks[t];i.type.checkAttrs(i.attrs),e=i.addToSet(e)}if(!TC.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((e=>e.type.name))}`);this.content.forEach((e=>e.check()))}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map((e=>e.toJSON()))),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let i;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");i=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,i)}let n=IC.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,n,i);return o.type.checkAttrs(o.attrs),o}};RC.prototype.text=void 0;let WC=class e extends RC{constructor(e,t,i,n){if(super(e,t,null,n),!i)throw new RangeError("Empty text nodes are not allowed");this.text=i}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):BC(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return 0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function BC(e,t){for(let i=e.length-1;i>=0;i--)t=e[i].type.name+"("+t+")";return t}class $C{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let i=new GC(e,t);if(null==i.next)return $C.empty;let n=FC(i);i.next&&i.err("Unexpected trailing text");let o=function(e){let t=Object.create(null);return i(eQ(e,0));function i(n){let o=[];n.forEach((t=>{e[t].forEach((({term:t,to:i})=>{if(!t)return;let n;for(let e=0;e<o.length;e++)o[e][0]==t&&(n=o[e][1]);eQ(e,i).forEach((e=>{n||o.push([t,n=[]]),-1==n.indexOf(e)&&n.push(e)}))}))}));let r=t[n.join(",")]=new $C(n.indexOf(e.length-1)>-1);for(let e=0;e<o.length;e++){let n=o[e][1].sort(KC);r.next.push({type:o[e][0],next:t[n.join(",")]||i(n)})}return r}}(function(e){let t=[[]];return o(r(e,0),i()),t;function i(){return t.push([])-1}function n(e,i,n){let o={term:n,to:i};return t[e].push(o),o}function o(e,t){e.forEach((e=>e.to=t))}function r(e,t){if("choice"==e.type)return e.exprs.reduce(((e,i)=>e.concat(r(i,t))),[]);if("seq"!=e.type){if("star"==e.type){let s=i();return n(t,s),o(r(e.expr,s),s),[n(s)]}if("plus"==e.type){let s=i();return o(r(e.expr,t),s),o(r(e.expr,s),s),[n(s)]}if("opt"==e.type)return[n(t)].concat(r(e.expr,t));if("range"==e.type){let s=t;for(let t=0;t<e.min;t++){let t=i();o(r(e.expr,s),t),s=t}if(-1==e.max)o(r(e.expr,s),s);else for(let t=e.min;t<e.max;t++){let t=i();n(s,t),o(r(e.expr,s),t),s=t}return[n(s)]}if("name"==e.type)return[n(t,void 0,e.value)];throw new Error("Unknown expr type")}for(let n=0;;n++){let s=r(e.exprs[n],t);if(n==e.exprs.length-1)return s;o(s,t=i())}}}(n));return function(e,t){for(let i=0,n=[e];i<n.length;i++){let e=n[i],o=!e.validEnd,r=[];for(let t=0;t<e.next.length;t++){let{type:i,next:s}=e.next[t];r.push(i.name),!o||i.isText||i.hasRequiredAttrs()||(o=!1),-1==n.indexOf(s)&&n.push(s)}o&&t.err("Only non-generatable nodes ("+r.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(o,i),o}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,i=e.childCount){let n=this;for(let o=t;n&&o<i;o++)n=n.matchType(e.child(o).type);return n}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!t.isText&&!t.hasRequiredAttrs())return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let i=0;i<e.next.length;i++)if(this.next[t].type==e.next[i].type)return!0;return!1}fillBefore(e,t=!1,i=0){let n=[this];return function o(r,s){let a=r.matchFragment(e,i);if(a&&(!t||a.validEnd))return IC.from(s.map((e=>e.createAndFill())));for(let e=0;e<r.next.length;e++){let{type:t,next:i}=r.next[e];if(!t.isText&&!t.hasRequiredAttrs()&&-1==n.indexOf(i)){n.push(i);let e=o(i,s.concat(t));if(e)return e}}return null}(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),i=[{match:this,type:null,via:null}];for(;i.length;){let n=i.shift(),o=n.match;if(o.matchType(e)){let e=[];for(let t=n;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<o.next.length;e++){let{type:r,next:s}=o.next[e];r.isLeaf||r.hasRequiredAttrs()||r.name in t||n.type&&!s.validEnd||(i.push({match:r.contentMatch,type:r,via:n}),t[r.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];return function t(i){e.push(i);for(let n=0;n<i.next.length;n++)-1==e.indexOf(i.next[n].next)&&t(i.next[n].next)}(this),e.map(((t,i)=>{let n=i+(t.validEnd?"*":" ")+" ";for(let i=0;i<t.next.length;i++)n+=(i?", ":"")+t.next[i].type.name+"->"+e.indexOf(t.next[i].next);return n})).join("\n")}}$C.empty=new $C(!0);class GC{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function FC(e){let t=[];do{t.push(HC(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function HC(e){let t=[];do{t.push(JC(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function JC(e){let t=function(e){if(e.eat("(")){let t=FC(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){let t=function(e,t){let i=e.nodeTypes,n=i[t];if(n)return[n];let o=[];for(let e in i){let n=i[e];n.isInGroup(t)&&o.push(n)}0==o.length&&e.err("No node type or group '"+t+"' found");return o}(e,e.next).map((t=>(null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t})));return e.pos++,1==t.length?t[0]:{type:"choice",exprs:t}}e.err("Unexpected token '"+e.next+"'")}(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=qC(e,t)}return t}function XC(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function qC(e,t){let i=XC(e),n=i;return e.eat(",")&&(n="}"!=e.next?XC(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:i,max:n,expr:t}}function KC(e,t){return t-e}function eQ(e,t){let i=[];return function t(n){let o=e[n];if(1==o.length&&!o[0].term)return t(o[0].to);i.push(n);for(let e=0;e<o.length;e++){let{term:n,to:r}=o[e];n||-1!=i.indexOf(r)||t(r)}}(t),i.sort(KC)}function tQ(e){let t=Object.create(null);for(let i in e){let n=e[i];if(!n.hasDefault)return null;t[i]=n.default}return t}function iQ(e,t){let i=Object.create(null);for(let n in e){let o=t&&t[n];if(void 0===o){let t=e[n];if(!t.hasDefault)throw new RangeError("No value supplied for attribute "+n);o=t.default}i[n]=o}return i}function nQ(e,t,i,n){for(let o in t)if(!(o in e))throw new RangeError(`Unsupported attribute ${o} for ${i} of type ${n}`);for(let i in e)e[i].validate&&e[i].validate(t[i])}function oQ(e,t){let i=Object.create(null);if(t)for(let n in t)i[n]=new sQ(e,n,t[n]);return i}let rQ=class e{constructor(e,t,i){this.name=e,this.schema=t,this.spec=i,this.markSet=null,this.groups=i.group?i.group.split(" "):[],this.attrs=oQ(e,i.attrs),this.defaultAttrs=tQ(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(i.inline||"text"==e),this.isText="text"==e}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==$C.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:iQ(this.attrs,e)}create(e=null,t,i){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new RC(this,this.computeAttrs(e),IC.from(t),TC.setFrom(i))}createChecked(e=null,t,i){return t=IC.from(t),this.checkContent(t),new RC(this,this.computeAttrs(e),t,TC.setFrom(i))}createAndFill(e=null,t,i){if(e=this.computeAttrs(e),(t=IC.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let n=this.contentMatch.matchFragment(t),o=n&&n.fillBefore(IC.empty,!0);return o?new RC(this,e,t.append(o),TC.setFrom(i)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){nQ(this.attrs,e,"node",this.name)}allowsMarkType(e){return null==this.markSet||this.markSet.indexOf(e)>-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(null==this.markSet)return e;let t;for(let i=0;i<e.length;i++)this.allowsMarkType(e[i].type)?t&&t.push(e[i]):t||(t=e.slice(0,i));return t?t.length?t:TC.none:e}static compile(t,i){let n=Object.create(null);t.forEach(((t,o)=>n[t]=new e(t,i,o)));let o=i.spec.topNode||"doc";if(!n[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let e in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}};class sQ{constructor(e,t,i){this.hasDefault=Object.prototype.hasOwnProperty.call(i,"default"),this.default=i.default,this.validate="string"==typeof i.validate?function(e,t,i){let n=i.split("|");return i=>{let o=null===i?"null":typeof i;if(n.indexOf(o)<0)throw new RangeError(`Expected value of type ${n} for attribute ${t} on type ${e}, got ${o}`)}}(e,t,i.validate):i.validate}get isRequired(){return!this.hasDefault}}class aQ{constructor(e,t,i,n){this.name=e,this.rank=t,this.schema=i,this.spec=n,this.attrs=oQ(e,n.attrs),this.excluded=null;let o=tQ(this.attrs);this.instance=o?new TC(this,o):null}create(e=null){return!e&&this.instance?this.instance:new TC(this,iQ(this.attrs,e))}static compile(e,t){let i=Object.create(null),n=0;return e.forEach(((e,o)=>i[e]=new aQ(e,n++,t,o))),i}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){nQ(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class lQ{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=hC.from(e.nodes),t.marks=hC.from(e.marks||{}),this.nodes=rQ.compile(this.spec.nodes,this),this.marks=aQ.compile(this.spec.marks,this);let i=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw new RangeError(e+" can not be both a node and a mark");let t=this.nodes[e],n=t.spec.content||"",o=t.spec.marks;if(t.contentMatch=i[n]||(i[n]=$C.parse(n,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!t.isInline||!t.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=t}t.markSet="_"==o?null:o?MQ(this,o.split(" ")):""!=o&&t.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],i=t.spec.excludes;t.excluded=null==i?[t]:""==i?[]:MQ(this,i.split(" "))}this.nodeFromJSON=e=>RC.fromJSON(this,e),this.markFromJSON=e=>TC.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,i,n){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof rQ))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,i,n)}text(e,t){let i=this.nodes.text;return new WC(i,i.defaultAttrs,e,TC.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function MQ(e,t){let i=[];for(let n=0;n<t.length;n++){let o=t[n],r=e.marks[o],s=r;if(r)i.push(r);else for(let t in e.marks){let n=e.marks[t];("_"==o||n.spec.group&&n.spec.group.split(" ").indexOf(o)>-1)&&i.push(s=n)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[n]+"'")}return i}let cQ=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let i=this.matchedStyles=[];t.forEach((e=>{if(function(e){return null!=e.tag}(e))this.tags.push(e);else if(function(e){return null!=e.style}(e)){let t=/[^=]*/.exec(e.style)[0];i.indexOf(t)<0&&i.push(t),this.styles.push(e)}})),this.normalizeLists=!this.tags.some((t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let i=e.nodes[t.node];return i.contentMatch.matchType(i)}))}parse(e,t={}){let i=new pQ(this,t,!1);return i.addAll(e,TC.none,t.from,t.to),i.finish()}parseSlice(e,t={}){let i=new pQ(this,t,!0);return i.addAll(e,TC.none,t.from,t.to),AC.maxOpen(i.finish())}matchTag(e,t,i){for(let n=i?this.tags.indexOf(i)+1:0;n<this.tags.length;n++){let i=this.tags[n];if(DQ(e,i.tag)&&(void 0===i.namespace||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs){let t=i.getAttrs(e);if(!1===t)continue;i.attrs=t||void 0}return i}}}matchStyle(e,t,i,n){for(let o=n?this.styles.indexOf(n)+1:0;o<this.styles.length;o++){let n=this.styles[o],r=n.style;if(!(0!=r.indexOf(e)||n.context&&!i.matchesContext(n.context)||r.length>e.length&&(61!=r.charCodeAt(e.length)||r.slice(e.length+1)!=t))){if(n.getAttrs){let e=n.getAttrs(t);if(!1===e)continue;n.attrs=e||void 0}return n}}}static schemaRules(e){let t=[];function i(e){let i=null==e.priority?50:e.priority,n=0;for(;n<t.length;n++){let e=t[n];if((null==e.priority?50:e.priority)<i)break}t.splice(n,0,e)}for(let t in e.marks){let n=e.marks[t].spec.parseDOM;n&&n.forEach((e=>{i(e=yQ(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)}))}for(let t in e.nodes){let n=e.nodes[t].spec.parseDOM;n&&n.forEach((e=>{i(e=yQ(e)),e.node||e.ignore||e.mark||(e.node=t)}))}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}};const uQ={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},gQ={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},dQ={ol:!0,ul:!0};function hQ(e,t,i){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&i}class NQ{constructor(e,t,i,n,o,r){this.type=e,this.attrs=t,this.marks=i,this.solid=n,this.options=r,this.content=[],this.activeMarks=TC.none,this.match=o||(4&r?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(IC.from(e));if(!t){let t,i=this.type.contentMatch;return(t=i.findWrapping(e.type))?(this.match=i,t):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e,t=this.content[this.content.length-1];if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let i=t;t.text.length==e[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-e[0].length))}}let t=IC.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(IC.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!uQ.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class pQ{constructor(e,t,i){this.parser=e,this.options=t,this.isOpen=i,this.open=0,this.localPreserveWS=!1;let n,o=t.topNode,r=hQ(null,t.preserveWhitespace,0)|(i?4:0);n=o?new NQ(o.type,o.attrs,TC.none,!0,t.topMatch||o.type.contentMatch,r):new NQ(i?null:e.schema.topNodeType,null,TC.none,!0,null,r),this.nodes=[n],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){3==e.nodeType?this.addTextNode(e,t):1==e.nodeType&&this.addElement(e,t)}addTextNode(e,t){let i=e.nodeValue,n=this.top,o=2&n.options?"full":this.localPreserveWS||(1&n.options)>0,{schema:r}=this.parser;if("full"===o||n.inlineContext(e)||/[^ \t\r\n\u000c]/.test(i)){if(o)if("full"===o)i=i.replace(/\r\n?/g,"\n");else if(r.linebreakReplacement&&/[\r\n]/.test(i)&&this.top.findWrapping(r.linebreakReplacement.create())){let e=i.split(/\r?\n|\r/);for(let i=0;i<e.length;i++)i&&this.insertNode(r.linebreakReplacement.create(),t,!0),e[i]&&this.insertNode(r.text(e[i]),t,!/\S/.test(e[i]));i=""}else i=i.replace(/\r?\n|\r/g," ");else if(i=i.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(i)&&this.open==this.nodes.length-1){let t=n.content[n.content.length-1],o=e.previousSibling;(!t||o&&"BR"==o.nodeName||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(i=i.slice(1))}i&&this.insertNode(r.text(i),t,!/\S/.test(i)),this.findInText(e)}else this.findInside(e)}addElement(e,t,i){let n=this.localPreserveWS,o=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let r,s=e.nodeName.toLowerCase();dQ.hasOwnProperty(s)&&this.parser.normalizeLists&&function(e){for(let t=e.firstChild,i=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&dQ.hasOwnProperty(e)&&i?(i.appendChild(t),t=i):"li"==e?i=t:e&&(i=null)}}(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(r=this.parser.matchTag(e,this,i));e:if(a?a.ignore:gQ.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let i,n=this.needsBlock;if(uQ.hasOwnProperty(s))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),i=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let r=a&&a.skip?t:this.readStyles(e,t);r&&this.addAll(e,r),i&&this.sync(o),this.needsBlock=n}else{let i=this.readStyles(e,t);i&&this.addElementByRule(e,a,i,!1===a.consuming?r:void 0)}this.localPreserveWS=n}leafFallback(e,t){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),t)}ignoreFallback(e,t){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let i=e.style;if(i&&i.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let n=this.parser.matchedStyles[e],o=i.getPropertyValue(n);if(o)for(let e;;){let i=this.parser.matchStyle(n,o,this,e);if(!i)break;if(i.ignore)return null;if(t=i.clearMark?t.filter((e=>!i.clearMark(e))):t.concat(this.parser.schema.marks[i.mark].create(i.attrs)),!1!==i.consuming)break;e=i}}return t}addElementByRule(e,t,i,n){let o,r;if(t.node)if(r=this.parser.schema.nodes[t.node],r.isLeaf)this.insertNode(r.create(t.attrs),i,"BR"==e.nodeName)||this.leafFallback(e,i);else{let e=this.enter(r,t.attrs||null,i,t.preserveWhitespace);e&&(o=!0,i=e)}else{let e=this.parser.schema.marks[t.mark];i=i.concat(e.create(t.attrs))}let s=this.top;if(r&&r.isLeaf)this.findInside(e);else if(n)this.addElement(e,i,n);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach((e=>this.insertNode(e,i,!1)));else{let n=e;"string"==typeof t.contentElement?n=e.querySelector(t.contentElement):"function"==typeof t.contentElement?n=t.contentElement(e):t.contentElement&&(n=t.contentElement),this.findAround(e,n,!0),this.addAll(n,i),this.findAround(e,n,!1)}o&&this.sync(s)&&this.open--}addAll(e,t,i,n){let o=i||0;for(let r=i?e.childNodes[i]:e.firstChild,s=null==n?null:e.childNodes[n];r!=s;r=r.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(r,t);this.findAtPoint(e,o)}findPlace(e,t,i){let n,o;for(let t=this.open,r=0;t>=0;t--){let s=this.nodes[t],a=s.findWrapping(e);if(a&&(!n||n.length>a.length+r)&&(n=a,o=s,!a.length))break;if(s.solid){if(i)break;r+=2}}if(!n)return null;this.sync(o);for(let e=0;e<n.length;e++)t=this.enterInner(n[e],null,t,!1);return t}insertNode(e,t,i){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let n=this.findPlace(e,t,i);if(n){this.closeExtra();let t=this.top;t.match&&(t.match=t.match.matchType(e.type));let i=TC.none;for(let o of n.concat(e.marks))(t.type?t.type.allowsMarkType(o.type):IQ(o.type,e.type))&&(i=o.addToSet(i));return t.content.push(e.mark(i)),!0}return!1}enter(e,t,i,n){let o=this.findPlace(e.create(t),i,!1);return o&&(o=this.enterInner(e,t,i,!0,n)),o}enterInner(e,t,i,n=!1,o){this.closeExtra();let r=this.top;r.match=r.match&&r.match.matchType(e);let s=hQ(e,o,r.options);4&r.options&&0==r.content.length&&(s|=4);let a=TC.none;return i=i.filter((t=>!(r.type?r.type.allowsMarkType(t.type):IQ(t.type,e))||(a=t.addToSet(a),!1))),this.nodes.push(new NQ(e,t,a,n,null,s)),this.open++,i}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!(!this.isOpen&&!this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=1)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let i=this.nodes[t].content;for(let t=i.length-1;t>=0;t--)e+=i[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let i=0;i<this.find.length;i++)this.find[i].node==e&&this.find[i].offset==t&&(this.find[i].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,i){if(e!=t&&this.find)for(let n=0;n<this.find.length;n++)if(null==this.find[n].pos&&1==e.nodeType&&e.contains(this.find[n].node)){t.compareDocumentPosition(this.find[n].node)&(i?2:4)&&(this.find[n].pos=this.currentPos)}}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),i=this.options.context,n=!(this.isOpen||i&&i.parent.type!=this.nodes[0].type),o=-(i?i.depth+1:0)+(n?0:1),r=(e,s)=>{for(;e>=0;e--){let a=t[e];if(""==a){if(e==t.length-1||0==e)continue;for(;s>=o;s--)if(r(e-1,s))return!0;return!1}{let e=s>0||0==s&&n?this.nodes[s].type:i&&s>=o?i.node(s-o).type:null;if(!e||e.name!=a&&!e.isInGroup(a))return!1;s--}}return!0};return r(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(i&&i.isTextblock&&i.defaultAttrs)return i}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}}function DQ(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function yQ(e){let t={};for(let i in e)t[i]=e[i];return t}function IQ(e,t){let i=t.schema.nodes;for(let n in i){let o=i[n];if(!o.allowsMarkType(e))continue;let r=[],s=e=>{r.push(e);for(let i=0;i<e.edgeCount;i++){let{type:n,next:o}=e.edge(i);if(n==t)return!0;if(r.indexOf(o)<0&&s(o))return!0}};if(s(o.contentMatch))return!0}}class jQ{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},i){i||(i=mQ(t).createDocumentFragment());let n=i,o=[];return e.forEach((e=>{if(o.length||e.marks.length){let i=0,r=0;for(;i<o.length&&r<e.marks.length;){let t=e.marks[r];if(this.marks[t.type.name]){if(!t.eq(o[i][0])||!1===t.type.spec.spanning)break;i++,r++}else r++}for(;i<o.length;)n=o.pop()[1];for(;r<e.marks.length;){let i=e.marks[r++],s=this.serializeMark(i,e.isInline,t);s&&(o.push([i,n]),n.appendChild(s.dom),n=s.contentDOM||s.dom)}}n.appendChild(this.serializeNodeInner(e,t))})),i}serializeNodeInner(e,t){if(e.isText)return mQ(t).createTextNode(e.text);let{dom:i,contentDOM:n}=AQ(mQ(t),this.nodes[e.type.name](e),null,e.attrs);if(n){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,n)}return i}serializeNode(e,t={}){let i=this.serializeNodeInner(e,t);for(let n=e.marks.length-1;n>=0;n--){let o=this.serializeMark(e.marks[n],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(i),i=o.dom)}return i}serializeMark(e,t,i={}){let n=this.marks[e.type.name];return n&&AQ(mQ(i),n(e,t),null,e.attrs)}static renderSpec(e,t,i=null,n){return"string"==typeof t?{dom:e.createTextNode(t)}:AQ(e,t,i,n)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new jQ(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=zQ(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return zQ(e.marks)}}function zQ(e){let t={};for(let i in e){let n=e[i].spec.toDOM;n&&(t[i]=n)}return t}function mQ(e){return e.document||window.document}const TQ=new WeakMap;function xQ(e){let t=TQ.get(e);return void 0===t&&TQ.set(e,t=function(e){let t=null;function i(e){if(e&&"object"==typeof e)if(Array.isArray(e))if("string"==typeof e[0])t||(t=[]),t.push(e);else for(let t=0;t<e.length;t++)i(e[t]);else for(let t in e)i(e[t])}return i(e),t}(e)),t}function AQ(e,t,i,n){if(1==t.nodeType)return{dom:t};if(t.dom&&1==t.dom.nodeType)return t;let o,r=t[0];if("string"!=typeof r)throw new RangeError("Invalid array passed to renderSpec");if(n&&(o=xQ(n))&&o.indexOf(t)>-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 s,a=r.indexOf(" ");a>0&&(i=r.slice(0,a),r=r.slice(a+1));let l=i?e.createElementNS(i,r):e.createElement(r),M=t[1],c=1;if(M&&"object"==typeof M&&null==M.nodeType&&!Array.isArray(M)){c=2;for(let e in M)if(null!=M[e]){let t=e.indexOf(" ");t>0?l.setAttributeNS(e.slice(0,t),e.slice(t+1),M[e]):"style"==e&&l.style?l.style.cssText=M[e]:l.setAttribute(e,M[e])}}for(let o=c;o<t.length;o++){let r=t[o];if(0===r){if(o<t.length-1||o>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}if("string"==typeof r)l.appendChild(e.createTextNode(r));else{let{dom:t,contentDOM:o}=AQ(e,r,i,n);if(l.appendChild(t),o){if(s)throw new RangeError("Multiple content holes");s=o}}}return{dom:l,contentDOM:s}}const OQ=Math.pow(2,16);function fQ(e,t){return e+t*OQ}function bQ(e){return 65535&e}class LQ{constructor(e,t,i){this.pos=e,this.delInfo=t,this.recover=i}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 wQ{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&wQ.empty)return wQ.empty}recover(e){let t=0,i=bQ(e);if(!this.inverted)for(let e=0;e<i;e++)t+=this.ranges[3*e+2]-this.ranges[3*e+1];return this.ranges[3*i]+t+function(e){return(e-(65535&e))/OQ}(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,i){let n=0,o=this.inverted?2:1,r=this.inverted?1:2;for(let s=0;s<this.ranges.length;s+=3){let a=this.ranges[s]-(this.inverted?n:0);if(a>e)break;let l=this.ranges[s+o],M=this.ranges[s+r],c=a+l;if(e<=c){let o=a+n+((l?e==a?-1:e==c?1:t:t)<0?0:M);if(i)return o;let r=e==(t<0?a:c)?null:fQ(s/3,e-a),u=e==a?2:e==c?1:4;return(t<0?e!=a:e!=c)&&(u|=8),new LQ(o,u,r)}n+=M-l}return i?e+n:new LQ(e+n,0,null)}touches(e,t){let i=0,n=bQ(t),o=this.inverted?2:1,r=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let s=this.ranges[t]-(this.inverted?i:0);if(s>e)break;let a=this.ranges[t+o];if(e<=s+a&&t==3*n)return!0;i+=this.ranges[t+r]-a}return!1}forEach(e){let t=this.inverted?2:1,i=this.inverted?1:2;for(let n=0,o=0;n<this.ranges.length;n+=3){let r=this.ranges[n],s=r-(this.inverted?o:0),a=r+(this.inverted?0:o),l=this.ranges[n+t],M=this.ranges[n+i];e(s,s+l,a,a+M),o+=M-l}}invert(){return new wQ(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?wQ.empty:new wQ(e<0?[0,-e,0]:[0,0,e])}}wQ.empty=new wQ([]);class vQ{constructor(e,t,i=0,n=(e?e.length:0)){this.mirror=t,this.from=i,this.to=n,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new vQ(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),null!=t&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,i=this._maps.length;t<e._maps.length;t++){let n=e.getMirror(t);this.appendMap(e._maps[t],null!=n&&n<t?i+n:void 0)}}getMirror(e){if(this.mirror)for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,i=this._maps.length+e._maps.length;t>=0;t--){let n=e.getMirror(t);this.appendMap(e._maps[t].invert(),null!=n&&n>t?i-n-1:void 0)}}invert(){let e=new vQ;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let i=this.from;i<this.to;i++)e=this._maps[i].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,i){let n=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i].mapResult(e,t);if(null!=o.recover){let t=this.getMirror(i);if(null!=t&&t>i&&t<this.to){i=t,e=this._maps[t].recover(o.recover);continue}}n|=o.delInfo,e=o.pos}return i?e:new LQ(e,n,null)}}const SQ=Object.create(null);class kQ{getMap(){return wQ.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let i=SQ[t.stepType];if(!i)throw new RangeError(`No step type ${t.stepType} defined`);return i.fromJSON(e,t)}static jsonID(e,t){if(e in SQ)throw new RangeError("Duplicate use of step JSON ID "+e);return SQ[e]=t,t.prototype.jsonID=e,t}}class EQ{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new EQ(e,null)}static fail(e){return new EQ(null,e)}static fromReplace(e,t,i,n){try{return EQ.ok(e.replace(t,i,n))}catch(e){if(e instanceof xC)return EQ.fail(e.message);throw e}}}function CQ(e,t,i){let n=[];for(let o=0;o<e.childCount;o++){let r=e.child(o);r.content.size&&(r=r.copy(CQ(r.content,t,r))),r.isInline&&(r=t(r,i,o)),n.push(r)}return IC.fromArray(n)}class QQ extends kQ{constructor(e,t,i){super(),this.from=e,this.to=t,this.mark=i}apply(e){let t=e.slice(this.from,this.to),i=e.resolve(this.from),n=i.node(i.sharedDepth(this.to)),o=new AC(CQ(t.content,((e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e),n),t.openStart,t.openEnd);return EQ.fromReplace(e,this.from,this.to,o)}invert(){return new UQ(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return t.deleted&&i.deleted||t.pos>=i.pos?null:new QQ(t.pos,i.pos,this.mark)}merge(e){return e instanceof QQ&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new QQ(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new QQ(t.from,t.to,e.markFromJSON(t.mark))}}kQ.jsonID("addMark",QQ);class UQ extends kQ{constructor(e,t,i){super(),this.from=e,this.to=t,this.mark=i}apply(e){let t=e.slice(this.from,this.to),i=new AC(CQ(t.content,(e=>e.mark(this.mark.removeFromSet(e.marks))),e),t.openStart,t.openEnd);return EQ.fromReplace(e,this.from,this.to,i)}invert(){return new QQ(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return t.deleted&&i.deleted||t.pos>=i.pos?null:new UQ(t.pos,i.pos,this.mark)}merge(e){return e instanceof UQ&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new UQ(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new UQ(t.from,t.to,e.markFromJSON(t.mark))}}kQ.jsonID("removeMark",UQ);class YQ extends kQ{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return EQ.fail("No node at mark step's position");let i=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return EQ.fromReplace(e,this.pos,this.pos+1,new AC(IC.from(i),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let e=this.mark.addToSet(t.marks);if(e.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(e))return new YQ(this.pos,t.marks[i]);return new YQ(this.pos,this.mark)}}return new ZQ(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new YQ(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new YQ(t.pos,e.markFromJSON(t.mark))}}kQ.jsonID("addNodeMark",YQ);class ZQ extends kQ{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return EQ.fail("No node at mark step's position");let i=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return EQ.fromReplace(e,this.pos,this.pos+1,new AC(IC.from(i),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new YQ(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ZQ(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new ZQ(t.pos,e.markFromJSON(t.mark))}}kQ.jsonID("removeNodeMark",ZQ);class _Q extends kQ{constructor(e,t,i,n=!1){super(),this.from=e,this.to=t,this.slice=i,this.structure=n}apply(e){return this.structure&&VQ(e,this.from,this.to)?EQ.fail("Structure replace would overwrite content"):EQ.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new wQ([this.from,this.to-this.from,this.slice.size])}invert(e){return new _Q(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),i=this.from==this.to&&_Q.MAP_BIAS<0?t:e.mapResult(this.from,1);return i.deletedAcross&&t.deletedAcross?null:new _Q(i.pos,Math.max(i.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof _Q)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;{let t=this.slice.size+e.slice.size==0?AC.empty:new AC(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new _Q(e.from,this.to,t,this.structure)}}{let t=this.slice.size+e.slice.size==0?AC.empty:new AC(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new _Q(this.from,this.to+(e.to-e.from),t,this.structure)}}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new _Q(t.from,t.to,AC.fromJSON(e,t.slice),!!t.structure)}}_Q.MAP_BIAS=1,kQ.jsonID("replace",_Q);class PQ extends kQ{constructor(e,t,i,n,o,r,s=!1){super(),this.from=e,this.to=t,this.gapFrom=i,this.gapTo=n,this.slice=o,this.insert=r,this.structure=s}apply(e){if(this.structure&&(VQ(e,this.from,this.gapFrom)||VQ(e,this.gapTo,this.to)))return EQ.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return EQ.fail("Gap is not a flat range");let i=this.slice.insertAt(this.insert,t.content);return i?EQ.fromReplace(e,this.from,this.to,i):EQ.fail("Content does not fit in gap")}getMap(){return new wQ([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new PQ(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),i=e.mapResult(this.to,-1),n=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?i.pos:e.map(this.gapTo,1);return t.deletedAcross&&i.deletedAcross||n<t.pos||o>i.pos?null:new PQ(t.pos,i.pos,n,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new PQ(t.from,t.to,t.gapFrom,t.gapTo,AC.fromJSON(e,t.slice),t.insert,!!t.structure)}}function VQ(e,t,i){let n=e.resolve(t),o=i-t,r=n.depth;for(;o>0&&r>0&&n.indexAfter(r)==n.node(r).childCount;)r--,o--;if(o>0){let e=n.node(r).maybeChild(n.indexAfter(r));for(;o>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,o--}}return!1}function RQ(e,t,i,n=i.contentMatch,o=!0){let r=e.doc.nodeAt(t),s=[],a=t+1;for(let t=0;t<r.childCount;t++){let l=r.child(t),M=a+l.nodeSize,c=n.matchType(l.type);if(c){n=c;for(let t=0;t<l.marks.length;t++)i.allowsMarkType(l.marks[t].type)||e.step(new UQ(a,M,l.marks[t]));if(o&&l.isText&&"pre"!=i.whitespace){let e,t,n=/\r?\n|\r/g;for(;e=n.exec(l.text);)t||(t=new AC(IC.from(i.schema.text(" ",i.allowedMarks(l.marks))),0,0)),s.push(new _Q(a+e.index,a+e.index+e[0].length,t))}}else s.push(new _Q(a,M,AC.empty));a=M}if(!n.validEnd){let t=n.fillBefore(IC.empty,!0);e.replace(a,a,new AC(t,0,0))}for(let t=s.length-1;t>=0;t--)e.step(s[t])}function WQ(e,t,i){return(0==t||e.canReplace(t,e.childCount))&&(i==e.childCount||e.canReplace(0,i))}function BQ(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let i=e.depth,n=0,o=0;;--i){let r=e.$from.node(i),s=e.$from.index(i)+n,a=e.$to.indexAfter(i)-o;if(i<e.depth&&r.canReplace(s,a,t))return i;if(0==i||r.type.spec.isolating||!WQ(r,s,a))break;s&&(n=1),a<r.childCount&&(o=1)}return null}function $Q(e,t,i=null,n=e){let o=function(e,t){let{parent:i,startIndex:n,endIndex:o}=e,r=i.contentMatchAt(n).findWrapping(t);if(!r)return null;let s=r.length?r[0]:t;return i.canReplaceWith(n,o,s)?r:null}(e,t),r=o&&function(e,t){let{parent:i,startIndex:n,endIndex:o}=e,r=i.child(n),s=t.contentMatch.findWrapping(r.type);if(!s)return null;let a=s.length?s[s.length-1]:t,l=a.contentMatch;for(let e=n;l&&e<o;e++)l=l.matchType(i.child(e).type);return l&&l.validEnd?s:null}(n,t);return r?o.map(GQ).concat({type:t,attrs:i}).concat(r.map(GQ)):null}function GQ(e){return{type:e,attrs:null}}function FQ(e,t,i,n){t.forEach(((o,r)=>{if(o.isText){let s,a=/\r?\n|\r/g;for(;s=a.exec(o.text);){let o=e.mapping.slice(n).map(i+1+r+s.index);e.replaceWith(o,o+1,t.type.schema.linebreakReplacement.create())}}}))}function HQ(e,t,i,n){t.forEach(((o,r)=>{if(o.type==o.type.schema.linebreakReplacement){let o=e.mapping.slice(n).map(i+1+r);e.replaceWith(o,o+1,t.type.schema.text("\n"))}}))}function JQ(e,t,i=1,n){let o=e.resolve(t),r=o.depth-i,s=n&&n[n.length-1]||o.parent;if(r<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let e=o.depth-1,t=i-2;e>r;e--,t--){let i=o.node(e),r=o.index(e);if(i.type.spec.isolating)return!1;let s=i.content.cutByIndex(r,i.childCount),a=n&&n[t+1];a&&(s=s.replaceChild(0,a.type.create(a.attrs)));let l=n&&n[t]||i;if(!i.canReplace(r+1,i.childCount)||!l.type.validContent(s))return!1}let a=o.indexAfter(r),l=n&&n[0];return o.node(r).canReplaceWith(a,a,l?l.type:o.node(r+1).type)}function XQ(e,t){let i=e.resolve(t),n=i.index();return function(e,t){return!(!e||!t||e.isLeaf||!function(e,t){t.content.size||e.type.compatibleContent(t.type);let i=e.contentMatchAt(e.childCount),{linebreakReplacement:n}=e.type.schema;for(let o=0;o<t.childCount;o++){let r=t.child(o),s=r.type==n?e.type.schema.nodes.text:r.type;if(i=i.matchType(s),!i)return!1;if(!e.type.allowsMarks(r.marks))return!1}return i.validEnd}(e,t))}(i.nodeBefore,i.nodeAfter)&&i.parent.canReplace(n,n+1)}function qQ(e,t,i){let n=e.resolve(t);if(!i.content.size)return t;let o=i.content;for(let e=0;e<i.openStart;e++)o=o.firstChild.content;for(let e=1;e<=(0==i.openStart&&i.size?2:1);e++)for(let t=n.depth;t>=0;t--){let i=t==n.depth?0:n.pos<=(n.start(t+1)+n.end(t+1))/2?-1:1,r=n.index(t)+(i>0?1:0),s=n.node(t),a=!1;if(1==e)a=s.canReplace(r,r,o);else{let e=s.contentMatchAt(r).findWrapping(o.firstChild.type);a=e&&s.canReplaceWith(r,r,e[0])}if(a)return 0==i?n.pos:i<0?n.before(t+1):n.after(t+1)}return null}function KQ(e,t,i=t,n=AC.empty){if(t==i&&!n.size)return null;let o=e.resolve(t),r=e.resolve(i);return eU(o,r,n)?new _Q(t,i,n):new tU(o,r,n).fit()}function eU(e,t,i){return!i.openStart&&!i.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),i.content)}kQ.jsonID("replaceAround",PQ);class tU{constructor(e,t,i){this.$from=e,this.$to=t,this.unplaced=i,this.frontier=[],this.placed=IC.empty;for(let t=0;t<=e.depth;t++){let i=e.node(t);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=IC.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,i=this.$from,n=this.close(e<0?this.$to:i.doc.resolve(e));if(!n)return null;let o=this.placed,r=i.depth,s=n.depth;for(;r&&s&&1==o.childCount;)o=o.firstChild.content,r--,s--;let a=new AC(o,r,s);return e>-1?new PQ(i.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||i.pos!=this.$to.pos?new _Q(i.pos,n.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,i=0,n=this.unplaced.openEnd;i<e;i++){let o=t.firstChild;if(t.childCount>1&&(n=0),o.type.spec.isolating&&n<=i){e=i;break}t=o.content}for(let t=1;t<=2;t++)for(let i=1==t?e:this.unplaced.openStart;i>=0;i--){let e,n=null;i?(n=oU(this.unplaced.content,i-1).firstChild,e=n.content):e=this.unplaced.content;let o=e.firstChild;for(let e=this.depth;e>=0;e--){let r,{type:s,match:a}=this.frontier[e],l=null;if(1==t&&(o?a.matchType(o.type)||(l=a.fillBefore(IC.from(o),!1)):n&&s.compatibleContent(n.type)))return{sliceDepth:i,frontierDepth:e,parent:n,inject:l};if(2==t&&o&&(r=a.findWrapping(o.type)))return{sliceDepth:i,frontierDepth:e,parent:n,wrap:r};if(n&&a.matchType(n.type))break}}}openMore(){let{content:e,openStart:t,openEnd:i}=this.unplaced,n=oU(e,t);return!(!n.childCount||n.firstChild.isLeaf)&&(this.unplaced=new AC(e,t+1,Math.max(i,n.size+t>=e.size-i?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:i}=this.unplaced,n=oU(e,t);if(n.childCount<=1&&t>0){let o=e.size-t<=t+n.size;this.unplaced=new AC(iU(e,t-1,1),t-1,o?t-1:i)}else this.unplaced=new AC(iU(e,t,1),t,i)}placeNodes({sliceDepth:e,frontierDepth:t,parent:i,inject:n,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let e=0;e<o.length;e++)this.openFrontierNode(o[e]);let r=this.unplaced,s=i?i.content:r.content,a=r.openStart-e,l=0,M=[],{match:c,type:u}=this.frontier[t];if(n){for(let e=0;e<n.childCount;e++)M.push(n.child(e));c=c.matchFragment(n)}let g=s.size+e-(r.content.size-r.openEnd);for(;l<s.childCount;){let e=s.child(l),t=c.matchType(e.type);if(!t)break;l++,(l>1||0==a||e.content.size)&&(c=t,M.push(rU(e.mark(u.allowedMarks(e.marks)),1==l?a:0,l==s.childCount?g:-1)))}let d=l==s.childCount;d||(g=-1),this.placed=nU(this.placed,t,IC.from(M)),this.frontier[t].match=c,d&&g<0&&i&&i.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=s;e<g;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=d?0==e?AC.empty:new AC(iU(r.content,e-1,1),e-1,g<0?r.openEnd:e-1):new AC(iU(r.content,e,l),r.openStart,r.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e,t=this.frontier[this.depth];if(!t.type.isTextblock||!sU(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:i}=this.$to,n=this.$to.after(i);for(;i>1&&n==this.$to.end(--i);)++n;return n}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:i,type:n}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),r=sU(e,t,n,i,o);if(r){for(let i=t-1;i>=0;i--){let{match:t,type:n}=this.frontier[i],o=sU(e,i,n,t,!0);if(!o||o.childCount)continue e}return{depth:t,fit:r,move:o?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=nU(this.placed,t.depth,t.fit)),e=t.move;for(let i=t.depth+1;i<=e.depth;i++){let t=e.node(i),n=t.type.contentMatch.fillBefore(t.content,!0,e.index(i));this.openFrontierNode(t.type,t.attrs,n)}return e}openFrontierNode(e,t=null,i){let n=this.frontier[this.depth];n.match=n.match.matchType(e),this.placed=nU(this.placed,this.depth,IC.from(e.create(t,i))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(IC.empty,!0);e.childCount&&(this.placed=nU(this.placed,this.frontier.length,e))}}function iU(e,t,i){return 0==t?e.cutByIndex(i,e.childCount):e.replaceChild(0,e.firstChild.copy(iU(e.firstChild.content,t-1,i)))}function nU(e,t,i){return 0==t?e.append(i):e.replaceChild(e.childCount-1,e.lastChild.copy(nU(e.lastChild.content,t-1,i)))}function oU(e,t){for(let i=0;i<t;i++)e=e.firstChild.content;return e}function rU(e,t,i){if(t<=0)return e;let n=e.content;return t>1&&(n=n.replaceChild(0,rU(n.firstChild,t-1,1==n.childCount?i-1:0))),t>0&&(n=e.type.contentMatch.fillBefore(n).append(n),i<=0&&(n=n.append(e.type.contentMatch.matchFragment(n).fillBefore(IC.empty,!0)))),e.copy(n)}function sU(e,t,i,n,o){let r=e.node(t),s=o?e.indexAfter(t):e.index(t);if(s==r.childCount&&!i.compatibleContent(r.type))return null;let a=n.fillBefore(r.content,!0,s);return a&&!function(e,t,i){for(let n=i;n<t.childCount;n++)if(!e.allowsMarks(t.child(n).marks))return!0;return!1}(i,r.content,s)?a:null}function aU(e,t,i,n,o){if(t<i){let o=e.firstChild;e=e.replaceChild(0,o.copy(aU(o.content,t+1,i,n,o)))}if(t>n){let t=o.contentMatchAt(0),i=t.fillBefore(e).append(e);e=i.append(t.matchFragment(i).fillBefore(IC.empty,!0))}return e}function lU(e,t){let i=[];for(let n=Math.min(e.depth,t.depth);n>=0;n--){let o=e.start(n);if(o<e.pos-(e.depth-n)||t.end(n)>t.pos+(t.depth-n)||e.node(n).type.spec.isolating||t.node(n).type.spec.isolating)break;(o==t.start(n)||n==e.depth&&n==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&n&&t.start(n-1)==o-1)&&i.push(n)}return i}class MU extends kQ{constructor(e,t,i){super(),this.pos=e,this.attr=t,this.value=i}apply(e){let t=e.nodeAt(this.pos);if(!t)return EQ.fail("No node at attribute step's position");let i=Object.create(null);for(let e in t.attrs)i[e]=t.attrs[e];i[this.attr]=this.value;let n=t.type.create(i,null,t.marks);return EQ.fromReplace(e,this.pos,this.pos+1,new AC(IC.from(n),0,t.isLeaf?0:1))}getMap(){return wQ.empty}invert(e){return new MU(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new MU(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if("number"!=typeof t.pos||"string"!=typeof t.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new MU(t.pos,t.attr,t.value)}}kQ.jsonID("attr",MU);class cU extends kQ{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let i=e.type.create(t,e.content,e.marks);return EQ.ok(i)}getMap(){return wQ.empty}invert(e){return new cU(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if("string"!=typeof t.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new cU(t.attr,t.value)}}kQ.jsonID("docAttr",cU);let uU=class extends Error{};uU=function e(t){let i=Error.call(this,t);return i.__proto__=e.prototype,i},(uU.prototype=Object.create(Error.prototype)).constructor=uU,uU.prototype.name="TransformError";class gU{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new vQ}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new uU(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let i=0;i<this.mapping.maps.length;i++){let n=this.mapping.maps[i];i&&(e=n.map(e,1),t=n.map(t,-1)),n.forEach(((i,n,o,r)=>{e=Math.min(e,o),t=Math.max(t,r)}))}return 1e9==e?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,i=AC.empty){let n=KQ(this.doc,e,t,i);return n&&this.step(n),this}replaceWith(e,t,i){return this.replace(e,t,new AC(IC.from(i),0,0))}delete(e,t){return this.replace(e,t,AC.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,i){return function(e,t,i,n){if(!n.size)return e.deleteRange(t,i);let o=e.doc.resolve(t),r=e.doc.resolve(i);if(eU(o,r,n))return e.step(new _Q(t,i,n));let s=lU(o,r);0==s[s.length-1]&&s.pop();let a=-(o.depth+1);s.unshift(a);for(let e=o.depth,t=o.pos-1;e>0;e--,t--){let i=o.node(e).type.spec;if(i.defining||i.definingAsContext||i.isolating)break;s.indexOf(e)>-1?a=e:o.before(e)==t&&s.splice(1,0,-e)}let l=s.indexOf(a),M=[],c=n.openStart;for(let e=n.content,t=0;;t++){let i=e.firstChild;if(M.push(i),t==n.openStart)break;e=i.content}for(let e=c-1;e>=0;e--){let t=M[e],i=(u=t.type).spec.defining||u.spec.definingForContent;if(i&&!t.sameMarkup(o.node(Math.abs(a)-1)))c=e;else if(i||!t.type.isTextblock)break}var u;for(let t=n.openStart;t>=0;t--){let a=(t+c+1)%(n.openStart+1),u=M[a];if(u)for(let t=0;t<s.length;t++){let M=s[(t+l)%s.length],c=!0;M<0&&(c=!1,M=-M);let g=o.node(M-1),d=o.index(M-1);if(g.canReplaceWith(d,d,u.type,u.marks))return e.replace(o.before(M),c?r.after(M):i,new AC(aU(n.content,0,n.openStart,a),a,n.openEnd))}}let g=e.steps.length;for(let a=s.length-1;a>=0&&(e.replace(t,i,n),!(e.steps.length>g));a--){let e=s[a];e<0||(t=o.before(e),i=r.after(e))}}(this,e,t,i),this}replaceRangeWith(e,t,i){return function(e,t,i,n){if(!n.isInline&&t==i&&e.doc.resolve(t).parent.content.size){let o=function(e,t,i){let n=e.resolve(t);if(n.parent.canReplaceWith(n.index(),n.index(),i))return t;if(0==n.parentOffset)for(let e=n.depth-1;e>=0;e--){let t=n.index(e);if(n.node(e).canReplaceWith(t,t,i))return n.before(e+1);if(t>0)return null}if(n.parentOffset==n.parent.content.size)for(let e=n.depth-1;e>=0;e--){let t=n.indexAfter(e);if(n.node(e).canReplaceWith(t,t,i))return n.after(e+1);if(t<n.node(e).childCount)return null}return null}(e.doc,t,n.type);null!=o&&(t=i=o)}e.replaceRange(t,i,new AC(IC.from(n),0,0))}(this,e,t,i),this}deleteRange(e,t){return function(e,t,i){let n=e.doc.resolve(t),o=e.doc.resolve(i);if(n.parent.isTextblock&&o.parent.isTextblock&&n.start()!=o.start()&&0==n.parentOffset&&0==o.parentOffset){let r=n.sharedDepth(i),s=!1;for(let e=n.depth;e>r;e--)n.node(e).type.spec.isolating&&(s=!0);for(let e=o.depth;e>r;e--)o.node(e).type.spec.isolating&&(s=!0);if(!s){for(let e=n.depth;e>0&&t==n.start(e);e--)t=n.before(e);for(let e=o.depth;e>0&&i==o.start(e);e--)i=o.before(e);n=e.doc.resolve(t),o=e.doc.resolve(i)}}let r=lU(n,o);for(let t=0;t<r.length;t++){let i=r[t],s=t==r.length-1;if(s&&0==i||n.node(i).type.contentMatch.validEnd)return e.delete(n.start(i),o.end(i));if(i>0&&(s||n.node(i-1).canReplace(n.index(i-1),o.indexAfter(i-1))))return e.delete(n.before(i),o.after(i))}for(let r=1;r<=n.depth&&r<=o.depth;r++)if(t-n.start(r)==n.depth-r&&i>n.end(r)&&o.end(r)-i!=o.depth-r&&n.start(r-1)==o.start(r-1)&&n.node(r-1).canReplace(n.index(r-1),o.index(r-1)))return e.delete(n.before(r),i);e.delete(t,i)}(this,e,t),this}lift(e,t){return function(e,t,i){let{$from:n,$to:o,depth:r}=t,s=n.before(r+1),a=o.after(r+1),l=s,M=a,c=IC.empty,u=0;for(let e=r,t=!1;e>i;e--)t||n.index(e)>0?(t=!0,c=IC.from(n.node(e).copy(c)),u++):l--;let g=IC.empty,d=0;for(let e=r,t=!1;e>i;e--)t||o.after(e+1)<o.end(e)?(t=!0,g=IC.from(o.node(e).copy(g)),d++):M++;e.step(new PQ(l,M,s,a,new AC(c.append(g),u,d),c.size-u,!0))}(this,e,t),this}join(e,t=1){return function(e,t,i){let n=null,{linebreakReplacement:o}=e.doc.type.schema,r=e.doc.resolve(t-i),s=r.node().type;if(o&&s.inlineContent){let e="pre"==s.whitespace,t=!!s.contentMatch.matchType(o);e&&!t?n=!1:!e&&t&&(n=!0)}let a=e.steps.length;if(!1===n){let n=e.doc.resolve(t+i);HQ(e,n.node(),n.before(),a)}s.inlineContent&&RQ(e,t+i-1,s,r.node().contentMatchAt(r.index()),null==n);let l=e.mapping.slice(a),M=l.map(t-i);if(e.step(new _Q(M,l.map(t+i,-1),AC.empty,!0)),!0===n){let t=e.doc.resolve(M);FQ(e,t.node(),t.before(),e.steps.length)}}(this,e,t),this}wrap(e,t){return function(e,t,i){let n=IC.empty;for(let e=i.length-1;e>=0;e--){if(n.size){let t=i[e].type.contentMatch.matchFragment(n);if(!t||!t.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=IC.from(i[e].type.create(i[e].attrs,n))}let o=t.start,r=t.end;e.step(new PQ(o,r,o,r,new AC(n,0,0),i.length,!0))}(this,e,t),this}setBlockType(e,t=e,i,n=null){return function(e,t,i,n,o){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let r=e.steps.length;e.doc.nodesBetween(t,i,((t,i)=>{let s="function"==typeof o?o(t):o;if(t.isTextblock&&!t.hasMarkup(n,s)&&function(e,t,i){let n=e.resolve(t),o=n.index();return n.parent.canReplaceWith(o,o+1,i)}(e.doc,e.mapping.slice(r).map(i),n)){let o=null;if(n.schema.linebreakReplacement){let e="pre"==n.whitespace,t=!!n.contentMatch.matchType(n.schema.linebreakReplacement);e&&!t?o=!1:!e&&t&&(o=!0)}!1===o&&HQ(e,t,i,r),RQ(e,e.mapping.slice(r).map(i,1),n,void 0,null===o);let a=e.mapping.slice(r),l=a.map(i,1),M=a.map(i+t.nodeSize,1);return e.step(new PQ(l,M,l+1,M-1,new AC(IC.from(n.create(s,null,t.marks)),0,0),1,!0)),!0===o&&FQ(e,t,i,r),!1}}))}(this,e,t,i,n),this}setNodeMarkup(e,t,i=null,n){return function(e,t,i,n,o){let r=e.doc.nodeAt(t);if(!r)throw new RangeError("No node at given position");i||(i=r.type);let s=i.create(n,null,o||r.marks);if(r.isLeaf)return e.replaceWith(t,t+r.nodeSize,s);if(!i.validContent(r.content))throw new RangeError("Invalid content for node type "+i.name);e.step(new PQ(t,t+r.nodeSize,t+1,t+r.nodeSize-1,new AC(IC.from(s),0,0),1,!0))}(this,e,t,i,n),this}setNodeAttribute(e,t,i){return this.step(new MU(e,t,i)),this}setDocAttribute(e,t){return this.step(new cU(e,t)),this}addNodeMark(e,t){return this.step(new YQ(e,t)),this}removeNodeMark(e,t){let i=this.doc.nodeAt(e);if(!i)throw new RangeError("No node at position "+e);if(t instanceof TC)t.isInSet(i.marks)&&this.step(new ZQ(e,t));else{let n,o=i.marks,r=[];for(;n=t.isInSet(o);)r.push(new ZQ(e,n)),o=n.removeFromSet(o);for(let e=r.length-1;e>=0;e--)this.step(r[e])}return this}split(e,t=1,i){return function(e,t,i=1,n){let o=e.doc.resolve(t),r=IC.empty,s=IC.empty;for(let e=o.depth,t=o.depth-i,a=i-1;e>t;e--,a--){r=IC.from(o.node(e).copy(r));let t=n&&n[a];s=IC.from(t?t.type.create(t.attrs,s):o.node(e).copy(s))}e.step(new _Q(t,t,new AC(r.append(s),i,i),!0))}(this,e,t,i),this}addMark(e,t,i){return function(e,t,i,n){let o,r,s=[],a=[];e.doc.nodesBetween(t,i,((e,l,M)=>{if(!e.isInline)return;let c=e.marks;if(!n.isInSet(c)&&M.type.allowsMarkType(n.type)){let M=Math.max(l,t),u=Math.min(l+e.nodeSize,i),g=n.addToSet(c);for(let e=0;e<c.length;e++)c[e].isInSet(g)||(o&&o.to==M&&o.mark.eq(c[e])?o.to=u:s.push(o=new UQ(M,u,c[e])));r&&r.to==M?r.to=u:a.push(r=new QQ(M,u,n))}})),s.forEach((t=>e.step(t))),a.forEach((t=>e.step(t)))}(this,e,t,i),this}removeMark(e,t,i){return function(e,t,i,n){let o=[],r=0;e.doc.nodesBetween(t,i,((e,s)=>{if(!e.isInline)return;r++;let a=null;if(n instanceof aQ){let t,i=e.marks;for(;t=n.isInSet(i);)(a||(a=[])).push(t),i=t.removeFromSet(i)}else n?n.isInSet(e.marks)&&(a=[n]):a=e.marks;if(a&&a.length){let n=Math.min(s+e.nodeSize,i);for(let e=0;e<a.length;e++){let i,l=a[e];for(let e=0;e<o.length;e++){let t=o[e];t.step==r-1&&l.eq(o[e].style)&&(i=t)}i?(i.to=n,i.step=r):o.push({style:l,from:Math.max(s,t),to:n,step:r})}}})),o.forEach((t=>e.step(new UQ(t.from,t.to,t.style))))}(this,e,t,i),this}clearIncompatible(e,t,i){return RQ(this,e,t,i),this}}const dU=Object.create(null);class hU{constructor(e,t,i){this.$anchor=e,this.$head=t,this.ranges=i||[new NU(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=AC.empty){let i=t.content.lastChild,n=null;for(let e=0;e<t.openEnd;e++)n=i,i=i.lastChild;let o=e.steps.length,r=this.ranges;for(let s=0;s<r.length;s++){let{$from:a,$to:l}=r[s],M=e.mapping.slice(o);e.replaceRange(M.map(a.pos),M.map(l.pos),s?AC.empty:t),0==s&&AU(e,o,(i?i.isInline:n&&n.isTextblock)?-1:1)}}replaceWith(e,t){let i=e.steps.length,n=this.ranges;for(let o=0;o<n.length;o++){let{$from:r,$to:s}=n[o],a=e.mapping.slice(i),l=a.map(r.pos),M=a.map(s.pos);o?e.deleteRange(l,M):(e.replaceRangeWith(l,M,t),AU(e,i,t.isInline?-1:1))}}static findFrom(e,t,i=!1){let n=e.parent.inlineContent?new yU(e):xU(e.node(0),e.parent,e.pos,e.index(),t,i);if(n)return n;for(let n=e.depth-1;n>=0;n--){let o=t<0?xU(e.node(0),e.node(n),e.before(n+1),e.index(n),t,i):xU(e.node(0),e.node(n),e.after(n+1),e.index(n)+1,t,i);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new mU(e.node(0))}static atStart(e){return xU(e,e,0,0,1)||new mU(e)}static atEnd(e){return xU(e,e,e.content.size,e.childCount,-1)||new mU(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let i=dU[t.type];if(!i)throw new RangeError(`No selection type ${t.type} defined`);return i.fromJSON(e,t)}static jsonID(e,t){if(e in dU)throw new RangeError("Duplicate use of selection JSON ID "+e);return dU[e]=t,t.prototype.jsonID=e,t}getBookmark(){return yU.between(this.$anchor,this.$head).getBookmark()}}hU.prototype.visible=!0;class NU{constructor(e,t){this.$from=e,this.$to=t}}let pU=!1;function DU(e){pU||e.parent.inlineContent||(pU=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class yU extends hU{constructor(e,t=e){DU(e),DU(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let i=e.resolve(t.map(this.head));if(!i.parent.inlineContent)return hU.near(i);let n=e.resolve(t.map(this.anchor));return new yU(n.parent.inlineContent?n:i,i)}replace(e,t=AC.empty){if(super.replace(e,t),t==AC.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof yU&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new IU(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new yU(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,i=t){let n=e.resolve(t);return new this(n,i==t?n:e.resolve(i))}static between(e,t,i){let n=e.pos-t.pos;if(i&&!n||(i=n>=0?1:-1),!t.parent.inlineContent){let e=hU.findFrom(t,i,!0)||hU.findFrom(t,-i,!0);if(!e)return hU.near(t,i);t=e.$head}return e.parent.inlineContent||(0==n||(e=(hU.findFrom(e,-i,!0)||hU.findFrom(e,i,!0)).$anchor).pos<t.pos!=n<0)&&(e=t),new yU(e,t)}}hU.jsonID("text",yU);class IU{constructor(e,t){this.anchor=e,this.head=t}map(e){return new IU(e.map(this.anchor),e.map(this.head))}resolve(e){return yU.between(e.resolve(this.anchor),e.resolve(this.head))}}class jU extends hU{constructor(e){let t=e.nodeAfter,i=e.node(0).resolve(e.pos+t.nodeSize);super(e,i),this.node=t}map(e,t){let{deleted:i,pos:n}=t.mapResult(this.anchor),o=e.resolve(n);return i?hU.near(o):new jU(o)}content(){return new AC(IC.from(this.node),0,0)}eq(e){return e instanceof jU&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new zU(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new jU(e.resolve(t.anchor))}static create(e,t){return new jU(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}jU.prototype.visible=!1,hU.jsonID("node",jU);class zU{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:i}=e.mapResult(this.anchor);return t?new IU(i,i):new zU(i)}resolve(e){let t=e.resolve(this.anchor),i=t.nodeAfter;return i&&jU.isSelectable(i)?new jU(t):hU.near(t)}}class mU extends hU{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=AC.empty){if(t==AC.empty){e.delete(0,e.doc.content.size);let t=hU.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new mU(e)}map(e){return new mU(e)}eq(e){return e instanceof mU}getBookmark(){return TU}}hU.jsonID("all",mU);const TU={map(){return this},resolve:e=>new mU(e)};function xU(e,t,i,n,o,r=!1){if(t.inlineContent)return yU.create(e,i);for(let s=n-(o>0?0:1);o>0?s<t.childCount:s>=0;s+=o){let n=t.child(s);if(n.isAtom){if(!r&&jU.isSelectable(n))return jU.create(e,i-(o<0?n.nodeSize:0))}else{let t=xU(e,n,i+o,o<0?n.childCount:0,o,r);if(t)return t}i+=n.nodeSize*o}return null}function AU(e,t,i){let n=e.steps.length-1;if(n<t)return;let o,r=e.steps[n];(r instanceof _Q||r instanceof PQ)&&(e.mapping.maps[n].forEach(((e,t,i,n)=>{null==o&&(o=n)})),e.setSelection(hU.near(e.doc.resolve(o),i)))}class OU extends gU{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=-3&this.updated|1,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return TC.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(e,t){super.addStep(e,t),this.updated=-3&this.updated,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let i=this.selection;return t&&(e=e.mark(this.storedMarks||(i.empty?i.$from.marks():i.$from.marksAcross(i.$to)||TC.none))),i.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,i){let n=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(n.text(e),!0):this.deleteSelection();{if(null==i&&(i=t),!e)return this.deleteRange(t,i);let o=this.storedMarks;if(!o){let e=this.doc.resolve(t);o=i==t?e.marks():e.marksAcross(this.doc.resolve(i))}return this.replaceRangeWith(t,i,n.text(e,o)),this.selection.empty||this.selection.to!=t+e.length||this.setSelection(hU.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function fU(e,t){return t&&e?e.bind(t):e}class bU{constructor(e,t,i){this.name=e,this.init=fU(t.init,i),this.apply=fU(t.apply,i)}}const LU=[new bU("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new bU("selection",{init:(e,t)=>e.selection||hU.atStart(t.doc),apply:e=>e.selection}),new bU("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,i,n)=>n.selection.$cursor?e.storedMarks:null}),new bU("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class wU{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=LU.slice(),t&&t.forEach((e=>{if(this.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new bU(e.key,e.spec.state,e))}))}}class vU{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let i=0;i<this.config.plugins.length;i++)if(i!=t){let t=this.config.plugins[i];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],i=this.applyInner(e),n=null;for(;;){let o=!1;for(let r=0;r<this.config.plugins.length;r++){let s=this.config.plugins[r];if(s.spec.appendTransaction){let a=n?n[r].n:0,l=n?n[r].state:this,M=a<t.length&&s.spec.appendTransaction.call(s,a?t.slice(a):t,l,i);if(M&&i.filterTransaction(M,r)){if(M.setMeta("appendedTransaction",e),!n){n=[];for(let e=0;e<this.config.plugins.length;e++)n.push(e<r?{state:i,n:t.length}:{state:this,n:0})}t.push(M),i=i.applyInner(M),o=!0}n&&(n[r]={state:i,n:t.length})}}if(!o)return{state:i,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new vU(this.config),i=this.config.fields;for(let n=0;n<i.length;n++){let o=i[n];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new OU(this)}static create(e){let t=new wU(e.doc?e.doc.type.schema:e.schema,e.plugins),i=new vU(t);for(let n=0;n<t.fields.length;n++)i[t.fields[n].name]=t.fields[n].init(e,i);return i}reconfigure(e){let t=new wU(this.schema,e.plugins),i=t.fields,n=new vU(t);for(let t=0;t<i.length;t++){let o=i[t].name;n[o]=this.hasOwnProperty(o)?this[o]:i[t].init(e,n)}return n}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map((e=>e.toJSON()))),e&&"object"==typeof e)for(let i in e){if("doc"==i||"selection"==i)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let n=e[i],o=n.spec.state;o&&o.toJSON&&(t[i]=o.toJSON.call(n,this[n.key]))}return t}static fromJSON(e,t,i){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let n=new wU(e.schema,e.plugins),o=new vU(n);return n.fields.forEach((n=>{if("doc"==n.name)o.doc=RC.fromJSON(e.schema,t.doc);else if("selection"==n.name)o.selection=hU.fromJSON(o.doc,t.selection);else if("storedMarks"==n.name)t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(i)for(let r in i){let s=i[r],a=s.spec.state;if(s.key==n.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(t,r))return void(o[n.name]=a.fromJSON.call(s,e,t[r],o))}o[n.name]=n.init(e,o)}})),o}}function SU(e,t,i){for(let n in e){let o=e[n];o instanceof Function?o=o.bind(t):"handleDOMEvents"==n&&(o=SU(o,t,{})),i[n]=o}return i}class kU{constructor(e){this.spec=e,this.props={},e.props&&SU(e.props,this,this.props),this.key=e.key?e.key.key:CU("plugin")}getState(e){return e[this.key]}}const EU=Object.create(null);function CU(e){return e in EU?e+"$"+ ++EU[e]:(EU[e]=0,e+"$")}class QU{constructor(e="key"){this.key=CU(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const UU=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},YU=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t};let ZU=null;const _U=function(e,t,i){let n=ZU||(ZU=document.createRange());return n.setEnd(e,null==i?e.nodeValue.length:i),n.setStart(e,t||0),n},PU=function(e,t,i,n){return i&&(RU(e,t,i,n,-1)||RU(e,t,i,n,1))},VU=/^(img|br|input|textarea|hr)$/i;function RU(e,t,i,n,o){for(var r;;){if(e==i&&t==n)return!0;if(t==(o<0?0:WU(e))){let i=e.parentNode;if(!i||1!=i.nodeType||BU(e)||VU.test(e.nodeName)||"false"==e.contentEditable)return!1;t=UU(e)+(o<0?0:1),e=i}else{if(1!=e.nodeType)return!1;{let i=e.childNodes[t+(o<0?-1:0)];if(1==i.nodeType&&"false"==i.contentEditable){if(!(null===(r=i.pmViewDesc)||void 0===r?void 0:r.ignoreForSelection))return!1;t+=o}else e=i,t=o<0?WU(e):0}}}}function WU(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function BU(e){let t;for(let i=e;i&&!(t=i.pmViewDesc);i=i.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const $U=function(e){return e.focusNode&&PU(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function GU(e,t){let i=document.createEvent("Event");return i.initEvent("keydown",!0,!0),i.keyCode=e,i.key=i.code=t,i}const FU="undefined"!=typeof navigator?navigator:null,HU="undefined"!=typeof document?document:null,JU=FU&&FU.userAgent||"",XU=/Edge\/(\d+)/.exec(JU),qU=/MSIE \d/.exec(JU),KU=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(JU),eY=!!(qU||KU||XU),tY=qU?document.documentMode:KU?+KU[1]:XU?+XU[1]:0,iY=!eY&&/gecko\/(\d+)/i.test(JU);iY&&(/Firefox\/(\d+)/.exec(JU)||[0,0])[1];const nY=!eY&&/Chrome\/(\d+)/.exec(JU),oY=!!nY,rY=nY?+nY[1]:0,sY=!eY&&!!FU&&/Apple Computer/.test(FU.vendor),aY=sY&&(/Mobile\/\w+/.test(JU)||!!FU&&FU.maxTouchPoints>2),lY=aY||!!FU&&/Mac/.test(FU.platform),MY=!!FU&&/Win/.test(FU.platform),cY=/Android \d/.test(JU),uY=!!HU&&"webkitFontSmoothing"in HU.documentElement.style,gY=uY?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function dY(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function hY(e,t){return"number"==typeof e?e:e[t]}function NY(e){let t=e.getBoundingClientRect(),i=t.width/e.offsetWidth||1,n=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*i,top:t.top,bottom:t.top+e.clientHeight*n}}function pY(e,t,i){if(!xY(t)&&0==t.left)return;let n=e.someProp("scrollThreshold")||0,o=e.someProp("scrollMargin")||5,r=e.dom.ownerDocument;for(let s=i||e.dom;s;){if(1!=s.nodeType){s=YU(s);continue}let e=s,i=e==r.body,a=i?dY(r):NY(e),l=0,M=0;if(t.top<a.top+hY(n,"top")?M=-(a.top-t.top+hY(o,"top")):t.bottom>a.bottom-hY(n,"bottom")&&(M=t.bottom-t.top>a.bottom-a.top?t.top+hY(o,"top")-a.top:t.bottom-a.bottom+hY(o,"bottom")),t.left<a.left+hY(n,"left")?l=-(a.left-t.left+hY(o,"left")):t.right>a.right-hY(n,"right")&&(l=t.right-a.right+hY(o,"right")),l||M)if(i)r.defaultView.scrollBy(l,M);else{let i=e.scrollLeft,n=e.scrollTop;M&&(e.scrollTop+=M),l&&(e.scrollLeft+=l);let o=e.scrollLeft-i,r=e.scrollTop-n;t={left:t.left-o,top:t.top-r,right:t.right-o,bottom:t.bottom-r}}let c=i?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(c))break;s="absolute"==c?s.offsetParent:YU(s)}}function DY(e){let t=[],i=e.ownerDocument;for(let n=e;n&&(t.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),e!=i);n=YU(n));return t}function yY(e,t){for(let i=0;i<e.length;i++){let{dom:n,top:o,left:r}=e[i];n.scrollTop!=o+t&&(n.scrollTop=o+t),n.scrollLeft!=r&&(n.scrollLeft=r)}}let IY=null;function jY(e,t){let i,n,o,r,s=2e8,a=0,l=t.top,M=t.top;for(let c=e.firstChild,u=0;c;c=c.nextSibling,u++){let e;if(1==c.nodeType)e=c.getClientRects();else{if(3!=c.nodeType)continue;e=_U(c).getClientRects()}for(let g=0;g<e.length;g++){let d=e[g];if(d.top<=l&&d.bottom>=M){l=Math.max(d.bottom,l),M=Math.min(d.top,M);let e=d.left>t.left?d.left-t.left:d.right<t.left?t.left-d.right:0;if(e<s){i=c,s=e,n=e&&3==i.nodeType?{left:d.right<t.left?d.right:d.left,top:t.top}:t,1==c.nodeType&&e&&(a=u+(t.left>=(d.left+d.right)/2?1:0));continue}}else d.top>t.top&&!o&&d.left<=t.left&&d.right>=t.left&&(o=c,r={left:Math.max(d.left,Math.min(d.right,t.left)),top:d.top});!i&&(t.left>=d.right&&t.top>=d.top||t.left>=d.left&&t.top>=d.bottom)&&(a=u+1)}}return!i&&o&&(i=o,n=r,s=0),i&&3==i.nodeType?function(e,t){let i,n=e.nodeValue.length,o=document.createRange();for(let r=0;r<n;r++){o.setEnd(e,r+1),o.setStart(e,r);let n=AY(o,1);if(n.top!=n.bottom&&zY(t,n)){i={node:e,offset:r+(t.left>=(n.left+n.right)/2?1:0)};break}}return o.detach(),i||{node:e,offset:0}}(i,n):!i||s&&1==i.nodeType?{node:e,offset:a}:jY(i,n)}function zY(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function mY(e,t,i){let n=e.childNodes.length;if(n&&i.top<i.bottom)for(let o=Math.max(0,Math.min(n-1,Math.floor(n*(t.top-i.top)/(i.bottom-i.top))-2)),r=o;;){let i=e.childNodes[r];if(1==i.nodeType){let e=i.getClientRects();for(let n=0;n<e.length;n++){let o=e[n];if(zY(t,o))return mY(i,t,o)}}if((r=(r+1)%n)==o)break}return e}function TY(e,t){let i,n=e.dom.ownerDocument,o=0,r=function(e,t,i){if(e.caretPositionFromPoint)try{let n=e.caretPositionFromPoint(t,i);if(n)return{node:n.offsetNode,offset:Math.min(WU(n.offsetNode),n.offset)}}catch(e){}if(e.caretRangeFromPoint){let n=e.caretRangeFromPoint(t,i);if(n)return{node:n.startContainer,offset:Math.min(WU(n.startContainer),n.startOffset)}}}(n,t.left,t.top);r&&({node:i,offset:o}=r);let s,a=(e.root.elementFromPoint?e.root:n).elementFromPoint(t.left,t.top);if(!a||!e.dom.contains(1!=a.nodeType?a.parentNode:a)){let i=e.dom.getBoundingClientRect();if(!zY(t,i))return null;if(a=mY(e.dom,t,i),!a)return null}if(sY)for(let e=a;i&&e;e=YU(e))e.draggable&&(i=void 0);if(a=function(e,t){let i=e.parentNode;return i&&/^li$/i.test(i.nodeName)&&t.left<e.getBoundingClientRect().left?i:e}(a,t),i){if(iY&&1==i.nodeType&&(o=Math.min(o,i.childNodes.length),o<i.childNodes.length)){let e,n=i.childNodes[o];"IMG"==n.nodeName&&(e=n.getBoundingClientRect()).right<=t.left&&e.bottom>t.top&&o++}let n;uY&&o&&1==i.nodeType&&1==(n=i.childNodes[o-1]).nodeType&&"false"==n.contentEditable&&n.getBoundingClientRect().top>=t.top&&o--,i==e.dom&&o==i.childNodes.length-1&&1==i.lastChild.nodeType&&t.top>i.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:0!=o&&1==i.nodeType&&"BR"==i.childNodes[o-1].nodeName||(s=function(e,t,i,n){let o=-1;for(let i=t,r=!1;i!=e.dom;){let t,s=e.docView.nearestDesc(i,!0);if(!s)return null;if(1==s.dom.nodeType&&(s.node.isBlock&&s.parent||!s.contentDOM)&&((t=s.dom.getBoundingClientRect()).width||t.height)&&(s.node.isBlock&&s.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(s.dom.nodeName)&&(!r&&t.left>n.left||t.top>n.top?o=s.posBefore:(!r&&t.right<n.left||t.bottom<n.top)&&(o=s.posAfter),r=!0),!s.contentDOM&&o<0&&!s.node.isText))return(s.node.isBlock?n.top<(t.top+t.bottom)/2:n.left<(t.left+t.right)/2)?s.posBefore:s.posAfter;i=s.dom.parentNode}return o>-1?o:e.docView.posFromDOM(t,i,-1)}(e,i,o,t))}null==s&&(s=function(e,t,i){let{node:n,offset:o}=jY(t,i),r=-1;if(1==n.nodeType&&!n.firstChild){let e=n.getBoundingClientRect();r=e.left!=e.right&&i.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(n,o,r)}(e,a,t));let l=e.docView.nearestDesc(a,!0);return{pos:s,inside:l?l.posAtStart-l.border:-1}}function xY(e){return e.top<e.bottom||e.left<e.right}function AY(e,t){let i=e.getClientRects();if(i.length){let e=i[t<0?0:i.length-1];if(xY(e))return e}return Array.prototype.find.call(i,xY)||e.getBoundingClientRect()}const OY=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function fY(e,t,i){let{node:n,offset:o,atom:r}=e.docView.domFromPos(t,i<0?-1:1),s=uY||iY;if(3==n.nodeType){if(!s||!OY.test(n.nodeValue)&&(i<0?o:o!=n.nodeValue.length)){let e=o,t=o,r=i<0?1:-1;return i<0&&!o?(t++,r=-1):i>=0&&o==n.nodeValue.length?(e--,r=1):i<0?e--:t++,bY(AY(_U(n,e,t),r),r<0)}{let e=AY(_U(n,o,o),i);if(iY&&o&&/\s/.test(n.nodeValue[o-1])&&o<n.nodeValue.length){let t=AY(_U(n,o-1,o-1),-1);if(t.top==e.top){let i=AY(_U(n,o,o+1),-1);if(i.top!=e.top)return bY(i,i.left<t.left)}}return e}}if(!e.state.doc.resolve(t-(r||0)).parent.inlineContent){if(null==r&&o&&(i<0||o==WU(n))){let e=n.childNodes[o-1];if(1==e.nodeType)return LY(e.getBoundingClientRect(),!1)}if(null==r&&o<WU(n)){let e=n.childNodes[o];if(1==e.nodeType)return LY(e.getBoundingClientRect(),!0)}return LY(n.getBoundingClientRect(),i>=0)}if(null==r&&o&&(i<0||o==WU(n))){let e=n.childNodes[o-1],t=3==e.nodeType?_U(e,WU(e)-(s?0:1)):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return bY(AY(t,1),!1)}if(null==r&&o<WU(n)){let e=n.childNodes[o];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?_U(e,0,s?0:1):1==e.nodeType?e:null:null;if(t)return bY(AY(t,-1),!0)}return bY(AY(3==n.nodeType?_U(n):n,-i),i>=0)}function bY(e,t){if(0==e.width)return e;let i=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:i,right:i}}function LY(e,t){if(0==e.height)return e;let i=t?e.top:e.bottom;return{top:i,bottom:i,left:e.left,right:e.right}}function wY(e,t,i){let n=e.state,o=e.root.activeElement;n!=t&&e.updateState(t),o!=e.dom&&e.focus();try{return i()}finally{n!=t&&e.updateState(n),o!=e.dom&&o&&o.focus()}}const vY=/[\u0590-\u08ac]/;let SY=null,kY=null,EY=!1;function CY(e,t,i){return SY==t&&kY==i?EY:(SY=t,kY=i,EY="up"==i||"down"==i?function(e,t,i){let n=t.selection,o="up"==i?n.$from:n.$to;return wY(e,t,(()=>{let{node:t}=e.docView.domFromPos(o.pos,"up"==i?-1:1);for(;;){let i=e.docView.nearestDesc(t,!0);if(!i)break;if(i.node.isBlock){t=i.contentDOM||i.dom;break}t=i.dom.parentNode}let n=fY(e,o.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=_U(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let o=t[e];if(o.bottom>o.top+1&&("up"==i?n.top-o.top>2*(o.bottom-n.top):o.bottom-n.bottom>2*(n.bottom-o.top)))return!1}}return!0}))}(e,t,i):function(e,t,i){let{$head:n}=t.selection;if(!n.parent.isTextblock)return!1;let o=n.parentOffset,r=!o,s=o==n.parent.content.size,a=e.domSelection();return a?vY.test(n.parent.textContent)&&a.modify?wY(e,t,(()=>{let{focusNode:t,focusOffset:o,anchorNode:r,anchorOffset:s}=e.domSelectionRange(),l=a.caretBidiLevel;a.modify("move",i,"character");let M=n.depth?e.docView.domAfterPos(n.before()):e.dom,{focusNode:c,focusOffset:u}=e.domSelectionRange(),g=c&&!M.contains(1==c.nodeType?c:c.parentNode)||t==c&&o==u;try{a.collapse(r,s),t&&(t!=r||o!=s)&&a.extend&&a.extend(t,o)}catch(e){}return null!=l&&(a.caretBidiLevel=l),g})):"left"==i||"backward"==i?r:s:n.pos==n.start()||n.pos==n.end()}(e,t,i))}class QY{constructor(e,t,i,n){this.parent=e,this.children=t,this.dom=i,this.contentDOM=n,this.dirty=0,i.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,i){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,i=this.posAtStart;;t++){let n=this.children[t];if(n==e)return i;i+=n.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,i){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(i<0){let i,n;if(e==this.contentDOM)i=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&(!(n=i.pmViewDesc)||n.parent!=this);)i=i.previousSibling;return i?this.posBeforeChild(n)+n.size:this.posAtStart}{let i,n;if(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&(!(n=i.pmViewDesc)||n.parent!=this);)i=i.nextSibling;return i?this.posBeforeChild(n):this.posAtEnd}}let n;if(e==this.dom&&this.contentDOM)n=t>UU(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))n=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){n=!1;break}if(t.previousSibling)break}if(null==n&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){n=!0;break}if(t.nextSibling)break}}return(null==n?i>0:n)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let i=!0,n=e;n;n=n.parentNode){let o,r=this.getDesc(n);if(r&&(!t||r.node)){if(!i||!(o=r.nodeDOM)||(1==o.nodeType?o.contains(1==e.nodeType?e:e.parentNode):o==e))return r;i=!1}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,i){for(let n=e;n;n=n.parentNode){let o=this.getDesc(n);if(o)return o.localPosFromDOM(e,t,i)}return-1}descAt(e){for(let t=0,i=0;t<this.children.length;t++){let n=this.children[t],o=i+n.size;if(i==e&&o!=i){for(;!n.border&&n.children.length;)for(let e=0;e<n.children.length;e++){let t=n.children[e];if(t.size){n=t;break}}return n}if(e<o)return n.descAt(e-i-n.border);i=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let i=0,n=0;for(let t=0;i<this.children.length;i++){let o=this.children[i],r=t+o.size;if(r>e||o instanceof RY){n=e-t;break}t=r}if(n)return this.children[i].domFromPos(n-this.children[i].border,t);for(let e;i&&!(e=this.children[i-1]).size&&e instanceof UY&&e.side>=0;i--);if(t<=0){let e,n=!0;for(;e=i?this.children[i-1]:null,e&&e.dom.parentNode!=this.contentDOM;i--,n=!1);return e&&t&&n&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?UU(e.dom)+1:0}}{let e,n=!0;for(;e=i<this.children.length?this.children[i]:null,e&&e.dom.parentNode!=this.contentDOM;i++,n=!1);return e&&n&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?UU(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,i=0){if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let n=-1,o=-1;for(let r=i,s=0;;s++){let i=this.children[s],a=r+i.size;if(-1==n&&e<=a){let o=r+i.border;if(e>=o&&t<=a-i.border&&i.node&&i.contentDOM&&this.contentDOM.contains(i.contentDOM))return i.parseRange(e,t,o);e=r;for(let t=s;t>0;t--){let i=this.children[t-1];if(i.size&&i.dom.parentNode==this.contentDOM&&!i.emptyChildAt(1)){n=UU(i.dom)+1;break}e-=i.size}-1==n&&(n=0)}if(n>-1&&(a>t||s==this.children.length-1)){t=a;for(let e=s+1;e<this.children.length;e++){let i=this.children[e];if(i.size&&i.dom.parentNode==this.contentDOM&&!i.emptyChildAt(-1)){o=UU(i.dom);break}t+=i.size}-1==o&&(o=this.contentDOM.childNodes.length);break}r=a}return{node:this.contentDOM,from:e,to:t,fromOffset:n,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:i}=this.domFromPos(e,0);if(1!=t.nodeType||i==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[i]}setSelection(e,t,i,n=!1){let o=Math.min(e,t),r=Math.max(e,t);for(let s=0,a=0;s<this.children.length;s++){let l=this.children[s],M=a+l.size;if(o>a&&r<M)return l.setSelection(e-a-l.border,t-a-l.border,i,n);a=M}let s=this.domFromPos(e,e?-1:1),a=t==e?s:this.domFromPos(t,t?-1:1),l=i.root.getSelection(),M=i.domSelectionRange(),c=!1;if((iY||sY)&&e==t){let{node:e,offset:t}=s;if(3==e.nodeType){if(c=!(!t||"\n"!=e.nodeValue[t-1]),c&&t==e.nodeValue.length)for(let t,i=e;i;i=i.parentNode){if(t=i.nextSibling){"BR"==t.nodeName&&(s=a={node:t.parentNode,offset:UU(t)+1});break}let e=i.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let i=e.childNodes[t-1];c=i&&("BR"==i.nodeName||"false"==i.contentEditable)}}if(iY&&M.focusNode&&M.focusNode!=a.node&&1==M.focusNode.nodeType){let e=M.focusNode.childNodes[M.focusOffset];e&&"false"==e.contentEditable&&(n=!0)}if(!(n||c&&sY)&&PU(s.node,s.offset,M.anchorNode,M.anchorOffset)&&PU(a.node,a.offset,M.focusNode,M.focusOffset))return;let u=!1;if((l.extend||e==t)&&(!c||!iY)){l.collapse(s.node,s.offset);try{e!=t&&l.extend(a.node,a.offset),u=!0}catch(e){}}if(!u){if(e>t){let e=s;s=a,a=e}let i=document.createRange();i.setEnd(a.node,a.offset),i.setStart(s.node,s.offset),l.removeAllRanges(),l.addRange(i)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let i=0,n=0;n<this.children.length;n++){let o=this.children[n],r=i+o.size;if(i==r?e<=r&&t>=i:e<r&&t>i){let n=i+o.border,s=r-o.border;if(e>=n&&t<=s)return this.dirty=e==i||t==r?2:1,void(e!=n||t!=s||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(e-n,t-n):o.dirty=3);o.dirty=o.dom!=o.contentDOM||o.dom.parentNode!=this.contentDOM||o.children.length?3:2}i=r}this.dirty=2}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let i=1==e?2:1;t.dirty<i&&(t.dirty=i)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class UY extends QY{constructor(e,t,i,n){let o,r=t.type.toDOM;if("function"==typeof r&&(r=r(i,(()=>o?o.parent?o.parent.posBeforeChild(o):void 0:n))),!t.type.spec.raw){if(1!=r.nodeType){let e=document.createElement("span");e.appendChild(r),r=e}r.contentEditable="false",r.classList.add("ProseMirror-widget")}super(e,[],r,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return 0==this.dirty&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return!!t&&t(e)}ignoreMutation(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class YY extends QY{constructor(e,t,i,n){super(e,[],t,null),this.textDOM=i,this.text=n}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue}}class ZY extends QY{constructor(e,t,i,n,o){super(e,[],i,n),this.mark=t,this.spec=o}static create(e,t,i,n){let o=n.nodeViews[t.type.name],r=o&&o(t,n,i);return r&&r.dom||(r=jQ.renderSpec(document,t.type.spec.toDOM(t,i),null,t.attrs)),new ZY(e,t,r.dom,r.contentDOM||r.dom,r)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return 3!=this.dirty&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),0!=this.dirty){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=0}}slice(e,t,i){let n=ZY.create(this.parent,this.mark,!0,i),o=this.children,r=this.size;t<r&&(o=iZ(o,t,r,i)),e>0&&(o=iZ(o,0,e,i));for(let e=0;e<o.length;e++)o[e].parent=n;return n.children=o,n}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class _Y extends QY{constructor(e,t,i,n,o,r,s){super(e,[],o,r),this.node=t,this.outerDeco=i,this.innerDeco=n,this.nodeDOM=s}static create(e,t,i,n,o,r){let s,a=o.nodeViews[t.type.name],l=a&&a(t,o,(()=>s?s.parent?s.parent.posBeforeChild(s):void 0:r),i,n),M=l&&l.dom,c=l&&l.contentDOM;if(t.isText)if(M){if(3!=M.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else M=document.createTextNode(t.text);else if(!M){let e=jQ.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs);({dom:M,contentDOM:c}=e)}c||t.isText||"BR"==M.nodeName||(M.hasAttribute("contenteditable")||(M.contentEditable="false"),t.type.spec.draggable&&(M.draggable=!0));let u=M;return M=XY(M,i,t),l?s=new WY(e,t,i,n,M,c||null,u,l):t.isText?new VY(e,t,i,n,M,u):new _Y(e,t,i,n,M,c||null,u)}parseRule(e){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 i=this.children[e];if(this.dom.contains(i.dom.parentNode)){t.contentElement=i.dom.parentNode;break}}if(!t.contentElement){let i=e&&e.find((t=>1==t.nodeType&&e.indexOf(t.parentNode)<0&&this.dom.contains(t)));i?t.contentElement=i:t.getContent=()=>IC.empty}}else t.contentElement=this.contentDOM;else t.getContent=()=>this.node.content;return t}matchesNode(e,t,i){return 0==this.dirty&&e.eq(this.node)&&qY(t,this.outerDeco)&&i.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let i=this.node.inlineContent,n=t,o=e.composing?this.localCompositionInfo(e,t):null,r=o&&o.pos>-1?o:null,s=o&&o.pos<0,a=new eZ(this,r&&r.node,e);!function(e,t,i,n){let o=t.locals(e),r=0;if(0==o.length){for(let i=0;i<e.childCount;i++){let s=e.child(i);n(s,o,t.forChild(r,s),i),r+=s.nodeSize}return}let s=0,a=[],l=null;for(let M=0;;){let c,u,g,d;for(;s<o.length&&o[s].to==r;){let e=o[s++];e.widget&&(c?(u||(u=[c])).push(e):c=e)}if(c)if(u){u.sort(tZ);for(let e=0;e<u.length;e++)i(u[e],M,!!l)}else i(c,M,!!l);if(l)d=-1,g=l,l=null;else{if(!(M<e.childCount))break;d=M,g=e.child(M++)}for(let e=0;e<a.length;e++)a[e].to<=r&&a.splice(e--,1);for(;s<o.length&&o[s].from<=r&&o[s].to>r;)a.push(o[s++]);let h=r+g.nodeSize;if(g.isText){let e=h;s<o.length&&o[s].from<e&&(e=o[s].from);for(let t=0;t<a.length;t++)a[t].to<e&&(e=a[t].to);e<h&&(l=g.cut(e-r),g=g.cut(0,e-r),h=e,d=-1)}else for(;s<o.length&&o[s].to<h;)s++;let N=g.isInline&&!g.isLeaf?a.filter((e=>!e.inline)):a.slice();n(g,N,t.forChild(r,g),d),r=h}}(this.node,this.innerDeco,((t,o,r)=>{t.spec.marks?a.syncToMarks(t.spec.marks,i,e,o):t.type.side>=0&&!r&&a.syncToMarks(o==this.node.childCount?TC.none:this.node.child(o).marks,i,e,o),a.placeWidget(t,e,n)}),((t,r,l,M)=>{let c;a.syncToMarks(t.marks,i,e,M),a.findNodeMatch(t,r,l,M)||s&&e.state.selection.from>n&&e.state.selection.to<n+t.nodeSize&&(c=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(t,r,l,c,e)||a.updateNextNode(t,r,l,e,M,n)||a.addNode(t,r,l,e,n),n+=t.nodeSize})),a.syncToMarks([],i,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||2==this.dirty)&&(r&&this.protectLocalComposition(e,r),BY(this.contentDOM,this.children,e),aY&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}localCompositionInfo(e,t){let{from:i,to:n}=e.state.selection;if(!(e.state.selection instanceof yU)||i<t||n>t+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let e=o.nodeValue,r=function(e,t,i,n){for(let o=0,r=0;o<e.childCount&&r<=n;){let s=e.child(o++),a=r;if(r+=s.nodeSize,!s.isText)continue;let l=s.text;for(;o<e.childCount;){let t=e.child(o++);if(r+=t.nodeSize,!t.isText)break;l+=t.text}if(r>=i){if(r>=n&&l.slice(n-t.length-a,n-a)==t)return n-t.length;let e=a<n?l.lastIndexOf(t,n-a-1):-1;if(e>=0&&e+t.length+a>=i)return a+e;if(i==n&&l.length>=n+t.length-a&&l.slice(n-a,n-a+t.length)==t)return n}}return-1}(this.node.content,e,i-t,n-t);return r<0?null:{node:o,pos:r,text:e}}return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:i,text:n}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let r=new YY(this,o,t,n);e.input.compositionNodes.push(r),this.children=iZ(this.children,i,i+n.length,e,r)}update(e,t,i,n){return!(3==this.dirty||!e.sameMarkup(this.node))&&(this.updateInner(e,t,i,n),!0)}updateInner(e,t,i,n){this.updateOuterDeco(t),this.node=e,this.innerDeco=i,this.contentDOM&&this.updateChildren(n,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(qY(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,i=this.dom;this.dom=HY(this.dom,this.nodeDOM,FY(this.outerDeco,this.node,t),FY(e,this.node,t)),this.dom!=i&&(i.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.nodeDOM.draggable=!0))}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function PY(e,t,i,n,o){XY(n,t,e);let r=new _Y(void 0,e,t,i,n,n,n);return r.contentDOM&&r.updateChildren(o,0),r}class VY extends _Y{constructor(e,t,i,n,o,r){super(e,t,i,n,o,null,r)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,i,n){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!e.sameMarkup(this.node))&&(this.updateOuterDeco(t),0==this.dirty&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,n.trackWrites==this.nodeDOM&&(n.trackWrites=null)),this.node=e,this.dirty=0,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,i){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,i)}ignoreMutation(e){return"characterData"!=e.type&&"selection"!=e.type}slice(e,t,i){let n=this.node.cut(e,t),o=document.createTextNode(n.text);return new VY(this.parent,n,this.outerDeco,this.innerDeco,o,o)}markDirty(e,t){super.markDirty(e,t),this.dom==this.nodeDOM||0!=e&&t!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}isText(e){return this.node.text==e}}class RY extends QY{parseRule(){return{ignore:!0}}matchesHack(e){return 0==this.dirty&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class WY extends _Y{constructor(e,t,i,n,o,r,s,a){super(e,t,i,n,o,r,s),this.spec=a}update(e,t,i,n){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,i);return o&&this.updateInner(e,t,i,n),o}return!(!this.contentDOM&&!e.isLeaf)&&super.update(e,t,i,n)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,i,n){this.spec.setSelection?this.spec.setSelection(e,t,i.root):super.setSelection(e,t,i,n)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function BY(e,t,i){let n=e.firstChild,o=!1;for(let r=0;r<t.length;r++){let s=t[r],a=s.dom;if(a.parentNode==e){for(;a!=n;)n=KY(n),o=!0;n=n.nextSibling}else o=!0,e.insertBefore(a,n);if(s instanceof ZY){let t=n?n.previousSibling:e.lastChild;BY(s.contentDOM,s.children,i),n=t?t.nextSibling:e.firstChild}}for(;n;)n=KY(n),o=!0;o&&i.trackWrites==e&&(i.trackWrites=null)}const $Y=function(e){e&&(this.nodeName=e)};$Y.prototype=Object.create(null);const GY=[new $Y];function FY(e,t,i){if(0==e.length)return GY;let n=i?GY[0]:new $Y,o=[n];for(let r=0;r<e.length;r++){let s=e[r].type.attrs;if(s){s.nodeName&&o.push(n=new $Y(s.nodeName));for(let e in s){let r=s[e];null!=r&&(i&&1==o.length&&o.push(n=new $Y(t.isInline?"span":"div")),"class"==e?n.class=(n.class?n.class+" ":"")+r:"style"==e?n.style=(n.style?n.style+";":"")+r:"nodeName"!=e&&(n[e]=r))}}}return o}function HY(e,t,i,n){if(i==GY&&n==GY)return t;let o=t;for(let t=0;t<n.length;t++){let r=n[t],s=i[t];if(t){let t;s&&s.nodeName==r.nodeName&&o!=e&&(t=o.parentNode)&&t.nodeName.toLowerCase()==r.nodeName||(t=document.createElement(r.nodeName),t.pmIsDeco=!0,t.appendChild(o),s=GY[0]),o=t}JY(o,s||GY[0],r)}return o}function JY(e,t,i){for(let n in t)"class"==n||"style"==n||"nodeName"==n||n in i||e.removeAttribute(n);for(let n in i)"class"!=n&&"style"!=n&&"nodeName"!=n&&i[n]!=t[n]&&e.setAttribute(n,i[n]);if(t.class!=i.class){let n=t.class?t.class.split(" ").filter(Boolean):[],o=i.class?i.class.split(" ").filter(Boolean):[];for(let t=0;t<n.length;t++)-1==o.indexOf(n[t])&&e.classList.remove(n[t]);for(let t=0;t<o.length;t++)-1==n.indexOf(o[t])&&e.classList.add(o[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=i.style){if(t.style){let i,n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;i=n.exec(t.style);)e.style.removeProperty(i[1])}i.style&&(e.style.cssText+=i.style)}}function XY(e,t,i){return HY(e,e,GY,FY(t,i,1!=e.nodeType))}function qY(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(!e[i].type.eq(t[i].type))return!1;return!0}function KY(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class eZ{constructor(e,t,i){this.lock=t,this.view=i,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=function(e,t){let i=t,n=i.children.length,o=e.childCount,r=new Map,s=[];e:for(;o>0;){let a;for(;;)if(n){let e=i.children[n-1];if(!(e instanceof ZY)){a=e,n--;break}i=e,n=e.children.length}else{if(i==t)break e;n=i.parent.children.indexOf(i),i=i.parent}let l=a.node;if(l){if(l!=e.child(o-1))break;--o,r.set(a,o),s.push(a)}}return{index:o,matched:r,matches:s.reverse()}}(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let i=e;i<t;i++)this.top.children[i].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,i,n){let o=0,r=this.stack.length>>1,s=Math.min(r,e.length);for(;o<s&&(o==r-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&!1!==e[o].type.spec.spanning;)o++;for(;o<r;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),r--;for(;r<e.length;){this.stack.push(this.top,this.index+1);let o=-1,s=this.top.children.length;n<this.preMatch.index&&(s=Math.min(this.index+3,s));for(let t=this.index;t<s;t++){let i=this.top.children[t];if(i.matchesMark(e[r])&&!this.isLocked(i.dom)){o=t;break}}if(o<0&&this.index<this.top.children.length){let t=this.top.children[this.index];t instanceof ZY&&3!=t.dirty&&t.mark.type==e[r].type&&t.spec.update&&!this.isLocked(t.dom)&&t.spec.update(e[r])&&(t.mark=e[r],o=this.index,this.changed=!0)}if(o>-1)o>this.index&&(this.changed=!0,this.destroyBetween(this.index,o)),this.top=this.top.children[this.index];else{let n=ZY.create(this.top,e[r],t,i);this.top.children.splice(this.index,0,n),this.top=n,this.changed=!0}this.index=0,r++}}findNodeMatch(e,t,i,n){let o,r=-1;if(n>=this.preMatch.index&&(o=this.preMatch.matches[n-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,i))r=this.top.children.indexOf(o,this.index);else for(let n=this.index,o=Math.min(this.top.children.length,n+5);n<o;n++){let o=this.top.children[n];if(o.matchesNode(e,t,i)&&!this.preMatch.matched.has(o)){r=n;break}}return!(r<0)&&(this.destroyBetween(this.index,r),this.index++,!0)}updateNodeAt(e,t,i,n,o){let r=this.top.children[n];return 3==r.dirty&&r.dom==r.contentDOM&&(r.dirty=2),!!r.update(e,t,i,o)&&(this.destroyBetween(this.index,n),this.index++,!0)}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t)for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e;return-1}e=t}}updateNextNode(e,t,i,n,o,r){for(let s=this.index;s<this.top.children.length;s++){let a=this.top.children[s];if(a instanceof _Y){let l=this.preMatch.matched.get(a);if(null!=l&&l!=o)return!1;let M,c=a.dom,u=this.isLocked(c)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&3!=a.dirty&&qY(t,a.outerDeco));if(!u&&a.update(e,t,i,n))return this.destroyBetween(this.index,s),a.dom!=c&&(this.changed=!0),this.index++,!0;if(!u&&(M=this.recreateWrapper(a,e,t,i,n,r)))return this.destroyBetween(this.index,s),this.top.children[this.index]=M,M.contentDOM&&(M.dirty=2,M.updateChildren(n,r+1),M.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,i,n,o,r){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!qY(i,e.outerDeco)||!n.eq(e.innerDeco))return null;let s=_Y.create(this.top,t,i,n,o,r);if(s.contentDOM){s.children=e.children,e.children=[];for(let e of s.children)e.parent=s}return e.destroy(),s}addNode(e,t,i,n,o){let r=_Y.create(this.top,e,t,i,n,o);r.contentDOM&&r.updateChildren(n,o+1),this.top.children.splice(this.index++,0,r),this.changed=!0}placeWidget(e,t,i){let n=this.index<this.top.children.length?this.top.children[this.index]:null;if(!n||!n.matchesWidget(e)||e!=n.widget&&n.widget.type.toDOM.parentNode){let n=new UY(this.top,e,t,i);this.top.children.splice(this.index++,0,n),this.changed=!0}else this.index++}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof ZY;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof VY)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((sY||oY)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let i=document.createElement(e);"IMG"==e&&(i.className="ProseMirror-separator",i.alt=""),"BR"==e&&(i.className="ProseMirror-trailingBreak");let n=new RY(this.top,[],i,null);t!=this.top?t.children.push(n):t.children.splice(this.index++,0,n),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}}function tZ(e,t){return e.type.side-t.type.side}function iZ(e,t,i,n,o){let r=[];for(let s=0,a=0;s<e.length;s++){let l=e[s],M=a,c=a+=l.size;M>=i||c<=t?r.push(l):(M<t&&r.push(l.slice(0,t-M,n)),o&&(r.push(o),o=void 0),c>i&&r.push(l.slice(i-M,l.size,n)))}return r}function nZ(e,t=null){let i=e.domSelectionRange(),n=e.state.doc;if(!i.focusNode)return null;let o=e.docView.nearestDesc(i.focusNode),r=o&&0==o.size,s=e.docView.posFromDOM(i.focusNode,i.focusOffset,1);if(s<0)return null;let a,l,M=n.resolve(s);if($U(i)){for(a=s;o&&!o.node;)o=o.parent;let e=o.node;if(o&&e.isAtom&&jU.isSelectable(e)&&o.parent&&(!e.isInline||!function(e,t,i){for(let n=0==t,o=t==WU(e);n||o;){if(e==i)return!0;let t=UU(e);if(!(e=e.parentNode))return!1;n=n&&0==t,o=o&&t==WU(e)}}(i.focusNode,i.focusOffset,o.dom))){let e=o.posBefore;l=new jU(s==e?M:n.resolve(e))}}else{if(i instanceof e.dom.ownerDocument.defaultView.Selection&&i.rangeCount>1){let t=s,o=s;for(let n=0;n<i.rangeCount;n++){let r=i.getRangeAt(n);t=Math.min(t,e.docView.posFromDOM(r.startContainer,r.startOffset,1)),o=Math.max(o,e.docView.posFromDOM(r.endContainer,r.endOffset,-1))}if(t<0)return null;[a,s]=o==e.state.selection.anchor?[o,t]:[t,o],M=n.resolve(s)}else a=e.docView.posFromDOM(i.anchorNode,i.anchorOffset,1);if(a<0)return null}let c=n.resolve(a);if(!l){l=gZ(e,c,M,"pointer"==t||e.state.selection.head<M.pos&&!r?1:-1)}return l}function oZ(e){return e.editable?e.hasFocus():hZ(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function rZ(e,t=!1){let i=e.state.selection;if(cZ(e,i),!oZ(e))return;let n=e.input.mouseDown;if(!t&&oY&&n){let t=e.domSelectionRange(),i=e.domObserver.currentSelection;if(t.anchorNode&&i.anchorNode&&PU(t.anchorNode,t.anchorOffset,i.anchorNode,i.anchorOffset)&&n.delaySelUpdate())return void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){let t=e.domSelection();if(!t)return;let i=e.cursorWrapper.dom,n="IMG"==i.nodeName;n?t.collapse(i.parentNode,UU(i)+1):t.collapse(i,0);!n&&!e.state.selection.visible&&eY&&tY<=11&&(i.disabled=!0,i.disabled=!1)}(e);else{let n,o,{anchor:r,head:s}=i;!sZ||i instanceof yU||(i.$from.parent.inlineContent||(n=aZ(e,i.from)),i.empty||i.$from.parent.inlineContent||(o=aZ(e,i.to))),e.docView.setSelection(r,s,e,t),sZ&&(n&&MZ(n),o&&MZ(o)),i.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let i=e.domSelectionRange(),n=i.anchorNode,o=i.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{i.anchorNode==n&&i.anchorOffset==o||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout((()=>{oZ(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")}),20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}const sZ=sY||oY&&rY<63;function aZ(e,t){let{node:i,offset:n}=e.docView.domFromPos(t,0),o=n<i.childNodes.length?i.childNodes[n]:null,r=n?i.childNodes[n-1]:null;if(sY&&o&&"false"==o.contentEditable)return lZ(o);if(!(o&&"false"!=o.contentEditable||r&&"false"!=r.contentEditable)){if(o)return lZ(o);if(r)return lZ(r)}}function lZ(e){return e.contentEditable="true",sY&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function MZ(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function cZ(e,t){if(t instanceof jU){let i=e.docView.descAt(t.from);i!=e.lastSelectedViewDesc&&(uZ(e),i&&i.selectNode(),e.lastSelectedViewDesc=i)}else uZ(e)}function uZ(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function gZ(e,t,i,n){return e.someProp("createSelectionBetween",(n=>n(e,t,i)))||yU.between(t,i,n)}function dZ(e){return!(e.editable&&!e.hasFocus())&&hZ(e)}function hZ(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function NZ(e,t){let{$anchor:i,$head:n}=e.selection,o=t>0?i.max(n):i.min(n),r=o.parent.inlineContent?o.depth?e.doc.resolve(t>0?o.after():o.before()):null:o;return r&&hU.findFrom(r,t)}function pZ(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function DZ(e,t,i){let n=e.state.selection;if(!(n instanceof yU)){if(n instanceof jU&&n.node.isInline)return pZ(e,new yU(t>0?n.$to:n.$from));{let i=NZ(e.state,t);return!!i&&pZ(e,i)}}if(i.indexOf("s")>-1){let{$head:i}=n,o=i.textOffset?null:t<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let r=e.state.doc.resolve(i.pos+o.nodeSize*(t<0?-1:1));return pZ(e,new yU(n.$anchor,r))}if(!n.empty)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){let i=NZ(e.state,t);return!!(i&&i instanceof jU)&&pZ(e,i)}if(!(lY&&i.indexOf("m")>-1)){let i,o=n.$head,r=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter;if(!r||r.isText)return!1;let s=t<0?o.pos-r.nodeSize:o.pos;return!!(r.isAtom||(i=e.docView.descAt(s))&&!i.contentDOM)&&(jU.isSelectable(r)?pZ(e,new jU(t<0?e.state.doc.resolve(o.pos-r.nodeSize):o)):!!uY&&pZ(e,new yU(e.state.doc.resolve(t<0?s:s+r.nodeSize))))}}function yZ(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function IZ(e,t){let i=e.pmViewDesc;return i&&0==i.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function jZ(e,t){return t<0?function(e){let t=e.domSelectionRange(),i=t.focusNode,n=t.focusOffset;if(!i)return;let o,r,s=!1;iY&&1==i.nodeType&&n<yZ(i)&&IZ(i.childNodes[n],-1)&&(s=!0);for(;;)if(n>0){if(1!=i.nodeType)break;{let e=i.childNodes[n-1];if(IZ(e,-1))o=i,r=--n;else{if(3!=e.nodeType)break;i=e,n=i.nodeValue.length}}}else{if(zZ(i))break;{let t=i.previousSibling;for(;t&&IZ(t,-1);)o=i.parentNode,r=UU(t),t=t.previousSibling;if(t)i=t,n=yZ(i);else{if(i=i.parentNode,i==e.dom)break;n=0}}}s?mZ(e,i,n):o&&mZ(e,o,r)}(e):function(e){let t=e.domSelectionRange(),i=t.focusNode,n=t.focusOffset;if(!i)return;let o,r,s=yZ(i);for(;;)if(n<s){if(1!=i.nodeType)break;if(!IZ(i.childNodes[n],1))break;o=i,r=++n}else{if(zZ(i))break;{let t=i.nextSibling;for(;t&&IZ(t,1);)o=t.parentNode,r=UU(t)+1,t=t.nextSibling;if(t)i=t,n=0,s=yZ(i);else{if(i=i.parentNode,i==e.dom)break;n=s=0}}}o&&mZ(e,o,r)}(e)}function zZ(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function mZ(e,t,i){if(3!=t.nodeType){let e,n;(n=function(e,t){for(;e&&t==e.childNodes.length&&!BU(e);)t=UU(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let i=e.childNodes[t];if(3==i.nodeType)return i;if(1==i.nodeType&&"false"==i.contentEditable)break;e=i,t=0}}(t,i))?(t=n,i=0):(e=function(e,t){for(;e&&!t&&!BU(e);)t=UU(e),e=e.parentNode;for(;e&&t;){let i=e.childNodes[t-1];if(3==i.nodeType)return i;if(1==i.nodeType&&"false"==i.contentEditable)break;t=(e=i).childNodes.length}}(t,i))&&(t=e,i=e.nodeValue.length)}let n=e.domSelection();if(!n)return;if($U(n)){let e=document.createRange();e.setEnd(t,i),e.setStart(t,i),n.removeAllRanges(),n.addRange(e)}else n.extend&&n.extend(t,i);e.domObserver.setCurSelection();let{state:o}=e;setTimeout((()=>{e.state==o&&rZ(e)}),50)}function TZ(e,t){let i=e.state.doc.resolve(t);if(!oY&&!MY&&i.parent.inlineContent){let n=e.coordsAtPos(t);if(t>i.start()){let i=e.coordsAtPos(t-1),o=(i.top+i.bottom)/2;if(o>n.top&&o<n.bottom&&Math.abs(i.left-n.left)>1)return i.left<n.left?"ltr":"rtl"}if(t<i.end()){let i=e.coordsAtPos(t+1),o=(i.top+i.bottom)/2;if(o>n.top&&o<n.bottom&&Math.abs(i.left-n.left)>1)return i.left>n.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function xZ(e,t,i){let n=e.state.selection;if(n instanceof yU&&!n.empty||i.indexOf("s")>-1)return!1;if(lY&&i.indexOf("m")>-1)return!1;let{$from:o,$to:r}=n;if(!o.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let i=NZ(e.state,t);if(i&&i instanceof jU)return pZ(e,i)}if(!o.parent.inlineContent){let i=t<0?o:r,s=n instanceof mU?hU.near(i,t):hU.findFrom(i,t);return!!s&&pZ(e,s)}return!1}function AZ(e,t){if(!(e.state.selection instanceof yU))return!0;let{$head:i,$anchor:n,empty:o}=e.state.selection;if(!i.sameParent(n))return!0;if(!o)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let r=!i.textOffset&&(t<0?i.nodeBefore:i.nodeAfter);if(r&&!r.isText){let n=e.state.tr;return t<0?n.delete(i.pos-r.nodeSize,i.pos):n.delete(i.pos,i.pos+r.nodeSize),e.dispatch(n),!0}return!1}function OZ(e,t,i){e.domObserver.stop(),t.contentEditable=i,e.domObserver.start()}function fZ(e,t){let i=t.keyCode,n=function(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);if(8==i||lY&&72==i&&"c"==n)return AZ(e,-1)||jZ(e,-1);if(46==i&&!t.shiftKey||lY&&68==i&&"c"==n)return AZ(e,1)||jZ(e,1);if(13==i||27==i)return!0;if(37==i||lY&&66==i&&"c"==n){let t=37==i?"ltr"==TZ(e,e.state.selection.from)?-1:1:-1;return DZ(e,t,n)||jZ(e,t)}if(39==i||lY&&70==i&&"c"==n){let t=39==i?"ltr"==TZ(e,e.state.selection.from)?1:-1:1;return DZ(e,t,n)||jZ(e,t)}return 38==i||lY&&80==i&&"c"==n?xZ(e,-1,n)||jZ(e,-1):40==i||lY&&78==i&&"c"==n?function(e){if(!sY||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:i}=e.domSelectionRange();if(t&&1==t.nodeType&&0==i&&t.firstChild&&"false"==t.firstChild.contentEditable){let i=t.firstChild;OZ(e,i,"true"),setTimeout((()=>OZ(e,i,"false")),20)}return!1}(e)||xZ(e,1,n)||jZ(e,1):n==(lY?"m":"c")&&(66==i||73==i||89==i||90==i)}function bZ(e,t){e.someProp("transformCopied",(i=>{t=i(t,e)}));let i=[],{content:n,openStart:o,openEnd:r}=t;for(;o>1&&r>1&&1==n.childCount&&1==n.firstChild.childCount;){o--,r--;let e=n.firstChild;i.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),n=e.content}let s=e.someProp("clipboardSerializer")||jQ.fromSchema(e.state.schema),a=UZ(),l=a.createElement("div");l.appendChild(s.serializeFragment(n,{document:a}));let M,c=l.firstChild,u=0;for(;c&&1==c.nodeType&&(M=QZ[c.nodeName.toLowerCase()]);){for(let e=M.length-1;e>=0;e--){let t=a.createElement(M[e]);for(;l.firstChild;)t.appendChild(l.firstChild);l.appendChild(t),u++}c=l.firstChild}c&&1==c.nodeType&&c.setAttribute("data-pm-slice",`${o} ${r}${u?` -${u}`:""} ${JSON.stringify(i)}`);let g=e.someProp("clipboardTextSerializer",(i=>i(t,e)))||t.content.textBetween(0,t.content.size,"\n\n");return{dom:l,text:g,slice:t}}function LZ(e,t,i,n,o){let r,s,a=o.parent.type.spec.code;if(!i&&!t)return null;let l=!!t&&(n||a||!i);if(l){if(e.someProp("transformPastedText",(i=>{t=i(t,a||n,e)})),a)return s=new AC(IC.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0),e.someProp("transformPasted",(t=>{s=t(s,e,!0)})),s;let i=e.someProp("clipboardTextParser",(i=>i(t,o,n,e)));if(i)s=i;else{let i=o.marks(),{schema:n}=e.state,s=jQ.fromSchema(n);r=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach((e=>{let t=r.appendChild(document.createElement("p"));e&&t.appendChild(s.serializeNode(n.text(e,i)))}))}}else e.someProp("transformPastedHTML",(t=>{i=t(i,e)})),r=function(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let i,n=UZ(),o=n.body,r=/<([a-z][^>\s]+)/i.exec(e);(i=r&&QZ[r[1].toLowerCase()])&&(e=i.map((e=>"<"+e+">")).join("")+e+i.map((e=>"</"+e+">")).reverse().join(""));if(o.innerHTML=function(e){let t=window.trustedTypes;if(!t)return e;YZ||(YZ=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:e=>e}));return YZ.createHTML(e)}(e),i)for(let e=0;e<i.length;e++)o=o.querySelector(i[e])||o;for(let e=0;e<n.styleSheets.length;e++){let t=n.styleSheets[e];for(let e=0;e<t.rules.length;e++){let i=t.rules[e];if(i instanceof CSSStyleRule){let e=o.querySelectorAll(i.selectorText);for(let t=0;t<e.length;t++)e[t].style.cssText+=i.style.cssText}}}return o}(i),uY&&function(e){let t=e.querySelectorAll(oY?"span:not([class]):not([style])":"span.Apple-converted-space");for(let i=0;i<t.length;i++){let n=t[i];1==n.childNodes.length&&" "==n.textContent&&n.parentNode&&n.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),n)}}(r);let M=r&&r.querySelector("[data-pm-slice]"),c=M&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(M.getAttribute("data-pm-slice")||"");if(c&&c[3])for(let e=+c[3];e>0;e--){let e=r.firstChild;for(;e&&1!=e.nodeType;)e=e.nextSibling;if(!e)break;r=e}if(!s){let t=e.someProp("clipboardParser")||e.someProp("domParser")||cQ.fromSchema(e.state.schema);s=t.parseSlice(r,{preserveWhitespace:!(!l&&!c),context:o,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||wZ.test(e.parentNode.nodeName)?null:{ignore:!0}})}if(c)s=function(e,t){if(!e.size)return e;let i,n=e.content.firstChild.type.schema;try{i=JSON.parse(t)}catch(t){return e}let{content:o,openStart:r,openEnd:s}=e;for(let e=i.length-2;e>=0;e-=2){let t=n.nodes[i[e]];if(!t||t.hasRequiredAttrs())break;o=IC.from(t.create(i[e+1],o)),r++,s++}return new AC(o,r,s)}(CZ(s,+c[1],+c[2]),c[4]);else if(s=AC.maxOpen(function(e,t){if(e.childCount<2)return e;for(let i=t.depth;i>=0;i--){let n,o=t.node(i).contentMatchAt(t.index(i)),r=[];if(e.forEach((e=>{if(!r)return;let t,i=o.findWrapping(e.type);if(!i)return r=null;if(t=r.length&&n.length&&SZ(i,n,e,r[r.length-1],0))r[r.length-1]=t;else{r.length&&(r[r.length-1]=kZ(r[r.length-1],n.length));let t=vZ(e,i);r.push(t),o=o.matchType(t.type),n=i}})),r)return IC.from(r)}return e}(s.content,o),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=CZ(s,e,t)}return e.someProp("transformPasted",(t=>{s=t(s,e,l)})),s}const wZ=/^(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 vZ(e,t,i=0){for(let n=t.length-1;n>=i;n--)e=t[n].create(null,IC.from(e));return e}function SZ(e,t,i,n,o){if(o<e.length&&o<t.length&&e[o]==t[o]){let r=SZ(e,t,i,n.lastChild,o+1);if(r)return n.copy(n.content.replaceChild(n.childCount-1,r));if(n.contentMatchAt(n.childCount).matchType(o==e.length-1?i.type:e[o+1]))return n.copy(n.content.append(IC.from(vZ(i,e,o+1))))}}function kZ(e,t){if(0==t)return e;let i=e.content.replaceChild(e.childCount-1,kZ(e.lastChild,t-1)),n=e.contentMatchAt(e.childCount).fillBefore(IC.empty,!0);return e.copy(i.append(n))}function EZ(e,t,i,n,o,r){let s=t<0?e.firstChild:e.lastChild,a=s.content;return e.childCount>1&&(r=0),o<n-1&&(a=EZ(a,t,i,n,o+1,r)),o>=i&&(a=t<0?s.contentMatchAt(0).fillBefore(a,r<=o).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(IC.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,s.copy(a))}function CZ(e,t,i){return t<e.openStart&&(e=new AC(EZ(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),i<e.openEnd&&(e=new AC(EZ(e.content,1,i,e.openEnd,0,0),e.openStart,i)),e}const QZ={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function UZ(){return document.implementation.createHTMLDocument("title")}let YZ=null;const ZZ={},_Z={},PZ={touchstart:!0,touchmove:!0};class VZ{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function RZ(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function WZ(e){e.someProp("handleDOMEvents",(t=>{for(let i in t)e.input.eventHandlers[i]||e.dom.addEventListener(i,e.input.eventHandlers[i]=t=>BZ(e,t))}))}function BZ(e,t){return e.someProp("handleDOMEvents",(i=>{let n=i[t.type];return!!n&&(n(e,t)||t.defaultPrevented)}))}function $Z(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let i=t.target;i!=e.dom;i=i.parentNode)if(!i||11==i.nodeType||i.pmViewDesc&&i.pmViewDesc.stopEvent(t))return!1;return!0}function GZ(e){return{left:e.clientX,top:e.clientY}}function FZ(e,t,i,n,o){if(-1==n)return!1;let r=e.state.doc.resolve(n);for(let n=r.depth+1;n>0;n--)if(e.someProp(t,(t=>n>r.depth?t(e,i,r.nodeAfter,r.before(n),o,!0):t(e,i,r.node(n),r.before(n),o,!1))))return!0;return!1}function HZ(e,t,i){if(e.focused||e.focus(),e.state.selection.eq(t))return;let n=e.state.tr.setSelection(t);"pointer"==i&&n.setMeta("pointer",!0),e.dispatch(n)}function JZ(e,t,i,n,o){return FZ(e,"handleClickOn",t,i,n)||e.someProp("handleClick",(i=>i(e,t,n)))||(o?function(e,t){if(-1==t)return!1;let i,n,o=e.state.selection;o instanceof jU&&(i=o.node);let r=e.state.doc.resolve(t);for(let e=r.depth+1;e>0;e--){let t=e>r.depth?r.nodeAfter:r.node(e);if(jU.isSelectable(t)){n=i&&o.$from.depth>0&&e>=o.$from.depth&&r.before(o.$from.depth+1)==o.$from.pos?r.before(o.$from.depth):r.before(e);break}}return null!=n&&(HZ(e,jU.create(e.state.doc,n),"pointer"),!0)}(e,i):function(e,t){if(-1==t)return!1;let i=e.state.doc.resolve(t),n=i.nodeAfter;return!!(n&&n.isAtom&&jU.isSelectable(n))&&(HZ(e,new jU(i),"pointer"),!0)}(e,i))}function XZ(e,t,i,n){return FZ(e,"handleDoubleClickOn",t,i,n)||e.someProp("handleDoubleClick",(i=>i(e,t,n)))}function qZ(e,t,i,n){return FZ(e,"handleTripleClickOn",t,i,n)||e.someProp("handleTripleClick",(i=>i(e,t,n)))||function(e,t,i){if(0!=i.button)return!1;let n=KZ(e,t,!0),o=e.state.doc;if(!n)return!1;HZ(e,n,"pointer"),n instanceof yU&&o.eq(e.state.doc)&&(e.input.mouseDown=new o_(e,n));return!0}(e,i,n)}function KZ(e,t,i){let n=e.state.doc;if(-1==t)return n.inlineContent?yU.create(n,0,n.content.size):null;let o=n.resolve(t);for(let e=o.depth+1;e>0;e--){let t=e>o.depth?o.nodeAfter:o.node(e),r=o.before(e);if(t.inlineContent)return yU.create(n,r+1,r+1+t.content.size);if(i&&jU.isSelectable(t))return jU.create(n,r)}return null}function e_(e){return c_(e)}_Z.keydown=(e,t)=>{let i=t;if(e.input.shiftKey=16==i.keyCode||i.shiftKey,!r_(e)&&(e.input.lastKeyCode=i.keyCode,e.input.lastKeyCodeTime=Date.now(),!cY||!oY||13!=i.keyCode))if(229!=i.keyCode&&e.domObserver.forceFlush(),!aY||13!=i.keyCode||i.ctrlKey||i.altKey||i.metaKey)e.someProp("handleKeyDown",(t=>t(e,i)))||fZ(e,i)?i.preventDefault():RZ(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",(t=>t(e,GU(13,"Enter")))),e.input.lastIOSEnter=0)}),200)}},_Z.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},_Z.keypress=(e,t)=>{let i=t;if(r_(e)||!i.charCode||i.ctrlKey&&!i.altKey||lY&&i.metaKey)return;if(e.someProp("handleKeyPress",(t=>t(e,i))))return void i.preventDefault();let n=e.state.selection;if(!(n instanceof yU&&n.$from.sameParent(n.$to))){let t=String.fromCharCode(i.charCode),o=()=>e.state.tr.insertText(t).scrollIntoView();/[\r\n]/.test(t)||e.someProp("handleTextInput",(i=>i(e,n.$from.pos,n.$to.pos,t,o)))||e.dispatch(o()),i.preventDefault()}};const t_=lY?"metaKey":"ctrlKey";ZZ.mousedown=(e,t)=>{let i=t;e.input.shiftKey=i.shiftKey;let n=e_(e),o=Date.now(),r="singleClick";o-e.input.lastClick.time<500&&function(e,t){let i=t.x-e.clientX,n=t.y-e.clientY;return i*i+n*n<100}(i,e.input.lastClick)&&!i[t_]&&e.input.lastClick.button==i.button&&("singleClick"==e.input.lastClick.type?r="doubleClick":"doubleClick"==e.input.lastClick.type&&(r="tripleClick")),e.input.lastClick={time:o,x:i.clientX,y:i.clientY,type:r,button:i.button},e.input.mouseDown&&e.input.mouseDown.done();let s=e.posAtCoords(GZ(i));s&&("singleClick"==r?e.input.mouseDown=new n_(e,s,i,!!n):("doubleClick"==r?XZ:qZ)(e,s.pos,s.inside,i)?i.preventDefault():RZ(e,"pointer"))};class i_{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){0==e.buttons&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}}class n_ extends i_{constructor(e,t,i,n){let o,r;if(super(e),this.pos=t,this.event=i,this.flushed=n,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!i[t_],this.allowDefault=i.shiftKey,t.inside>-1)o=e.state.doc.nodeAt(t.inside),r=t.inside;else{let i=e.state.doc.resolve(t.pos);o=i.parent,r=i.depth?i.before():0}const s=n?null:i.target,a=s?e.docView.nearestDesc(s,!0):null;this.target=a&&1==a.nodeDOM.nodeType?a.nodeDOM:null;let{selection:l}=e.state;0==i.button&&(o.type.spec.draggable&&!1!==o.type.spec.selectable||l instanceof jU&&l.from<=r&&l.to>r)&&(this.mightDrag={node:o,pos:r,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!iY||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()),RZ(e,"pointer")}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout((()=>{this.view.isDestroyed||rZ(this.view)}))}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(GZ(e))),this.updateAllowDefault(e),this.allowDefault||!t?RZ(this.view,"pointer"):JZ(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||sY&&this.mightDrag&&!this.mightDrag.node.isAtom||oY&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(HZ(this.view,hU.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):RZ(this.view,"pointer")}move(e){this.updateAllowDefault(e),RZ(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return!!this.allowDefault&&(this.delayedSelectionSync=!0,!0)}}class o_ extends i_{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(0==e.buttons||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc))return void this.done();e.preventDefault(),RZ(this.view,"pointer");let t=this.view.posAtCoords(GZ(e)),i=t&&KZ(this.view,t.inside,!1);if(!i)return;let{doc:n}=this.view.state,o=this.startSelection,[r,s]=i.from<o.from?[o.to,i.from]:[o.from,i.to];HZ(this.view,yU.create(n,r,s),"pointer")}}function r_(e,t){return!!e.composing||!!(sY&&Math.abs(Date.now()-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}ZZ.touchstart=e=>{e.input.lastTouch=Date.now(),e_(e),RZ(e,"pointer")},ZZ.touchmove=e=>{e.input.lastTouch=Date.now(),RZ(e,"pointer")},ZZ.contextmenu=e=>e_(e);const s_=cY?5e3:-1;function a_(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout((()=>c_(e)),t))}function l_(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function M_(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let i=function(e,t){for(;;){if(3==e.nodeType&&t)return e;if(1==e.nodeType&&t>0){if("false"==e.contentEditable)return null;t=WU(e=e.childNodes[t-1])}else{if(!e.parentNode||BU(e))return null;t=UU(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),n=function(e,t){for(;;){if(3==e.nodeType&&t<e.nodeValue.length)return e;if(1==e.nodeType&&t<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[t],t=0}else{if(!e.parentNode||BU(e))return null;t=UU(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(i&&n&&i!=n){let t=n.pmViewDesc,o=e.domObserver.lastChangedTextNode;if(i==o||n==o)return o;if(!t||!t.isText(n.nodeValue))return n;if(e.input.compositionNode==n){let e=i.pmViewDesc;if(e&&e.isText(i.nodeValue))return n}}return i||n}function c_(e,t=!1){if(!(cY&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),l_(e),t||e.docView&&e.docView.dirty){let i=nZ(e),n=e.state.selection;return i&&!i.eq(n)?e.dispatch(e.state.tr.setSelection(i)):!e.markCursor&&!t||n.$from.node(n.$from.sharedDepth(n.to)).inlineContent?e.updateState(e.state):e.dispatch(e.state.tr.deleteSelection()),!0}return!1}}_Z.compositionstart=_Z.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,i=t.selection.$to;if(t.selection instanceof yU&&(t.storedMarks||!i.textOffset&&i.parentOffset&&i.nodeBefore.marks.some((e=>!1===e.type.spec.inclusive))||oY&&MY&&function(e){let{focusNode:t,focusOffset:i}=e.domSelectionRange();if(!t||1!=t.nodeType||i>=t.childNodes.length)return!1;let n=t.childNodes[i];return 1==n.nodeType&&"false"==n.contentEditable}(e)))e.markCursor=e.state.storedMarks||i.marks(),c_(e,!0),e.markCursor=null;else if(c_(e,!t.selection.empty),iY&&t.selection.empty&&i.parentOffset&&!i.textOffset&&i.nodeBefore.marks.length){let t=e.domSelectionRange();for(let i=t.focusNode,n=t.focusOffset;i&&1==i.nodeType&&0!=n;){let t=n<0?i.lastChild:i.childNodes[n-1];if(!t)break;if(3==t.nodeType){let i=e.domSelection();i&&i.collapse(t,t.nodeValue.length);break}i=t,n=-1}}e.input.composing=!0}a_(e,s_)},_Z.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now(),e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then((()=>e.domObserver.flush())),e.input.compositionID++,a_(e,20))};const u_=eY&&tY<15||aY&&gY<604;function g_(e,t,i,n,o){let r=LZ(e,t,i,n,e.state.selection.$from);if(e.someProp("handlePaste",(t=>t(e,o,r||AC.empty))))return!0;if(!r)return!1;let s=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(r),a=s?e.state.tr.replaceSelectionWith(s,n):e.state.tr.replaceSelection(r);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function d_(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let i=e.getData("text/uri-list");return i?i.replace(/\r?\n/g," "):""}ZZ.copy=_Z.cut=(e,t)=>{let i=t,n=e.state.selection,o="cut"==i.type;if(n.empty)return;let r=u_?null:i.clipboardData,s=n.content(),{dom:a,text:l}=bZ(e,s);r?(i.preventDefault(),r.clearData(),r.setData("text/html",a.innerHTML),r.setData("text/plain",l)):function(e,t){if(!e.dom.parentNode)return;let i=e.dom.parentNode.appendChild(document.createElement("div"));i.appendChild(t),i.style.cssText="position: fixed; left: -10000px; top: 10px";let n=getSelection(),o=document.createRange();o.selectNodeContents(t),e.dom.blur(),n.removeAllRanges(),n.addRange(o),setTimeout((()=>{i.parentNode&&i.parentNode.removeChild(i),e.focus()}),50)}(e,a),o&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},_Z.paste=(e,t)=>{let i=t;if(e.composing&&!cY)return;let n=u_?null:i.clipboardData,o=e.input.shiftKey&&45!=e.input.lastKeyCode;n&&g_(e,d_(n),n.getData("text/html"),o,i)?i.preventDefault():function(e,t){if(!e.dom.parentNode)return;let i=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,n=e.dom.parentNode.appendChild(document.createElement(i?"textarea":"div"));i||(n.contentEditable="true"),n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus();let o=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout((()=>{e.focus(),n.parentNode&&n.parentNode.removeChild(n),i?g_(e,n.value,null,o,t):g_(e,n.textContent,n.innerHTML,o,t)}),50)}(e,i)};class h_{constructor(e,t,i){this.slice=e,this.move=t,this.node=i}}const N_=lY?"altKey":"ctrlKey";function p_(e,t){let i;return e.someProp("dragCopies",(e=>{i=i||e(t)})),null!=i?!i:!t[N_]}ZZ.dragstart=(e,t)=>{let i=t,n=e.input.mouseDown;if(n&&n.done(),!i.dataTransfer)return;let o,r=e.state.selection,s=r.empty?null:e.posAtCoords(GZ(i));if(s&&s.pos>=r.from&&s.pos<=(r instanceof jU?r.to-1:r.to));else if(n&&n.mightDrag)o=jU.create(e.state.doc,n.mightDrag.pos);else if(i.target&&1==i.target.nodeType){let t=e.docView.nearestDesc(i.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=jU.create(e.state.doc,t.posBefore))}let a=(o||e.state.selection).content(),{dom:l,text:M,slice:c}=bZ(e,a);(!i.dataTransfer.files.length||!oY||rY>120)&&i.dataTransfer.clearData(),i.dataTransfer.setData(u_?"Text":"text/html",l.innerHTML),i.dataTransfer.effectAllowed="copyMove",u_||i.dataTransfer.setData("text/plain",M),e.dragging=new h_(c,p_(e,i),o)},ZZ.dragend=e=>{let t=e.dragging;window.setTimeout((()=>{e.dragging==t&&(e.dragging=null)}),50)},_Z.dragover=_Z.dragenter=(e,t)=>t.preventDefault(),_Z.drop=(e,t)=>{try{!function(e,t,i){if(!t.dataTransfer)return;let n=e.posAtCoords(GZ(t));if(!n)return;let o=e.state.doc.resolve(n.pos),r=i&&i.slice;r?e.someProp("transformPasted",(t=>{r=t(r,e,!1)})):r=LZ(e,d_(t.dataTransfer),u_?null:t.dataTransfer.getData("text/html"),!1,o);let s=!(!i||!p_(e,t));if(e.someProp("handleDrop",(i=>i(e,t,r||AC.empty,s))))return void t.preventDefault();if(!r)return;t.preventDefault();let a=r?qQ(e.state.doc,o.pos,r):o.pos;null==a&&(a=o.pos);let l=e.state.tr;if(s){let{node:e}=i;e?e.replace(l):l.deleteSelection()}let M=l.mapping.map(a),c=0==r.openStart&&0==r.openEnd&&1==r.content.childCount,u=l.doc;c?l.replaceRangeWith(M,M,r.content.firstChild):l.replaceRange(M,M,r);if(l.doc.eq(u))return;let g=l.doc.resolve(M);if(c&&jU.isSelectable(r.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(r.content.firstChild))l.setSelection(new jU(g));else{let t=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach(((e,i,n,o)=>t=o)),l.setSelection(gZ(e,g,l.doc.resolve(t)))}e.focus(),e.dispatch(l.setMeta("uiEvent","drop"))}(e,t,e.dragging)}finally{e.dragging=null}},ZZ.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout((()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&rZ(e)}),20))},ZZ.blur=(e,t)=>{let i=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),i.relatedTarget&&e.dom.contains(i.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},ZZ.beforeinput=(e,t)=>{if(cY&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout((()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",(t=>t(e,GU(8,"Backspace")))))return;let{$cursor:i}=e.state.selection;i&&i.pos>0&&e.dispatch(e.state.tr.delete(i.pos-1,i.pos).scrollIntoView())}),50)}};for(let e in _Z)ZZ[e]=_Z[e];function D_(e,t){if(e==t)return!0;for(let i in e)if(e[i]!==t[i])return!1;for(let i in t)if(!(i in e))return!1;return!0}class y_{constructor(e,t){this.toDOM=e,this.spec=t||T_,this.side=this.spec.side||0}map(e,t,i,n){let{pos:o,deleted:r}=e.mapResult(t.from+n,this.side<0?-1:1);return r?null:new z_(o-i,o-i,this)}valid(){return!0}eq(e){return this==e||e instanceof y_&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&D_(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class I_{constructor(e,t){this.attrs=e,this.spec=t||T_}map(e,t,i,n){let o=e.map(t.from+n,this.spec.inclusiveStart?-1:1)-i,r=e.map(t.to+n,this.spec.inclusiveEnd?1:-1)-i;return o>=r?null:new z_(o,r,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof I_&&D_(this.attrs,e.attrs)&&D_(this.spec,e.spec)}static is(e){return e.type instanceof I_}destroy(){}}class j_{constructor(e,t){this.attrs=e,this.spec=t||T_}map(e,t,i,n){let o=e.mapResult(t.from+n,1);if(o.deleted)return null;let r=e.mapResult(t.to+n,-1);return r.deleted||r.pos<=o.pos?null:new z_(o.pos-i,r.pos-i,this)}valid(e,t){let i,{index:n,offset:o}=e.content.findIndex(t.from);return o==t.from&&!(i=e.child(n)).isText&&o+i.nodeSize==t.to}eq(e){return this==e||e instanceof j_&&D_(this.attrs,e.attrs)&&D_(this.spec,e.spec)}destroy(){}}class z_{constructor(e,t,i){this.from=e,this.to=t,this.type=i}copy(e,t){return new z_(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,i){return this.type.map(e,this,t,i)}static widget(e,t,i){return new z_(e,e,new y_(t,i))}static inline(e,t,i,n){return new z_(e,t,new I_(i,n))}static node(e,t,i,n){return new z_(e,t,new j_(i,n))}get spec(){return this.type.spec}get inline(){return this.type instanceof I_}get widget(){return this.type instanceof y_}}const m_=[],T_={};class x_{constructor(e,t){this.local=e.length?e:m_,this.children=t.length?t:m_}static create(e,t){return t.length?w_(t,e,0,T_):A_}find(e,t,i){let n=[];return this.findInner(null==e?0:e,null==t?1e9:t,n,0,i),n}findInner(e,t,i,n,o){for(let r=0;r<this.local.length;r++){let s=this.local[r];s.from<=t&&s.to>=e&&(!o||o(s.spec))&&i.push(s.copy(s.from+n,s.to+n))}for(let r=0;r<this.children.length;r+=3)if(this.children[r]<t&&this.children[r+1]>e){let s=this.children[r]+1;this.children[r+2].findInner(e-s,t-s,i,n+s,o)}}map(e,t,i){return this==A_||0==e.maps.length?this:this.mapInner(e,t,0,0,i||T_)}mapInner(e,t,i,n,o){let r;for(let s=0;s<this.local.length;s++){let a=this.local[s].map(e,i,n);a&&a.type.valid(t,a)?(r||(r=[])).push(a):o.onRemove&&o.onRemove(this.local[s].spec)}return this.children.length?function(e,t,i,n,o,r,s){let a=e.slice();for(let e=0,t=r;e<i.maps.length;e++){let n=0;i.maps[e].forEach(((e,i,o,r)=>{let s=r-o-(i-e);for(let o=0;o<a.length;o+=3){let r=a[o+1];if(r<0||e>r+t-n)continue;let l=a[o]+t-n;i>=l?a[o+1]=e<=l?-2:-1:e>=t&&s&&(a[o]+=s,a[o+1]+=s)}n+=s})),t=i.maps[e].map(t,-1)}let l=!1;for(let t=0;t<a.length;t+=3)if(a[t+1]<0){if(-2==a[t+1]){l=!0,a[t+1]=-1;continue}let M=i.map(e[t]+r),c=M-o;if(c<0||c>=n.content.size){l=!0;continue}let u=i.map(e[t+1]+r,-1)-o,{index:g,offset:d}=n.content.findIndex(c),h=n.maybeChild(g);if(h&&d==c&&d+h.nodeSize==u){let n=a[t+2].mapInner(i,h,M+1,e[t]+r+1,s);n!=A_?(a[t]=c,a[t+1]=u,a[t+2]=n):(a[t+1]=-2,l=!0)}else l=!0}if(l){let l=function(e,t,i,n,o,r,s){function a(e,t){for(let r=0;r<e.local.length;r++){let a=e.local[r].map(n,o,t);a?i.push(a):s.onRemove&&s.onRemove(e.local[r].spec)}for(let i=0;i<e.children.length;i+=3)a(e.children[i+2],e.children[i]+t+1)}for(let i=0;i<e.length;i+=3)-1==e[i+1]&&a(e[i+2],t[i]+r+1);return i}(a,e,t,i,o,r,s),M=w_(l,n,0,s);t=M.local;for(let e=0;e<a.length;e+=3)a[e+1]<0&&(a.splice(e,3),e-=3);for(let e=0,t=0;e<M.children.length;e+=3){let i=M.children[e];for(;t<a.length&&a[t]<i;)t+=3;a.splice(t,0,M.children[e],M.children[e+1],M.children[e+2])}}return new x_(t.sort(v_),a)}(this.children,r||[],e,t,i,n,o):r?new x_(r.sort(v_),m_):A_}add(e,t){return t.length?this==A_?x_.create(e,t):this.addInner(e,t,0):this}addInner(e,t,i){let n,o=0;e.forEach(((e,r)=>{let s,a=r+i;if(s=b_(t,e,a)){for(n||(n=this.children.slice());o<n.length&&n[o]<r;)o+=3;n[o]==r?n[o+2]=n[o+2].addInner(e,s,a+1):n.splice(o,0,r,r+e.nodeSize,w_(s,e,a+1,T_)),o+=3}}));let r=f_(o?L_(t):t,-i);for(let t=0;t<r.length;t++)r[t].type.valid(e,r[t])||r.splice(t--,1);return new x_(r.length?this.local.concat(r).sort(v_):this.local,n||this.children)}remove(e){return 0==e.length||this==A_?this:this.removeInner(e,0)}removeInner(e,t){let i=this.children,n=this.local;for(let n=0;n<i.length;n+=3){let o,r=i[n]+t,s=i[n+1]+t;for(let t,i=0;i<e.length;i++)(t=e[i])&&t.from>r&&t.to<s&&(e[i]=null,(o||(o=[])).push(t));if(!o)continue;i==this.children&&(i=this.children.slice());let a=i[n+2].removeInner(o,r+1);a!=A_?i[n+2]=a:(i.splice(n,3),n-=3)}if(n.length)for(let i,o=0;o<e.length;o++)if(i=e[o])for(let e=0;e<n.length;e++)n[e].eq(i,t)&&(n==this.local&&(n=this.local.slice()),n.splice(e--,1));return i==this.children&&n==this.local?this:n.length||i.length?new x_(n,i):A_}forChild(e,t){if(this==A_)return this;if(t.isLeaf)return x_.empty;let i,n;for(let t=0;t<this.children.length;t+=3)if(this.children[t]>=e){this.children[t]==e&&(i=this.children[t+2]);break}let o=e+1,r=o+t.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<r&&t.to>o&&t.type instanceof I_){let e=Math.max(o,t.from)-o,i=Math.min(r,t.to)-o;e<i&&(n||(n=[])).push(t.copy(e,i))}}if(n){let e=new x_(n.sort(v_),m_);return i?new O_([e,i]):e}return i||A_}eq(e){if(this==e)return!0;if(!(e instanceof x_)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return S_(this.localsInner(e))}localsInner(e){if(this==A_)return m_;if(e.inlineContent||!this.local.some(I_.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof I_||t.push(this.local[e]);return t}forEachSet(e){e(this)}}x_.empty=new x_([],[]),x_.removeOverlap=S_;const A_=x_.empty;class O_{constructor(e){this.members=e}map(e,t){const i=this.members.map((i=>i.map(e,t,T_)));return O_.from(i)}forChild(e,t){if(t.isLeaf)return x_.empty;let i=[];for(let n=0;n<this.members.length;n++){let o=this.members[n].forChild(e,t);o!=A_&&(o instanceof O_?i=i.concat(o.members):i.push(o))}return O_.from(i)}eq(e){if(!(e instanceof O_)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,i=!0;for(let n=0;n<this.members.length;n++){let o=this.members[n].localsInner(e);if(o.length)if(t){i&&(t=t.slice(),i=!1);for(let e=0;e<o.length;e++)t.push(o[e])}else t=o}return t?S_(i?t:t.sort(v_)):m_}static from(e){switch(e.length){case 0:return A_;case 1:return e[0];default:return new O_(e.every((e=>e instanceof x_))?e:e.reduce(((e,t)=>e.concat(t instanceof x_?t:t.members)),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function f_(e,t){if(!t||!e.length)return e;let i=[];for(let n=0;n<e.length;n++){let o=e[n];i.push(new z_(o.from+t,o.to+t,o.type))}return i}function b_(e,t,i){if(t.isLeaf)return null;let n=i+t.nodeSize,o=null;for(let t,r=0;r<e.length;r++)(t=e[r])&&t.from>i&&t.to<n&&((o||(o=[])).push(t),e[r]=null);return o}function L_(e){let t=[];for(let i=0;i<e.length;i++)null!=e[i]&&t.push(e[i]);return t}function w_(e,t,i,n){let o=[],r=!1;t.forEach(((t,s)=>{let a=b_(e,t,s+i);if(a){r=!0;let e=w_(a,t,i+s+1,n);e!=A_&&o.push(s,s+t.nodeSize,e)}}));let s=f_(r?L_(e):e,-i).sort(v_);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||(n.onRemove&&n.onRemove(s[e].spec),s.splice(e--,1));return s.length||o.length?new x_(s,o):A_}function v_(e,t){return e.from-t.from||e.to-t.to}function S_(e){let t=e;for(let i=0;i<t.length-1;i++){let n=t[i];if(n.from!=n.to)for(let o=i+1;o<t.length;o++){let r=t[o];if(r.from!=n.from){r.from<n.to&&(t==e&&(t=e.slice()),t[i]=n.copy(n.from,r.from),k_(t,o,n.copy(r.from,n.to)));break}r.to!=n.to&&(t==e&&(t=e.slice()),t[o]=r.copy(r.from,n.to),k_(t,o+1,r.copy(n.to,r.to)))}}return t}function k_(e,t,i){for(;t<e.length&&v_(i,e[t])>0;)t++;e.splice(t,0,i)}function E_(e){let t=[];return e.someProp("decorations",(i=>{let n=i(e.state);n&&n!=A_&&t.push(n)})),e.cursorWrapper&&t.push(x_.create(e.state.doc,[e.cursorWrapper.deco])),O_.from(t)}const C_={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Q_=eY&&tY<=11;class U_{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Y_{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new U_,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]);eY&&tY<=11&&t.some((e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length))?this.flushSoon():sY&&e.composing&&t.some((e=>"childList"==e.type&&"TR"==e.target.nodeName))?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()})),Q_&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.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,C_)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout((()=>this.flush()),20)}this.observer.disconnect()}this.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(dZ(this.view)){if(this.suppressingSelectionUpdates)return rZ(this.view);if(eY&&tY<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&PU(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t,i=new Set;for(let t=e.focusNode;t;t=YU(t))i.add(t);for(let n=e.anchorNode;n;n=YU(n))if(i.has(n)){t=n;break}let n=t&&this.view.docView.nearestDesc(t);return n&&n.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let i=e.domSelectionRange(),n=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(i)&&dZ(e)&&!this.ignoreSelectionChange(i),o=-1,r=-1,s=!1,a=[];if(e.editable)for(let e=0;e<t.length;e++){let i=this.registerMutation(t[e],a);i&&(o=o<0?i.from:Math.min(i.from,o),r=r<0?i.to:Math.max(i.to,r),i.typeOver&&(s=!0))}if(a.some((e=>"BR"==e.nodeName))&&(8==e.input.lastKeyCode||46==e.input.lastKeyCode||oY&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some((e=>"childList"==e.type&&e.removedNodes.length)))){for(let e of a)if("BR"==e.nodeName&&e.parentNode){let t=e.nextSibling;for(;t&&1==t.nodeType;){if("false"==t.contentEditable){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(iY&&a.length){let t=a.filter((e=>"BR"==e.nodeName));if(2==t.length){let[e,i]=t;e.parentNode&&e.parentNode.parentNode==i.parentNode?i.remove():e.remove()}else{let{focusNode:i}=this.currentSelection;for(let n of t){let t=n.parentNode;!t||"LI"!=t.nodeName||i&&V_(e,i)==t||n.remove()}}}let l=null;o<0&&n&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&$U(i)&&(l=nZ(e))&&l.eq(hU.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,rZ(e),this.currentSelection.set(i),e.scrollToSelection()):(o>-1||n)&&(o>-1&&(e.docView.markDirty(o,r),function(e){if(Z_.has(e))return;if(Z_.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)){if(e.requiresGeckoHackNode=iY,__)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."),__=!0}}(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,function(e,t){var i;let{focusNode:n,focusOffset:o}=e.domSelectionRange();for(let r of t)if("TR"==(null===(i=r.parentNode)||void 0===i?void 0:i.nodeName)){let t=r.nextSibling;for(;t&&"TD"!=t.nodeName&&"TH"!=t.nodeName;)t=t.nextSibling;if(t){let i=t;for(;;){let e=i.firstChild;if(!e||1!=e.nodeType||"false"==e.contentEditable||/^(BR|IMG)$/.test(e.nodeName))break;i=e}i.insertBefore(r,i.firstChild),n==r&&e.domSelection().collapse(r,o)}else r.parentNode.removeChild(r)}}(e,a)),this.handleDOMChange(o,r,s,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(i)||rZ(e),this.currentSelection.set(i))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let i=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(i==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!i||i.ignoreMutation(e))return null;if("childList"==e.type){for(let i=0;i<e.addedNodes.length;i++){let n=e.addedNodes[i];t.push(n),3==n.nodeType&&(this.lastChangedTextNode=n)}if(i.contentDOM&&i.contentDOM!=i.dom&&!i.contentDOM.contains(e.target))return{from:i.posBefore,to:i.posAfter};let n=e.previousSibling,o=e.nextSibling;if(eY&&tY<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:i,nextSibling:r}=e.addedNodes[t];(!i||Array.prototype.indexOf.call(e.addedNodes,i)<0)&&(n=i),(!r||Array.prototype.indexOf.call(e.addedNodes,r)<0)&&(o=r)}let r=n&&n.parentNode==e.target?UU(n)+1:0,s=i.localPosFromDOM(e.target,r,-1),a=o&&o.parentNode==e.target?UU(o):e.target.childNodes.length;return{from:s,to:i.localPosFromDOM(e.target,a,1)}}return"attributes"==e.type?{from:i.posAtStart-i.border,to:i.posAtEnd+i.border}:(this.lastChangedTextNode=e.target,{from:i.posAtStart,to:i.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Z_=new WeakMap,__=!1;function P_(e,t){let i=t.startContainer,n=t.startOffset,o=t.endContainer,r=t.endOffset,s=e.domAtPos(e.state.selection.anchor);return PU(s.node,s.offset,o,r)&&([i,n,o,r]=[o,r,i,n]),{anchorNode:i,anchorOffset:n,focusNode:o,focusOffset:r}}function V_(e,t){for(let i=t.parentNode;i&&i!=e.dom;i=i.parentNode){let t=e.docView.nearestDesc(i,!0);if(t&&t.node.isBlock)return i}return null}const R_=e=>t=>{let i=t.pmViewDesc;if(i)return i.parseRule(e);if("BR"==t.nodeName&&t.parentNode){if(sY&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}if(t.parentNode.lastChild==t||sY&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if("IMG"==t.nodeName&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null},W_=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function B_(e,t,i,n,o){let r=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,i=nZ(e,t);if(i&&!e.state.selection.eq(i)){if(oY&&cY&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",(t=>t(e,GU(13,"Enter")))))return;let n=e.state.tr.setSelection(i);"pointer"==t?n.setMeta("pointer",!0):"key"==t&&n.scrollIntoView(),r&&n.setMeta("composition",r),e.dispatch(n)}return}let s=e.state.doc.resolve(t),a=s.sharedDepth(i);t=s.before(a+1),i=e.state.doc.resolve(i).after(a+1);let l,M,c=e.state.selection,u=function(e,t,i,n){let o,{node:r,fromOffset:s,toOffset:a,from:l,to:M}=e.docView.parseRange(t,i),c=e.domSelectionRange(),u=c.anchorNode;if(u&&e.dom.contains(1==u.nodeType?u:u.parentNode)&&(o=[{node:u,offset:c.anchorOffset}],$U(c)||o.push({node:c.focusNode,offset:c.focusOffset})),oY&&8===e.input.lastKeyCode)for(let e=a;e>s;e--){let t=r.childNodes[e-1],i=t.pmViewDesc;if("BR"==t.nodeName&&!i){a=e;break}if(!i||i.size)break}let g=e.state.doc,d=e.someProp("domParser")||cQ.fromSchema(e.state.schema),h=g.resolve(l),N=null,p=d.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:s,to:a,preserveWhitespace:"pre"!=h.parent.type.whitespace||"full",findPositions:o,ruleFromNode:R_(n),context:h});if(o&&null!=o[0].pos){let e=o[0].pos,t=o[1]&&o[1].pos;null==t&&(t=e),N={anchor:e+l,head:t+l}}return{doc:p,sel:N,from:l,to:M}}(e,t,i,o),g=e.state.doc,d=g.slice(u.from,u.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(l=e.state.selection.to,M="end"):(l=e.state.selection.from,M="start"),e.input.lastKeyCode=null;let h=function(e,t,i,n,o){let r=e.findDiffStart(t,i),s=i+e.size,a=i+t.size;if(null==r)return null;let{a:l,b:M}=e.findDiffEnd(t,s,a);if("end"==o){n-=l+Math.max(0,r-Math.min(l,M))-r}if(l<r&&s<a){r-=n<=r&&n>=l?r-n:0,M=r+(M-l),l=r}else if(M<r){r-=n<=r&&n>=M?r-n:0,l=r+(l-M),M=r}return{start:r,endA:l,endB:M}}(d.content,u.doc.content,u.from,l,M);if(h&&e.input.domChangeCount++,(aY&&e.input.lastIOSEnter>Date.now()-225||cY)&&o.some((e=>1==e.nodeType&&!W_.test(e.nodeName)))&&(!h||h.endA>=h.endB)&&e.someProp("handleKeyDown",(t=>t(e,GU(13,"Enter")))))return void(e.input.lastIOSEnter=0);if(!h){if(!(n&&c instanceof yU&&!c.empty&&c.$head.sameParent(c.$anchor))||e.composing||u.sel&&u.sel.anchor!=u.sel.head){if(u.sel){let t=$_(e,e.state.doc,u.sel);if(t&&!t.eq(e.state.selection)){let i=e.state.tr.setSelection(t);r&&i.setMeta("composition",r),e.dispatch(i)}}return}h={start:c.from,endA:c.to,endB:c.to}}e.state.selection.from<e.state.selection.to&&h.start==h.endB&&e.state.selection instanceof yU&&(h.start>e.state.selection.from&&h.start<=e.state.selection.from+2&&e.state.selection.from>=u.from?h.start=e.state.selection.from:h.endA<e.state.selection.to&&h.endA>=e.state.selection.to-2&&e.state.selection.to<=u.to&&(h.endB+=e.state.selection.to-h.endA,h.endA=e.state.selection.to)),eY&&tY<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>u.from&&"  "==u.doc.textBetween(h.start-u.from-1,h.start-u.from+1)&&(h.start--,h.endA--,h.endB--);let N=u.doc.resolveNoCache(h.start-u.from),p=u.doc.resolveNoCache(h.endB-u.from),D=g.resolve(h.start),y=N.sameParent(p)&&N.parent.inlineContent&&D.end()>=h.endA;if((aY&&e.input.lastIOSEnter>Date.now()-225&&(!y||o.some((e=>"DIV"==e.nodeName||"P"==e.nodeName)))||!y&&N.pos<u.doc.content.size&&(!N.sameParent(p)||!N.parent.inlineContent)&&N.pos<p.pos&&!/\S/.test(u.doc.textBetween(N.pos,p.pos,"","")))&&e.someProp("handleKeyDown",(t=>t(e,GU(13,"Enter")))))return void(e.input.lastIOSEnter=0);if(e.state.selection.anchor>h.start&&function(e,t,i,n,o){if(i-t<=o.pos-n.pos||G_(n,!0,!1)<o.pos)return!1;let r=e.resolve(t);if(!n.parent.isTextblock){let e=r.nodeAfter;return null!=e&&i==t+e.nodeSize}if(r.parentOffset<r.parent.content.size||!r.parent.isTextblock)return!1;let s=e.resolve(G_(r,!0,!0));return!(!s.parent.isTextblock||s.pos>i||G_(s,!0,!1)<i)&&n.parent.content.cut(n.parentOffset).eq(s.parent.content)}(g,h.start,h.endA,N,p)&&e.someProp("handleKeyDown",(t=>t(e,GU(8,"Backspace")))))return void(cY&&oY&&e.domObserver.suppressSelectionUpdates());oY&&h.endB==h.start&&(e.input.lastChromeDelete=Date.now()),cY&&!y&&N.start()!=p.start()&&0==p.parentOffset&&N.depth==p.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==h.endA&&(h.endB-=2,p=u.doc.resolveNoCache(h.endB-u.from),setTimeout((()=>{e.someProp("handleKeyDown",(function(t){return t(e,GU(13,"Enter"))}))}),20));let I,j=h.start,z=h.endA,m=t=>{let i=t||e.state.tr.replace(j,z,u.doc.slice(h.start-u.from,h.endB-u.from));if(u.sel){let t=$_(e,i.doc,u.sel);t&&!(oY&&e.composing&&t.empty&&(h.start!=h.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==j||t.head==i.mapping.map(z)-1)||eY&&t.empty&&t.head==j)&&i.setSelection(t)}return r&&i.setMeta("composition",r),i.scrollIntoView()};if(y)if(N.pos==p.pos){eY&&tY<=11&&0==N.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout((()=>rZ(e)),20));let t=m(e.state.tr.delete(j,z)),i=g.resolve(h.start).marksAcross(g.resolve(h.endA));i&&t.ensureMarks(i),e.dispatch(t)}else if(h.endA==h.endB&&(I=function(e,t){let i,n,o,r=e.firstChild.marks,s=t.firstChild.marks,a=r,l=s;for(let e=0;e<s.length;e++)a=s[e].removeFromSet(a);for(let e=0;e<r.length;e++)l=r[e].removeFromSet(l);if(1==a.length&&0==l.length)n=a[0],i="add",o=e=>e.mark(n.addToSet(e.marks));else{if(0!=a.length||1!=l.length)return null;n=l[0],i="remove",o=e=>e.mark(n.removeFromSet(e.marks))}let M=[];for(let e=0;e<t.childCount;e++)M.push(o(t.child(e)));if(IC.from(M).eq(e))return{mark:n,type:i}}(N.parent.content.cut(N.parentOffset,p.parentOffset),D.parent.content.cut(D.parentOffset,h.endA-D.start())))){let t=m(e.state.tr);"add"==I.type?t.addMark(j,z,I.mark):t.removeMark(j,z,I.mark),e.dispatch(t)}else if(N.parent.child(N.index()).isText&&N.index()==p.index()-(p.textOffset?0:1)){let t=N.parent.textBetween(N.parentOffset,p.parentOffset),i=()=>m(e.state.tr.insertText(t,j,z));e.someProp("handleTextInput",(n=>n(e,j,z,t,i)))||e.dispatch(i())}else e.dispatch(m());else e.dispatch(m())}function $_(e,t,i){return Math.max(i.anchor,i.head)>t.content.size?null:gZ(e,t.resolve(i.anchor),t.resolve(i.head))}function G_(e,t,i){let n=e.depth,o=t?e.end():e.pos;for(;n>0&&(t||e.indexAfter(n)==e.node(n).childCount);)n--,o++,t=!1;if(i){let t=e.node(n).maybeChild(e.indexAfter(n));for(;t&&!t.isLeaf;)t=t.firstChild,o++}return o}class F_{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new VZ,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(K_),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=X_(this),J_(this),this.nodeViews=q_(this),this.docView=PY(this.state.doc,H_(this),E_(this),this.dom,this),this.domObserver=new Y_(this,((e,t,i,n)=>B_(this,e,t,i,n))),this.domObserver.start(),function(e){for(let t in ZZ){let i=ZZ[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!$Z(e,t)||BZ(e,t)||!e.editable&&t.type in _Z||i(e,t)},PZ[t]?{passive:!0}:void 0)}sY&&e.dom.addEventListener("input",(()=>null)),WZ(e)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&WZ(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(K_),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let i in e)t[i]=e[i];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var i;let n=this.state,o=!1,r=!1;e.storedMarks&&this.composing&&(l_(this),r=!0),this.state=e;let s=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(s||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=q_(this);(function(e,t){let i=0,n=0;for(let n in e){if(e[n]!=t[n])return!0;i++}for(let e in t)n++;return i!=n})(e,this.nodeViews)&&(this.nodeViews=e,o=!0)}(s||t.handleDOMEvents!=this._props.handleDOMEvents)&&WZ(this),this.editable=X_(this),J_(this);let a=E_(this),l=H_(this),M=n.plugins==e.plugins||n.doc.eq(e.doc)?e.scrollToSelection>n.scrollToSelection?"to selection":"preserve":"reset",c=o||!this.docView.matchesNode(e.doc,l,a);!c&&e.selection.eq(n.selection)||(r=!0);let u="preserve"==M&&r&&null==this.dom.style.overflowAnchor&&function(e){let t,i,n=e.dom.getBoundingClientRect(),o=Math.max(0,n.top);for(let r=(n.left+n.right)/2,s=o+1;s<Math.min(innerHeight,n.bottom);s+=5){let n=e.root.elementFromPoint(r,s);if(!n||n==e.dom||!e.dom.contains(n))continue;let a=n.getBoundingClientRect();if(a.top>=o-20){t=n,i=a.top;break}}return{refDOM:t,refTop:i,stack:DY(e.dom)}}(this);if(r){this.domObserver.stop();let t=c&&(eY||oY)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&function(e,t){let i=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(i)!=t.$anchor.start(i)}(n.selection,e.selection);if(c){let i=oY?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=M_(this)),!o&&this.docView.update(e.doc,l,a,this)||(this.docView.updateOuterDeco(l),this.docView.destroy(),this.docView=PY(e.doc,l,a,this.dom,this)),!i||this.trackWrites&&this.dom.contains(this.trackWrites)||(t=!0)}let i=this.input.mouseDown;t||!(i&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),i=e.domSelectionRange();return PU(t.node,t.offset,i.anchorNode,i.anchorOffset)}(this)&&i.delaySelUpdate())?rZ(this,t):(cZ(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),(null===(i=this.dragging)||void 0===i?void 0:i.node)&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),"reset"==M?this.dom.scrollTop=0:"to selection"==M?this.scrollToSelection():u&&function({refDOM:e,refTop:t,stack:i}){let n=e?e.getBoundingClientRect().top:0;yY(i,0==n?0:n-t)}(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&this.dom.contains(1==e.nodeType?e:e.parentNode))if(this.someProp("handleScrollToSelection",(e=>e(this))));else if(this.state.selection instanceof jU){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&pY(this,t.getBoundingClientRect(),e)}else pY(this,this.coordsAtPos(this.state.selection.head,1),e);else;}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(e&&e.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let t=0;t<this.pluginViews.length;t++){let i=this.pluginViews[t];i.update&&i.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}}updateDraggedNode(e,t){let i=e.node,n=-1;if(i.from<this.state.doc.content.size&&this.state.doc.nodeAt(i.from)==i.node)n=i.from;else{let e=i.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==i.node&&(n=e)}this.dragging=new h_(e.slice,e.move,n<0?void 0:jU.create(this.state.doc,n))}someProp(e,t){let i,n=this._props&&this._props[e];if(null!=n&&(i=t?t(n):n))return i;for(let n=0;n<this.directPlugins.length;n++){let o=this.directPlugins[n].props[e];if(null!=o&&(i=t?t(o):o))return i}let o=this.state.plugins;if(o)for(let n=0;n<o.length;n++){let r=o[n].props[e];if(null!=r&&(i=t?t(r):r))return i}}hasFocus(){if(eY){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(IY)return e.focus(IY);let t=DY(e);e.focus(null==IY?{get preventScroll(){return IY={preventScroll:!0},!0}}:void 0),IY||(IY=!1,yY(t,0))}(this.dom),rZ(this),this.domObserver.start()}get root(){let e=this._root;if(null==e)for(let e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e;return e||document}updateRoot(){this._root=null}posAtCoords(e){return TY(this,e)}coordsAtPos(e,t=1){return fY(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,i=-1){let n=this.docView.posFromDOM(e,t,i);if(null==n)throw new RangeError("DOM position not inside the editor");return n}endOfTextblock(e,t){return CY(this,t||this.state,e)}pasteHTML(e,t){return g_(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return g_(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return bZ(this,e)}destroy(){this.docView&&(!function(e){e.input.mouseDown&&e.input.mouseDown.done(),e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],E_(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,ZU=null)}get isDestroyed(){return null==this.docView}dispatchEvent(e){return function(e,t){BZ(e,t)||!ZZ[t.type]||!e.editable&&t.type in _Z||ZZ[t.type](e,t)}(this,e)}domSelectionRange(){let e=this.domSelection();return e?sY&&11===this.root.nodeType&&function(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom&&function(e,t){if(t.getComposedRanges){let i=t.getComposedRanges(e.root)[0];if(i)return P_(e,i)}let i;function n(e){e.preventDefault(),e.stopImmediatePropagation(),i=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",n,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",n,!0),i?P_(e,i):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function H_(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",(i=>{if("function"==typeof i&&(i=i(e.state)),i)for(let e in i)"class"==e?t.class+=" "+i[e]:"style"==e?t.style=(t.style?t.style+";":"")+i[e]:t[e]||"contenteditable"==e||"nodeName"==e||(t[e]=String(i[e]))})),t.translate||(t.translate="no"),[z_.node(0,e.state.doc.content.size,t)]}function J_(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:z_.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function X_(e){return!e.someProp("editable",(t=>!1===t(e.state)))}function q_(e){let t=Object.create(null);function i(e){for(let i in e)Object.prototype.hasOwnProperty.call(t,i)||(t[i]=e[i])}return e.someProp("nodeViews",i),e.someProp("markViews",i),t}function K_(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}F_.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};const eP=s`
22892
22956
  :host {
22893
22957
  display: block;
22894
22958
  font-family: var(