This repository has been archived by the owner on Jul 7, 2022. It is now read-only.
forked from getkirby/editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
1 lines (1 loc) · 250 KB
/
index.js
1
(function () {function Ek(e,t){return Ck(e)||Dk(e,t)||eh()}function eh(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function Dk(e,t){var o=[],r=!0,n=!1,a=void 0;try{for(var i,l=e[Symbol.iterator]();!(r=(i=l.next()).done)&&(o.push(i.value),!t||o.length!==t);r=!0);}catch(d){n=!0,a=d}finally{try{r||null==l.return||l.return()}finally{if(n)throw a}}return o}function Ck(e){if(Array.isArray(e))return e}var dc,Jb={};!function(t,e){if("object"==typeof Jb)Jb=e();else if("function"==typeof dc&&dc.amd)dc([],e);else if("object"==typeof Jb){var n=e();Jb.ClipboardJS=n}else t.ClipboardJS=e()}(Jb,function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),i=u(n(1)),a=u(n(3)),c=u(n(4));function u(t){return t&&t.__esModule?t:{default:t}}var l=function(t){function e(t,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);var r=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return r.resolveOptions(n),r.listenClick(t),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,a.default),o(e,[{key:"resolveOptions",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.action="function"==typeof t.action?t.action:this.defaultAction,this.target="function"==typeof t.target?t.target:this.defaultTarget,this.text="function"==typeof t.text?t.text:this.defaultText,this.container="object"===r(t.container)?t.container:document.body}},{key:"listenClick",value:function(t){var e=this;this.listener=(0,c.default)(t,"click",function(t){return e.onClick(t)})}},{key:"onClick",value:function(t){var e=t.delegateTarget||t.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new i.default({action:this.action(e),target:this.target(e),text:this.text(e),container:this.container,trigger:e,emitter:this})}},{key:"defaultAction",value:function(t){return s("action",t)}},{key:"defaultTarget",value:function(t){var e=s("target",t);if(e)return document.querySelector(e)}},{key:"defaultText",value:function(t){return s("text",t)}},{key:"destroy",value:function(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}],[{key:"isSupported",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["copy","cut"],e="string"==typeof t?[t]:t,n=!!document.queryCommandSupported;return e.forEach(function(t){n=n&&!!document.queryCommandSupported(t)}),n}}]),e}();function s(t,e){var n="data-clipboard-"+t;if(e.hasAttribute(n))return e.getAttribute(n)}t.exports=l},function(t,e,n){var r,o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),a=n(2),c=(r=a)&&r.__esModule?r:{default:r};var u=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.resolveOptions(e),this.initSelection()}return i(t,[{key:"resolveOptions",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.action=t.action,this.container=t.container,this.emitter=t.emitter,this.target=t.target,this.text=t.text,this.trigger=t.trigger,this.selectedText=""}},{key:"initSelection",value:function(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"selectFake",value:function(){var t=this,e="rtl"==document.documentElement.getAttribute("dir");this.removeFake(),this.fakeHandlerCallback=function(){return t.removeFake()},this.fakeHandler=this.container.addEventListener("click",this.fakeHandlerCallback)||!0,this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[e?"right":"left"]="-9999px";var n=window.pageYOffset||document.documentElement.scrollTop;this.fakeElem.style.top=n+"px",this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,this.container.appendChild(this.fakeElem),this.selectedText=(0,c.default)(this.fakeElem),this.copyText()}},{key:"removeFake",value:function(){this.fakeHandler&&(this.container.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(this.container.removeChild(this.fakeElem),this.fakeElem=null)}},{key:"selectTarget",value:function(){this.selectedText=(0,c.default)(this.target),this.copyText()}},{key:"copyText",value:function(){var t=void 0;try{t=document.execCommand(this.action)}catch(e){t=!1}this.handleResult(t)}},{key:"handleResult",value:function(t){this.emitter.emit(t?"success":"error",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})}},{key:"clearSelection",value:function(){this.trigger&&this.trigger.focus(),window.getSelection().removeAllRanges()}},{key:"destroy",value:function(){this.removeFake()}},{key:"action",set:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"copy";if(this._action=t,"copy"!==this._action&&"cut"!==this._action)throw new Error("Invalid \"action\" value, use either \"copy\" or \"cut\"")},get:function(){return this._action}},{key:"target",set:function(t){if(void 0!==t){if(!t||"object"!==(void 0===t?"undefined":o(t))||1!==t.nodeType)throw new Error("Invalid \"target\" value, use a valid Element");if("copy"===this.action&&t.hasAttribute("disabled"))throw new Error("Invalid \"target\" attribute. Please use \"readonly\" instead of \"disabled\" attribute");if("cut"===this.action&&(t.hasAttribute("readonly")||t.hasAttribute("disabled")))throw new Error("Invalid \"target\" attribute. You can't cut text from elements with \"readonly\" or \"disabled\" attributes");this._target=t}},get:function(){return this._target}}]),t}();t.exports=u},function(t,e){t.exports=function(t){var e;if("SELECT"===t.nodeName)t.focus(),e=t.value;else if("INPUT"===t.nodeName||"TEXTAREA"===t.nodeName){var n=t.hasAttribute("readonly");n||t.setAttribute("readonly",""),t.select(),t.setSelectionRange(0,t.value.length),n||t.removeAttribute("readonly"),e=t.value}else{t.hasAttribute("contenteditable")&&t.focus();var r=window.getSelection(),o=document.createRange();o.selectNodeContents(t),r.removeAllRanges(),r.addRange(o),e=r.toString()}return e}},function(t,e){function n(){}n.prototype={on:function(t,e,n){var r=this.e||(this.e={});return(r[t]||(r[t]=[])).push({fn:e,ctx:n}),this},once:function(t,e,n){var r=this;function o(){r.off(t,o),e.apply(n,arguments)}return o._=e,this.on(t,o,n)},emit:function(t){for(var e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),r=0,o=n.length;r<o;r++)n[r].fn.apply(n[r].ctx,e);return this},off:function(t,e){var n=this.e||(this.e={}),r=n[t],o=[];if(r&&e)for(var i=0,a=r.length;i<a;i++)r[i].fn!==e&&r[i].fn._!==e&&o.push(r[i]);return o.length?n[t]=o:delete n[t],this}},t.exports=n},function(t,e,n){var r=n(5),o=n(6);t.exports=function(t,e,n){if(!t&&!e&&!n)throw new Error("Missing required arguments");if(!r.string(e))throw new TypeError("Second argument must be a String");if(!r.fn(n))throw new TypeError("Third argument must be a Function");if(r.node(t))return function(t,e,n){return t.addEventListener(e,n),{destroy:function(){t.removeEventListener(e,n)}}}(t,e,n);if(r.nodeList(t))return function(t,e,n){return Array.prototype.forEach.call(t,function(t){t.addEventListener(e,n)}),{destroy:function(){Array.prototype.forEach.call(t,function(t){t.removeEventListener(e,n)})}}}(t,e,n);if(r.string(t))return function(t,e,n){return o(document.body,t,e,n)}(t,e,n);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}},function(t,e){e.node=function(t){return void 0!==t&&t instanceof HTMLElement&&1===t.nodeType},e.nodeList=function(t){var n=Object.prototype.toString.call(t);return void 0!==t&&("[object NodeList]"===n||"[object HTMLCollection]"===n)&&"length"in t&&(0===t.length||e.node(t[0]))},e.string=function(t){return"string"==typeof t||t instanceof String},e.fn=function(t){return"[object Function]"===Object.prototype.toString.call(t)}},function(t,e,n){var r=n(7);function o(t,e,n,o,i){var a=function(t,e,n,o){return function(n){n.delegateTarget=r(n.target,e),n.delegateTarget&&o.call(t,n)}}.apply(this,arguments);return t.addEventListener(n,a,i),{destroy:function(){t.removeEventListener(n,a,i)}}}t.exports=function(t,e,n,r,i){return"function"==typeof t.addEventListener?o.apply(null,arguments):"function"==typeof n?o.bind(null,document).apply(null,arguments):("string"==typeof t&&(t=document.querySelectorAll(t)),Array.prototype.map.call(t,function(t){return o(t,e,n,r,i)}))}},function(t,e){var n=9;if("undefined"!=typeof Element&&!Element.prototype.matches){var r=Element.prototype;r.matches=r.matchesSelector||r.mozMatchesSelector||r.msMatchesSelector||r.oMatchesSelector||r.webkitMatchesSelector}t.exports=function(t,e){for(;t&&t.nodeType!==n;){if("function"==typeof t.matches&&t.matches(e))return t;t=t.parentNode}}}])});function _c(t){return wk(t)||xk(t)||yk()}function yk(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function xk(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}function wk(t){if(Array.isArray(t)){for(var o=0,e=new Array(t.length);o<t.length;o++)e[o]=t[o];return e}}function Nf(t){for(var o=1;o<arguments.length;o++){var e=null!=arguments[o]?arguments[o]:{},n=Object.keys(e);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(e).filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.forEach(function(o){sk(t,o,e[o])})}return t}function sk(t,o,e){return o in t?Object.defineProperty(t,o,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[o]=e,t}var rb={props:{blocks:Object,block:Object,menu:{type:Function,default:function(){return function(){return[]}}},sortable:{type:Boolean,default:!0}},data:function(){return{mode:null,menuItems:[]}},methods:{open:function(){this.menuItems=this.menu(),this.$refs.blockOptions.toggle(),this.$emit("focus")},close:function(){this.menuItems=[],this.$refs.blockOptions.close()},go:function(t){this.mode=t,this.$refs.blockOptions.open()},onClose:function(){this.mode=null}}};if(typeof rb==="function"){rb=rb.options}Object.assign(rb,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("nav",{staticClass:"k-editor-block-options"},[_c("button",{staticClass:"k-editor-block-option k-sort-handle",attrs:{"disabled":!_vm.sortable,"type":"button"}},[_c("k-icon",{attrs:{"type":"sort"}})],1),_vm._v(" "),_c("k-dropdown",[_c("button",{staticClass:"k-editor-block-option k-editor-block-options-sort",attrs:{"type":"button"},on:{"mousedown":function($event){$event.stopPropagation();return _vm.open($event)}}},[_c("k-icon",{attrs:{"type":"angle-down"}})],1),_vm._v(" "),_c("k-dropdown-content",{ref:"blockOptions",staticClass:"k-editor-block-option-dropdown",on:{"close":_vm.onClose},nativeOn:{"mousedown":function($event){$event.stopPropagation()}}},[_vm.mode==="insert"?[_c("k-dropdown-item",{staticClass:"k-editor-block-option-heading",attrs:{"icon":"angle-left"},on:{"click":function($event){return _vm.go()}}},[_vm._v(" "+_vm._s(_vm.$t("editor.options.insert.below"))+" \u2026 ")]),_vm._v(" "),_c("hr"),_vm._v(" "),_vm._l(_vm.blocks,function(definition){return _c("k-dropdown-item",{key:definition.type,attrs:{"icon":definition.icon},on:{"click":function($event){return _vm.$emit("add",definition.type)}}},[_vm._v(" "+_vm._s(definition.label)+" ")])})]:_vm.mode==="convert"?[_c("k-dropdown-item",{staticClass:"k-editor-block-option-heading",attrs:{"icon":"angle-left"},on:{"click":function($event){return _vm.go()}}},[_vm._v(" "+_vm._s(_vm.$t("editor.options.convert"))+" \u2026 ")]),_vm._v(" "),_c("hr"),_vm._v(" "),_vm._l(_vm.blocks,function(definition){return _vm.block.type!==definition.type?_c("k-dropdown-item",{key:definition.type,attrs:{"icon":definition.icon},on:{"click":function($event){return _vm.$emit("convert",definition.type)}}},[_vm._v(" "+_vm._s(definition.label)+" ")]):_vm._e()})]:[_c("k-dropdown-item",{attrs:{"icon":"add"},on:{"click":function($event){return _vm.go("insert")}}},[_vm._v(_vm._s(_vm.$t("editor.options.insert.below"))+" \u2026")]),_vm._v(" "),_c("hr"),_vm._v(" "),Object.keys(_vm.blocks).length>1?_c("k-dropdown-item",{attrs:{"icon":"refresh"},on:{"click":function($event){return _vm.go("convert")}}},[_vm._v(_vm._s(_vm.$t("editor.options.convert"))+" \u2026")]):_vm._e(),_vm._v(" "),_c("k-dropdown-item",{attrs:{"icon":"copy"},on:{"click":function($event){return _vm.$emit("duplicate")}}},[_vm._v(_vm._s(_vm.$t("editor.options.duplicate")))]),_vm._v(" "),_c("hr"),_vm._v(" "),_vm.menuItems.length?[_vm._l(_vm.menuItems,function(menuItem,index){return _c("k-dropdown-item",{key:index,attrs:{"icon":menuItem.icon,"disabled":menuItem.disabled},on:{"click":menuItem.click}},[_vm._v(" "+_vm._s(menuItem.label)+" ")])}),_vm._v(" "),_c("hr")]:_vm._e(),_vm._v(" "),_c("k-dropdown-item",{attrs:{"icon":"trash"},on:{"click":function($event){return _vm.$emit("remove")}}},[_vm._v(_vm._s(_vm.$t("editor.options.delete")))])]],2)],1)],1)};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());function rk(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},n=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.forEach(function(r){ok(e,r,t[r])})}return e}function ok(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}window.editor={blocks:{},block:function(e,r){(r=rk({},{type:e,icon:"page"},r)).bind={append:r.append,breaks:r.breaks,code:r.code,marks:r.marks,placeholder:r.placeholder},this.blocks[e]=r}};var Fc={icon:"quote",extends:"paragraph",breaks:!0};if(typeof Fc==="function"){Fc=Fc.options}var ub={inheritAttrs:!1,icon:"code",props:{content:String,attrs:[Object,Array]},languages:[{id:"bash",label:"Bash"},{id:"basic",label:"BASIC"},{id:"c",label:"C"},{id:"clojure",label:"Clojure"},{id:"cpp",label:"C++"},{id:"csharp",label:"C#"},{id:"css",label:"CSS"},{id:"diff",label:"Diff"},{id:"elixir",label:"Elixir"},{id:"elm",label:"Elm"},{id:"erlang",label:"Erlang"},{id:"go",label:"Go"},{id:"graphql",label:"GraphQL"},{id:"haskell",label:"Haskell"},{id:"html",label:"HTML"},{id:"java",label:"Java"},{id:"js",label:"JavaScript"},{id:"json",label:"JSON"},{id:"latext",label:"LaTeX"},{id:"less",label:"Less"},{id:"lisp",label:"Lisp"},{id:"lua",label:"Lua"},{id:"makefile",label:"Makefile"},{id:"markdown",label:"Markdown"},{id:"markup",label:"Markup"},{id:"objectivec",label:"Objective-C"},{id:"pascal",label:"Pascal"},{id:"perl",label:"Perl"},{id:"php",label:"PHP"},{id:"text",label:"Plain Text"},{id:"python",label:"Python"},{id:"r",label:"R"},{id:"ruby",label:"Ruby"},{id:"rust",label:"Rust"},{id:"sass",label:"Sass"},{id:"scss",label:"SCSS"},{id:"shell",label:"Shell"},{id:"sql",label:"SQL"},{id:"swift",label:"Swift"},{id:"typescript",label:"TypeScript"},{id:"vbnet",label:"VB.net"},{id:"xml",label:"XML"},{id:"yaml",label:"YAML"}],data:function(){return{language:this.attrs.language}},computed:{selectedLanguage:function(){var l=null,a=this.language||"text";return this.$options.languages.forEach(function(e){e.id===a&&(l=e.label)}),l}},methods:{focus:function(){this.$refs.editor.focus()},onInput:function(l){this.$emit("input",{content:l})},setLanguage:function(l){this.language=l,this.$emit("input",{attrs:{language:l}})}}};if(typeof ub==="function"){ub=ub.options}Object.assign(ub,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",{staticClass:"k-editor-code-block-wrapper"},[_c("k-editable",{ref:"editor",attrs:{"breaks":true,"code":true,"content":_vm.content},on:{"input":_vm.onInput}}),_vm._v(" "),_c("k-dropdown",{staticClass:"k-editor-code-block-languages"},[_c("k-button",{staticClass:"k-editor-code-block-languages-toggle",attrs:{"icon":"code"},on:{"click":function($event){return _vm.$refs.languages.toggle()}}},[_vm._v(_vm._s(_vm.selectedLanguage))]),_vm._v(" "),_c("k-dropdown-content",{ref:"languages",attrs:{"align":"right"}},_vm._l(_vm.$options.languages,function(language){return _c("k-dropdown-item",{key:language.id,on:{"click":function($event){return _vm.setLanguage(language.id)}}},[_vm._v(_vm._s(language.label))])}),1)],1)],1)};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());function lk(t){return ik(t)||jk(t)||kk()}function kk(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function jk(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}function ik(t){if(Array.isArray(t)){for(var o=0,e=new Array(t.length);o<t.length;o++)e[o]=t[o];return e}}function hk(t){return(hk="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var xj={};function C(r){this.content=r}C.prototype={constructor:C,find:function(r){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===r)return e;return-1},get:function(r){var e=this.find(r);return-1==e?void 0:this.content[e+1]},update:function(r,e,t){var n=t&&t!=r?this.remove(t):this,a=n.find(r),o=n.content.slice();return-1==a?o.push(t||r,e):(o[a+1]=e,t&&(o[a]=t)),new C(o)},remove:function(r){var e=this.find(r);if(-1==e)return this;var t=this.content.slice();return t.splice(e,2),new C(t)},addToStart:function(r,e){return new C([r,e].concat(this.remove(r).content))},addToEnd:function(r,e){var t=this.remove(r).content.slice();return t.push(r,e),new C(t)},addBefore:function(r,e,t){var n=this.remove(e),a=n.content.slice(),o=n.find(r);return a.splice(-1==o?a.length:o,0,e,t),new C(a)},forEach:function(r){for(var e=0;e<this.content.length;e+=2)r(this.content[e],this.content[e+1])},prepend:function(r){return(r=C.from(r)).size?new C(r.content.concat(this.subtract(r).content)):this},append:function(r){return(r=C.from(r)).size?new C(this.subtract(r).content.concat(r.content)):this},subtract:function(r){var e=this;r=C.from(r);for(var t=0;t<r.content.length;t+=2)e=e.remove(r.content[t]);return e},get size(){return this.content.length>>1}},C.from=function(r){if(r instanceof C)return r;var e=[];if(r)for(var t in r)e.push(t,r[t]);return new C(e)},xj=C;var H={};function wj(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(H,"__esModule",{value:!0});var Gf=wj(xj);function Df(t,e,r){for(var n=0;;n++){if(n==t.childCount||n==e.childCount)return t.childCount==e.childCount?null:r;var o=t.child(n),a=e.child(n);if(o!=a){if(!o.sameMarkup(a))return r;if(o.isText&&o.text!=a.text){for(var i=0;o.text[i]==a.text[i];i++)r++;return r}if(o.content.size||a.content.size){var s=Df(o.content,a.content,r+1);if(null!=s)return s}r+=o.nodeSize}else r+=o.nodeSize}}function tf(t,e,r,n){for(var o=t.childCount,a=e.childCount;;){if(0==o||0==a)return o==a?null:{a:r,b:n};var i=t.child(--o),s=e.child(--a),$=i.nodeSize;if(i!=s){if(!i.sameMarkup(s))return{a:r,b:n};if(i.isText&&i.text!=s.text){for(var S=0,p=Math.min(i.text.length,s.text.length);S<p&&i.text[i.text.length-S-1]==s.text[s.text.length-S-1];)S++,r--,n--;return{a:r,b:n}}if(i.content.size||s.content.size){var h=tf(i.content,s.content,r-1,n-1);if(h)return h}r-=$,n-=$}else r-=$,n-=$}}var b=function(t,e){if(this.content=t,this.size=e||0,null==e)for(var r=0;r<t.length;r++)this.size+=t[r].nodeSize},ob={firstChild:{},lastChild:{},childCount:{}};b.prototype.nodesBetween=function(t,e,r,n,o){void 0===n&&(n=0);for(var a=0,i=0;i<e;a++){var s=this.content[a],$=i+s.nodeSize;if($>t&&!1!==r(s,n+i,o,a)&&s.content.size){var S=i+1;s.nodesBetween(Math.max(0,t-S),Math.min(s.content.size,e-S),r,n+S)}i=$}},b.prototype.descendants=function(t){this.nodesBetween(0,this.size,t)},b.prototype.textBetween=function(t,e,r,n){var o="",a=!0;return this.nodesBetween(t,e,function(i,s){i.isText?(o+=i.text.slice(Math.max(t,s)-s,e-s),a=!r):i.isLeaf&&n?(o+=n,a=!r):!a&&i.isBlock&&(o+=r,a=!0)},0),o},b.prototype.append=function(t){if(!t.size)return this;if(!this.size)return t;var e=this.lastChild,r=t.firstChild,n=this.content.slice(),o=0;for(e.isText&&e.sameMarkup(r)&&(n[n.length-1]=e.withText(e.text+r.text),o=1);o<t.content.length;o++)n.push(t.content[o]);return new b(n,this.size+t.size)},b.prototype.cut=function(t,e){if(null==e&&(e=this.size),0==t&&e==this.size)return this;var r=[],n=0;if(e>t)for(var o=0,a=0;a<e;o++){var i=this.content[o],s=a+i.nodeSize;s>t&&((a<t||s>e)&&(i=i.isText?i.cut(Math.max(0,t-a),Math.min(i.text.length,e-a)):i.cut(Math.max(0,t-a-1),Math.min(i.content.size,e-a-1))),r.push(i),n+=i.nodeSize),a=s}return new b(r,n)},b.prototype.cutByIndex=function(t,e){return t==e?b.empty:0==t&&e==this.content.length?this:new b(this.content.slice(t,e))},b.prototype.replaceChild=function(t,e){var r=this.content[t];if(r==e)return this;var n=this.content.slice(),o=this.size+e.nodeSize-r.nodeSize;return n[t]=e,new b(n,o)},b.prototype.addToStart=function(t){return new b([t].concat(this.content),this.size+t.nodeSize)},b.prototype.addToEnd=function(t){return new b(this.content.concat(t),this.size+t.nodeSize)},b.prototype.eq=function(t){if(this.content.length!=t.content.length)return!1;for(var e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))return!1;return!0},ob.firstChild.get=function(){return this.content.length?this.content[0]:null},ob.lastChild.get=function(){return this.content.length?this.content[this.content.length-1]:null},ob.childCount.get=function(){return this.content.length},b.prototype.child=function(t){var e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e},b.prototype.maybeChild=function(t){return this.content[t]},b.prototype.forEach=function(t){for(var e=0,r=0;e<this.content.length;e++){var n=this.content[e];t(n,r,e),r+=n.nodeSize}},b.prototype.findDiffStart=function(t,e){return void 0===e&&(e=0),Df(this,t,e)},b.prototype.findDiffEnd=function(t,e,r){return void 0===e&&(e=this.size),void 0===r&&(r=t.size),tf(this,t,e,r)},b.prototype.findIndex=function(t,e){if(void 0===e&&(e=-1),0==t)return pb(0,t);if(t==this.size)return pb(this.content.length,t);if(t>this.size||t<0)throw new RangeError("Position "+t+" outside of fragment ("+this+")");for(var r=0,n=0;;r++){var o=n+this.child(r).nodeSize;if(o>=t)return o==t||e>0?pb(r+1,o):pb(r,n);n=o}},b.prototype.toString=function(){return"<"+this.toStringInner()+">"},b.prototype.toStringInner=function(){return this.content.join(", ")},b.prototype.toJSON=function(){return this.content.length?this.content.map(function(t){return t.toJSON()}):null},b.fromJSON=function(t,e){if(!e)return b.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new b(e.map(t.nodeFromJSON))},b.fromArray=function(t){if(!t.length)return b.empty;for(var e,r=0,n=0;n<t.length;n++){var o=t[n];r+=o.nodeSize,n&&o.isText&&t[n-1].sameMarkup(o)?(e||(e=t.slice(0,n)),e[e.length-1]=o.withText(e[e.length-1].text+o.text)):e&&e.push(o)}return new b(e||t,r)},b.from=function(t){if(!t)return b.empty;if(t instanceof b)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new b([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))},Object.defineProperties(b.prototype,ob);var kc={index:0,offset:0};function pb(t,e){return kc.index=t,kc.offset=e,kc}function qb(t,e){if(t===e)return!0;if(!t||"object"!=typeof t||!e||"object"!=typeof e)return!1;var r=Array.isArray(t);if(Array.isArray(e)!=r)return!1;if(r){if(t.length!=e.length)return!1;for(var n=0;n<t.length;n++)if(!qb(t[n],e[n]))return!1}else{for(var o in t)if(!(o in e&&qb(t[o],e[o])))return!1;for(var a in e)if(!(a in t))return!1}return!0}b.empty=new b([],0);var c=function(t,e){this.type=t,this.attrs=e};function O(t){var e=Error.call(this,t);return e.__proto__=O.prototype,e}c.prototype.addToSet=function(t){for(var e,r=!1,n=0;n<t.length;n++){var o=t[n];if(this.eq(o))return t;if(this.type.excludes(o.type))e||(e=t.slice(0,n));else{if(o.type.excludes(this.type))return t;!r&&o.type.rank>this.type.rank&&(e||(e=t.slice(0,n)),e.push(this),r=!0),e&&e.push(o)}}return e||(e=t.slice()),r||e.push(this),e},c.prototype.removeFromSet=function(t){for(var e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t},c.prototype.isInSet=function(t){for(var e=0;e<t.length;e++)if(this.eq(t[e]))return!0;return!1},c.prototype.eq=function(t){return this==t||this.type==t.type&&qb(this.attrs,t.attrs)},c.prototype.toJSON=function(){var t={type:this.type.name};for(var e in this.attrs){t.attrs=this.attrs;break}return t},c.fromJSON=function(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");var r=t.marks[e.type];if(!r)throw new RangeError("There is no mark type "+e.type+" in this schema");return r.create(e.attrs)},c.sameSet=function(t,e){if(t==e)return!0;if(t.length!=e.length)return!1;for(var r=0;r<t.length;r++)if(!t[r].eq(e[r]))return!1;return!0},c.setFrom=function(t){if(!t||0==t.length)return c.none;if(t instanceof c)return[t];var e=t.slice();return e.sort(function(t,e){return t.type.rank-e.type.rank}),e},c.none=[],O.prototype=Object.create(Error.prototype),O.prototype.constructor=O,O.prototype.name="ReplaceError";var p=function(t,e,r){this.content=t,this.openStart=e,this.openEnd=r},rf={size:{}};function qf(t,e,r){var n=t.findIndex(e),o=n.index,a=n.offset,i=t.maybeChild(o),s=t.findIndex(r),$=s.index,S=s.offset;if(a==e||i.isText){if(S!=r&&!t.child($).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(r))}if(o!=$)throw new RangeError("Removing non-flat range");return t.replaceChild(o,i.copy(qf(i.content,e-a-1,r-a-1)))}function pf(t,e,r,n){var o=t.findIndex(e),a=o.index,i=o.offset,s=t.maybeChild(a);if(i==e||s.isText)return n&&!n.canReplace(a,a,r)?null:t.cut(0,e).append(r).append(t.cut(e));var $=pf(s.content,e-i-1,r);return $&&t.replaceChild(a,s.copy($))}function Ei(t,e,r){if(r.openStart>t.depth)throw new O("Inserted content deeper than insertion position");if(t.depth-r.openStart!=e.depth-r.openEnd)throw new O("Inconsistent open depths");return gf(t,e,r,0)}function gf(t,e,r,n){var o=t.index(n),a=t.node(n);if(o==e.index(n)&&n<t.depth-r.openStart){var i=gf(t,e,r,n+1);return a.copy(a.content.replaceChild(o,i))}if(r.content.size){if(r.openStart||r.openEnd||t.depth!=n||e.depth!=n){var s=ci(r,t);return ma(a,af(t,s.start,s.end,e,n))}var $=t.parent,S=$.content;return ma($,S.cut(0,t.parentOffset).append(r.content).append(S.cut(e.parentOffset)))}return ma(a,fb(t,e,n))}function ff(t,e){if(!e.type.compatibleContent(t.type))throw new O("Cannot join "+e.type.name+" onto "+t.type.name)}function ic(t,e,r){var n=t.node(r);return ff(n,e.node(r)),n}function ka(t,e){var r=e.length-1;r>=0&&t.isText&&t.sameMarkup(e[r])?e[r]=t.withText(e[r].text+t.text):e.push(t)}function Xa(t,e,r,n){var o=(e||t).node(r),a=0,i=e?e.index(r):o.childCount;t&&(a=t.index(r),t.depth>r?a++:t.textOffset&&(ka(t.nodeAfter,n),a++));for(var s=a;s<i;s++)ka(o.child(s),n);e&&e.depth==r&&e.textOffset&&ka(e.nodeBefore,n)}function ma(t,e){if(!t.type.validContent(e))throw new O("Invalid content for node "+t.type.name);return t.copy(e)}function af(t,e,r,n,o){var a=t.depth>o&&ic(t,e,o+1),i=n.depth>o&&ic(r,n,o+1),s=[];return Xa(null,t,o,s),a&&i&&e.index(o)==r.index(o)?(ff(a,i),ka(ma(a,af(t,e,r,n,o+1)),s)):(a&&ka(ma(a,fb(t,e,o+1)),s),Xa(e,r,o,s),i&&ka(ma(i,fb(r,n,o+1)),s)),Xa(n,null,o,s),new b(s)}function fb(t,e,r){var n=[];(Xa(null,t,r,n),t.depth>r)&&ka(ma(ic(t,e,r+1),fb(t,e,r+1)),n);return Xa(e,null,r,n),new b(n)}function ci(t,e){for(var r=e.depth-t.openStart,n=e.node(r).copy(t.content),o=r-1;o>=0;o--)n=e.node(o).copy(b.from(n));return{start:n.resolveNoCache(t.openStart+r),end:n.resolveNoCache(n.content.size-t.openEnd-r)}}rf.size.get=function(){return this.content.size-this.openStart-this.openEnd},p.prototype.insertAt=function(t,e){var r=pf(this.content,t+this.openStart,e,null);return r&&new p(r,this.openStart,this.openEnd)},p.prototype.removeBetween=function(t,e){return new p(qf(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)},p.prototype.eq=function(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd},p.prototype.toString=function(){return this.content+"("+this.openStart+","+this.openEnd+")"},p.prototype.toJSON=function(){if(!this.content.size)return null;var t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t},p.fromJSON=function(t,e){if(!e)return p.empty;var r=e.openStart||0,n=e.openEnd||0;if("number"!=typeof r||"number"!=typeof n)throw new RangeError("Invalid input for Slice.fromJSON");return new p(b.fromJSON(t,e.content),e.openStart||0,e.openEnd||0)},p.maxOpen=function(t,e){void 0===e&&(e=!0);for(var r=0,n=0,o=t.firstChild;o&&!o.isLeaf&&(e||!o.type.spec.isolating);o=o.firstChild)r++;for(var a=t.lastChild;a&&!a.isLeaf&&(e||!a.type.spec.isolating);a=a.lastChild)n++;return new p(t,r,n)},Object.defineProperties(p.prototype,rf),p.empty=new p(b.empty,0,0);var l=function(t,e,r){this.pos=t,this.path=e,this.depth=e.length/3-1,this.parentOffset=r},wa={parent:{},doc:{},textOffset:{},nodeAfter:{},nodeBefore:{}};l.prototype.resolveDepth=function(t){return null==t?this.depth:t<0?this.depth+t:t},wa.parent.get=function(){return this.node(this.depth)},wa.doc.get=function(){return this.node(0)},l.prototype.node=function(t){return this.path[3*this.resolveDepth(t)]},l.prototype.index=function(t){return this.path[3*this.resolveDepth(t)+1]},l.prototype.indexAfter=function(t){return t=this.resolveDepth(t),this.index(t)+(t!=this.depth||this.textOffset?1:0)},l.prototype.start=function(t){return 0==(t=this.resolveDepth(t))?0:this.path[3*t-1]+1},l.prototype.end=function(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size},l.prototype.before=function(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]},l.prototype.after=function(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]+this.path[3*t].nodeSize},wa.textOffset.get=function(){return this.pos-this.path[this.path.length-1]},wa.nodeAfter.get=function(){var t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;var r=this.pos-this.path[this.path.length-1],n=t.child(e);return r?t.child(e).cut(r):n},wa.nodeBefore.get=function(){var t=this.index(this.depth),e=this.pos-this.path[this.path.length-1];return e?this.parent.child(t).cut(0,e):0==t?null:this.parent.child(t-1)},l.prototype.marks=function(){var t=this.parent,e=this.index();if(0==t.content.size)return c.none;if(this.textOffset)return t.child(e).marks;var r=t.maybeChild(e-1),n=t.maybeChild(e);if(!r){var o=r;r=n,n=o}for(var a=r.marks,i=0;i<a.length;i++)!1!==a[i].type.spec.inclusive||n&&a[i].isInSet(n.marks)||(a=a[i--].removeFromSet(a));return a},l.prototype.marksAcross=function(t){var e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;for(var r=e.marks,n=t.parent.maybeChild(t.index()),o=0;o<r.length;o++)!1!==r[o].type.spec.inclusive||n&&r[o].isInSet(n.marks)||(r=r[o--].removeFromSet(r));return r},l.prototype.sharedDepth=function(t){for(var e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0},l.prototype.blockRange=function(t,e){if(void 0===t&&(t=this),t.pos<this.pos)return t.blockRange(this);for(var r=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);r>=0;r--)if(t.pos<=this.end(r)&&(!e||e(this.node(r))))return new Yb(this,t,r)},l.prototype.sameParent=function(t){return this.pos-this.parentOffset==t.pos-t.parentOffset},l.prototype.max=function(t){return t.pos>this.pos?t:this},l.prototype.min=function(t){return t.pos<this.pos?t:this},l.prototype.toString=function(){for(var t="",e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset},l.resolve=function(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");for(var r=[],n=0,o=e,a=t;;){var i=a.content.findIndex(o),s=i.index,$=i.offset,S=o-$;if(r.push(a,s,n+$),!S)break;if((a=a.child(s)).isText)break;o=S-1,n+=$+1}return new l(e,r,o)},l.resolveCached=function(t,e){for(var r=0;r<Kc.length;r++){var n=Kc[r];if(n.pos==e&&n.doc==t)return n}var o=Kc[_e]=l.resolve(t,e);return _e=(_e+1)%ai,o},Object.defineProperties(l.prototype,wa);var Kc=[],_e=0,ai=12,Yb=function(t,e,r){this.$from=t,this.$to=e,this.depth=r},Aa={start:{},end:{},parent:{},startIndex:{},endIndex:{}};Aa.start.get=function(){return this.$from.before(this.depth+1)},Aa.end.get=function(){return this.$to.after(this.depth+1)},Aa.parent.get=function(){return this.$from.node(this.depth)},Aa.startIndex.get=function(){return this.$from.index(this.depth)},Aa.endIndex.get=function(){return this.$to.indexAfter(this.depth)},Object.defineProperties(Yb.prototype,Aa);var Wh=Object.create(null),a=function(t,e,r,n){this.type=t,this.attrs=e,this.content=r||b.empty,this.marks=n||c.none},I={nodeSize:{},childCount:{},textContent:{},firstChild:{},lastChild:{},isBlock:{},isTextblock:{},inlineContent:{},isInline:{},isText:{},isLeaf:{},isAtom:{}};I.nodeSize.get=function(){return this.isLeaf?1:2+this.content.size},I.childCount.get=function(){return this.content.childCount},a.prototype.child=function(t){return this.content.child(t)},a.prototype.maybeChild=function(t){return this.content.maybeChild(t)},a.prototype.forEach=function(t){this.content.forEach(t)},a.prototype.nodesBetween=function(t,e,r,n){void 0===n&&(n=0),this.content.nodesBetween(t,e,r,n,this)},a.prototype.descendants=function(t){this.nodesBetween(0,this.content.size,t)},I.textContent.get=function(){return this.textBetween(0,this.content.size,"")},a.prototype.textBetween=function(t,e,r,n){return this.content.textBetween(t,e,r,n)},I.firstChild.get=function(){return this.content.firstChild},I.lastChild.get=function(){return this.content.lastChild},a.prototype.eq=function(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)},a.prototype.sameMarkup=function(t){return this.hasMarkup(t.type,t.attrs,t.marks)},a.prototype.hasMarkup=function(t,e,r){return this.type==t&&qb(this.attrs,e||t.defaultAttrs||Wh)&&c.sameSet(this.marks,r||c.none)},a.prototype.copy=function(t){return void 0===t&&(t=null),t==this.content?this:new this.constructor(this.type,this.attrs,t,this.marks)},a.prototype.mark=function(t){return t==this.marks?this:new this.constructor(this.type,this.attrs,this.content,t)},a.prototype.cut=function(t,e){return 0==t&&e==this.content.size?this:this.copy(this.content.cut(t,e))},a.prototype.slice=function(t,e,r){if(void 0===e&&(e=this.content.size),void 0===r&&(r=!1),t==e)return p.empty;var n=this.resolve(t),o=this.resolve(e),a=r?0:n.sharedDepth(e),i=n.start(a),s=n.node(a).content.cut(n.pos-i,o.pos-i);return new p(s,n.depth-a,o.depth-a)},a.prototype.replace=function(t,e,r){return Ei(this.resolve(t),this.resolve(e),r)},a.prototype.nodeAt=function(t){for(var e=this;;){var r=e.content.findIndex(t),n=r.index,o=r.offset;if(!(e=e.maybeChild(n)))return null;if(o==t||e.isText)return e;t-=o+1}},a.prototype.childAfter=function(t){var e=this.content.findIndex(t),r=e.index,n=e.offset;return{node:this.content.maybeChild(r),index:r,offset:n}},a.prototype.childBefore=function(t){if(0==t)return{node:null,index:0,offset:0};var e=this.content.findIndex(t),r=e.index,n=e.offset;if(n<t)return{node:this.content.child(r),index:r,offset:n};var o=this.content.child(r-1);return{node:o,index:r-1,offset:n-o.nodeSize}},a.prototype.resolve=function(t){return l.resolveCached(this,t)},a.prototype.resolveNoCache=function(t){return l.resolve(this,t)},a.prototype.rangeHasMark=function(t,e,r){var n=!1;return e>t&&this.nodesBetween(t,e,function(t){return r.isInSet(t.marks)&&(n=!0),!n}),n},I.isBlock.get=function(){return this.type.isBlock},I.isTextblock.get=function(){return this.type.isTextblock},I.inlineContent.get=function(){return this.type.inlineContent},I.isInline.get=function(){return this.type.isInline},I.isText.get=function(){return this.type.isText},I.isLeaf.get=function(){return this.type.isLeaf},I.isAtom.get=function(){return this.type.isAtom},a.prototype.toString=function(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);var t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),Ye(this.marks,t)},a.prototype.contentMatchAt=function(t){var e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e},a.prototype.canReplace=function(t,e,r,n,o){void 0===r&&(r=b.empty),void 0===n&&(n=0),void 0===o&&(o=r.childCount);var a=this.contentMatchAt(t).matchFragment(r,n,o),i=a&&a.matchFragment(this.content,e);if(!i||!i.validEnd)return!1;for(var s=n;s<o;s++)if(!this.type.allowsMarks(r.child(s).marks))return!1;return!0},a.prototype.canReplaceWith=function(t,e,r,n){if(n&&!this.type.allowsMarks(n))return!1;var o=this.contentMatchAt(t).matchType(r),a=o&&o.matchFragment(this.content,e);return!!a&&a.validEnd},a.prototype.canAppend=function(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)},a.prototype.defaultContentType=function(t){return this.contentMatchAt(t).defaultType},a.prototype.check=function(){if(!this.type.validContent(this.content))throw new RangeError("Invalid content for node "+this.type.name+": "+this.content.toString().slice(0,50));this.content.forEach(function(t){return t.check()})},a.prototype.toJSON=function(){var t={type:this.type.name};for(var e in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map(function(t){return t.toJSON()})),t},a.fromJSON=function(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");var r=null;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=e.marks.map(t.markFromJSON)}if("text"==e.type){if("string"!=typeof e.text)throw new RangeError("Invalid text node in JSON");return t.text(e.text,r)}var n=b.fromJSON(t,e.content);return t.nodeType(e.type).create(e.attrs,n,r)},Object.defineProperties(a.prototype,I);var Vh=function(t){function e(e,r,n,o){if(t.call(this,e,r,null,o),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={textContent:{},nodeSize:{}};return e.prototype.toString=function(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Ye(this.marks,JSON.stringify(this.text))},r.textContent.get=function(){return this.text},e.prototype.textBetween=function(t,e){return this.text.slice(t,e)},r.nodeSize.get=function(){return this.text.length},e.prototype.mark=function(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)},e.prototype.withText=function(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)},e.prototype.cut=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.text.length),0==t&&e==this.text.length?this:this.withText(this.text.slice(t,e))},e.prototype.eq=function(t){return this.sameMarkup(t)&&this.text==t.text},e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.text=this.text,e},Object.defineProperties(e.prototype,r),e}(a);function Ye(t,e){for(var r=t.length-1;r>=0;r--)e=t[r].type.name+"("+e+")";return e}var v=function(t){this.validEnd=t,this.next=[],this.wrapCache=[]},zb={inlineContent:{},defaultType:{},edgeCount:{}};v.parse=function(t,e){var r=new Ab(t,e);if(null==r.next)return v.empty;var n=Ue(r);r.next&&r.err("Unexpected trailing text");var o=Jg(_g(n));return Ig(o,r),o},v.prototype.matchType=function(t){for(var e=0;e<this.next.length;e+=2)if(this.next[e]==t)return this.next[e+1];return null},v.prototype.matchFragment=function(t,e,r){void 0===e&&(e=0),void 0===r&&(r=t.childCount);for(var n=this,o=e;n&&o<r;o++)n=n.matchType(t.child(o).type);return n},zb.inlineContent.get=function(){var t=this.next[0];return!!t&&t.isInline},zb.defaultType.get=function(){for(var t=0;t<this.next.length;t+=2){var e=this.next[t];if(!e.isText&&!e.hasRequiredAttrs())return e}},v.prototype.compatible=function(t){for(var e=0;e<this.next.length;e+=2)for(var r=0;r<t.next.length;r+=2)if(this.next[e]==t.next[r])return!0;return!1},v.prototype.fillBefore=function(t,e,r){void 0===e&&(e=!1),void 0===r&&(r=0);var n=[this];return function o(a,i){var s=a.matchFragment(t,r);if(s&&(!e||s.validEnd))return b.from(i.map(function(t){return t.createAndFill()}));for(var $=0;$<a.next.length;$+=2){var S=a.next[$],p=a.next[$+1];if(!S.isText&&!S.hasRequiredAttrs()&&-1==n.indexOf(p)){n.push(p);var h=o(p,i.concat(S));if(h)return h}}}(this,[])},v.prototype.findWrapping=function(t){for(var e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];var r=this.computeWrapping(t);return this.wrapCache.push(t,r),r},v.prototype.computeWrapping=function(t){for(var e=Object.create(null),r=[{match:this,type:null,via:null}];r.length;){var n=r.shift(),o=n.match;if(o.matchType(t)){for(var a=[],i=n;i.type;i=i.via)a.push(i.type);return a.reverse()}for(var s=0;s<o.next.length;s+=2){var $=o.next[s];$.isLeaf||$.hasRequiredAttrs()||$.name in e||n.type&&!o.next[s+1].validEnd||(r.push({match:$.contentMatch,type:$,via:n}),e[$.name]=!0)}}},zb.edgeCount.get=function(){return this.next.length>>1},v.prototype.edge=function(t){var e=t<<1;if(e>this.next.length)throw new RangeError("There's no "+t+"th edge in this content match");return{type:this.next[e],next:this.next[e+1]}},v.prototype.toString=function(){var t=[];return function e(r){t.push(r);for(var n=1;n<r.next.length;n+=2)-1==t.indexOf(r.next[n])&&e(r.next[n])}(this),t.map(function(e,r){for(var n=r+(e.validEnd?"*":" ")+" ",o=0;o<e.next.length;o+=2)n+=(o?", ":"")+e.next[o].name+"->"+t.indexOf(e.next[o+1]);return n}).join("\n")},Object.defineProperties(v.prototype,zb),v.empty=new v(!0);var Ab=function(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.unshift()},Xe={next:{}};function Ue(t){var e=[];do{e.push(sh(t))}while(t.eat("|"));return 1==e.length?e[0]:{type:"choice",exprs:e}}function sh(t){var e=[];do{e.push(oh(t))}while(t.next&&")"!=t.next&&"|"!=t.next);return 1==e.length?e[0]:{type:"seq",exprs:e}}function oh(t){for(var e=ch(t);;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else{if(!t.eat("{"))break;e=ih(t,e)}return e}function Re(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");var e=Number(t.next);return t.pos++,e}function ih(t,e){var r=Re(t),n=r;return t.eat(",")&&(n="}"!=t.next?Re(t):-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:r,max:n,expr:e}}function gh(t,e){var r=t.nodeTypes,n=r[e];if(n)return[n];var o=[];for(var a in r){var i=r[a];i.groups.indexOf(e)>-1&&o.push(i)}return 0==o.length&&t.err("No node type or group '"+e+"' found"),o}function ch(t){if(t.eat("(")){var e=Ue(t);return t.eat(")")||t.err("Missing closing paren"),e}if(!/\W/.test(t.next)){var r=gh(t,t.next).map(function(e){return null==t.inline?t.inline=e.isInline:t.inline!=e.isInline&&t.err("Mixing inline and block content"),{type:"name",value:e}});return t.pos++,1==r.length?r[0]:{type:"choice",exprs:r}}t.err("Unexpected token '"+t.next+"'")}function _g(t){var e=[[]];return o(function t(e,a){if("choice"==e.type)return e.exprs.reduce(function(e,r){return e.concat(t(r,a))},[]);if("seq"==e.type)for(var i=0;;i++){var s=t(e.exprs[i],a);if(i==e.exprs.length-1)return s;o(s,a=r())}else{if("star"==e.type){var $=r();return n(a,$),o(t(e.expr,$),$),[n($)]}if("plus"==e.type){var S=r();return o(t(e.expr,a),S),o(t(e.expr,S),S),[n(S)]}if("opt"==e.type)return[n(a)].concat(t(e.expr,a));if("range"==e.type){for(var p=a,h=0;h<e.min;h++){var c=r();o(t(e.expr,p),c),p=c}if(-1==e.max)o(t(e.expr,p),p);else for(var j=e.min;j<e.max;j++){var v=r();n(p,v),o(t(e.expr,p),v),p=v}return[n(p)]}if("name"==e.type)return[n(a,null,e.value)]}}(t,0),r()),e;function r(){return e.push([])-1}function n(t,r,n){var o={term:n,to:r};return e[t].push(o),o}function o(t,e){t.forEach(function(t){return t.to=e})}}function Oe(t,e){return t-e}function Ge(t,e){var r=[];return function e(n){var o=t[n];if(1==o.length&&!o[0].term)return e(o[0].to);r.push(n);for(var a=0;a<o.length;a++){var i=o[a],s=i.term,$=i.to;s||-1!=r.indexOf($)||e($)}}(e),r.sort(Oe)}function Jg(t){var e=Object.create(null);return function r(n){var o=[];n.forEach(function(e){t[e].forEach(function(e){var r=e.term,n=e.to;if(r){var a=o.indexOf(r),i=a>-1&&o[a+1];Ge(t,n).forEach(function(t){i||o.push(r,i=[]),-1==i.indexOf(t)&&i.push(t)})}})});var a=e[n.join(",")]=new v(n.indexOf(t.length-1)>-1);for(var i=0;i<o.length;i+=2){var s=o[i+1].sort(Oe);a.next.push(o[i],e[s.join(",")]||r(s))}return a}(Ge(t,0))}function Ig(t,e){for(var r=0,n=[t];r<n.length;r++){for(var o=n[r],a=!o.validEnd,i=[],s=0;s<o.next.length;s+=2){var $=o.next[s],S=o.next[s+1];i.push($.name),!a||$.isText||$.hasRequiredAttrs()||(a=!1),-1==n.indexOf(S)&&n.push(S)}a&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position")}}function Ee(t){var e=Object.create(null);for(var r in t){var n=t[r];if(!n.hasDefault)return null;e[r]=n.default}return e}function De(t,e){var r=Object.create(null);for(var n in t){var o=e&&e[n];if(void 0===o){var a=t[n];if(!a.hasDefault)throw new RangeError("No value supplied for attribute "+n);o=a.default}r[n]=o}return r}function Ce(t){var e=Object.create(null);if(t)for(var r in t)e[r]=new ye(t[r]);return e}Xe.next.get=function(){return this.tokens[this.pos]},Ab.prototype.eat=function(t){return this.next==t&&(this.pos++||!0)},Ab.prototype.err=function(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")},Object.defineProperties(Ab.prototype,Xe);var y=function(t,e,r){this.name=t,this.schema=e,this.spec=r,this.groups=r.group?r.group.split(" "):[],this.attrs=Ce(r.attrs),this.defaultAttrs=Ee(this.attrs),this.contentMatch=null,this.markSet=null,this.inlineContent=null,this.isBlock=!(r.inline||"text"==t),this.isText="text"==t},Wa={isInline:{},isTextblock:{},isLeaf:{},isAtom:{}};Wa.isInline.get=function(){return!this.isBlock},Wa.isTextblock.get=function(){return this.isBlock&&this.inlineContent},Wa.isLeaf.get=function(){return this.contentMatch==v.empty},Wa.isAtom.get=function(){return this.isLeaf||this.spec.atom},y.prototype.hasRequiredAttrs=function(t){for(var e in this.attrs)if(this.attrs[e].isRequired&&(!t||!(e in t)))return!0;return!1},y.prototype.compatibleContent=function(t){return this==t||this.contentMatch.compatible(t.contentMatch)},y.prototype.computeAttrs=function(t){return!t&&this.defaultAttrs?this.defaultAttrs:De(this.attrs,t)},y.prototype.create=function(t,e,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new a(this,this.computeAttrs(t),b.from(e),c.setFrom(r))},y.prototype.createChecked=function(t,e,r){if(e=b.from(e),!this.validContent(e))throw new RangeError("Invalid content for node "+this.name);return new a(this,this.computeAttrs(t),e,c.setFrom(r))},y.prototype.createAndFill=function(t,e,r){if(t=this.computeAttrs(t),(e=b.from(e)).size){var n=this.contentMatch.fillBefore(e);if(!n)return null;e=n.append(e)}var o=this.contentMatch.matchFragment(e).fillBefore(b.empty,!0);return o?new a(this,t,e.append(o),c.setFrom(r)):null},y.prototype.validContent=function(t){var e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return!1;for(var r=0;r<t.childCount;r++)if(!this.allowsMarks(t.child(r).marks))return!1;return!0},y.prototype.allowsMarkType=function(t){return null==this.markSet||this.markSet.indexOf(t)>-1},y.prototype.allowsMarks=function(t){if(null==this.markSet)return!0;for(var e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return!1;return!0},y.prototype.allowedMarks=function(t){var e;if(null==this.markSet)return t;for(var r=0;r<t.length;r++)this.allowsMarkType(t[r].type)?e&&e.push(t[r]):e||(e=t.slice(0,r));return e?e.length?e:c.empty:t},y.compile=function(t,e){var r=Object.create(null);t.forEach(function(t,n){return r[t]=new y(t,e,n)});var n=e.spec.topNode||"doc";if(!r[n])throw new RangeError("Schema is missing its top node type ('"+n+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(var o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r},Object.defineProperties(y.prototype,Wa);var ye=function(t){this.hasDefault=Object.prototype.hasOwnProperty.call(t,"default"),this.default=t.default},xe={isRequired:{}};xe.isRequired.get=function(){return!this.hasDefault},Object.defineProperties(ye.prototype,xe);var da=function(t,e,r,n){this.name=t,this.schema=r,this.spec=n,this.attrs=Ce(n.attrs),this.rank=e,this.excluded=null;var o=Ee(this.attrs);this.instance=o&&new c(this,o)};da.prototype.create=function(t){return!t&&this.instance?this.instance:new c(this,De(this.attrs,t))},da.compile=function(t,e){var r=Object.create(null),n=0;return t.forEach(function(t,o){return r[t]=new da(t,n++,e,o)}),r},da.prototype.removeFromSet=function(t){for(var e=0;e<t.length;e++)if(t[e].type==this)return t.slice(0,e).concat(t.slice(e+1));return t},da.prototype.isInSet=function(t){for(var e=0;e<t.length;e++)if(t[e].type==this)return t[e]},da.prototype.excludes=function(t){return this.excluded.indexOf(t)>-1};var pa=function(t){for(var e in this.spec={},t)this.spec[e]=t[e];this.spec.nodes=Gf.from(t.nodes),this.spec.marks=Gf.from(t.marks),this.nodes=y.compile(this.spec.nodes,this),this.marks=da.compile(this.spec.marks,this);var r=Object.create(null);for(var n in this.nodes){if(n in this.marks)throw new RangeError(n+" can not be both a node and a mark");var o=this.nodes[n],a=o.spec.content||"",i=o.spec.marks;o.contentMatch=r[a]||(r[a]=v.parse(a,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.markSet="_"==i?null:i?we(this,i.split(" ")):""!=i&&o.inlineContent?null:[]}for(var s in this.marks){var $=this.marks[s],S=$.spec.excludes;$.excluded=null==S?[$]:""==S?[]:we(this,S.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached=Object.create(null),this.cached.wrappings=Object.create(null)};function we(t,e){for(var r=[],n=0;n<e.length;n++){var o=e[n],a=t.marks[o],i=a;if(a)r.push(a);else for(var s in t.marks){var $=t.marks[s];("_"==o||$.spec.group&&$.spec.group.split(" ").indexOf(o)>-1)&&r.push(i=$)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[n]+"'")}return r}pa.prototype.node=function(t,e,r,n){if("string"==typeof t)t=this.nodeType(t);else{if(!(t instanceof y))throw new RangeError("Invalid node type: "+t);if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}return t.createChecked(e,r,n)},pa.prototype.text=function(t,e){var r=this.nodes.text;return new Vh(r,r.defaultAttrs,t,c.setFrom(e))},pa.prototype.mark=function(t,e){return"string"==typeof t&&(t=this.marks[t]),t.create(e)},pa.prototype.nodeFromJSON=function(t){return a.fromJSON(this,t)},pa.prototype.markFromJSON=function(t){return c.fromJSON(this,t)},pa.prototype.nodeType=function(t){var e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e};var $=function(t,e){var r=this;this.schema=t,this.rules=e,this.tags=[],this.styles=[],e.forEach(function(t){t.tag?r.tags.push(t):t.style&&r.styles.push(t)})};$.prototype.parse=function(t,e){void 0===e&&(e={});var r=new h(this,e,!1);return r.addAll(t,null,e.from,e.to),r.finish()},$.prototype.parseSlice=function(t,e){void 0===e&&(e={});var r=new h(this,e,!0);return r.addAll(t,null,e.from,e.to),p.maxOpen(r.finish())},$.prototype.matchTag=function(t,e){for(var r=0;r<this.tags.length;r++){var n=this.tags[r];if(og(t,n.tag)&&(void 0===n.namespace||t.namespaceURI==n.namespace)&&(!n.context||e.matchesContext(n.context))){if(n.getAttrs){var o=n.getAttrs(t);if(!1===o)continue;n.attrs=o}return n}}},$.prototype.matchStyle=function(t,e,r){for(var n=0;n<this.styles.length;n++){var o=this.styles[n];if(!(0!=o.style.indexOf(t)||o.context&&!r.matchesContext(o.context)||o.style.length>t.length&&(61!=o.style.charCodeAt(t.length)||o.style.slice(t.length+1)!=e))){if(o.getAttrs){var a=o.getAttrs(e);if(!1===a)continue;o.attrs=a}return o}}},$.schemaRules=function(t){var e=[];function r(t){for(var r=null==t.priority?50:t.priority,n=0;n<e.length;n++){var o=e[n];if((null==o.priority?50:o.priority)<r)break}e.splice(n,0,t)}var n=function(e){var n=t.marks[e].spec.parseDOM;n&&n.forEach(function(t){r(t=pe(t)),t.mark=e})};for(var o in t.marks)n(o);var a;for(var i in t.nodes)a=void 0,(a=t.nodes[i].spec.parseDOM)&&a.forEach(function(t){r(t=pe(t)),t.node=i});return e},$.fromSchema=function(t){return t.cached.domParser||(t.cached.domParser=new $(t,$.schemaRules(t)))};var ve={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},ug={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},$c={ol:!0,ul:!0},vc=1,se=2,Ja=4;function re(t){return(t?vc:0)|("full"===t?se:0)}var Ya=function(t,e,r,n,o,a){this.type=t,this.attrs=e,this.solid=n,this.match=o||(a&Ja?null:t.contentMatch),this.options=a,this.content=[],this.marks=r,this.activeMarks=c.none};Ya.prototype.findWrapping=function(t){if(!this.match){if(!this.type)return[];var e=this.type.contentMatch.fillBefore(b.from(t));if(!e){var r,n=this.type.contentMatch;return(r=n.findWrapping(t.type))?(this.match=n,r):null}this.match=this.type.contentMatch.matchFragment(e)}return this.match.findWrapping(t.type)},Ya.prototype.finish=function(t){if(!(this.options&vc)){var e,r=this.content[this.content.length-1];r&&r.isText&&(e=/\s+$/.exec(r.text))&&(r.text.length==e[0].length?this.content.pop():this.content[this.content.length-1]=r.withText(r.text.slice(0,r.text.length-e[0].length)))}var n=b.from(this.content);return!t&&this.match&&(n=n.append(this.match.fillBefore(b.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n};var h=function(t,e,r){this.parser=t,this.options=e,this.isOpen=r,this.pendingMarks=[];var n,o=e.topNode,a=re(e.preserveWhitespace)|(r?Ja:0);n=o?new Ya(o.type,o.attrs,c.none,!0,e.topMatch||o.type.contentMatch,a):new Ya(r?null:t.schema.topNodeType,null,c.none,!0,null,a),this.nodes=[n],this.open=0,this.find=e.findPositions,this.needsBlock=!1},Jc={top:{},currentPos:{}};function pg(t){for(var e=t.firstChild,r=null;e;e=e.nextSibling){var n=1==e.nodeType?e.nodeName.toLowerCase():null;n&&$c.hasOwnProperty(n)&&r?(r.appendChild(e),e=r):"li"==n?r=e:n&&(r=null)}}function og(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function kg(t){for(var e,r=/\s*([\w-]+)\s*:\s*([^;]+)/g,n=[];e=r.exec(t);)n.push(e[1],e[2].trim());return n}function pe(t){var e={};for(var r in t)e[r]=t[r];return e}Jc.top.get=function(){return this.nodes[this.open]},h.prototype.addDOM=function(t){if(3==t.nodeType)this.addTextNode(t);else if(1==t.nodeType){var e=t.getAttribute("style"),r=e?this.readStyles(kg(e)):null;if(null!=r)for(var n=0;n<r.length;n++)this.addPendingMark(r[n]);if(this.addElement(t),null!=r)for(var o=0;o<r.length;o++)this.removePendingMark(r[o])}},h.prototype.addTextNode=function(t){var e=t.nodeValue,r=this.top;if((r.type?r.type.inlineContent:r.content.length&&r.content[0].isInline)||/\S/.test(e)){if(r.options&vc)r.options&se||(e=e.replace(/\r?\n|\r/g," "));else if(e=e.replace(/\s+/g," "),/^\s/.test(e)&&this.open==this.nodes.length-1){var n=r.content[r.content.length-1],o=t.previousSibling;(!n||o&&"BR"==o.nodeName||n.isText&&/\s$/.test(n.text))&&(e=e.slice(1))}e&&this.insertNode(this.parser.schema.text(e)),this.findInText(t)}else this.findInside(t)},h.prototype.addElement=function(t){var e=t.nodeName.toLowerCase();$c.hasOwnProperty(e)&&pg(t);var r=this.options.ruleFromNode&&this.options.ruleFromNode(t)||this.parser.matchTag(t,this);if(r?r.ignore:ug.hasOwnProperty(e))this.findInside(t);else if(!r||r.skip){r&&r.skip.nodeType&&(t=r.skip);var n,o=this.top,a=this.needsBlock;ve.hasOwnProperty(e)&&(n=!0,o.type||(this.needsBlock=!0)),this.addAll(t),n&&this.sync(o),this.needsBlock=a}else this.addElementByRule(t,r)},h.prototype.readStyles=function(t){for(var e=c.none,r=0;r<t.length;r+=2){var n=this.parser.matchStyle(t[r],t[r+1],this);if(n){if(n.ignore)return null;e=this.parser.schema.marks[n.mark].create(n.attrs).addToSet(e)}}return e},h.prototype.addElementByRule=function(t,e){var r,n,o,a=this;e.node?(n=this.parser.schema.nodes[e.node]).isLeaf?this.insertNode(n.create(e.attrs)):r=this.enter(n,e.attrs,e.preserveWhitespace):(o=this.parser.schema.marks[e.mark].create(e.attrs),this.addPendingMark(o));var i=this.top;if(n&&n.isLeaf)this.findInside(t);else if(e.getContent)this.findInside(t),e.getContent(t,this.parser.schema).forEach(function(t){return a.insertNode(t)});else{var s=e.contentElement;"string"==typeof s?s=t.querySelector(s):"function"==typeof s&&(s=s(t)),s||(s=t),this.findAround(t,s,!0),this.addAll(s,r)}return r&&(this.sync(i),this.open--),o&&this.removePendingMark(o),!0},h.prototype.addAll=function(t,e,r,n){for(var o=r||0,a=r?t.childNodes[r]:t.firstChild,i=null==n?null:t.childNodes[n];a!=i;a=a.nextSibling,++o)this.findAtPoint(t,o),this.addDOM(a),e&&ve.hasOwnProperty(a.nodeName.toLowerCase())&&this.sync(e);this.findAtPoint(t,o)},h.prototype.findPlace=function(t){for(var e,r,n=this.open;n>=0;n--){var o=this.nodes[n],a=o.findWrapping(t);if(a&&(!e||e.length>a.length)&&(e=a,r=o,!a.length))break;if(o.solid)break}if(!e)return!1;this.sync(r);for(var i=0;i<e.length;i++)this.enterInner(e[i],null,!1);return!0},h.prototype.insertNode=function(t){if(t.isInline&&this.needsBlock&&!this.top.type){var e=this.textblockFromContext();e&&this.enterInner(e)}if(this.findPlace(t)){this.closeExtra();var r=this.top;this.applyPendingMarks(r),r.match&&(r.match=r.match.matchType(t.type));for(var n=r.activeMarks,o=0;o<t.marks.length;o++)r.type&&!r.type.allowsMarkType(t.marks[o].type)||(n=t.marks[o].addToSet(n));r.content.push(t.mark(n))}},h.prototype.applyPendingMarks=function(t){for(var e=0;e<this.pendingMarks.length;e++){var r=this.pendingMarks[e];t.type&&!t.type.allowsMarkType(r.type)||r.isInSet(t.activeMarks)||(t.activeMarks=r.addToSet(t.activeMarks),this.pendingMarks.splice(e--,1))}},h.prototype.enter=function(t,e,r){var n=this.findPlace(t.create(e));return n&&(this.applyPendingMarks(this.top),this.enterInner(t,e,!0,r)),n},h.prototype.enterInner=function(t,e,r,n){this.closeExtra();var o=this.top;o.match=o.match&&o.match.matchType(t,e);var a=null==n?o.options&~Ja:re(n);o.options&Ja&&0==o.content.length&&(a|=Ja),this.nodes.push(new Ya(t,e,o.activeMarks,r,null,a)),this.open++},h.prototype.closeExtra=function(t){var e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}},h.prototype.finish=function(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)},h.prototype.sync=function(t){for(var e=this.open;e>=0;e--)if(this.nodes[e]==t)return void(this.open=e)},h.prototype.addPendingMark=function(t){this.pendingMarks.push(t)},h.prototype.removePendingMark=function(t){var e=this.pendingMarks.lastIndexOf(t);if(e>-1)this.pendingMarks.splice(e,1);else{var r=this.top;r.activeMarks=t.removeFromSet(r.activeMarks)}},Jc.currentPos.get=function(){this.closeExtra();for(var t=0,e=this.open;e>=0;e--){for(var r=this.nodes[e].content,n=r.length-1;n>=0;n--)t+=r[n].nodeSize;e&&t++}return t},h.prototype.findAtPoint=function(t,e){if(this.find)for(var r=0;r<this.find.length;r++)this.find[r].node==t&&this.find[r].offset==e&&(this.find[r].pos=this.currentPos)},h.prototype.findInside=function(t){if(this.find)for(var e=0;e<this.find.length;e++)null==this.find[e].pos&&1==t.nodeType&&t.contains(this.find[e].node)&&(this.find[e].pos=this.currentPos)},h.prototype.findAround=function(t,e,r){if(t!=e&&this.find)for(var n=0;n<this.find.length;n++){if(null==this.find[n].pos&&1==t.nodeType&&t.contains(this.find[n].node))e.compareDocumentPosition(this.find[n].node)&(r?2:4)&&(this.find[n].pos=this.currentPos)}},h.prototype.findInText=function(t){if(this.find)for(var e=0;e<this.find.length;e++)this.find[e].node==t&&(this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset))},h.prototype.matchesContext=function(t){var e=this;if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);var r=t.split("/"),n=this.options.context,o=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),a=-(n?n.depth+1:0)+(o?0:1),i=function(t,s){for(;t>=0;t--){var $=r[t];if(""==$){if(t==r.length-1||0==t)continue;for(;s>=a;s--)if(i(t-1,s))return!0;return!1}var S=s>0||0==s&&o?e.nodes[s].type:n&&s>=a?n.node(s-a).type:null;if(!S||S.name!=$&&-1==S.groups.indexOf($))return!1;s--}return!0};return i(r.length-1,this.open)},h.prototype.textblockFromContext=function(){var t=this.options.context;if(t)for(var e=t.depth;e>=0;e--){var r=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(var n in this.parser.schema.nodes){var o=this.parser.schema.nodes[n];if(o.isTextblock&&o.defaultAttrs)return o}},Object.defineProperties(h.prototype,Jc);var K=function(t,e){this.nodes=t||{},this.marks=e||{}};function oe(t){var e={};for(var r in t){var n=t[r].spec.toDOM;n&&(e[r]=n)}return e}function Sb(t){return t.document||window.document}K.prototype.serializeFragment=function(t,e,r){var n=this;void 0===e&&(e={}),r||(r=Sb(e).createDocumentFragment());var o=r,a=null;return t.forEach(function(t){if(a||t.marks.length){a||(a=[]);for(var r=0,i=0;r<a.length&&i<t.marks.length;){var s=t.marks[i];if(n.marks[s.type.name]){if(!s.eq(a[r])||!1===s.type.spec.spanning)break;r+=2,i++}else i++}for(;r<a.length;)o=a.pop(),a.pop();for(;i<t.marks.length;){var $=t.marks[i++],S=n.serializeMark($,t.isInline,e);S&&(a.push($,o),o.appendChild(S.dom),o=S.contentDOM||S.dom)}}o.appendChild(n.serializeNode(t,e))}),r},K.prototype.serializeNode=function(t,e){void 0===e&&(e={});var r=K.renderSpec(Sb(e),this.nodes[t.type.name](t)),n=r.dom,o=r.contentDOM;if(o){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");e.onContent?e.onContent(t,o,e):this.serializeFragment(t.content,e,o)}return n},K.prototype.serializeNodeAndMarks=function(t,e){void 0===e&&(e={});for(var r=this.serializeNode(t,e),n=t.marks.length-1;n>=0;n--){var o=this.serializeMark(t.marks[n],t.isInline,e);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r},K.prototype.serializeMark=function(t,e,r){void 0===r&&(r={});var n=this.marks[t.type.name];return n&&K.renderSpec(Sb(r),n(t,e))},K.renderSpec=function(t,e){if("string"==typeof e)return{dom:t.createTextNode(e)};if(null!=e.nodeType)return{dom:e};var r=t.createElement(e[0]),n=null,o=e[1],a=1;if(o&&"object"==typeof o&&null==o.nodeType&&!Array.isArray(o))for(var i in a=2,o)null!=o[i]&&r.setAttribute(i,o[i]);for(var s=a;s<e.length;s++){var $=e[s];if(0===$){if(s<e.length-1||s>a)throw new RangeError("Content hole must be the only child of its parent node");return{dom:r,contentDOM:r}}var S=K.renderSpec(t,$),p=S.dom,h=S.contentDOM;if(r.appendChild(p),h){if(n)throw new RangeError("Multiple content holes");n=h}}return{dom:r,contentDOM:n}},K.fromSchema=function(t){return t.cached.domSerializer||(t.cached.domSerializer=new K(this.nodesFromSchema(t),this.marksFromSchema(t)))},K.nodesFromSchema=function(t){var e=oe(t.nodes);return e.text||(e.text=function(t){return t.text}),e},K.marksFromSchema=function(t){return oe(t.marks)};var le=a;H.Node=le;var _f=l;H.ResolvedPos=_f;var Uf=Yb;H.NodeRange=Uf;var g=b;H.Fragment=g;var k=p;H.Slice=k;var je=O;H.ReplaceError=je;var Qa=c;H.Mark=Qa;var cc=pa;H.Schema=cc;var Rf=y;H.NodeType=Rf;var ie=da;H.MarkType=ie;var vk=v;H.ContentMatch=vk;var jb=$;H.DOMParser=jb;var Ga=K;H.DOMSerializer=Ga;var n={};Object.defineProperty(n,"__esModule",{value:!0});var he=65535,ge=Math.pow(2,16);function vj(e,r){return e+r*ge}function fe(e){return e&he}function tj(e){return(e-(e&he))/ge}var sb=function(e,r,t){void 0===r&&(r=!1),void 0===t&&(t=null),this.pos=e,this.deleted=r,this.recover=t},s=function(e,r){void 0===r&&(r=!1),this.ranges=e,this.inverted=r};s.prototype.recover=function(e){var r=0,t=fe(e);if(!this.inverted)for(var a=0;a<t;a++)r+=this.ranges[3*a+2]-this.ranges[3*a+1];return this.ranges[3*t]+r+tj(e)},s.prototype.mapResult=function(e,r){return void 0===r&&(r=1),this._map(e,r,!1)},s.prototype.map=function(e,r){return void 0===r&&(r=1),this._map(e,r,!0)},s.prototype._map=function(e,r,t){for(var a=0,o=this.inverted?2:1,n=this.inverted?1:2,i=0;i<this.ranges.length;i+=3){var p=this.ranges[i]-(this.inverted?a:0);if(p>e)break;var $=this.ranges[i+o],v=this.ranges[i+n],s=p+$;if(e<=s){var c=p+a+(($?e==p?-1:e==s?1:r:r)<0?0:v);if(t)return c;var l=vj(i/3,e-p);return new sb(c,r<0?e!=p:e!=s,l)}a+=v-$}return t?e+a:new sb(e+a)},s.prototype.touches=function(e,r){for(var t=0,a=fe(r),o=this.inverted?2:1,n=this.inverted?1:2,i=0;i<this.ranges.length;i+=3){var p=this.ranges[i]-(this.inverted?t:0);if(p>e)break;var $=this.ranges[i+o];if(e<=p+$&&i==3*a)return!0;t+=this.ranges[i+n]-$}return!1},s.prototype.forEach=function(e){for(var r=this.inverted?2:1,t=this.inverted?1:2,a=0,o=0;a<this.ranges.length;a+=3){var n=this.ranges[a],i=n-(this.inverted?o:0),p=n+(this.inverted?0:o),$=this.ranges[a+r],v=this.ranges[a+t];e(i,i+$,p,p+v),o+=v-$}},s.prototype.invert=function(){return new s(this.ranges,!this.inverted)},s.prototype.toString=function(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)},s.offset=function(e){return 0==e?s.empty:new s(e<0?[0,-e,0]:[0,0,e])},s.empty=new s([]);var t=function(e,r,t,a){this.maps=e||[],this.from=t||0,this.to=null==a?this.maps.length:a,this.mirror=r};function la(e){var r=Error.call(this,e);return r.__proto__=la.prototype,r}t.prototype.slice=function(e,r){return void 0===e&&(e=0),void 0===r&&(r=this.maps.length),new t(this.maps,this.mirror,e,r)},t.prototype.copy=function(){return new t(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)},t.prototype.appendMap=function(e,r){this.to=this.maps.push(e),null!=r&&this.setMirror(this.maps.length-1,r)},t.prototype.appendMapping=function(e){for(var r=0,t=this.maps.length;r<e.maps.length;r++){var a=e.getMirror(r);this.appendMap(e.maps[r],null!=a&&a<r?t+a:null)}},t.prototype.getMirror=function(e){if(this.mirror)for(var r=0;r<this.mirror.length;r++)if(this.mirror[r]==e)return this.mirror[r+(r%2?-1:1)]},t.prototype.setMirror=function(e,r){this.mirror||(this.mirror=[]),this.mirror.push(e,r)},t.prototype.appendMappingInverted=function(e){for(var r=e.maps.length-1,t=this.maps.length+e.maps.length;r>=0;r--){var a=e.getMirror(r);this.appendMap(e.maps[r].invert(),null!=a&&a>r?t-a-1:null)}},t.prototype.invert=function(){var e=new t;return e.appendMappingInverted(this),e},t.prototype.map=function(e,r){if(void 0===r&&(r=1),this.mirror)return this._map(e,r,!0);for(var t=this.from;t<this.to;t++)e=this.maps[t].map(e,r);return e},t.prototype.mapResult=function(e,r){return void 0===r&&(r=1),this._map(e,r,!1)},t.prototype._map=function(e,r,t){for(var a=!1,o=null,n=this.from;n<this.to;n++){var i=this.maps[n],p=o&&o[n];if(null!=p&&i.touches(e,p))e=i.recover(p);else{var $=i.mapResult(e,r);if(null!=$.recover){var v=this.getMirror(n);if(null!=v&&v>n&&v<this.to){if($.deleted){n=v,e=this.maps[v].recover($.recover);continue}(o||(o=Object.create(null)))[v]=$.recover}}$.deleted&&(a=!0),e=$.pos}}return t?e:new sb(e,a)},la.prototype=Object.create(Error.prototype),la.prototype.constructor=la,la.prototype.name="TransformError";var i=function(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new t},Dc={before:{},docChanged:{}};function yb(){throw new Error("Override me")}Dc.before.get=function(){return this.docs.length?this.docs[0]:this.doc},i.prototype.step=function(e){var r=this.maybeStep(e);if(r.failed)throw new la(r.failed);return this},i.prototype.maybeStep=function(e){var r=e.apply(this.doc);return r.failed||this.addStep(e,r.doc),r},Dc.docChanged.get=function(){return this.steps.length>0},i.prototype.addStep=function(e,r){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=r},Object.defineProperties(i.prototype,Dc);var Gc=Object.create(null),r=function(){};r.prototype.apply=function(e){return yb()},r.prototype.getMap=function(){return s.empty},r.prototype.invert=function(e){return yb()},r.prototype.map=function(e){return yb()},r.prototype.merge=function(e){return null},r.prototype.toJSON=function(){return yb()},r.fromJSON=function(e,r){if(!r||!r.stepType)throw new RangeError("Invalid input for Step.fromJSON");var t=Gc[r.stepType];if(!t)throw new RangeError("No step type "+r.stepType+" defined");return t.fromJSON(e,r)},r.jsonID=function(e,r){if(e in Gc)throw new RangeError("Duplicate use of step JSON ID "+e);return Gc[e]=r,r.prototype.jsonID=e,r};var D=function(e,r){this.doc=e,this.failed=r};D.ok=function(e){return new D(e,null)},D.fail=function(e){return new D(null,e)},D.fromReplace=function(e,r,t,a){try{return D.ok(e.replace(r,t,a))}catch(o){if(o instanceof je)return D.fail(o.message);throw o}};var aa=function(e){function r(r,t,a,o){e.call(this),this.from=r,this.to=t,this.slice=a,this.structure=!!o}return e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r,r.prototype.apply=function(e){return this.structure&&Mc(e,this.from,this.to)?D.fail("Structure replace would overwrite content"):D.fromReplace(e,this.from,this.to,this.slice)},r.prototype.getMap=function(){return new s([this.from,this.to-this.from,this.slice.size])},r.prototype.invert=function(e){return new r(this.from,this.from+this.slice.size,e.slice(this.from,this.to))},r.prototype.map=function(e){var t=e.mapResult(this.from,1),a=e.mapResult(this.to,-1);return t.deleted&&a.deleted?null:new r(t.pos,Math.max(t.pos,a.pos),this.slice)},r.prototype.merge=function(e){if(!(e instanceof r)||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;var t=this.slice.size+e.slice.size==0?k.empty:new k(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new r(e.from,this.to,t,this.structure)}var a=this.slice.size+e.slice.size==0?k.empty:new k(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new r(this.from,this.to+(e.to-e.from),a,this.structure)},r.prototype.toJSON=function(){var e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e},r.fromJSON=function(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new r(t.from,t.to,k.fromJSON(e,t.slice),!!t.structure)},r}(r);r.jsonID("replace",aa);var qa=function(e){function r(r,t,a,o,n,i,p){e.call(this),this.from=r,this.to=t,this.gapFrom=a,this.gapTo=o,this.slice=n,this.insert=i,this.structure=!!p}return e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r,r.prototype.apply=function(e){if(this.structure&&(Mc(e,this.from,this.gapFrom)||Mc(e,this.gapTo,this.to)))return D.fail("Structure gap-replace would overwrite content");var r=e.slice(this.gapFrom,this.gapTo);if(r.openStart||r.openEnd)return D.fail("Gap is not a flat range");var t=this.slice.insertAt(this.insert,r.content);return t?D.fromReplace(e,this.from,this.to,t):D.fail("Content does not fit in gap")},r.prototype.getMap=function(){return new s([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])},r.prototype.invert=function(e){var t=this.gapTo-this.gapFrom;return new r(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)},r.prototype.map=function(e){var t=e.mapResult(this.from,1),a=e.mapResult(this.to,-1),o=e.map(this.gapFrom,-1),n=e.map(this.gapTo,1);return t.deleted&&a.deleted||o<t.pos||n>a.pos?null:new r(t.pos,a.pos,o,n,this.slice,this.insert,this.structure)},r.prototype.toJSON=function(){var 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},r.fromJSON=function(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 r(t.from,t.to,t.gapFrom,t.gapTo,k.fromJSON(e,t.slice),t.insert,!!t.structure)},r}(r);function Mc(e,r,t){for(var a=e.resolve(r),o=t-r,n=a.depth;o>0&&n>0&&a.indexAfter(n)==a.node(n).childCount;)n--,o--;if(o>0)for(var i=a.node(n).maybeChild(a.indexAfter(n));o>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,o--}return!1}function mj(e,r,t){return(0==r||e.canReplace(r,e.childCount))&&(t==e.childCount||e.canReplace(0,t))}function Yi(e){for(var r=e.parent.content.cutByIndex(e.startIndex,e.endIndex),t=e.depth;;--t){var a=e.$from.node(t),o=e.$from.index(t),n=e.$to.indexAfter(t);if(t<e.depth&&a.canReplace(o,n,r))return t;if(0==t||a.type.spec.isolating||!mj(a,o,n))break}}function Xi(e,r,t,a){void 0===a&&(a=e);var o=ti(e,r),n=o&&oi(a,r);return n?o.map(ae).concat({type:r,attrs:t}).concat(n.map(ae)):null}function ae(e){return{type:e,attrs:null}}function ti(e,r){var t=e.parent,a=e.startIndex,o=e.endIndex,n=t.contentMatchAt(a).findWrapping(r);if(!n)return null;var i=n.length?n[0]:r;return t.canReplaceWith(a,o,i)?n:null}function oi(e,r){var t=e.parent,a=e.startIndex,o=e.endIndex,n=t.child(a),i=r.contentMatch.findWrapping(n.type);if(!i)return null;for(var p=(i.length?i[i.length-1]:r).contentMatch,$=a;p&&$<o;$++)p=p.matchType(t.child($).type);return p&&p.validEnd?i:null}function $h(e,r,t){var a=e.resolve(r),o=a.index();return a.parent.canReplaceWith(o,o+1,t)}function nh(e,r,t,a){void 0===t&&(t=1);var o=e.resolve(r),n=o.depth-t,i=a&&a[a.length-1]||o.parent;if(n<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!i.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(var p=o.depth-1,$=t-2;p>n;p--,$--){var v=o.node(p),s=o.index(p);if(v.type.spec.isolating)return!1;var c=v.content.cutByIndex(s,v.childCount),l=a&&a[$]||v;if(l!=v&&(c=c.replaceChild(0,l.type.create(l.attrs))),!v.canReplace(s+1,v.childCount)||!l.type.validContent(c))return!1}var y=o.indexAfter(n),f=a&&a[0];return o.node(n).canReplaceWith(y,y,f?f.type:o.node(n+1).type)}function ah(e,r){var t=e.resolve(r),a=t.index();return Rd(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(a,a+1)}function Rd(e,r){return e&&r&&!e.isLeaf&&e.canAppend(r)}function Tg(e,r,t){void 0===t&&(t=-1);for(var a=e.resolve(r),o=a.depth;;o--){var n=void 0,i=void 0;if(o==a.depth?(n=a.nodeBefore,i=a.nodeAfter):t>0?(n=a.node(o+1),i=a.node(o).maybeChild(a.index(o)+1)):(n=a.node(o).maybeChild(a.index(o)-1),i=a.node(o+1)),n&&!n.isTextblock&&Rd(n,i))return r;if(0==o)break;r=t<0?a.before(o):a.after(o)}}function Pd(e,r,t){var a=e.resolve(r);if(a.parent.canReplaceWith(a.index(),a.index(),t))return r;if(0==a.parentOffset)for(var o=a.depth-1;o>=0;o--){var n=a.index(o);if(a.node(o).canReplaceWith(n,n,t))return a.before(o+1);if(n>0)return null}if(a.parentOffset==a.parent.content.size)for(var i=a.depth-1;i>=0;i--){var p=a.indexAfter(i);if(a.node(i).canReplaceWith(p,p,t))return a.after(i+1);if(p<a.node(i).childCount)return null}}function Pg(e,r,t){var a=e.resolve(r);if(!t.content.size)return r;for(var o=t.content,n=0;n<t.openStart;n++)o=o.firstChild.content;for(var i=1;i<=(0==t.openStart&&t.size?2:1);i++)for(var p=a.depth;p>=0;p--){var $=p==a.depth?0:a.pos<=(a.start(p+1)+a.end(p+1))/2?-1:1,v=a.index(p)+($>0?1:0);if(1==i?a.node(p).canReplace(v,v,o):a.node(p).contentMatchAt(v).findWrapping(o.firstChild.type))return 0==$?a.pos:$<0?a.before(p+1):a.after(p+1)}return null}function Rb(e,r,t){for(var a=[],o=0;o<e.childCount;o++){var n=e.child(o);n.content.size&&(n=n.copy(Rb(n.content,r,n))),n.isInline&&(n=r(n,t,o)),a.push(n)}return g.fromArray(a)}r.jsonID("replaceAround",qa),i.prototype.lift=function(e,r){for(var t=e.$from,a=e.$to,o=e.depth,n=t.before(o+1),i=a.after(o+1),p=n,$=i,v=g.empty,s=0,c=o,l=!1;c>r;c--)l||t.index(c)>0?(l=!0,v=g.from(t.node(c).copy(v)),s++):p--;for(var y=g.empty,f=0,h=o,d=!1;h>r;h--)d||a.after(h+1)<a.end(h)?(d=!0,y=g.from(a.node(h).copy(y)),f++):$++;return this.step(new qa(p,$,n,i,new k(v.append(y),s,f),v.size-s,!0))},i.prototype.wrap=function(e,r){for(var t=g.empty,a=r.length-1;a>=0;a--)t=g.from(r[a].type.create(r[a].attrs,t));var o=e.start,n=e.end;return this.step(new qa(o,n,o,n,new k(t,0,0),r.length,!0))},i.prototype.setBlockType=function(e,r,t,a){var o=this;if(void 0===r&&(r=e),!t.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");var n=this.steps.length;return this.doc.nodesBetween(e,r,function(e,r){if(e.isTextblock&&!e.hasMarkup(t,a)&&$h(o.doc,o.mapping.slice(n).map(r),t)){o.clearIncompatible(o.mapping.slice(n).map(r,1),t);var i=o.mapping.slice(n),p=i.map(r,1),$=i.map(r+e.nodeSize,1);return o.step(new qa(p,$,p+1,$-1,new k(g.from(t.create(a,null,e.marks)),0,0),1,!0)),!1}}),this},i.prototype.setNodeMarkup=function(e,r,t,a){var o=this.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");r||(r=o.type);var n=r.create(t,null,a||o.marks);if(o.isLeaf)return this.replaceWith(e,e+o.nodeSize,n);if(!r.validContent(o.content))throw new RangeError("Invalid content for node type "+r.name);return this.step(new qa(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new k(g.from(n),0,0),1,!0))},i.prototype.split=function(e,r,t){void 0===r&&(r=1);for(var a=this.doc.resolve(e),o=g.empty,n=g.empty,i=a.depth,p=a.depth-r,$=r-1;i>p;i--,$--){o=g.from(a.node(i).copy(o));var v=t&&t[$];n=g.from(v?v.type.create(v.attrs,n):a.node(i).copy(n))}return this.step(new aa(e,e,new k(o.append(n),r,r,!0)))},i.prototype.join=function(e,r){void 0===r&&(r=1);var t=new aa(e-r,e+r,k.empty,!0);return this.step(t)};var Kb=function(e){function r(r,t,a){e.call(this),this.from=r,this.to=t,this.mark=a}return e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r,r.prototype.apply=function(e){var r=this,t=e.slice(this.from,this.to),a=e.resolve(this.from),o=a.node(a.sharedDepth(this.to)),n=new k(Rb(t.content,function(e,t){return t.type.allowsMarkType(r.mark.type)?e.mark(r.mark.addToSet(e.marks)):e},o),t.openStart,t.openEnd);return D.fromReplace(e,this.from,this.to,n)},r.prototype.invert=function(){return new ya(this.from,this.to,this.mark)},r.prototype.map=function(e){var t=e.mapResult(this.from,1),a=e.mapResult(this.to,-1);return t.deleted&&a.deleted||t.pos>=a.pos?null:new r(t.pos,a.pos,this.mark)},r.prototype.merge=function(e){if(e instanceof r&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from)return new r(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark)},r.prototype.toJSON=function(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}},r.fromJSON=function(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new r(t.from,t.to,e.markFromJSON(t.mark))},r}(r);r.jsonID("addMark",Kb);var ya=function(e){function r(r,t,a){e.call(this),this.from=r,this.to=t,this.mark=a}return e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r,r.prototype.apply=function(e){var r=this,t=e.slice(this.from,this.to),a=new k(Rb(t.content,function(e){return e.mark(r.mark.removeFromSet(e.marks))}),t.openStart,t.openEnd);return D.fromReplace(e,this.from,this.to,a)},r.prototype.invert=function(){return new Kb(this.from,this.to,this.mark)},r.prototype.map=function(e){var t=e.mapResult(this.from,1),a=e.mapResult(this.to,-1);return t.deleted&&a.deleted||t.pos>=a.pos?null:new r(t.pos,a.pos,this.mark)},r.prototype.merge=function(e){if(e instanceof r&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from)return new r(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark)},r.prototype.toJSON=function(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}},r.fromJSON=function(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new r(t.from,t.to,e.markFromJSON(t.mark))},r}(r);function Nd(e,r,t,a){if(void 0===t&&(t=r),void 0===a&&(a=k.empty),r==t&&!a.size)return null;var o=e.resolve(r),n=e.resolve(t);if(Ad(o,n,a))return new aa(r,t,a);var i=Ag(o,uj(o,a)),p=Cd(o,n,i);if(!p)return null;if(i.size!=p.size&&Zj(o,n,i)){for(var $=n.depth,v=n.after($);$>1&&v==n.end(--$);)++v;var s=Cd(o,e.resolve(v),i);if(s)return new qa(r,v,t,n.end(),s,i.size)}return p.size||r!=t?new aa(r,t,p):null}function Md(e,r,t,a){var o=g.empty,n=0,i=t[r];if(e.depth>r){var p=Md(e,r+1,t,a||i);n=p.openEnd+1,o=g.from(e.node(r+1).copy(p.content))}return i&&(o=o.append(i.content),n=i.openEnd),a&&(o=o.append(e.node(r).contentMatchAt(e.indexAfter(r)).fillBefore(g.empty,!0)),n=0),{content:o,openEnd:n}}function Ag(e,r){var t=Md(e,0,r,!1),a=t.content,o=t.openEnd;return new k(a,e.depth,o||0)}function Id(e,r,t,a,o,n,i){var p,$=e.childCount,v=$-(i>0?1:0),s=n<0?r:t.node(o);p=n<0?s.contentMatchAt(v):1==$&&i>0?s.contentMatchAt(n?t.index(o):t.indexAfter(o)):s.contentMatchAt(t.indexAfter(o)).matchFragment(e,$>0&&n?1:0,v);var c=a.node(o);if(i>0&&o<a.depth){var l=c.content.cutByIndex(a.indexAfter(o)).addToStart(e.lastChild),y=p.fillBefore(l,!0);if(y&&y.size&&n>0&&1==$&&(y=null),y){var f=Id(e.lastChild.content,e.lastChild,t,a,o+1,1==$?n-1:-1,i-1);if(f){var h=e.lastChild.copy(f);return y.size?e.cutByIndex(0,$-1).append(y).addToEnd(h):e.replaceChild($-1,h)}}}i>0&&(p=p.matchType((1==$&&n>0?t.node(o+1):e.lastChild).type));var d=a.index(o);if(d==c.childCount&&!c.type.compatibleContent(r.type))return null;for(var u=p.fillBefore(c.content,!0,d),m=d;u&&m<c.content.childCount;m++)s.type.allowsMarks(c.content.child(m).marks)||(u=null);if(!u)return null;if(i>0){var J=Hd(e.lastChild,i-1,t,o+1,1==$?n-1:-1);e=e.replaceChild($-1,J)}return e=e.append(u),a.depth>o&&(e=e.addToEnd(Gd(a,o+1))),e}function Hd(e,r,t,a,o){var n,i=e.content,p=i.childCount;if(n=o>=0?t.node(a).contentMatchAt(t.indexAfter(a)).matchFragment(i,o>0?1:0,p):e.contentMatchAt(p),r>0){var $=Hd(i.lastChild,r-1,t,a+1,1==p?o-1:-1);i=i.replaceChild(p-1,$)}return e.copy(i.append(n.fillBefore(g.empty,!0)))}function Gd(e,r){var t=e.node(r),a=t.contentMatchAt(0).fillBefore(t.content,!0,e.index(r));return e.depth>r&&(a=a.addToEnd(Gd(e,r+1))),t.copy(a)}function eg(e,r,t){for(;r>0&&t>0&&1==e.childCount;)e=e.firstChild.content,r--,t--;return new k(e,r,t)}function Cd(e,r,t){var a=Id(t.content,e.node(0),e,r,0,t.openStart,t.openEnd);return a?eg(a,t.openStart,r.depth):null}function Ad(e,r,t){return!t.openStart&&!t.openEnd&&e.start()==r.start()&&e.parent.canReplace(e.index(),r.index(),t.content)}function Zj(e,r,t){if(!r.parent.isTextblock)return!1;var a,o=t.openEnd?yj(t.content,t.openEnd):e.node(e.depth-(t.openStart-t.openEnd));if(!o.isTextblock)return!1;for(var n=r.index();n<r.parent.childCount;n++)if(!o.type.allowsMarks(r.parent.child(n).marks))return!1;return t.openEnd?a=o.contentMatchAt(o.childCount):(a=o.contentMatchAt(o.childCount),t.size&&(a=a.matchFragment(t.content,t.openStart?1:0))),(a=a.matchFragment(r.parent.content,r.index()))&&a.validEnd}function yj(e,r){for(var t=1;t<r;t++)e=e.lastChild.content;return e.lastChild}function uj(e,r){for(var t=new Ua(e),a=1;r.size&&a<=3;a++)r=t.placeSlice(r.content,r.openStart,r.openEnd,a);for(;t.open.length;)t.closeNode();return t.placed}r.jsonID("removeMark",ya),i.prototype.addMark=function(e,r,t){var a=this,o=[],n=[],i=null,p=null;return this.doc.nodesBetween(e,r,function(a,$,v){if(a.isInline){var s=a.marks;if(!t.isInSet(s)&&v.type.allowsMarkType(t.type)){for(var c=Math.max($,e),l=Math.min($+a.nodeSize,r),y=t.addToSet(s),f=0;f<s.length;f++)s[f].isInSet(y)||(i&&i.to==c&&i.mark.eq(s[f])?i.to=l:o.push(i=new ya(c,l,s[f])));p&&p.to==c?p.to=l:n.push(p=new Kb(c,l,t))}}}),o.forEach(function(e){return a.step(e)}),n.forEach(function(e){return a.step(e)}),this},i.prototype.removeMark=function(e,r,t){var a=this;void 0===t&&(t=null);var o=[],n=0;return this.doc.nodesBetween(e,r,function(a,i){if(a.isInline){n++;var p=null;if(t instanceof ie){var $=t.isInSet(a.marks);$&&(p=[$])}else t?t.isInSet(a.marks)&&(p=[t]):p=a.marks;if(p&&p.length)for(var v=Math.min(i+a.nodeSize,r),s=0;s<p.length;s++){for(var c=p[s],l=void 0,y=0;y<o.length;y++){var f=o[y];f.step==n-1&&c.eq(o[y].style)&&(l=f)}l?(l.to=v,l.step=n):o.push({style:c,from:Math.max(i,e),to:v,step:n})}}}),o.forEach(function(e){return a.step(new ya(e.from,e.to,e.style))}),this},i.prototype.clearIncompatible=function(e,r,t){void 0===t&&(t=r.contentMatch);for(var a=this.doc.nodeAt(e),o=[],n=e+1,i=0;i<a.childCount;i++){var p=a.child(i),$=n+p.nodeSize,v=t.matchType(p.type,p.attrs);if(v){t=v;for(var s=0;s<p.marks.length;s++)r.allowsMarkType(p.marks[s].type)||this.step(new ya(n,$,p.marks[s]))}else o.push(new aa(n,$,k.empty));n=$}if(!t.validEnd){var c=t.fillBefore(g.empty,!0);this.replace(n,n,new k(c,0,0))}for(var l=o.length-1;l>=0;l--)this.step(o[l]);return this},i.prototype.replace=function(e,r,t){void 0===r&&(r=e),void 0===t&&(t=k.empty);var a=Nd(this.doc,e,r,t);return a&&this.step(a),this},i.prototype.replaceWith=function(e,r,t){return this.replace(e,r,new k(g.from(t),0,0))},i.prototype.delete=function(e,r){return this.replace(e,r,k.empty)},i.prototype.insert=function(e,r){return this.replaceWith(e,e,r)};var Ua=function(e){this.open=[];for(var r=0;r<=e.depth;r++){var t=e.node(r),a=t.contentMatchAt(e.indexAfter(r));this.open.push({parent:t,match:a,content:g.empty,wrapper:!1,openEnd:0,depth:r})}this.placed=[]};function zd(e,r,t){var a=e.content;if(r>1){var o=zd(e.firstChild,r-1,1==e.childCount?t-1:0);a=e.content.replaceChild(0,o)}var n=e.type.contentMatch.fillBefore(a,0==t);return e.copy(n.append(a))}function yd(e,r){var t=e.content;if(r>1){var a=yd(e.lastChild,r-1);t=e.content.replaceChild(e.childCount-1,a)}var o=e.contentMatchAt(e.childCount).fillBefore(g.empty,!0);return e.copy(t.append(o))}function uh(e,r){return r?e.replaceChild(e.childCount-1,yd(e.lastChild,r)):e}function vd(e,r,t,a,o){if(r<t){var n=e.firstChild;e=e.replaceChild(0,n.copy(vd(n.content,r+1,t,a,n)))}return r>a&&(e=o.contentMatchAt(0).fillBefore(e,!0).append(e)),e}function td(e,r){for(var t=[],a=Math.min(e.depth,r.depth);a>=0;a--){var o=e.start(a);if(o<e.pos-(e.depth-a)||r.end(a)>r.pos+(r.depth-a)||e.node(a).type.spec.isolating||r.node(a).type.spec.isolating)break;o==r.start(a)&&t.push(a)}return t}Ua.prototype.placeSlice=function(e,r,t,a,o){if(r>0){var n=e.firstChild,i=this.placeSlice(n.content,Math.max(0,r-1),t&&1==e.childCount?t-1:0,a,n);i.content!=n.content&&(i.content.size?(e=e.replaceChild(0,n.copy(i.content)),r=i.openStart+1):(1==e.childCount&&(t=0),e=e.cutByIndex(1),r=0))}var p=this.placeContent(e,r,t,a,o);if(a>2&&p.size&&0==r){for(var $=0;$<p.content.childCount;$++){var v=p.content.child($);this.placeContent(v.content,0,t&&$==p.content.childCount.length-1?t-1:0,a,v)}p=g.empty}return p},Ua.prototype.placeContent=function(e,r,t,a,o){for(var n=0;n<e.childCount;n++){for(var i=e.child(n),p=!1,$=n==e.childCount-1,v=this.open.length-1;v>=0;v--){var s=this.open[v],c=void 0;if(a>1&&(c=s.match.findWrapping(i.type))&&(!o||!c.length||c[c.length-1]!=o.type)){for(;this.open.length-1>v;)this.closeNode();for(var l=0;l<c.length;l++)s.match=s.match.matchType(c[l]),v++,s={parent:c[l].create(),match:c[l].contentMatch,content:g.empty,wrapper:!0,openEnd:0,depth:v+l},this.open.push(s)}var y=s.match.matchType(i.type);if(!y){var f=s.match.fillBefore(g.from(i));if(!f){if(o&&s.match.matchType(o.type))break;continue}for(var h=0;h<f.childCount;h++){var d=f.child(h);this.addNode(s,d,0),y=s.match.matchFragment(d)}}for(;this.open.length-1>v;)this.closeNode();i=i.mark(s.parent.type.allowedMarks(i.marks)),r&&(i=zd(i,r,$?t:0),r=0),this.addNode(s,i,$?t:0),s.match=y,$&&(t=0),p=!0;break}if(!p)break}return this.open.length>1&&(n>0&&n==e.childCount||o&&this.open[this.open.length-1].parent.type==o.type)&&this.closeNode(),new k(e.cutByIndex(n),r,t)},Ua.prototype.addNode=function(e,r,t){e.content=uh(e.content,e.openEnd).addToEnd(r),e.openEnd=t},Ua.prototype.closeNode=function(){var e=this.open.pop();0==e.content.size||(e.wrapper?this.addNode(this.open[this.open.length-1],e.parent.copy(e.content),e.openEnd+1):this.placed[e.depth]={depth:e.depth,content:e.content,openEnd:e.openEnd})},i.prototype.replaceRange=function(e,r,t){if(!t.size)return this.deleteRange(e,r);var a=this.doc.resolve(e),o=this.doc.resolve(r);if(Ad(a,o,t))return this.step(new aa(e,r,t));var n=td(a,this.doc.resolve(r));0==n[n.length-1]&&n.pop();var i=-(a.depth+1);n.unshift(i);for(var p=a.depth,$=a.pos-1;p>0;p--,$--){var v=a.node(p).type.spec;if(v.defining||v.isolating)break;n.indexOf(p)>-1?i=p:a.before(p)==$&&n.splice(1,0,-p)}for(var s=n.indexOf(i),c=[],l=t.openStart,y=t.content,f=0;;f++){var h=y.firstChild;if(c.push(h),f==t.openStart)break;y=h.content}l>0&&c[l-1].type.spec.defining&&a.node(s).type!=c[l-1].type?l-=1:l>=2&&c[l-1].isTextblock&&c[l-2].type.spec.defining&&a.node(s).type!=c[l-2].type&&(l-=2);for(var d=t.openStart;d>=0;d--){var u=(d+l+1)%(t.openStart+1),m=c[u];if(m)for(var J=0;J<n.length;J++){var g=n[(J+s)%n.length],S=!0;g<0&&(S=!1,g=-g);var M=a.node(g-1),R=a.index(g-1);if(M.canReplaceWith(R,R,m.type,m.marks))return this.replace(a.before(g),S?o.after(g):r,new k(vd(t.content,0,t.openStart,u),u,t.openEnd))}}return this.replace(e,r,t)},i.prototype.replaceRangeWith=function(e,r,t){if(!t.isInline&&e==r&&this.doc.resolve(e).parent.content.size){var a=Pd(this.doc,e,t.type);null!=a&&(e=r=a)}return this.replaceRange(e,r,new k(g.from(t),0,0))},i.prototype.deleteRange=function(e,r){for(var t=this.doc.resolve(e),a=this.doc.resolve(r),o=td(t,a),n=0;n<o.length;n++){var i=o[n],p=n==o.length-1;if(p&&0==i||t.node(i).type.contentMatch.validEnd)return this.delete(t.start(i),a.end(i));if(i>0&&(p||t.node(i-1).canReplace(t.index(i-1),a.indexAfter(i-1))))return this.delete(t.before(i),a.after(i))}for(var $=1;$<=t.depth;$++)if(e-t.start($)==t.depth-$&&r>t.end($))return this.delete(t.before($),r);return this.delete(e,r)};var qd=i;n.Transform=qd;var hg=la;n.TransformError=hg;var fg=r;n.Step=fg;var Tf=D;n.StepResult=Tf;var oc=Tg;n.joinPoint=oc;var sa=ah;n.canJoin=sa;var Ia=nh;n.canSplit=Ia;var _i=Pd;n.insertPoint=_i;var od=Pg;n.dropPoint=od;var Ka=Yi;n.liftTarget=Ka;var uc=Xi;n.findWrapping=uc;var jh=s;n.StepMap=jh;var Rg=sb;n.MapResult=Rg;var md=t;n.Mapping=md;var yg=Kb;n.AddMarkStep=yg;var sg=ya;n.RemoveMarkStep=sg;var kd=aa;n.ReplaceStep=kd;var Bc=qa;n.ReplaceAroundStep=Bc;var bi=Nd;n.replaceStep=bi;var N={};Object.defineProperty(N,"__esModule",{value:!0});var Ec=Object.create(null),m=function(e,t,r){this.ranges=r||[new id(e.min(t),e.max(t))],this.$anchor=e,this.$head=t},ea={anchor:{},head:{},from:{},to:{},$from:{},$to:{},empty:{}};ea.anchor.get=function(){return this.$anchor.pos},ea.head.get=function(){return this.$head.pos},ea.from.get=function(){return this.$from.pos},ea.to.get=function(){return this.$to.pos},ea.$from.get=function(){return this.ranges[0].$from},ea.$to.get=function(){return this.ranges[0].$to},ea.empty.get=function(){for(var e=this.ranges,t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0},m.prototype.content=function(){return this.$from.node(0).slice(this.from,this.to,!0)},m.prototype.replace=function(e,t){void 0===t&&(t=k.empty);for(var r=t.content.lastChild,o=null,n=0;n<t.openEnd;n++)o=r,r=r.lastChild;for(var i=e.steps.length,a=this.ranges,$=0;$<a.length;$++){var p=a[$],s=p.$from,c=p.$to,d=e.mapping.slice(i);e.replaceRange(d.map(s.pos),d.map(c.pos),$?k.empty:t),0==$&&fd(e,i,(r?r.isInline:o&&o.isTextblock)?-1:1)}},m.prototype.replaceWith=function(e,t){for(var r=e.steps.length,o=this.ranges,n=0;n<o.length;n++){var i=o[n],a=i.$from,$=i.$to,p=e.mapping.slice(r),s=p.map(a.pos),c=p.map($.pos);n?e.deleteRange(s,c):(e.replaceRangeWith(s,c,t),fd(e,r,t.isInline?-1:1))}},m.findFrom=function(e,t,r){var o=e.parent.inlineContent?new Ca(e):Ea(e.node(0),e.parent,e.pos,e.index(),t,r);if(o)return o;for(var n=e.depth-1;n>=0;n--){var i=t<0?Ea(e.node(0),e.node(n),e.before(n+1),e.index(n),t,r):Ea(e.node(0),e.node(n),e.after(n+1),e.index(n)+1,t,r);if(i)return i}},m.near=function(e,t){return void 0===t&&(t=1),this.findFrom(e,t)||this.findFrom(e,-t)||new Da(e.node(0))},m.atStart=function(e){return Ea(e,e,0,0,1)||new Da(e)},m.atEnd=function(e){return Ea(e,e,e.content.size,e.childCount,-1)||new Da(e)},m.fromJSON=function(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");var r=Ec[t.type];if(!r)throw new RangeError("No selection type "+t.type+" defined");return r.fromJSON(e,t)},m.jsonID=function(e,t){if(e in Ec)throw new RangeError("Duplicate use of selection JSON ID "+e);return Ec[e]=t,t.prototype.jsonID=e,t},m.prototype.getBookmark=function(){return Ca.between(this.$anchor,this.$head).getBookmark()},Object.defineProperties(m.prototype,ea),m.prototype.visible=!0;var id=function(e,t){this.$from=e,this.$to=t},Ca=function(e){function t(t,r){void 0===r&&(r=t),e.call(this,t,r)}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={$cursor:{}};return r.$cursor.get=function(){return this.$anchor.pos==this.$head.pos?this.$head:null},t.prototype.map=function(r,o){var n=r.resolve(o.map(this.head));if(!n.parent.inlineContent)return e.near(n);var i=r.resolve(o.map(this.anchor));return new t(i.parent.inlineContent?i:n,n)},t.prototype.replace=function(t,r){if(void 0===r&&(r=k.empty),e.prototype.replace.call(this,t,r),r==k.empty){var o=this.$from.marksAcross(this.$to);o&&t.ensureMarks(o)}},t.prototype.eq=function(e){return e instanceof t&&e.anchor==this.anchor&&e.head==this.head},t.prototype.getBookmark=function(){return new Sa(this.anchor,this.head)},t.prototype.toJSON=function(){return{type:"text",anchor:this.anchor,head:this.head}},t.fromJSON=function(e,r){if("number"!=typeof r.anchor||"number"!=typeof r.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new t(e.resolve(r.anchor),e.resolve(r.head))},t.create=function(e,t,r){void 0===r&&(r=t);var o=e.resolve(t);return new this(o,r==t?o:e.resolve(r))},t.between=function(r,o,n){var i=r.pos-o.pos;if(n&&!i||(n=i>=0?1:-1),!o.parent.inlineContent){var a=e.findFrom(o,n,!0)||e.findFrom(o,-n,!0);if(!a)return e.near(o,n);o=a.$head}return r.parent.inlineContent||(0==i?r=o:(r=(e.findFrom(r,-n,!0)||e.findFrom(r,n,!0)).$anchor).pos<o.pos!=i<0&&(r=o)),new t(r,o)},Object.defineProperties(t.prototype,r),t}(m);m.jsonID("text",Ca);var Sa=function(e,t){this.anchor=e,this.head=t};Sa.prototype.map=function(e){return new Sa(e.map(this.anchor),e.map(this.head))},Sa.prototype.resolve=function(e){return Ca.between(e.resolve(this.anchor),e.resolve(this.head))};var oa=function(e){function t(t){var r=t.nodeAfter,o=t.node(0).resolve(t.pos+r.nodeSize);e.call(this,t,o),this.node=r}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.map=function(r,o){var n=o.mapResult(this.anchor),i=n.deleted,a=n.pos,$=r.resolve(a);return i?e.near($):new t($)},t.prototype.content=function(){return new k(g.from(this.node),0,0)},t.prototype.eq=function(e){return e instanceof t&&e.anchor==this.anchor},t.prototype.toJSON=function(){return{type:"node",anchor:this.anchor}},t.prototype.getBookmark=function(){return new Cb(this.anchor)},t.fromJSON=function(e,r){if("number"!=typeof r.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new t(e.resolve(r.anchor))},t.create=function(e,t){return new this(e.resolve(t))},t.isSelectable=function(e){return!e.isText&&!1!==e.type.spec.selectable},t}(m);oa.prototype.visible=!1,m.jsonID("node",oa);var Cb=function(e){this.anchor=e};Cb.prototype.map=function(e){var t=e.mapResult(this.anchor),r=t.deleted,o=t.pos;return r?new Sa(o,o):new Cb(o)},Cb.prototype.resolve=function(e){var t=e.resolve(this.anchor),r=t.nodeAfter;return r&&oa.isSelectable(r)?new oa(t):m.near(t)};var Da=function(e){function t(t){e.call(this,t.resolve(0),t.resolve(t.content.size))}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.toJSON=function(){return{type:"all"}},t.fromJSON=function(e){return new t(e)},t.prototype.map=function(e){return new t(e)},t.prototype.eq=function(e){return e instanceof t},t.prototype.getBookmark=function(){return tg},t}(m);m.jsonID("all",Da);var tg={map:function(){return this},resolve:function(e){return new Da(e)}};function Ea(e,t,r,o,n,i){if(t.inlineContent)return Ca.create(e,r);for(var a=o-(n>0?0:1);n>0?a<t.childCount:a>=0;a+=n){var $=t.child(a);if($.isAtom){if(!i&&oa.isSelectable($))return oa.create(e,r-(n<0?$.nodeSize:0))}else{var p=Ea(e,$,r+n,n<0?$.childCount:0,n,i);if(p)return p}r+=$.nodeSize*n}}function fd(e,t,r){var o=e.steps.length-1;if(!(o<t)){var n,i=e.steps[o];if(i instanceof kd||i instanceof Bc)e.mapping.maps[o].forEach(function(e,t,r,o){null==n&&(n=o)}),e.setSelection(m.near(e.doc.resolve(n),r))}}var ed=1,Ib=2,dd=4,cd=function(e){function t(t){e.call(this,t.doc),this.time=Date.now(),this.curSelection=t.selection,this.curSelectionFor=0,this.storedMarks=t.storedMarks,this.updated=0,this.meta=Object.create(null)}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={selection:{},selectionSet:{},storedMarksSet:{},isGeneric:{},scrolledIntoView:{}};return r.selection.get=function(){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},t.prototype.setSelection=function(e){return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|ed)&~Ib,this.storedMarks=null,this},r.selectionSet.get=function(){return(this.updated&ed)>0},t.prototype.setStoredMarks=function(e){return this.storedMarks=e,this.updated|=Ib,this},t.prototype.ensureMarks=function(e){return Qa.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this},t.prototype.addStoredMark=function(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))},t.prototype.removeStoredMark=function(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))},r.storedMarksSet.get=function(){return(this.updated&Ib)>0},t.prototype.addStep=function(t,r){e.prototype.addStep.call(this,t,r),this.updated=this.updated&~Ib,this.storedMarks=null},t.prototype.setTime=function(e){return this.time=e,this},t.prototype.replaceSelection=function(e){return this.selection.replace(this,e),this},t.prototype.replaceSelectionWith=function(e,t){var r=this.selection;return!1!==t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Qa.none))),r.replaceWith(this,e),this},t.prototype.deleteSelection=function(){return this.selection.replace(this),this},t.prototype.insertText=function(e,t,r){void 0===r&&(r=t);var o=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();if(!e)return this.deleteRange(t,r);var n=this.storedMarks;if(!n){var i=this.doc.resolve(t);n=r==t?i.marks():i.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,o.text(e,n)),this.selection.empty||this.setSelection(m.near(this.selection.$to)),this},t.prototype.setMeta=function(e,t){return this.meta["string"==typeof e?e:e.key]=t,this},t.prototype.getMeta=function(e){return this.meta["string"==typeof e?e:e.key]},r.isGeneric.get=function(){for(var e in this.meta)return!1;return!0},t.prototype.scrollIntoView=function(){return this.updated|=dd,this},r.scrolledIntoView.get=function(){return(this.updated&dd)>0},Object.defineProperties(t.prototype,r),t}(qd);function ad(e,t){return t&&e?e.bind(t):e}var Za=function(e,t,r){this.name=e,this.init=ad(t.init,r),this.apply=ad(t.apply,r)},Dg=[new Za("doc",{init:function(e){return e.doc||e.schema.topNodeType.createAndFill()},apply:function(e){return e.doc}}),new Za("selection",{init:function(e,t){return e.selection||m.atStart(t.doc)},apply:function(e){return e.selection}}),new Za("storedMarks",{init:function(e){return e.storedMarks||null},apply:function(e,t,r,o){return o.selection.$cursor?e.storedMarks:null}}),new Za("scrollToSelection",{init:function(){return 0},apply:function(e,t){return e.scrolledIntoView?t+1:t}})],Xc=function(e,t){var r=this;this.schema=e,this.fields=Dg.concat(),this.plugins=[],this.pluginsByKey=Object.create(null),t&&t.forEach(function(e){if(r.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");r.plugins.push(e),r.pluginsByKey[e.key]=e,e.spec.state&&r.fields.push(new Za(e.key,e.spec.state,e))})},B=function(e){this.config=e},Nb={schema:{},plugins:{},tr:{}};Nb.schema.get=function(){return this.config.schema},Nb.plugins.get=function(){return this.config.plugins},B.prototype.apply=function(e){return this.applyTransaction(e).state},B.prototype.filterTransaction=function(e,t){void 0===t&&(t=-1);for(var r=0;r<this.config.plugins.length;r++)if(r!=t){var o=this.config.plugins[r];if(o.spec.filterTransaction&&!o.spec.filterTransaction.call(o,e,this))return!1}return!0},B.prototype.applyTransaction=function(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};for(var t=[e],r=this.applyInner(e),o=null;;){for(var n=!1,i=0;i<this.config.plugins.length;i++){var a=this.config.plugins[i];if(a.spec.appendTransaction){var $=o?o[i].n:0,p=o?o[i].state:this,s=$<t.length&&a.spec.appendTransaction.call(a,$?t.slice($):t,p,r);if(s&&r.filterTransaction(s,i)){if(s.setMeta("appendedTransaction",e),!o){o=[];for(var c=0;c<this.config.plugins.length;c++)o.push(c<i?{state:r,n:t.length}:{state:this,n:0})}t.push(s),r=r.applyInner(s),n=!0}o&&(o[i]={state:r,n:t.length})}}if(!n)return{state:r,transactions:t}}},B.prototype.applyInner=function(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");for(var t=new B(this.config),r=this.config.fields,o=0;o<r.length;o++){var n=r[o];t[n.name]=n.apply(e,this[n.name],this,t)}for(var i=0;i<$a.length;i++)$a[i](this,e,t);return t},Nb.tr.get=function(){return new cd(this)},B.create=function(e){for(var t=new Xc(e.schema||e.doc.type.schema,e.plugins),r=new B(t),o=0;o<t.fields.length;o++)r[t.fields[o].name]=t.fields[o].init(e,r);return r},B.prototype.reconfigure=function(e){for(var t=new Xc(e.schema||this.schema,e.plugins),r=t.fields,o=new B(t),n=0;n<r.length;n++){var i=r[n].name;o[i]=this.hasOwnProperty(i)?this[i]:r[n].init(e,o)}return o},B.prototype.toJSON=function(e){var t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(function(e){return e.toJSON()})),e&&"object"==typeof e)for(var r in e){if("doc"==r||"selection"==r)throw new RangeError("The JSON fields `doc` and `selection` are reserved");var o=e[r],n=o.spec.state;n&&n.toJSON&&(t[r]=n.toJSON.call(o,this[o.key]))}return t},B.fromJSON=function(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");var o=new Xc(e.schema,e.plugins),n=new B(o);return o.fields.forEach(function(o){if("doc"==o.name)n.doc=le.fromJSON(e.schema,t.doc);else if("selection"==o.name)n.selection=m.fromJSON(n.doc,t.selection);else if("storedMarks"==o.name)t.storedMarks&&(n.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(var i in r){var a=r[i],$=a.spec.state;if(a.key==o.name&&$&&$.fromJSON&&Object.prototype.hasOwnProperty.call(t,i))return void(n[o.name]=$.fromJSON.call(a,e,t[i],n))}n[o.name]=o.init(e,n)}}),n},B.addApplyListener=function(e){$a.push(e)},B.removeApplyListener=function(e){var t=$a.indexOf(e);t>-1&&$a.splice(t,1)},Object.defineProperties(B.prototype,Nb);var $a=[];function Le(e,t,r){for(var o in e){var n=e[o];n instanceof Function?n=n.bind(t):"handleDOMEvents"==o&&(n=Le(n,t,{})),r[o]=n}return r}var te=function(e){this.props={},e.props&&Le(e.props,this,this.props),this.spec=e,this.key=e.key?e.key.key:bd("plugin")};te.prototype.getState=function(e){return e[this.key]};var Uc=Object.create(null);function bd(e){return e in Uc?e+"$"+ ++Uc[e]:(Uc[e]=0,e+"$")}var Tc=function(e){void 0===e&&(e="key"),this.key=bd(e)};Tc.prototype.get=function(e){return e.config.pluginsByKey[this.key]},Tc.prototype.getState=function(e){return e[this.key]};var _=m;N.Selection=_;var Bk=id;N.SelectionRange=Bk;var x=Ca;N.TextSelection=x;var f=oa;N.NodeSelection=f;var gd=Da;N.AllSelection=gd;var ph=cd;N.Transaction=ph;var hd=B;N.EditorState=hd;var Eb=te;N.Plugin=Eb;var Hc=Tc;N.PluginKey=Hc;var jd=function(e,r,t){var o=document.createElement("div");return r=r||"",t?(o.innerHTML="<pre><code style='white-space: pre-wrap'></code></pre>",o.querySelector("code").appendChild(document.createTextNode(r))):o.innerHTML=r,jb.fromSchema(e).parse(o)};var ra={};Object.defineProperty(ra,"__esModule",{value:!0});var j={};if("undefined"!=typeof navigator&&"undefined"!=typeof document){var zc=/Edge\/(\d+)/.exec(navigator.userAgent),ld=/MSIE \d/.test(navigator.userAgent),yc=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);j.mac=/Mac/.test(navigator.platform);var tb=j.ie=!!(ld||yc||zc);j.ie_version=ld?document.documentMode||6:yc?+yc[1]:zc?+zc[1]:null,j.gecko=!tb&&/gecko\/(\d+)/i.test(navigator.userAgent),j.gecko_version=j.gecko&&+(/Firefox\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];var wc=!tb&&/Chrome\/(\d+)/.exec(navigator.userAgent);j.chrome=!!wc,j.chrome_version=wc&&+wc[1],j.ios=!tb&&/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),j.android=/Android \d/.test(navigator.userAgent),j.webkit=!tb&&"WebkitAppearance"in document.documentElement.style,j.safari=/Apple Computer/.test(navigator.vendor),j.webkit_version=j.webkit&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]}var ga=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},nd=function(e){var t=e.parentNode;return t&&11==t.nodeType?t.host:t},P=function(e,t,r){var o=document.createRange();return o.setEnd(e,null==r?e.nodeValue.length:r),o.setStart(e,t||0),o},rc=function(e,t,r,o){return r&&(pd(e,t,r,o,-1)||pd(e,t,r,o,1))},ej=/^(img|br|input|textarea|hr)$/i;function pd(e,t,r,o,n){for(;;){if(e==r&&t==o)return!0;if(t==(n<0?0:nb(e))||3==e.nodeType&&"\uFEFF"==e.nodeValue){var i=e.parentNode;if(1!=i.nodeType||cg(e)||ej.test(e.nodeName)||"false"==e.contentEditable)return!1;t=ga(e)+(n<0?0:1),e=i}else{if(1!=e.nodeType)return!1;e=e.childNodes[t+(n<0?-1:0)],t=n<0?nb(e):0}}}function nb(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function cg(e){var t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}var mc=function(e){var t=e.isCollapsed;return t&&j.chrome&&e.rangeCount&&!e.getRangeAt(0).collapsed&&(t=!1),t};function lc(e,t){var r=document.createEvent("Event");return r.initEvent("keydown",!0,!0),r.keyCode=e,r.key=r.code=t,r}function rg(e){return{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function ba(e,t){return"number"==typeof e?e:e[t]}function rd(e,t,r){for(var o=e.someProp("scrollThreshold")||0,n=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument,a=i.defaultView,s=r||e.dom;s;s=nd(s))if(1==s.nodeType){var $=s==i.body||1!=s.nodeType,c=$?rg(a):s.getBoundingClientRect(),l=0,d=0;if(t.top<c.top+ba(o,"top")?d=-(c.top-t.top+ba(n,"top")):t.bottom>c.bottom-ba(o,"bottom")&&(d=t.bottom-c.bottom+ba(n,"bottom")),t.left<c.left+ba(o,"left")?l=-(c.left-t.left+ba(n,"left")):t.right>c.right-ba(o,"right")&&(l=t.right-c.right+ba(n,"right")),(l||d)&&($?a.scrollBy(l,d):(d&&(s.scrollTop+=d),l&&(s.scrollLeft+=l))),$)break}}function vg(e){for(var t,r,o=e.dom.getBoundingClientRect(),n=Math.max(0,o.top),i=e.dom.ownerDocument,a=(o.left+o.right)/2,s=n+1;s<Math.min(innerHeight,o.bottom);s+=5){var $=e.root.elementFromPoint(a,s);if($!=e.dom&&e.dom.contains($)){var c=$.getBoundingClientRect();if(c.top>=n-20){t=$,r=c.top;break}}}for(var l=[],d=e.dom;d&&(l.push({dom:d,top:d.scrollTop,left:d.scrollLeft}),d!=i.body);d=nd(d));return{refDOM:t,refTop:r,stack:l}}function wg(e){for(var t=e.refDOM,r=e.refTop,o=e.stack,n=t?t.getBoundingClientRect().top:0,i=0==n?0:n-r,a=0;a<o.length;a++){var s=o[a],$=s.dom,c=s.top,l=s.left;$.scrollTop!=c+i&&($.scrollTop=c+i),$.scrollLeft!=l&&($.scrollLeft=l)}}function sd(e,t){for(var r,o,n=2e8,i=0,a=t.top,s=t.top,$=e.firstChild,c=0;$;$=$.nextSibling,c++){var l=void 0;if(1==$.nodeType)l=$.getClientRects();else{if(3!=$.nodeType)continue;l=P($).getClientRects()}for(var d=0;d<l.length;d++){var p=l[d];if(p.top<=a&&p.bottom>=s){a=Math.max(p.bottom,a),s=Math.min(p.top,s);var v=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(v<n){r=$,n=v,o=v&&3==r.nodeType?{left:p.right<t.left?p.right:p.left,top:t.top}:t,1==$.nodeType&&v&&(i=c+(t.left>=(p.left+p.right)/2?1:0));continue}}!r&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(i=c+1)}}return r&&3==r.nodeType?Cg(r,o):!r||n&&1==r.nodeType?{node:e,offset:i}:sd(r,o)}function Cg(e,t){for(var r=e.nodeValue.length,o=document.createRange(),n=0;n<r;n++){o.setEnd(e,n+1),o.setStart(e,n);var i=ia(o,1);if(i.top!=i.bottom&&jc(t,i))return{node:e,offset:n+(t.left>=(i.left+i.right)/2?1:0)}}return{node:e,offset:0}}function jc(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function Ng(e,t){var r=e.parentNode;return r&&/^li$/i.test(r.nodeName)&&t.left<e.getBoundingClientRect().left?r:e}function Og(e,t,r){var o=sd(t,r),n=o.node,i=o.offset,a=-1;if(1==n.nodeType&&!n.firstChild){var s=n.getBoundingClientRect();a=s.left!=s.right&&r.left>(s.left+s.right)/2?1:-1}return e.docView.posFromDOM(n,i,a)}function Qg(e,t,r,o){for(var n=-1,i=t;i!=e.dom;){var a=e.docView.nearestDesc(i,!0);if(!a)return null;if(a.node.isBlock&&a.parent){var s=a.dom.getBoundingClientRect();if(s.left>o.left||s.top>o.top)n=a.posBefore;else{if(!(s.right<o.left||s.bottom<o.top))break;n=a.posAfter}}i=a.dom.parentNode}return n>-1?n:e.docView.posFromDOM(t,r)}function ud(e,t,r){var o=e.childNodes.length;if(o&&r.top<r.bottom)for(var n=Math.max(0,Math.floor(o*(t.top-r.top)/(r.bottom-r.top))-2),i=n;;){var a=e.childNodes[i];if(1==a.nodeType)for(var s=a.getClientRects(),$=0;$<s.length;$++){var c=s[$];if(jc(t,c))return ud(a,t,c)}if((i=(i+1)%o)==n)break}return e}function $g(e,t){var r,o,n=e.root;if(n.caretPositionFromPoint){var i,a=n.caretPositionFromPoint(t.left,t.top);if(a)r=(i=a).offsetNode,o=i.offset}if(!r&&n.caretRangeFromPoint){var s,$=n.caretRangeFromPoint(t.left,t.top);if($)r=(s=$).startContainer,o=s.startOffset}var c,l=n.elementFromPoint(t.left,t.top+1);if(!l||!e.dom.contains(1!=l.nodeType?l.parentNode:l)){var d=e.dom.getBoundingClientRect();if(!jc(t,d))return null;if(!(l=ud(e.dom,t,d)))return null}l=Ng(l,t),r&&(r==e.dom&&o==r.childNodes.length-1&&1==r.lastChild.nodeType&&t.top>r.lastChild.getBoundingClientRect().bottom?c=e.state.doc.content.size:0!=o&&1==r.nodeType&&"BR"==r.childNodes[o-1].nodeName||(c=Qg(e,r,o,t))),null==c&&(c=Og(e,l,t));var p=e.docView.nearestDesc(l,!0);return{pos:c,inside:p?p.posAtStart-p.border:-1}}function ia(e,t){var r=e.getClientRects();return r.length?r[t<0?0:r.length-1]:e.getBoundingClientRect()}function wd(e,t){var r=e.docView.domFromPos(t),o=r.node,n=r.offset;if(3==o.nodeType&&(j.chrome||j.gecko)){var i=ia(P(o,n,n),0);if(j.gecko&&n&&/\s/.test(o.nodeValue[n-1])&&n<o.nodeValue.length){var a=ia(P(o,n-1,n-1),-1);if(Math.abs(a.left-i.left)<1&&a.top==i.top){var s=ia(P(o,n,n+1),-1);return kb(s,s.left<a.left)}}return i}if(1==o.nodeType&&!e.state.doc.resolve(t).parent.inlineContent){var $,c=!0;if(n<o.childNodes.length){var l=o.childNodes[n];1==l.nodeType&&($=l.getBoundingClientRect())}if(!$&&n){var d=o.childNodes[n-1];1==d.nodeType&&($=d.getBoundingClientRect(),c=!1)}return vh($||o.getBoundingClientRect(),c)}for(var p=-1;p<2;p+=2)if(p<0&&n){var v=void 0,h=3==o.nodeType?P(o,n-1,n):3==(v=o.childNodes[n-1]).nodeType?P(v):1==v.nodeType&&"BR"!=v.nodeName?v:null;if(h){var u=ia(h,1);if(u.top<u.bottom)return kb(u,!1)}}else if(p>0&&n<nb(o)){var f=void 0,D=3==o.nodeType?P(o,n,n+1):3==(f=o.childNodes[n]).nodeType?P(f):1==f.nodeType?f:null;if(D){var S=ia(D,-1);if(S.top<S.bottom)return kb(S,!0)}}return kb(ia(3==o.nodeType?P(o):o,0),!1)}function kb(e,t){if(0==e.width)return e;var r=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:r,right:r}}function vh(e,t){if(0==e.height)return e;var r=t?e.top:e.bottom;return{top:r,bottom:r,left:e.left,right:e.right}}function xd(e,t,r){var o=e.state,n=e.root.activeElement;o!=t&&e.updateState(t),n!=e.dom&&e.focus();try{return r()}finally{o!=t&&e.updateState(o),n!=e.dom&&n.focus()}}function di(e,t,r){var o=t.selection,n="up"==r?o.$anchor.min(o.$head):o.$anchor.max(o.$head);return xd(e,t,function(){for(var t=e.docView.domFromPos(n.pos).node;;){var o=e.docView.nearestDesc(t,!0);if(!o)break;if(o.node.isBlock){t=o.dom;break}t=o.dom.parentNode}for(var i=wd(e,n.pos),a=t.firstChild;a;a=a.nextSibling){var s=void 0;if(1==a.nodeType)s=a.getClientRects();else{if(3!=a.nodeType)continue;s=P(a,0,a.nodeValue.length).getClientRects()}for(var $=0;$<s.length;$++){var c=s[$];if(c.bottom>c.top&&("up"==r?c.bottom<i.top+1:c.top>i.bottom-1))return!1}}return!0})}var li=/[\u0590-\u08ac]/;function mi(e,t,r){var o=t.selection.$head;if(!o.parent.isTextblock)return!1;var n=o.parentOffset,i=!n,a=n==o.parent.content.size,s=getSelection();return li.test(o.parent.textContent)&&s.modify?xd(e,t,function(){var t=s.getRangeAt(0),n=s.focusNode,i=s.focusOffset;s.modify("move",r,"character");var a=!(o.depth?e.docView.domAfterPos(o.before()):e.dom).contains(1==s.focusNode.nodeType?s.focusNode:s.focusNode.parentNode)||n==s.focusNode&&i==s.focusOffset;return s.removeAllRanges(),s.addRange(t),a}):"left"==r||"backward"==r?i:a}var yi=null,Qi=null,Vi=!1;function $i(e,t,r){return yi==t&&Qi==r?Vi:(yi=t,Qi=r,Vi="up"==r||"down"==r?di(e,t,r):mi(e,t,r))}var L=0,dj=1,ib=2,ua=3,d=function(e,t,r,o){this.parent=e,this.children=t,this.dom=r,r.pmViewDesc=this,this.contentDOM=o,this.dirty=L},X={beforePosition:{},size:{},border:{},posBefore:{},posAtStart:{},posAfter:{},posAtEnd:{},contentLost:{}};d.prototype.matchesWidget=function(){return!1},d.prototype.matchesMark=function(){return!1},d.prototype.matchesNode=function(){return!1},d.prototype.matchesHack=function(){return!1},X.beforePosition.get=function(){return!1},d.prototype.parseRule=function(){return null},d.prototype.stopEvent=function(){return!1},X.size.get=function(){for(var e=0,t=0;t<this.children.length;t++)e+=this.children[t].size;return e},X.border.get=function(){return 0},d.prototype.destroy=function(){this.parent=null,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=null);for(var e=0;e<this.children.length;e++)this.children[e].destroy()},d.prototype.posBeforeChild=function(e){for(var t=0,r=this.posAtStart;t<this.children.length;t++){var o=this.children[t];if(o==e)return r;r+=o.size}},X.posBefore.get=function(){return this.parent.posBeforeChild(this)},X.posAtStart.get=function(){return this.parent?this.parent.posBeforeChild(this)+this.border:0},X.posAfter.get=function(){return this.posBefore+this.size},X.posAtEnd.get=function(){return this.posAtStart+this.size-2*this.border},d.prototype.localPosFromDOM=function(e,t,r){var o;if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(r<0){var n,i;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&(!(i=n.pmViewDesc)||i.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(i)+i.size:this.posAtStart}var a,s;if(e==this.contentDOM)a=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.nextSibling}for(;a&&(!(s=a.pmViewDesc)||s.parent!=this);)a=a.nextSibling;return a?this.posBeforeChild(s):this.posAtEnd}if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(var $=e;;$=$.parentNode){if($==this.dom){o=!1;break}if($.parentNode.firstChild!=$)break}if(null==o&&t==e.childNodes.length)for(var c=e;;c=c.parentNode){if(c==this.dom){o=!0;break}if(c.parentNode.lastChild!=c)break}}return(null==o?r>0:o)?this.posAtEnd:this.posAtStart},d.prototype.nearestDesc=function(e,t){for(var r=!0,o=e;o;o=o.parentNode){var n=this.getDesc(o);if(n&&(!t||n.node)){if(!r||!n.nodeDOM||(1==n.nodeDOM.nodeType?n.nodeDOM.contains(e):n.nodeDOM==e))return n;r=!1}}},d.prototype.getDesc=function(e){for(var t=e.pmViewDesc,r=t;r;r=r.parent)if(r==this)return t},d.prototype.posFromDOM=function(e,t,r){for(var o=e;;o=o.parentNode){var n=this.getDesc(o);if(n)return n.localPosFromDOM(e,t,r)}},d.prototype.descAt=function(e){for(var t=0,r=0;t<this.children.length;t++){var o=this.children[t],n=r+o.size;if(r==e&&n!=r){for(;!o.border&&o.children.length;)o=o.children[0];return o}if(e<n)return o.descAt(e-r-o.border);r=n}},d.prototype.domFromPos=function(e){if(!this.contentDOM)return{node:this.dom,offset:0};for(var t=0,r=0;;r++){if(t==e){for(;r<this.children.length&&(this.children[r].beforePosition||this.children[r].dom.parentNode!=this.contentDOM);)r++;return{node:this.contentDOM,offset:r==this.children.length?this.contentDOM.childNodes.length:ga(this.children[r].dom)}}if(r==this.children.length)throw new Error("Invalid position "+e);var o=this.children[r],n=t+o.size;if(e<n)return o.domFromPos(e-t-o.border);t=n}},d.prototype.parseRange=function(e,t,r){if(void 0===r&&(r=0),0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};for(var o=-1,n=-1,i=r,a=0;;a++){var s=this.children[a],$=i+s.size;if(-1==o&&e<=$){var c=i+s.border;if(e>=c&&t<=$-s.border&&s.node&&s.contentDOM&&this.contentDOM.contains(s.contentDOM))return s.parseRange(e,t,c);e=i;for(var l=a;l>0;l--){var d=this.children[l-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){o=ga(d.dom)+1;break}e-=d.size}-1==o&&(o=0)}if(o>-1&&t<=$){t=$;for(var p=a+1;p<this.children.length;p++){var v=this.children[p];if(v.size&&v.dom.parentNode==this.contentDOM&&!v.emptyChildAt(-1)){n=ga(v.dom);break}t+=v.size}-1==n&&(n=this.contentDOM.childNodes.length);break}i=$}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:n}},d.prototype.emptyChildAt=function(e){if(this.border||!this.contentDOM||!this.children.length)return!1;var t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)},d.prototype.domAfterPos=function(e){var t=this.domFromPos(e),r=t.node,o=t.offset;if(1!=r.nodeType||o==r.childNodes.length)throw new RangeError("No node after pos "+e);return r.childNodes[o]},d.prototype.setSelection=function(e,t,r,o){for(var n=Math.min(e,t),i=Math.max(e,t),a=0,s=0;a<this.children.length;a++){var $=this.children[a],c=s+$.size;if(n>s&&i<c)return $.setSelection(e-s-$.border,t-s-$.border,r,o);s=c}var l=this.domFromPos(e),d=this.domFromPos(t),p=r.getSelection(),v=document.createRange();if(o||!rc(l.node,l.offset,p.anchorNode,p.anchorOffset)||!rc(d.node,d.offset,p.focusNode,p.focusOffset)){if(p.extend)v.setEnd(l.node,l.offset),v.collapse(!1);else{if(e>t){var h=l;l=d,d=h}v.setEnd(d.node,d.offset),v.setStart(l.node,l.offset)}p.removeAllRanges(),p.addRange(v),p.extend&&p.extend(d.node,d.offset)}},d.prototype.ignoreMutation=function(e){return!this.contentDOM},X.contentLost.get=function(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)},d.prototype.markDirty=function(e,t){for(var r=0,o=0;o<this.children.length;o++){var n=this.children[o],i=r+n.size;if(r==i?e<=i&&t>=r:e<i&&t>r){var a=r+n.border,s=i-n.border;if(e>=a&&t<=s)return this.dirty=e==r||t==i?ib:dj,void(e==a&&t==s&&n.contentLost?n.dirty=ua:n.markDirty(e-a,t-a));n.dirty=ua}r=i}this.dirty=ib},d.prototype.markParentsDirty=function(){for(var e=this.parent;e;e=e.parent){var t=ib;e.dirty<t&&(e.dirty=t)}},Object.defineProperties(d.prototype,X);var W=[],Bd=function(e){function t(t,r,o,n){var i,a=r.type.toDOM;if("function"==typeof a&&(a=a(o,function(){return i?i.parent?i.parent.posBeforeChild(i):void 0:n})),!r.type.spec.raw){if(1!=a.nodeType){var s=document.createElement("span");s.appendChild(a),a=s}a.contentEditable=!1,a.classList.add("ProseMirror-widget")}e.call(this,t,W,a,null),this.widget=r,i=this}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={beforePosition:{}};return r.beforePosition.get=function(){return this.widget.type.side<0},t.prototype.matchesWidget=function(e){return this.dirty==L&&e.type.eq(this.widget.type)},t.prototype.parseRule=function(){return{ignore:!0}},t.prototype.stopEvent=function(e){var t=this.widget.spec.stopEvent;return!!t&&t(e)},Object.defineProperties(t.prototype,r),t}(d),ag=function(e){function t(){e.apply(this,arguments)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.parseRule=function(){return{skip:Od(this.dom)}},t.prototype.ignoreMutation=function(){return!1},t}(Bd),bg=function(e){function t(t,r,o,n){e.call(this,t,W,r,null),this.textDOM=o,this.text=n}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={size:{}};return r.size.get=function(){return this.text.length},t.prototype.parseRule=function(){return{skip:Od(this.dom)}},t.prototype.localPosFromDOM=function(e,t){if(e!=this.textDOM)return this.posAtStart+(t?this.size:0);var r=this.textDOM.nodeValue.indexOf("\uFEFF");return this.posAtStart+t-(r>-1&&r<t?1:0)},t.prototype.domFromPos=function(e){var t=this.textDOM.nodeValue.indexOf("\uFEFF");return{node:this.textDOM,offset:e+(t>-1&&t<=e?1:0)}},t.prototype.ignoreMutation=function(){return!1},Object.defineProperties(t.prototype,r),t}(d),_b=function(e){function t(t,r,o,n){e.call(this,t,[],o,n),this.mark=r}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.create=function(e,r,o,n){var i=n.nodeViews[r.type.name],a=i&&i(r,n,o);return a&&a.dom||(a=Ga.renderSpec(document,r.type.spec.toDOM(r,o))),new t(e,r,a.dom,a.contentDOM||a.dom)},t.prototype.parseRule=function(){return{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}},t.prototype.matchesMark=function(e){return this.dirty!=ua&&this.mark.eq(e)},t.prototype.markDirty=function(t,r){if(e.prototype.markDirty.call(this,t,r),this.dirty!=L){for(var o=this.parent;!o.node;)o=o.parent;o.dirty<this.dirty&&(o.dirty=this.dirty),this.dirty=L}},t.prototype.slice=function(e,r,o){var n=t.create(this.parent,this.mark,!0,o),i=this.children,a=this.size;r<a&&(i=Ub(i,r,a,o)),e>0&&(i=Ub(i,0,e,o));for(var s=0;s<i.length;s++)i[s].parent=n;return n.children=i,n},t}(d),Ra=function(e){function t(t,r,o,n,i,a,s,$,c){e.call(this,t,r.isLeaf?W:[],i,a),this.nodeDOM=s,this.node=r,this.outerDeco=o,this.innerDeco=n,a&&this.updateChildren($,c)}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={size:{},border:{}};return t.create=function(e,r,o,n,i,a){var s,$=i.nodeViews[r.type.name],c=$&&$(r,i,function(){return s?s.parent?s.parent.posBeforeChild(s):void 0:a},o),l=c&&c.dom,d=c&&c.contentDOM;if(r.isText){if(l){if(3!=l.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else l=document.createTextNode(r.text);}else if(!l){var p;l=(p=Ga.renderSpec(document,r.type.spec.toDOM(r))).dom,d=p.contentDOM}d||r.isText||"BR"==l.nodeName||(l.hasAttribute("contenteditable")||(l.contentEditable=!1),r.type.spec.draggable&&(l.draggable=!0));var v=l;return l=Kd(l,o,r),c?s=new qg(e,r,o,n,l,d,v,c,i,a+1):r.isText?new Ed(e,r,o,n,l,v,i):new t(e,r,o,n,l,d,v,i,a+1)},t.prototype.parseRule=function(){var e=this;if(this.node.type.spec.reparseInView)return null;var t={node:this.node.type.name,attrs:this.node.attrs};return this.node.type.spec.code&&(t.preserveWhitespace="full"),this.contentDOM&&!this.contentLost?t.contentElement=this.contentDOM:t.getContent=function(){return e.contentDOM?g.empty:e.node.content},t},t.prototype.matchesNode=function(e,t,r){return this.dirty==L&&e.eq(this.node)&&Wb(t,this.outerDeco)&&r.eq(this.innerDeco)},r.size.get=function(){return this.node.nodeSize},r.border.get=function(){return this.node.isLeaf?0:1},t.prototype.updateChildren=function(e,t){var r=this,o=this.node.inlineContent,n=t,i=o&&e.composing&&this.localCompositionNode(e,t),a=new M(this,i&&i.node);Gg(this.node,this.innerDeco,function(t,i){t.spec.marks?a.syncToMarks(t.spec.marks,o,e):t.type.side>=0&&a.syncToMarks(i==r.node.childCount?Qa.none:r.node.child(i).marks,o,e),a.placeWidget(t,e,n)},function(t,r,i,s){a.syncToMarks(t.marks,o,e),a.findNodeMatch(t,r,i,s)||a.updateNextNode(t,r,i,e,s)||a.addNode(t,r,i,e,n),n+=t.nodeSize}),a.syncToMarks(W,o,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==ib)&&(i&&this.protectLocalComposition(e,i),this.renderChildren())},t.prototype.renderChildren=function(){Fd(this.contentDOM,this.children,t.is),j.ios&&Hg(this.dom)},t.prototype.localCompositionNode=function(e,t){var r=e.state.selection,o=r.from,n=r.to;if(!(!(e.state.selection instanceof x)||o<t||n>t+this.node.content.size)){var i=e.root.getSelection(),a=Kg(i.focusNode,i.focusOffset);if(a&&this.dom.contains(a.parentNode)){var s=a.nodeValue.replace(/\ufeff/g,""),$=Lg(this.node.content,s,o-t,n-t);return $<0?null:{node:a,pos:$,text:s}}}},t.prototype.protectLocalComposition=function(e,t){var r=t.node,o=t.pos,n=t.text;if(!this.getDesc(r)){for(var i=r;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=null)}var a=new bg(this,i,r,n);e.compositionNodes.push(a),this.children=Ub(this.children,o,o+n.length,e,a)}},t.prototype.update=function(e,t,r,o){return!(this.dirty==ua||!e.sameMarkup(this.node))&&(this.updateInner(e,t,r,o),!0)},t.prototype.updateInner=function(e,t,r,o){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=L},t.prototype.updateOuterDeco=function(e){if(!Wb(e,this.outerDeco)){var t=1!=this.nodeDOM.nodeType,r=this.dom;this.dom=Jd(this.dom,this.nodeDOM,Xb(this.outerDeco,this.node,t),Xb(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=null,this.dom.pmViewDesc=this),this.outerDeco=e}},t.prototype.selectNode=function(){this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)},t.prototype.deselectNode=function(){this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!1)},Object.defineProperties(t.prototype,r),t}(d);function Dd(e,t,r,o,n){return Kd(o,t,e),new Ra(null,e,t,r,o,o,o,n,0)}var Ed=function(e){function t(t,r,o,n,i,a,s){e.call(this,t,r,o,n,i,null,a,s)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.parseRule=function(){var e=this.nodeDOM.parentNode;return e?{skip:e}:{ignore:!0}},t.prototype.update=function(e,t){return!(this.dirty==ua||this.dirty!=L&&!this.inParent()||!e.sameMarkup(this.node))&&(this.updateOuterDeco(t),this.dirty==L&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text),this.node=e,this.dirty=L,!0)},t.prototype.inParent=function(){for(var e=this.parent.contentDOM,t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1},t.prototype.domFromPos=function(e){return{node:this.nodeDOM,offset:e}},t.prototype.localPosFromDOM=function(t,r,o){return t==this.nodeDOM?this.posAtStart+Math.min(r,this.node.text.length):e.prototype.localPosFromDOM.call(this,t,r,o)},t.prototype.ignoreMutation=function(e){return"characterData"!=e.type},t.prototype.slice=function(e,r,o){var n=this.node.cut(e,r),i=document.createTextNode(n.text);return new t(this.parent,n,this.outerDeco,this.innerDeco,i,i,o)},t}(Ra),ng=function(e){function t(){e.apply(this,arguments)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.parseRule=function(){return{ignore:!0}},t.prototype.matchesHack=function(){return this.dirty==L},t}(d),qg=function(e){function t(t,r,o,n,i,a,s,$,c,l){e.call(this,t,r,o,n,i,a,s,c,l),this.spec=$}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.update=function(t,r,o,n){if(this.dirty==ua)return!1;if(this.spec.update){var i=this.spec.update(t,r);return i&&this.updateInner(t,r,o,n),i}return!(!this.contentDOM&&!t.isLeaf)&&e.prototype.update.call(this,t,r,o,n)},t.prototype.selectNode=function(){this.spec.selectNode?this.spec.selectNode():e.prototype.selectNode.call(this)},t.prototype.deselectNode=function(){this.spec.deselectNode?this.spec.deselectNode():e.prototype.deselectNode.call(this)},t.prototype.setSelection=function(t,r,o,n){this.spec.setSelection?this.spec.setSelection(t,r,o):e.prototype.setSelection.call(this,t,r,o,n)},t.prototype.destroy=function(){this.spec.destroy&&this.spec.destroy(),e.prototype.destroy.call(this)},t.prototype.stopEvent=function(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)},t.prototype.ignoreMutation=function(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):e.prototype.ignoreMutation.call(this,t)},t}(Ra);function Fd(e,t){for(var r=e.firstChild,o=0;o<t.length;o++){var n=t[o],i=n.dom;if(i.parentNode==e){for(;i!=r;)r=Ld(r);r=r.nextSibling}else e.insertBefore(i,r);if(n instanceof _b){var a=r?r.previousSibling:e.lastChild;Fd(n.contentDOM,n.children),r=a?a.nextSibling:e.firstChild}}for(;r;)r=Ld(r)}function Oa(e){e&&(this.nodeName=e)}Oa.prototype=Object.create(null);var za=[new Oa];function Xb(e,t,r){if(0==e.length)return za;for(var o=r?za[0]:new Oa,n=[o],i=0;i<e.length;i++){var a=e[i].type.attrs,s=o;if(a)for(var $ in a.nodeName&&n.push(s=new Oa(a.nodeName)),a){var c=a[$];null!=c&&(r&&1==n.length&&n.push(s=o=new Oa(t.isInline?"span":"div")),"class"==$?s.class=(s.class?s.class+" ":"")+c:"style"==$?s.style=(s.style?s.style+";":"")+c:"nodeName"!=$&&(s[$]=c))}}return n}function Jd(e,t,r,o){if(r==za&&o==za)return t;for(var n=t,i=0;i<o.length;i++){var a=o[i],s=r[i];if(i){var $=void 0;s&&s.nodeName==a.nodeName&&n!=e&&($=t.parentNode)&&$.tagName.toLowerCase()==a.nodeName?n=$:(($=document.createElement(a.nodeName)).appendChild(n),n=$)}xg(n,s||za[0],a)}return n}function xg(e,t,r){for(var o in t)"class"==o||"style"==o||"nodeName"==o||o in r||e.removeAttribute(o);for(var n in r)"class"!=n&&"style"!=n&&"nodeName"!=n&&r[n]!=t[n]&&e.setAttribute(n,r[n]);if(t.class!=r.class){for(var i=t.class?t.class.split(" "):W,a=r.class?r.class.split(" "):W,s=0;s<i.length;s++)-1==a.indexOf(i[s])&&e.classList.remove(i[s]);for(var $=0;$<a.length;$++)-1==i.indexOf(a[$])&&e.classList.add(a[$])}if(t.style!=r.style){if(t.style)for(var c,l=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;c=l.exec(t.style);)e.style[c[1].toLowerCase()]="";r.style&&(e.style.cssText+=r.style)}}function Kd(e,t,r){return Jd(e,e,za,Xb(t,r,1!=e.nodeType))}function Wb(e,t){if(e.length!=t.length)return!1;for(var r=0;r<e.length;r++)if(!e[r].type.eq(t[r].type))return!1;return!0}function Ld(e){var t=e.nextSibling;return e.parentNode.removeChild(e),t}var M=function(e,t){this.top=e,this.lock=t,this.index=0,this.stack=[],this.changed=!1;var r=Eg(e.node.content,e.children);this.preMatched=r.nodes,this.preMatchOffset=r.offset};function Eg(e,t){for(var r=[],o=e.childCount,n=t.length-1;o>0&&n>=0;n--){var i=t[n],a=i.node;if(a){if(a!=e.child(o-1))break;r.push(i),--o}}return{nodes:r.reverse(),offset:o}}function Fg(e,t){return e.type.side-t.type.side}function Gg(e,t,r,o){var n=t.locals(e),i=0;if(0!=n.length)for(var a=0,s=[],$=null,c=0;;){if(a<n.length&&n[a].to==i){for(var l=n[a++],d=void 0;a<n.length&&n[a].to==i;)(d||(d=[l])).push(n[a++]);if(d){d.sort(Fg);for(var p=0;p<d.length;p++)r(d[p],c)}else r(l,c)}var v=void 0,h=void 0;if($)h=-1,v=$,$=null;else{if(!(c<e.childCount))break;h=c,v=e.child(c++)}for(var u=0;u<s.length;u++)s[u].to<=i&&s.splice(u--,1);for(;a<n.length&&n[a].from==i;)s.push(n[a++]);var f=i+v.nodeSize;if(v.isText){var D=f;a<n.length&&n[a].from<D&&(D=n[a].from);for(var S=0;S<s.length;S++)s[S].to<D&&(D=s[S].to);D<f&&($=v.cut(D-i),v=v.cut(0,D-i),f=D,h=-1)}o(v,s.length?s.slice():W,t.forChild(i,v),h),i=f}else for(var z=0;z<e.childCount;z++){var m=e.child(z);o(m,n,t.forChild(i,m),z),i+=m.nodeSize}}function Hg(e){if("UL"==e.nodeName||"OL"==e.nodeName){var t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}function Kg(e,t){for(;;){if(3==e.nodeType)return e;if(1==e.nodeType&&t>0)t=nb(e=e.childNodes[t-1]);else{if(!(1==e.nodeType&&t<e.childNodes.length))return null;e=e.childNodes[t],t=0}}}function Lg(e,t,r,o){for(var n="",i=0,a=0;i<e.childCount;i++){var s=e.child(i),$=a+s.nodeSize;if(s.isText){if(n+=s.text,$>=o){for(var c=$-n.length,l=n.lastIndexOf(t);l>-1&&c+l>r;)l=n.lastIndexOf(t,l-1);if(l>-1&&c+l+t.length>=o)return c+l;if($>o-t.length)break}}else n="";a=$}return-1}function Ub(e,t,r,o,n){for(var i=[],a=0,s=0;a<e.length;a++){var $=e[a],c=s,l=s+=$.size;c>=r||l<=t?i.push($):(c<t&&i.push($.slice(0,t-c,o)),n&&(i.push(n),n=null),l>r&&i.push($.slice(r-c,$.size,o)))}return i}function Od(e){var t=e.cloneNode(!0);return function e(t){if(1==t.nodeType)for(var r=t.firstChild;r;r=r.nextSibling)e(r);else 3==t.nodeType&&(t.nodeValue=t.nodeValue.replace(/\ufeff/g,""))}(t),t}function Qb(e,t){var r=e.selection,o=r.$anchor,n=r.$head,i=t>0?o.max(n):o.min(n),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return a&&_.findFrom(a,t)}function ta(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Qd(e,t,r){var o=e.state.selection;if(o instanceof x){if(!o.empty||r.indexOf("s")>-1)return!1;if(e.endOfTextblock(t>0?"right":"left")){var n=Qb(e.state,t);return!!(n&&n instanceof f)&&ta(e,n)}var i,a=o.$head,s=a.textOffset?null:t<0?a.nodeBefore:a.nodeAfter;if(!s||s.isText)return!1;var $=t<0?a.pos-s.nodeSize:a.pos;return!!(s.isAtom||(i=e.docView.descAt($))&&!i.contentDOM)&&(f.isSelectable(s)?ta(e,new f(t<0?e.state.doc.resolve(a.pos-s.nodeSize):a)):!!j.webkit&&ta(e,new x(e.state.doc.resolve(t<0?$:$+s.nodeSize))))}if(o instanceof f&&o.node.isInline)return ta(e,new x(t>0?o.$to:o.$from));var c=Qb(e.state,t);return!!c&&ta(e,c)}function Hb(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Ha(e){var t=e.pmViewDesc;return t&&0==t.size&&(e.nextSibling||"BR"!=e.nodeName)}function Yc(e){var t=e.root.getSelection(),r=t.focusNode,o=t.focusOffset;if(r){var n,i,a=!1;for(j.gecko&&1==r.nodeType&&o<Hb(r)&&Ha(r.childNodes[o])&&(a=!0);;)if(o>0){if(1!=r.nodeType){if(3!=r.nodeType||"\uFEFF"!=r.nodeValue.charAt(o-1))break;j.ie&&j.ie_version<=11&&(a=!0),n=r,i=--o}else{var s=r.childNodes[o-1];if(Ha(s))n=r,i=--o;else{if(3!=s.nodeType)break;o=(r=s).nodeValue.length}}}else{if(Sd(r))break;for(var $=r.previousSibling;$&&Ha($);)n=r.parentNode,i=ga($),$=$.previousSibling;if($)o=Hb(r=$);else{if((r=r.parentNode)==e.dom)break;o=0}}a?Wc(e,t,r,o):n&&Wc(e,t,n,i)}}function bc(e){var t=e.root.getSelection(),r=t.focusNode,o=t.focusOffset;if(r){for(var n,i,a=Hb(r);;)if(o<a){if(1!=r.nodeType)break;if(!Ha(r.childNodes[o]))break;n=r,i=++o}else{if(Sd(r))break;for(var s=r.nextSibling;s&&Ha(s);)n=s.parentNode,i=ga(s)+1,s=s.nextSibling;if(s)o=0,a=Hb(r=s);else{if((r=r.parentNode)==e.dom)break;o=a=0}}n&&Wc(e,t,n,i)}}function Sd(e){var t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Wc(e,t,r,o){if(mc(t)){var n=document.createRange();n.setEnd(r,o),n.setStart(r,o),t.removeAllRanges(),t.addRange(n)}else t.extend&&t.extend(r,o);e.domObserver.setCurSelection()}function Td(e,t,r){var o=e.state.selection;if(o instanceof x&&!o.empty||r.indexOf("s")>-1)return!1;var n=o.$from,i=o.$to;if(!n.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){var a=Qb(e.state,t);if(a&&a instanceof f)return ta(e,a)}if(!n.parent.inlineContent){var s=_.findFrom(t<0?n:i,t);return!s||ta(e,s)}return!1}function Ud(e,t){if(!(e.state.selection instanceof x))return!0;var r=e.state.selection,o=r.$head,n=r.$anchor,i=r.empty;if(!o.sameParent(n))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;var a=!o.textOffset&&(t<0?o.nodeBefore:o.nodeAfter);if(a&&!a.isText){var s=e.state.tr;return t<0?s.delete(o.pos-a.nodeSize,o.pos):s.delete(o.pos,o.pos+a.nodeSize),e.dispatch(s),!0}return!1}function Vd(e,t,r){e.domObserver.stop(),t.contentEditable=r,e.domObserver.start()}function Dh(e){if(j.chrome&&!(e.state.selection.$head.parentOffset>0)){var t=e.root.getSelection(),r=t.focusNode,o=t.focusOffset;if(r&&1==r.nodeType&&0==o&&r.firstChild&&"false"==r.firstChild.contentEditable){var n=r.firstChild;Vd(e,n,!0),setTimeout(function(){return Vd(e,n,!1)},20)}}}function Eh(e){var t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}function Fh(e,t){var r=t.keyCode,o=Eh(t);return 8==r||j.mac&&72==r&&"c"==o?Ud(e,-1)||Yc(e):46==r||j.mac&&68==r&&"c"==o?Ud(e,1)||bc(e):13==r||27==r||(37==r?Qd(e,-1,o)||Yc(e):39==r?Qd(e,1,o)||bc(e):38==r?Td(e,-1,o)||Yc(e):40==r?Dh(e)||Td(e,1,o)||bc(e):o==(j.mac?"m":"c")&&(66==r||73==r||89==r||90==r))}function Xh(e,t){var r,o,n=e.root.getSelection(),i=e.state.doc,a=e.docView.nearestDesc(n.focusNode),s=a&&0==a.size,$=e.docView.posFromDOM(n.focusNode,n.focusOffset),c=i.resolve($);if(mc(n)){for(r=c;a&&!a.node;)a=a.parent;if(a&&a.node.isAtom&&f.isSelectable(a.node)&&a.parent){var l=a.posBefore;o=new f($==l?c:i.resolve(l))}}else r=i.resolve(e.docView.posFromDOM(n.anchorNode,n.anchorOffset));o||(o=Sc(e,r,c,"pointer"==t||e.state.selection.head<c.pos&&!s?1:-1));return o}function Na(e,t,r){var o=e.state.selection;if(Yd(e,o),e.editable&&!e.hasFocus()){if(!t)return;j.gecko&&j.gecko_version<=55&&(e.domObserver.disconnectSelection(),e.dom.focus(),e.domObserver.connectSelection())}else if(!e.editable&&!Rc(e)&&!t)return;if(e.domObserver.disconnectSelection(),e.cursorWrapper)ji(e);else{var n,i,a=o.anchor,s=o.head;!Wd||o instanceof x||(o.$from.parent.inlineContent||(n=Xd(e,o.from)),o.empty||o.$from.parent.inlineContent||(i=Xd(e,o.to))),e.docView.setSelection(a,s,e.root,r),Wd&&(n&&(n.contentEditable="false"),i&&(i.contentEditable="false")),o.visible?e.dom.classList.remove("ProseMirror-hideselection"):a!=s&&(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&fi(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}M.prototype.getPreMatch=function(e){return e>=this.preMatchOffset?this.preMatched[e-this.preMatchOffset]:null},M.prototype.destroyBetween=function(e,t){if(e!=t){for(var r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}},M.prototype.destroyRest=function(){this.destroyBetween(this.index,this.top.children.length)},M.prototype.syncToMarks=function(e,t,r){for(var o=0,n=this.stack.length>>1,i=Math.min(n,e.length);o<i&&(o==n-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&!1!==e[o].type.spec.spanning;)o++;for(;o<n;)this.destroyRest(),this.top.dirty=L,this.index=this.stack.pop(),this.top=this.stack.pop(),n--;for(;n<e.length;){this.stack.push(this.top,this.index+1);for(var a=-1,s=this.index;s<Math.min(this.index+3,this.top.children.length);s++)if(this.top.children[s].matchesMark(e[n])){a=s;break}if(a>-1)a>this.index&&(this.changed=!0,this.top.children.splice(this.index,a-this.index)),this.top=this.top.children[this.index];else{var $=_b.create(this.top,e[n],t,r);this.top.children.splice(this.index,0,$),this.top=$,this.changed=!0}this.index=0,n++}},M.prototype.findNodeMatch=function(e,t,r,o){var n=-1,i=o<0?void 0:this.getPreMatch(o),a=this.top.children;if(i&&i.matchesNode(e,t,r))n=a.indexOf(i);else for(var s=this.index,$=Math.min(a.length,s+5);s<$;s++){var c=a[s];if(c.matchesNode(e,t,r)&&this.preMatched.indexOf(c)<0){n=s;break}}return!(n<0)&&(this.destroyBetween(this.index,n),this.index++,!0)},M.prototype.updateNextNode=function(e,t,r,o,n){if(this.index==this.top.children.length)return!1;var i=this.top.children[this.index];if(i instanceof Ra){var a=this.preMatched.indexOf(i);if(a>-1&&a+this.preMatchOffset!=n)return!1;var s=i.dom;if(!(this.lock&&(s==this.lock||1==s.nodeType&&s.contains(this.lock.parentNode))&&!(e.isText&&i.node&&i.node.isText&&i.nodeDOM.nodeValue==e.text&&i.dirty!=ua&&Wb(t,i.outerDeco)))&&i.update(e,t,r,o))return i.dom!=s&&(this.changed=!0),this.index++,!0}return!1},M.prototype.addNode=function(e,t,r,o,n){this.top.children.splice(this.index++,0,Ra.create(this.top,e,t,r,o,n)),this.changed=!0},M.prototype.placeWidget=function(e,t,r){if(this.index<this.top.children.length&&this.top.children[this.index].matchesWidget(e))this.index++;else{var o=new(e.spec.isCursorWrapper?ag:Bd)(this.top,e,t,r);this.top.children.splice(this.index++,0,o),this.changed=!0}},M.prototype.placeComposition=function(e,t){this.syncToMarks(W,!0,e),this.top.children[this.index]==t?this.index++:(this.top.children.splice(this.index++,0,t),this.changed=!0)},M.prototype.addTextblockHacks=function(){for(var e=this.top.children[this.index-1];e instanceof _b;)e=e.children[e.children.length-1];if(!e||!(e instanceof Ed)||/\n$/.test(e.node.text))if(this.index<this.top.children.length&&this.top.children[this.index].matchesHack())this.index++;else{var t=document.createElement("br");this.top.children.splice(this.index++,0,new ng(this.top,W,t,null)),this.changed=!0}};var Wd=j.safari||j.chrome&&j.chrome_version<63;function Xd(e,t){var r=e.docView.domFromPos(t),o=r.node,n=r.offset,i=n<o.childNodes.length?o.childNodes[n]:null,a=n?o.childNodes[n-1]:null;if(!(i&&"false"!=i.contentEditable||a&&"false"!=a.contentEditable)){if(i)return i.contentEditable="true",i;if(a)return a.contentEditable="true",a}}function fi(e){var t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.hideSelectionGuard);var r=e.root.getSelection(),o=r.anchorNode,n=r.anchorOffset;t.addEventListener("selectionchange",e.hideSelectionGuard=function(){r.anchorNode==o&&r.anchorOffset==n||(t.removeEventListener("selectionchange",e.hideSelectionGuard),e.dom.classList.remove("ProseMirror-hideselection"))})}function ji(e){var t=e.root.getSelection(),r=document.createRange(),o=e.cursorWrapper.dom;r.setEnd(o,o.childNodes.length),r.collapse(!1),t.removeAllRanges(),t.addRange(r),!e.state.selection.visible&&j.ie&&j.ie_version<=11&&(o.disabled=!0,o.disabled=!1)}function Yd(e,t){if(t instanceof f){var r=e.docView.descAt(t.from);r!=e.lastSelectedViewDesc&&(Zd(e),r&&r.selectNode(),e.lastSelectedViewDesc=r)}else Zd(e)}function Zd(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=null)}function Sc(e,t,r,o){return e.someProp("createSelectionBetween",function(o){return o(e,t,r)})||x.between(t,r,o)}function pi(e){return(!e.editable||e.root.activeElement==e.dom)&&Rc(e)}function Rc(e){var t=e.root.getSelection();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(r){return!1}}function xi(e){return!1===e.type.spec.inclusive}function $d(e){var t=e.selection,r=t.$head,o=t.$anchor,n=t.visible,i=r.pos!=o.pos||n&&!r.parent.inlineContent?null:r;return i&&(!n||e.storedMarks||0==i.parent.content.length||i.parentOffset&&!i.textOffset&&i.nodeBefore.marks.some(xi))?i:null}function zi(e){var t=e.docView.domFromPos(e.state.selection.anchor),r=e.root.getSelection();return rc(t.node,t.offset,r.anchorNode,r.anchorOffset)}function Ai(e,t,r){var o=e.docView.parseRange(t,r),n=o.node,i=o.fromOffset,a=o.toOffset,s=o.from,$=o.to,c=e.root.getSelection(),l=null,d=c.anchorNode;if(d&&e.dom.contains(1==d.nodeType?d:d.parentNode)&&(l=[{node:d,offset:c.anchorOffset}],mc(c)||l.push({node:c.focusNode,offset:c.focusOffset})),j.chrome&&8===e.lastKeyCode)for(var p=a;p>i;p--){var v=n.childNodes[p-1],h=v.pmViewDesc;if("BR"==v.nodeType&&!h){a=p;break}if(!h||h.size)break}var u=e.state.doc,f=e.someProp("domParser")||jb.fromSchema(e.state.schema),D=u.resolve(s),S=null,z=f.parse(n,{topNode:D.parent,topMatch:D.parent.contentMatchAt(D.index()),topOpen:!0,from:i,to:a,preserveWhitespace:!D.parent.type.spec.code||"full",editableContent:!0,findPositions:l,ruleFromNode:Fi(f,D),context:D});if(l&&null!=l[0].pos){var m=l[0].pos,g=l[1]&&l[1].pos;null==g&&(g=m),S={anchor:m+s,head:g+s}}return{doc:z,sel:S,from:s,to:$}}function Fi(e,t){return function(r){var o=r.pmViewDesc;if(o)return o.parseRule();if("BR"==r.nodeName&&r.parentNode){if(j.safari&&/^(ul|ol)$/i.test(r.parentNode.nodeName))return e.matchTag(document.createElement("li"),t);if(r.parentNode.lastChild==r||j.safari&&/^(tr|table)$/i.test(r.parentNode.nodeName))return{ignore:!0}}}}function Ii(e,t,r,o){if(t<0){var n=e.lastSelectionTime>Date.now()-50?e.lastSelectionOrigin:null,i=Xh(e,n);if(!e.state.selection.eq(i)){var a=e.state.tr.setSelection(i);"pointer"==n?a.setMeta("pointer",!0):"key"==n&&a.scrollIntoView(),e.dispatch(a)}}else{var s=e.state.doc.resolve(t),$=s.sharedDepth(r);t=s.before($+1),r=e.state.doc.resolve(r).after($+1);var c,l,d=e.state.selection,p=Ai(e,t,r),v=e.state.doc,h=v.slice(p.from,p.to);8===e.lastKeyCode&&Date.now()-100<e.lastKeyCodeTime?(c=e.state.selection.to,l="end"):(c=e.state.selection.from,l="start"),e.lastKeyCode=null;var u=Wi(h.content,p.doc.content,p.from,c,l);if(u){e.domChangeCount++,e.state.selection.from<e.state.selection.to&&u.start==u.endB&&e.state.selection instanceof x&&(u.start>e.state.selection.from&&u.start<=e.state.selection.from+2?u.start=e.state.selection.from:u.endA<e.state.selection.to&&u.endA>=e.state.selection.to-2&&(u.endB+=e.state.selection.to-u.endA,u.endA=e.state.selection.to));var f,D=p.doc.resolveNoCache(u.start-p.from),S=p.doc.resolveNoCache(u.endB-p.from);if(!(!D.sameParent(S)&&D.pos<p.doc.content.size&&(f=_.findFrom(p.doc.resolve(D.pos+1),1,!0))&&f.head==S.pos&&e.someProp("handleKeyDown",function(t){return t(e,lc(13,"Enter"))})))if(e.state.selection.anchor>u.start&&Ui(v,u.start,u.endA,D,S)&&e.someProp("handleKeyDown",function(t){return t(e,lc(8,"Backspace"))}))j.android&&j.chrome&&e.domObserver.suppressSelectionUpdates();else{var z,m,g,y,b=u.start,w=u.endA;if(D.sameParent(S)&&D.parent.inlineContent)if(D.pos==S.pos)j.ie&&j.ie_version<=11&&0==D.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout(function(){return Na(e)},20)),z=e.state.tr.delete(b,w),m=v.resolve(u.start).marksAcross(v.resolve(u.endA));else if(u.endA==u.endB&&(y=v.resolve(u.start))&&(g=Ti(D.parent.content.cut(D.parentOffset,S.parentOffset),y.parent.content.cut(y.parentOffset,u.endA-y.start()))))z=e.state.tr,"add"==g.type?z.addMark(b,w,g.mark):z.removeMark(b,w,g.mark);else if(D.parent.child(D.index()).isText&&D.index()==S.index()-(S.textOffset?0:1)){var O=D.parent.textBetween(D.parentOffset,S.parentOffset);if(e.someProp("handleTextInput",function(t){return t(e,b,w,O)}))return;z=e.state.tr.insertText(O,b,w)}if(z||(z=e.state.tr.replace(b,w,p.doc.slice(u.start-p.from,u.endB-p.from))),p.sel){var C=_d(e,z.doc,p.sel);C&&z.setSelection(C)}m&&z.ensureMarks(m),e.dispatch(z.scrollIntoView())}}else if(!(o&&d instanceof x&&!d.empty&&d.$head.sameParent(d.$anchor))||e.composing||p.sel&&p.sel.anchor!=p.sel.head){if(p.sel){var N=_d(e,e.state.doc,p.sel);N&&!N.eq(e.state.selection)&&e.dispatch(e.state.tr.setSelection(N))}}else{var T=e.state,M=T.selection;e.dispatch(T.tr.replaceSelectionWith(T.schema.text(T.doc.textBetween(M.from,M.to)),!0).scrollIntoView())}}}function _d(e,t,r){return Math.max(r.anchor,r.head)>t.content.size?null:Sc(e,t.resolve(r.anchor),t.resolve(r.head))}function Ti(e,t){for(var r,o,n,i=e.firstChild.marks,a=t.firstChild.marks,s=i,$=a,c=0;c<a.length;c++)s=a[c].removeFromSet(s);for(var l=0;l<i.length;l++)$=i[l].removeFromSet($);if(1==s.length&&0==$.length)o=s[0],r="add",n=function(e){return e.mark(o.addToSet(e.marks))};else{if(0!=s.length||1!=$.length)return null;o=$[0],r="remove",n=function(e){return e.mark(o.removeFromSet(e.marks))}}for(var d=[],p=0;p<t.childCount;p++)d.push(n(t.child(p)));if(g.from(d).eq(e))return{mark:o,type:r}}function Ui(e,t,r,o,n){if(!o.parent.isTextblock||r-t<=n.pos-o.pos||Qc(o,!0,!1)<n.pos)return!1;var i=e.resolve(t);if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;var a=e.resolve(Qc(i,!0,!0));return!(!a.parent.isTextblock||a.pos>r||Qc(a,!0,!1)<r)&&o.parent.content.cut(o.parentOffset).eq(a.parent.content)}function Qc(e,t,r){for(var o=e.depth,n=t?e.end():e.pos;o>0&&(t||e.indexAfter(o)==e.node(o).childCount);)o--,n++,t=!1;if(r)for(var i=e.node(o).maybeChild(e.indexAfter(o));i&&!i.isLeaf;)i=i.firstChild,n++;return n}function Wi(e,t,r,o,n){var i=e.findDiffStart(t,r);if(null==i)return null;var a=e.findDiffEnd(t,r+e.size,r+t.size),s=a.a,$=a.b;"end"==n&&(o-=s+Math.max(0,i-Math.min(s,$))-i);if(s<i&&e.size<t.size)$=(i-=o<=i&&o>=s?i-o:0)+($-s),s=i;else if($<i){s=(i-=o<=i&&o>=$?i-o:0)+(s-$),$=i}return{start:i,endA:s,endB:$}}function Pc(e,t){for(var r=[],o=t.content,n=t.openStart,i=t.openEnd;n>1&&i>1&&1==o.childCount&&1==o.firstChild.childCount;){n--,i--;var a=o.firstChild;r.push(a.type.name,a.type.hasRequiredAttrs()?a.attrs:null),o=a.content}var s=e.someProp("clipboardSerializer")||Ga.fromSchema(e.state.schema),$=document.createElement("div");$.appendChild(s.serializeFragment(o));for(var c,l=$.firstChild;l&&1==l.nodeType&&(c=ee[l.nodeName.toLowerCase()]);){for(var d=c.length-1;d>=0;d--){for(var p=document.createElement(c[d]);$.firstChild;)p.appendChild($.firstChild);$.appendChild(p)}l=$.firstChild}return l&&1==l.nodeType&&l.setAttribute("data-pm-slice",n+" "+i+" "+JSON.stringify(r)),{dom:$,text:e.someProp("clipboardTextSerializer",function(e){return e(t)})||t.content.textBetween(0,t.content.size,"\n\n")}}function Oc(e,t,r,o,n){var i,a,s=n.parent.type.spec.code;if(!r&&!t)return null;var $=t&&(o||s||!r);if($){if(e.someProp("transformPastedText",function(e){t=e(t)}),s)return new k(g.from(e.state.schema.text(t)),0,0);var c=e.someProp("clipboardTextParser",function(e){return e(t,n)});c?a=c:(i=document.createElement("div"),t.trim().split(/(?:\r\n?|\n)+/).forEach(function(e){i.appendChild(document.createElement("p")).textContent=e}))}else e.someProp("transformPastedHTML",function(e){r=e(r)}),i=gj(r);var l=i&&i.querySelector("[data-pm-slice]"),d=l&&/^(\d+) (\d+) (.*)/.exec(l.getAttribute("data-pm-slice"));if(!a){var p=e.someProp("clipboardParser")||e.someProp("domParser")||jb.fromSchema(e.state.schema);a=p.parseSlice(i,{preserveWhitespace:!(!$&&!d),context:n})}return a=d?hj(new k(a.content,Math.min(a.openStart,+d[1]),Math.min(a.openEnd,+d[2])),d[3]):k.maxOpen(Zi(a.content,n),!1),e.someProp("transformPasted",function(e){a=e(a)}),a}function Zi(e,t){if(e.childCount<2)return e;for(var r=function(r){var o=t.node(r).contentMatchAt(t.index(r)),n=void 0,i=[];if(e.forEach(function(e){if(i){var t,r=o.findWrapping(e.type);if(!r)return i=null;if(t=i.length&&n.length&&ce(r,n,e,i[i.length-1],0))i[i.length-1]=t;else{i.length&&(i[i.length-1]=de(i[i.length-1],n.length));var a=be(e,r);i.push(a),o=o.matchType(a.type,a.attrs),n=r}}}),i)return{v:g.from(i)}},o=t.depth;o>=0;o--){var n=r(o);if(n)return n.v}return e}function be(e,t,r){void 0===r&&(r=0);for(var o=t.length-1;o>=r;o--)e=t[o].create(null,g.from(e));return e}function ce(e,t,r,o,n){if(n<e.length&&n<t.length&&e[n]==t[n]){var i=ce(e,t,r,o.lastChild,n+1);if(i)return o.copy(o.content.replaceChild(o.childCount-1,i));if(o.contentMatchAt(o.childCount).matchType(n==e.length-1?r.type:e[n+1]))return o.copy(o.content.append(g.from(be(r,e,n+1))))}}function de(e,t){if(0==t)return e;var r=e.content.replaceChild(e.childCount-1,de(e.lastChild,t-1)),o=e.contentMatchAt(e.childCount).fillBefore(g.empty,!0);return e.copy(r.append(o))}var ee={thead:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},fj=null;function gj(e){var t=/(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));var r,o=(fj||(fj=document.implementation.createHTMLDocument("title"))).createElement("div"),n=/(?:<meta [^>]*>)*<([a-z][^>\s]+)/i.exec(e),i=0;(r=n&&ee[n[1].toLowerCase()])&&(e=r.map(function(e){return"<"+e+">"}).join("")+e+r.map(function(e){return"</"+e+">"}).reverse().join(""),i=r.length),o.innerHTML=e;for(var a=0;a<i;a++)o=o.firstChild;return o}function hj(e,t){if(!e.size)return e;var r,o=e.content.firstChild.type.schema;try{r=JSON.parse(t)}catch(c){return e}for(var n=e.content,i=e.openStart,a=e.openEnd,s=r.length-2;s>=0;s-=2){var $=o.nodes[r[s]];if(!$||$.hasRequiredAttrs())break;n=g.from($.create(r[s+1],n)),i++,a++}return new k(n,i,a)}var kj={childList:!0,characterData:!0,attributes:!0,subtree:!0,characterDataOldValue:!0},Nc=j.ie&&j.ie_version<=11,sc=function(){this.anchorNode=this.anchorOffset=this.focusNode=this.focusOffset=null};sc.prototype.set=function(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset},sc.prototype.eq=function(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset};var U=function(e,t){var r=this;this.view=e,this.handleDOMChange=t,this.observer=window.MutationObserver&&new window.MutationObserver(function(e){return r.flush(e)}),this.currentSelection=new sc,this.queue=[],Nc&&(this.onCharData=function(e){r.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),window.setTimeout(function(){return r.flush()},20)}),this.onSelectionChange=this.onSelectionChange.bind(this),this.suppressingSelectionUpdates=!1};U.prototype.start=function(){this.observer&&this.observer.observe(this.view.dom,kj),Nc&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()},U.prototype.stop=function(){var e=this,t=this.observer.takeRecords();if(t.length){for(var r=0;r<t.length;r++)e.queue.push(t[r]);window.setTimeout(function(){return e.flush()},20)}this.observer&&this.observer.disconnect(),Nc&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()},U.prototype.connectSelection=function(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)},U.prototype.disconnectSelection=function(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)},U.prototype.suppressSelectionUpdates=function(){var e=this;this.suppressingSelectionUpdates=!0,setTimeout(function(){return e.suppressingSelectionUpdates=!1},50)},U.prototype.onSelectionChange=function(){if(pi(this.view))return this.suppressingSelectionUpdates?Na(this.view):void this.flush()},U.prototype.setCurSelection=function(){this.currentSelection.set(this.view.root.getSelection())},U.prototype.flush=function(e){if(this.view.docView){e||(e=this.observer.takeRecords()),this.queue.length&&(e=this.queue.concat(e),this.queue.length=0);var t=this.view.root.getSelection(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(t)&&Rc(this.view),o=-1,n=-1,i=!1;if(this.view.editable)for(var a=0;a<e.length;a++){var s=this.registerMutation(e[a]);s&&(o=o<0?s.from:Math.min(s.from,o),n=n<0?s.to:Math.max(s.to,n),s.typeOver&&(i=!0))}(o>-1||r)&&(o>-1&&this.view.docView.markDirty(o,n),this.handleDOMChange(o,n,i),this.view.docView.dirty?this.view.updateState(this.view.state):this.currentSelection.eq(t)||Na(this.view))}},U.prototype.registerMutation=function(e){var t=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(t==this.view.docView||"contenteditable"==e.attributeName))return null;if(!t||t.ignoreMutation(e))return null;if("childList"==e.type){var r=e.previousSibling&&e.previousSibling.parentNode==e.target?ga(e.previousSibling)+1:0,o=t.localPosFromDOM(e.target,r,-1),n=e.nextSibling&&e.nextSibling.parentNode==e.target?ga(e.nextSibling):e.target.childNodes.length;return{from:o,to:t.localPosFromDOM(e.target,n,1)}}return"attributes"==e.type?{from:t.posAtStart-t.border,to:t.posAtEnd+t.border}:{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}};var G={},E={};function Tj(e){e.shiftKey=!1,e.mouseDown=null,e.lastKeyCode=null,e.lastKeyCodeTime=0,e.lastClick={time:0,x:0,y:0,type:""},e.lastSelectionOrigin=null,e.lastSelectionTime=0,e.composing=!1,e.composingTimeout=null,e.compositionNodes=[],e.compositionEndedAt=-2e8,e.domObserver=new U(e,function(t,r,o){return Ii(e,t,r,o)}),e.domObserver.start(),e.domChangeCount=0,e.eventHandlers=Object.create(null);var t=function(t){var r=G[t];e.dom.addEventListener(t,e.eventHandlers[t]=function(t){!Pf(e,t)||ec(e,t)||!e.editable&&t.type in E||r(e,t)})};for(var r in G)t(r);j.safari&&e.dom.addEventListener("input",function(){return null}),fc(e)}function ja(e,t){e.lastSelectionOrigin=t,e.lastSelectionTime=Date.now()}function fk(e){for(var t in e.domObserver.stop(),e.eventHandlers)e.dom.removeEventListener(t,e.eventHandlers[t]);clearTimeout(e.composingTimeout)}function fc(e){e.someProp("handleDOMEvents",function(t){for(var r in t)e.eventHandlers[r]||e.dom.addEventListener(r,e.eventHandlers[r]=function(t){return ec(e,t)})})}function ec(e,t){return e.someProp("handleDOMEvents",function(r){var o=r[t.type];return!!o&&(o(e,t)||t.defaultPrevented)})}function Pf(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(var r=t.target;r!=e.dom;r=r.parentNode)if(!r||11==r.nodeType||r.pmViewDesc&&r.pmViewDesc.stopEvent(t))return!1;return!0}function Qf(e,t){ec(e,t)||!G[t.type]||!e.editable&&t.type in E||G[t.type](e,t)}function hb(e){return{left:e.clientX,top:e.clientY}}function Sf(e,t){var r=t.x-e.clientX,o=t.y-e.clientY;return r*r+o*o<100}function ac(e,t,r,o,n){if(-1==o)return!1;for(var i=e.state.doc.resolve(o),a=function(o){if(e.someProp(t,function(t){return o>i.depth?t(e,r,i.nodeAfter,i.before(o),n,!0):t(e,r,i.node(o),i.before(o),n,!1)}))return{v:!0}},s=i.depth+1;s>0;s--){var $=a(s);if($)return $.v}return!1}function Ba(e,t,r){e.focused||e.focus();var o=e.state.tr.setSelection(t);"pointer"==r&&o.setMeta("pointer",!0),e.dispatch(o)}function Vf(e,t){if(-1==t)return!1;var r=e.state.doc.resolve(t),o=r.nodeAfter;return!!(o&&o.isAtom&&f.isSelectable(o))&&(Ba(e,new f(r),"pointer"),!0)}function Wf(e,t){if(-1==t)return!1;var r,o,n=e.state.selection;n instanceof f&&(r=n.node);for(var i=e.state.doc.resolve(t),a=i.depth+1;a>0;a--){var s=a>i.depth?i.nodeAfter:i.node(a);if(f.isSelectable(s)){o=r&&n.$from.depth>0&&a>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?i.before(n.$from.depth):i.before(a);break}}return null!=o&&(Ba(e,f.create(e.state.doc,o),"pointer"),!0)}function Xf(e,t,r,o,n){return ac(e,"handleClickOn",t,r,o)||e.someProp("handleClick",function(r){return r(e,t,o)})||(n?Wf(e,r):Vf(e,r))}function Yf(e,t,r,o){return ac(e,"handleDoubleClickOn",t,r,o)||e.someProp("handleDoubleClick",function(r){return r(e,t,o)})}function Zf(e,t,r,o){return ac(e,"handleTripleClickOn",t,r,o)||e.someProp("handleTripleClick",function(r){return r(e,t,o)})||$f(e,r)}function $f(e,t){var r=e.state.doc;if(-1==t)return!!r.inlineContent&&(Ba(e,x.create(r,0,r.content.size),"pointer"),!0);for(var o=r.resolve(t),n=o.depth+1;n>0;n--){var i=n>o.depth?o.nodeAfter:o.node(n),a=o.before(n);if(i.inlineContent)Ba(e,x.create(r,a+1,a+1+i.content.size),"pointer");else{if(!f.isSelectable(i))continue;Ba(e,f.create(r,a),"pointer")}return!0}}function Vb(e){return bb(e)}E.keydown=function(e,t){e.shiftKey=16==t.keyCode||t.shiftKey,me(e,t)||(e.lastKeyCode=t.keyCode,e.lastKeyCodeTime=Date.now(),e.someProp("handleKeyDown",function(r){return r(e,t)})||Fh(e,t)?t.preventDefault():ja(e,"key"))},E.keyup=function(e,t){16==t.keyCode&&(e.shiftKey=!1)},E.keypress=function(e,t){if(!(me(e,t)||!t.charCode||t.ctrlKey&&!t.altKey||j.mac&&t.metaKey))if(e.someProp("handleKeyPress",function(r){return r(e,t)}))t.preventDefault();else{var r=e.state.selection;if(!(r instanceof x&&r.$from.sameParent(r.$to))){var o=String.fromCharCode(t.charCode);e.someProp("handleTextInput",function(t){return t(e,r.$from.pos,r.$to.pos,o)})||e.dispatch(e.state.tr.insertText(o).scrollIntoView()),t.preventDefault()}}};var ke=j.mac?"metaKey":"ctrlKey";G.mousedown=function(e,t){e.shiftKey=t.shiftKey;var r=Vb(e),o=Date.now(),n="singleClick";o-e.lastClick.time<500&&Sf(t,e.lastClick)&&!t[ke]&&("singleClick"==e.lastClick.type?n="doubleClick":"doubleClick"==e.lastClick.type&&(n="tripleClick")),e.lastClick={time:o,x:t.clientX,y:t.clientY,type:n};var i=e.posAtCoords(hb(t));i&&("singleClick"==n?e.mouseDown=new cb(e,i,t,r):("doubleClick"==n?Yf:Zf)(e,i.pos,i.inside,t)?t.preventDefault():ja(e,"pointer"))};var cb=function(e,t,r,o){var n,i,a=this;if(this.view=e,this.startDoc=e.state.doc,this.pos=t,this.event=r,this.flushed=o,this.selectNode=r[ke],this.allowDefault=r.shiftKey,t.inside>-1)n=e.state.doc.nodeAt(t.inside),i=t.inside;else{var s=e.state.doc.resolve(t.pos);n=s.parent,i=s.depth?s.before():0}this.mightDrag=null;var $=o?null:r.target,c=$?e.docView.nearestDesc($,!0):null;this.target=c?c.dom:null,(n.type.spec.draggable&&!1!==n.type.spec.selectable||e.state.selection instanceof f&&i==e.state.selection.from)&&(this.mightDrag={node:n,pos:i,addAttr:this.target&&!this.target.draggable,setUneditable:this.target&&j.gecko&&!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(function(){return a.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),ja(e,"pointer")};function me(e,t){return!!e.composing||!!(j.safari&&Math.abs(t.timeStamp-e.compositionEndedAt)<500)&&(e.compositionEndedAt=-2e8,!0)}cb.prototype.done=function(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!1),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.view.mouseDown=null},cb.prototype.up=function(e){if(this.done(),this.view.dom.contains(3==e.target.nodeType?e.target.parentNode:e.target)){var t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(hb(e))),this.allowDefault||!t?(j.ie&&$d(this.view.state)&&this.view.updateState(this.view.state),ja(this.view,"pointer")):Xf(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():!this.flushed&&(!j.chrome||this.view.state.selection instanceof x||t.pos!=this.view.state.selection.from&&t.pos!=this.view.state.selection.to)?ja(this.view,"pointer"):(Ba(this.view,_.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault())}},cb.prototype.move=function(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0),ja(this.view,"pointer")},G.touchdown=function(e){Vb(e),ja(e,"pointer")},G.contextmenu=function(e){return Vb(e)};var dg=j.android?5e3:-1;function ne(e,t){clearTimeout(e.composingTimeout),t>-1&&(e.composingTimeout=setTimeout(function(){return bb(e)},t))}function bb(e){for(e.composing=!1;e.compositionNodes.length>0;)e.compositionNodes.pop().markParentsDirty();return!!e.docView.dirty&&(e.updateState(e.state),!0)}function gg(e,t){var r=t.ownerDocument,o=r.body.appendChild(r.createElement("div"));o.appendChild(t),o.style.cssText="position: fixed; left: -10000px; top: 10px";var n=getSelection(),i=r.createRange();i.selectNodeContents(t),e.dom.blur(),n.removeAllRanges(),n.addRange(i),setTimeout(function(){r.body.removeChild(o),e.focus()},50)}E.compositionstart=E.compositionupdate=function(e){e.composing||(e.domObserver.flush(),bb(e),e.composing=!0),ne(e,dg)},E.compositionend=function(e,t){e.composing&&(e.composing=!1,e.compositionEndedAt=t.timeStamp,ne(e,20))};var xa=j.ie&&j.ie_version<15||j.ios&&j.webkit_version<604;function ig(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}function jg(e,t){var r=e.dom.ownerDocument,o=e.shiftKey||e.state.selection.$from.parent.type.spec.code,n=r.body.appendChild(r.createElement(o?"textarea":"div"));o||(n.contentEditable="true"),n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(function(){e.focus(),r.body.removeChild(n),o?Vc(e,n.value,null,t):Vc(e,n.textContent,n.innerHTML,t)},50)}function Vc(e,t,r,o){var n=Oc(e,t,r,e.shiftKey,e.state.selection.$from);if(e.someProp("handlePaste",function(t){return t(e,o,n||k.empty)})||!n)return!0;var i=ig(n),a=i?e.state.tr.replaceSelectionWith(i,e.shiftKey):e.state.tr.replaceSelection(n);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}G.copy=E.cut=function(e,t){var r=e.state.selection,o="cut"==t.type;if(!r.empty){var n=xa?null:t.clipboardData,i=Pc(e,r.content()),a=i.dom,s=i.text;n?(t.preventDefault(),n.clearData(),n.setData("text/html",a.innerHTML),n.setData("text/plain",s)):gg(e,a),o&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))}},E.paste=function(e,t){var r=xa?null:t.clipboardData;r&&(Vc(e,r.getData("text/plain"),r.getData("text/html"),t)||r.files.length>0)?t.preventDefault():jg(e,t)};var lg=function(e,t){this.slice=e,this.move=t},mg=j.mac?"altKey":"ctrlKey";for(var qe in G.dragstart=function(e,t){var r=e.mouseDown;if(r&&r.done(),t.dataTransfer){var o=e.state.selection,n=o.empty?null:e.posAtCoords(hb(t));if(n&&n.pos>=o.from&&n.pos<=(o instanceof f?o.to-1:o.to));else if(r&&r.mightDrag)e.dispatch(e.state.tr.setSelection(f.create(e.state.doc,r.mightDrag.pos)));else if(t.target&&1==t.target.nodeType){var i=e.docView.nearestDesc(t.target,!0);if(!i||!i.node.type.spec.draggable||i==e.docView)return;e.dispatch(e.state.tr.setSelection(f.create(e.state.doc,i.posBefore)))}var a=e.state.selection.content(),s=Pc(e,a),$=s.dom,c=s.text;t.dataTransfer.clearData(),t.dataTransfer.setData(xa?"Text":"text/html",$.innerHTML),xa||t.dataTransfer.setData("text/plain",c),e.dragging=new lg(a,!t[mg])}},G.dragend=function(e){window.setTimeout(function(){return e.dragging=null},50)},E.dragover=E.dragenter=function(e,t){return t.preventDefault()},E.drop=function(e,t){var r=e.dragging;if(e.dragging=null,t.dataTransfer){var o=e.posAtCoords(hb(t));if(o){var n=e.state.doc.resolve(o.pos);if(n){var i=r&&r.slice||Oc(e,t.dataTransfer.getData(xa?"Text":"text/plain"),xa?null:t.dataTransfer.getData("text/html"),!1,n);if(i&&(t.preventDefault(),!e.someProp("handleDrop",function(o){return o(e,t,i,r&&r.move)}))){var a=i?od(e.state.doc,n.pos,i):n.pos;null==a&&(a=n.pos);var s=e.state.tr;r&&r.move&&s.deleteSelection();var $=s.mapping.map(a),c=0==i.openStart&&0==i.openEnd&&1==i.content.childCount,l=s.doc;if(c?s.replaceRangeWith($,$,i.content.firstChild):s.replaceRange($,$,i),!s.doc.eq(l)){var d=s.doc.resolve($);c&&f.isSelectable(i.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(i.content.firstChild)?s.setSelection(new f(d)):s.setSelection(Sc(e,d,s.doc.resolve(s.mapping.map(a)))),e.focus(),e.dispatch(s.setMeta("uiEvent","drop"))}}}}}},G.focus=function(e){e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0)},G.blur=function(e){e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),e.focused=!1)},G.beforeinput=function(e,t){if(j.chrome&&j.android&&"deleteContentBackward"==t.inputType){var r=e.domChangeCount;setTimeout(function(){if(e.domChangeCount==r&&(e.dom.blur(),e.focus(),!e.someProp("handleKeyDown",function(t){return t(e,lc(8,"Backspace"))}))){var t=e.state.selection.$cursor;t&&t.pos>0&&e.dispatch(e.state.tr.delete(t.pos-1,t.pos).scrollIntoView())}},50)}},E)G[qe]=E[qe];function Ma(e,t){if(e==t)return!0;for(var r in e)if(e[r]!==t[r])return!1;for(var o in t)if(!(o in e))return!1;return!0}var Va=function(e,t){this.spec=t||va,this.side=this.spec.side||0,this.toDOM=e};Va.prototype.map=function(e,t,r,o){var n=e.mapResult(t.from+o,this.side<0?-1:1),i=n.pos;return n.deleted?null:new u(i-r,i-r,this)},Va.prototype.valid=function(){return!0},Va.prototype.eq=function(e){return this==e||e instanceof Va&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Ma(this.spec,e.spec))};var V=function(e,t){this.spec=t||va,this.attrs=e};V.prototype.map=function(e,t,r,o){var n=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-r,i=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-r;return n>=i?null:new u(n,i,this)},V.prototype.valid=function(e,t){return t.from<t.to},V.prototype.eq=function(e){return this==e||e instanceof V&&Ma(this.attrs,e.attrs)&&Ma(this.spec,e.spec)},V.is=function(e){return e.type instanceof V};var _a=function(e,t){this.spec=t||va,this.attrs=e};_a.prototype.map=function(e,t,r,o){var n=e.mapResult(t.from+o,1);if(n.deleted)return null;var i=e.mapResult(t.to+o,-1);return i.deleted||i.pos<=n.pos?null:new u(n.pos-r,i.pos-r,this)},_a.prototype.valid=function(e,t){var r=e.content.findIndex(t.from),o=r.index,n=r.offset;return n==t.from&&n+e.child(o).nodeSize==t.to},_a.prototype.eq=function(e){return this==e||e instanceof _a&&Ma(this.attrs,e.attrs)&&Ma(this.spec,e.spec)};var u=function(e,t,r){this.from=e,this.to=t,this.type=r},ue={spec:{}};u.prototype.copy=function(e,t){return new u(e,t,this.type)},u.prototype.eq=function(e){return this.type.eq(e.type)&&this.from==e.from&&this.to==e.to},u.prototype.map=function(e,t,r){return this.type.map(e,this,t,r)},u.widget=function(e,t,r){return new u(e,e,new Va(t,r))},u.inline=function(e,t,r,o){return new u(e,t,new V(r,o))},u.node=function(e,t,r,o){return new u(e,t,new _a(r,o))},ue.spec.get=function(){return this.type.spec},Object.defineProperties(u.prototype,ue);var xb=[],va={},q=function(e,t){this.local=e&&e.length?e:xb,this.children=t&&t.length?t:xb};q.create=function(e,t){return t.length?gb(t,e,0,va):A},q.prototype.find=function(e,t,r){var o=[];return this.findInner(null==e?0:e,null==t?1e9:t,o,0,r),o},q.prototype.findInner=function(e,t,r,o,n){for(var i=0;i<this.local.length;i++){var a=this.local[i];a.from<=t&&a.to>=e&&(!n||n(a.spec))&&r.push(a.copy(a.from+o,a.to+o))}for(var s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){var $=this.children[s]+1;this.children[s+2].findInner(e-$,t-$,r,o+$,n)}},q.prototype.map=function(e,t,r){return this==A||0==e.maps.length?this:this.mapInner(e,t,0,0,r||va)},q.prototype.mapInner=function(e,t,r,o,n){for(var i,a=0;a<this.local.length;a++){var s=this.local[a].map(e,r,o);s&&s.type.valid(t,s)?(i||(i=[])).push(s):n.onRemove&&n.onRemove(this.local[a].spec)}return this.children.length?zg(this.children,i,e,t,r,o,n):i?new q(i.sort(na)):A},q.prototype.add=function(e,t){return t.length?this==A?q.create(e,t):this.addInner(e,t,0):this},q.prototype.addInner=function(e,t,r){var o,n=this,i=0;e.forEach(function(e,a){var s,$=a+r;if(s=Ae(t,e,$)){for(o||(o=n.children.slice());i<o.length&&o[i]<a;)i+=3;o[i]==a?o[i+2]=o[i+2].addInner(e,s,$+1):o.splice(i,0,a,a+e.nodeSize,gb(s,e,$+1,va)),i+=3}});var a=ze(i?Be(t):t,-r);return new q(a.length?this.local.concat(a).sort(na):this.local,o||this.children)},q.prototype.remove=function(e){return 0==e.length||this==A?this:this.removeInner(e,0)},q.prototype.removeInner=function(e,t){for(var r=this.children,o=this.local,n=0;n<r.length;n+=3){for(var i=void 0,a=r[n]+t,s=r[n+1]+t,$=0,c=void 0;$<e.length;$++)(c=e[$])&&c.from>a&&c.to<s&&(e[$]=null,(i||(i=[])).push(c));if(i){r==this.children&&(r=this.children.slice());var l=r[n+2].removeInner(i,a+1);l!=A?r[n+2]=l:(r.splice(n,3),n-=3)}}if(o.length)for(var d=0,p=void 0;d<e.length;d++)if(p=e[d])for(var v=0;v<o.length;v++)o[v].type.eq(p.type)&&(o==this.local&&(o=this.local.slice()),o.splice(v--,1));return r==this.children&&o==this.local?this:o.length||r.length?new q(o,r):A},q.prototype.forChild=function(e,t){var r,o;if(this==A)return this;if(t.isLeaf)return q.empty;for(var n=0;n<this.children.length;n+=3)if(this.children[n]>=e){this.children[n]==e&&(r=this.children[n+2]);break}for(var i=e+1,a=i+t.content.size,s=0;s<this.local.length;s++){var $=this.local[s];if($.from<a&&$.to>i&&$.type instanceof V){var c=Math.max(i,$.from)-i,l=Math.min(a,$.to)-i;c<l&&(o||(o=[])).push($.copy(c,l))}}if(o){var d=new q(o.sort(na));return r?new R([d,r]):d}return r||A},q.prototype.eq=function(e){if(this==e)return!0;if(!(e instanceof q)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(var t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(var r=0;r<this.children.length;r+=3)if(this.children[r]!=e.children[r]||this.children[r+1]!=e.children[r+1]||!this.children[r+2].eq(e.children[r+2]))return!1;return!1},q.prototype.locals=function(e){return Tb(this.localsInner(e))},q.prototype.localsInner=function(e){if(this==A)return xb;if(e.inlineContent||!this.local.some(V.is))return this.local;for(var t=[],r=0;r<this.local.length;r++)this.local[r].type instanceof V||t.push(this.local[r]);return t};var A=new q;q.empty=A,q.removeOverlap=Tb;var R=function(e){this.members=e};function zg(e,t,r,o,n,i,a){for(var s=e.slice(),$=function(e,t,r,o){for(var a=0;a<s.length;a+=3){var $=s[a+1],c=void 0;-1==$||e>$+i||(t>=s[a]+i?s[a+1]=-1:(c=o-r-(t-e)+(i-n))&&(s[a]+=c,s[a+1]+=c))}},c=0;c<r.maps.length;c++)r.maps[c].forEach($);for(var l=!1,d=0;d<s.length;d+=3)if(-1==s[d+1]){var p=r.map(s[d]+i),v=p-n;if(v<0||v>=o.content.size){l=!0;continue}var h=r.map(e[d+1]+i,-1)-n,u=o.content.findIndex(v),f=u.index,D=u.offset,S=o.maybeChild(f);if(S&&D==v&&D+S.nodeSize==h){var z=s[d+2].mapInner(r,S,p+1,s[d]+i+1,a);z!=A?(s[d]=v,s[d+1]=h,s[d+2]=z):(s[d+1]=-2,l=!0)}else l=!0}if(l){var m=gb(Bg(s,e,t||[],r,n,i,a),o,0,a);t=m.local;for(var g=0;g<s.length;g+=3)s[g+1]<0&&(s.splice(g,3),g-=3);for(var y=0,b=0;y<m.children.length;y+=3){for(var w=m.children[y];b<s.length&&s[b]<w;)b+=3;s.splice(b,0,m.children[y],m.children[y+1],m.children[y+2])}}return new q(t&&t.sort(na),s)}function ze(e,t){if(!t||!e.length)return e;for(var r=[],o=0;o<e.length;o++){var n=e[o];r.push(new u(n.from+t,n.to+t,n.type))}return r}function Bg(e,t,r,o,n,i,a){function s(e,t){for(var i=0;i<e.local.length;i++){var $=e.local[i].map(o,n,t);$?r.push($):a.onRemove&&a.onRemove(e.local[i].spec)}for(var c=0;c<e.children.length;c+=3)s(e.children[c+2],e.children[c]+t+1)}for(var $=0;$<e.length;$+=3)-1==e[$+1]&&s(e[$+2],t[$]+i+1);return r}function Ae(e,t,r){if(t.isLeaf)return null;for(var o=r+t.nodeSize,n=null,i=0,a=void 0;i<e.length;i++)(a=e[i])&&a.from>r&&a.to<o&&((n||(n=[])).push(a),e[i]=null);return n}function Be(e){for(var t=[],r=0;r<e.length;r++)null!=e[r]&&t.push(e[r]);return t}function gb(e,t,r,o){var n=[],i=!1;t.forEach(function(t,a){var s=Ae(e,t,a+r);if(s){i=!0;var $=gb(s,t,r+a+1,o);$!=A&&n.push(a,a+t.nodeSize,$)}});for(var a=ze(i?Be(e):e,-r).sort(na),s=0;s<a.length;s++)a[s].type.valid(t,a[s])||(o.onRemove&&o.onRemove(a[s].spec),a.splice(s--,1));return a.length||n.length?new q(a,n):A}function na(e,t){return e.from-t.from||e.to-t.to}function Tb(e){for(var t=e,r=0;r<t.length-1;r++){var o=t[r];if(o.from!=o.to)for(var n=r+1;n<t.length;n++){var i=t[n];if(i.from!=o.from){i.from<o.to&&(t==e&&(t=e.slice()),t[r]=o.copy(o.from,i.from),Fe(t,n,o.copy(i.from,o.to)));break}i.to!=o.to&&(t==e&&(t=e.slice()),t[n]=i.copy(i.from,o.to),Fe(t,n+1,i.copy(o.to,i.to)))}}return t}function Fe(e,t,r){for(;t<e.length&&na(r,e[t])>0;)t++;e.splice(t,0,r)}function Pb(e){var t=[];return e.someProp("decorations",function(r){var o=r(e.state);o&&o!=A&&t.push(o)}),e.cursorWrapper&&t.push(q.create(e.state.doc,[e.cursorWrapper.deco])),R.from(t)}R.prototype.forChild=function(e,t){if(t.isLeaf)return q.empty;for(var r=[],o=0;o<this.members.length;o++){var n=this.members[o].forChild(e,t);n!=A&&(n instanceof R?r=r.concat(n.members):r.push(n))}return R.from(r)},R.prototype.eq=function(e){if(!(e instanceof R)||e.members.length!=this.members.length)return!1;for(var t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0},R.prototype.locals=function(e){for(var t,r=!0,o=0;o<this.members.length;o++){var n=this.members[o].localsInner(e);if(n.length)if(t){r&&(t=t.slice(),r=!1);for(var i=0;i<n.length;i++)t.push(n[i])}else t=n}return t?Tb(r?t:t.sort(na)):xb},R.from=function(e){switch(e.length){case 0:return A;case 1:return e[0];default:return new R(e);}};var o=function(e,t){this._props=t,this.state=t.state,this.dispatch=this.dispatch.bind(this),this._root=null,this.focused=!1,this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):e.apply?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Je(this),this.cursorWrapper=null,Ie(this),this.nodeViews=Me(this),this.docView=Dd(this.state.doc,He(this),Pb(this),this.dom,this),this.lastSelectedViewDesc=null,this.dragging=null,Tj(this),this.pluginViews=[],this.updatePluginViews()},Zc={props:{},root:{}};function He(e){var t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",function(r){if("function"==typeof r&&(r=r(e.state)),r)for(var o in r)"class"==o?t.class+=" "+r[o]:t[o]||"contenteditable"==o||"nodeName"==o||(t[o]=String(r[o]))}),[u.node(0,e.state.doc.content.size,t)]}function Mg(e){var t=document.createElement("span");return t.textContent="\uFEFF",e||(t.style.position="absolute",t.style.left="-100000px"),t}function Ie(e){var t=$d(e.state);if(!t||j.ie&&e.mouseDown)e.cursorWrapper=null;else{var r,o=e.state.selection.visible,n=e.state.storedMarks||t.marks();e.cursorWrapper&&Qa.sameSet(e.cursorWrapper.deco.spec.marks,n)&&"\uFEFF"==e.cursorWrapper.dom.textContent&&e.cursorWrapper.deco.spec.visible==o?e.cursorWrapper.deco.pos!=t.pos&&(r=e.cursorWrapper.dom):r=Mg(o),r&&(e.cursorWrapper={dom:r,deco:u.widget(t.pos,r,{isCursorWrapper:!0,marks:n,raw:!0,visible:o})})}}function Je(e){return!e.someProp("editable",function(t){return!1===t(e.state)})}function Ke(e){var t=e.getSelection(),r=t.focusOffset,o=t.focusNode;return o&&3!=o.nodeType?[o,r,1==o.nodeType?o.childNodes[r-1]:null,1==o.nodeType?o.childNodes[r]:null]:null}function Of(e,t){var r=Ke(t);if(!r||3==r[0].nodeType)return!1;for(var o=0;o<e.length;o++)if(r[o]!=e[o])return!0;return!1}function Me(e){var t={};return e.someProp("nodeViews",function(e){for(var r in e)Object.prototype.hasOwnProperty.call(t,r)||(t[r]=e[r])}),t}function Sg(e,t){var r=0,o=0;for(var n in e){if(e[n]!=t[n])return!0;r++}for(var i in t)o++;return r!=o}Zc.props.get=function(){if(this._props.state!=this.state){var e=this._props;for(var t in this._props={},e)this._props[t]=e[t];this._props.state=this.state}return this._props},o.prototype.update=function(e){e.handleDOMEvents!=this._props.handleDOMEvents&&fc(this),this._props=e,this.updateStateInner(e.state,!0)},o.prototype.setProps=function(e){var t={};for(var r in this._props)t[r]=this._props[r];for(var o in t.state=this.state,e)t[o]=e[o];this.update(t)},o.prototype.updateState=function(e){this.updateStateInner(e,this.state.plugins!=e.plugins)},o.prototype.updateStateInner=function(e,t){var r=this,o=this.state,n=!1;if(this.state=e,t){var i=Me(this);Sg(i,this.nodeViews)&&(this.nodeViews=i,n=!0),fc(this)}this.editable=Je(this),Ie(this);var a=Pb(this),s=He(this),$=t?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",c=n||!this.docView.matchesNode(e.doc,s,a),l=c||!e.selection.eq(o.selection),d="preserve"==$&&l&&null==this.dom.style.overflowAnchor&&vg(this);if(l){this.domObserver.stop();var p=!1;if(c){var v=j.chrome&&Ke(this.root);!n&&this.docView.update(e.doc,s,a,this)||(this.docView.destroy(),this.docView=Dd(e.doc,s,a,this.dom,this)),v&&(p=Of(v,this.root))}p||!(this.mouseDown&&this.domObserver.currentSelection.eq(this.root.getSelection())&&zi(this))?Na(this,!1,p):(Yd(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}if(this.updatePluginViews(o),"reset"==$)this.dom.scrollTop=0;else if("to selection"==$){var h=this.root.getSelection().focusNode;this.someProp("handleScrollToSelection",function(e){return e(r)})||(e.selection instanceof f?rd(this,this.docView.domAfterPos(e.selection.from).getBoundingClientRect(),h):rd(this,this.coordsAtPos(e.selection.head),h))}else d&&wg(d)},o.prototype.destroyPluginViews=function(){for(var e;e=this.pluginViews.pop();)e.destroy&&e.destroy()},o.prototype.updatePluginViews=function(e){if(e&&e.plugins==this.state.plugins)for(var t=0;t<this.pluginViews.length;t++){var r=this.pluginViews[t];r.update&&r.update(this,e)}else{this.destroyPluginViews();for(var o=0;o<this.state.plugins.length;o++){var n=this.state.plugins[o];n.spec.view&&this.pluginViews.push(n.spec.view(this))}}},o.prototype.someProp=function(e,t){var r,o=this._props&&this._props[e];if(null!=o&&(r=t?t(o):o))return r;var n=this.state.plugins;if(n)for(var i=0;i<n.length;i++){var a=n[i].props[e];if(null!=a&&(r=t?t(a):a))return r}},o.prototype.hasFocus=function(){return this.root.activeElement==this.dom},o.prototype.focus=function(){this.domObserver.stop(),Na(this,!0),this.domObserver.start(),this.editable&&this.dom.focus()},Zc.root.get=function(){var e=this._root;if(null==e)for(var t=this.dom.parentNode;t;t=t.parentNode)if(9==t.nodeType||11==t.nodeType&&t.host)return this._root=t;return e||document},o.prototype.posAtCoords=function(e){return $g(this,e)},o.prototype.coordsAtPos=function(e){return wd(this,e)},o.prototype.domAtPos=function(e){return this.docView.domFromPos(e)},o.prototype.nodeDOM=function(e){var t=this.docView.descAt(e);return t?t.nodeDOM:null},o.prototype.posAtDOM=function(e,t,r){void 0===r&&(r=-1);var o=this.docView.posFromDOM(e,t,r);if(null==o)throw new RangeError("DOM position not inside the editor");return o},o.prototype.endOfTextblock=function(e,t){return $i(this,t||this.state,e)},o.prototype.destroy=function(){this.docView&&(fk(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Pb(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)},o.prototype.dispatchEvent=function(e){return Qf(this,e)},o.prototype.dispatch=function(e){var t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))},Object.defineProperties(o.prototype,Zc);var Ne=o;ra.EditorView=Ne;var Ug=u;ra.Decoration=Ug;var Vg=q;ra.DecorationSet=Vg;var Wg=Pc;ra.__serializeForClipboard=Wg;var Xg=Oc;ra.__parseFromClipboard=Xg;var Yg=bb;ra.__endComposition=Yg;var Zg={},db=200,w=function(){};w.prototype.append=function(e){return e.length?(e=w.from(e),!this.length&&e||e.length<db&&this.leafAppend(e)||this.length<db&&e.leafPrepend(this)||this.appendInner(e)):this},w.prototype.prepend=function(e){return e.length?w.from(e).append(this):this},w.prototype.appendInner=function(e){return new bh(this,e)},w.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?w.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},w.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},w.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},w.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},w.from=function(e){return e instanceof w?e:e&&e.length?new Pe(e):w.empty};var Pe=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{},depth:{}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var o=t;o<n;o++)if(!1===e(this.values[o],r+o))return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var o=t-1;o>=n;o--)if(!1===e(this.values[o],r+o))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=db)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=db)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(w);w.empty=new Pe([]);var bh=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var o=this.left.length;return!(t<o&&!1===this.left.forEachInner(e,t,Math.min(n,o),r))&&!(n>o&&!1===this.right.forEachInner(e,Math.max(t-o,0),Math.min(this.length,n)-o,r+o))&&void 0},t.prototype.forEachInvertedInner=function(e,t,n,r){var o=this.left.length;return!(t>o&&!1===this.right.forEachInvertedInner(e,t-o,Math.max(n,o)-o,r+o))&&!(n<o&&!1===this.left.forEachInvertedInner(e,Math.min(t,o),n,r))&&void 0},t.prototype.sliceInner=function(e,t){if(0==e&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(w);Zg=w;var ca={};function dh(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(ca,"__esModule",{value:!0});var Qe=dh(Zg),fh=500,z=function(e,r){this.items=e,this.eventCount=r};function hh(e,r){var t;return e.forEach(function(e,i){if(e.selection&&0==r--)return t=i,!1}),e.slice(t)}z.prototype.popEvent=function(e,r){var t=this;if(0==this.eventCount)return null;for(var i,n,$=this.items.length;;$--){if(t.items.get($-1).selection){--$;break}}r&&(i=this.remapping($,this.items.length),n=i.maps.length);var a,s,o=e.tr,p=[],y=[];return this.items.forEach(function(e,r){if(!e.step)return i||(i=t.remapping($,r+1),n=i.maps.length),n--,void y.push(e);if(i){y.push(new S(e.map));var v,u=e.step.map(i.slice(n));u&&o.maybeStep(u).doc&&(v=o.mapping.maps[o.mapping.maps.length-1],p.push(new S(v,null,null,p.length+y.length))),n--,v&&i.appendMap(v,n)}else o.maybeStep(e.step);return e.selection?(a=i?e.selection.map(i.slice(n)):e.selection,s=new z(t.items.slice(0,$).append(y.reverse().concat(p)),t.eventCount-1),!1):void 0},this.items.length,0),{remaining:s,transform:o,selection:a}},z.prototype.addTransform=function(e,r,t,i){for(var n=[],$=this.eventCount,a=this.items,s=!i&&a.length?a.get(a.length-1):null,o=0;o<e.steps.length;o++){var p,y=e.steps[o].invert(e.docs[o]),v=new S(e.mapping.maps[o],y,r);(p=s&&s.merge(v))&&(v=p,o?n.pop():a=a.slice(0,a.length-1)),n.push(v),r&&($++,r=null),i||(s=v)}var u=$-t.depth;return u>kh&&(a=hh(a,u),$-=u),new z(a.append(n),$)},z.prototype.remapping=function(e,r){var t=new md;return this.items.forEach(function(r,i){var n=null!=r.mirrorOffset&&i-r.mirrorOffset>=e?n=t.maps.length-r.mirrorOffset:null;t.appendMap(r.map,n)},e,r),t},z.prototype.addMaps=function(e){return 0==this.eventCount?this:new z(this.items.append(e.map(function(e){return new S(e)})),this.eventCount)},z.prototype.rebased=function(e,r){if(!this.eventCount)return this;var t=[],i=Math.max(0,this.items.length-r),n=e.mapping,$=e.steps.length,a=this.eventCount;this.items.forEach(function(e){e.selection&&a--},i);var s=r;this.items.forEach(function(r){var i=n.getMirror(--s);if(null!=i){$=Math.min($,i);var o=n.maps[i];if(r.step){var p=e.steps[i].invert(e.docs[i]),y=r.selection&&r.selection.map(n.slice(s+1,i));y&&a++,t.push(new S(o,p,y))}else t.push(new S(o))}},i);for(var o=[],p=r;p<$;p++)o.push(new S(n.maps[p]));var y=this.items.slice(0,i).append(o).append(t),v=new z(y,a);return v.emptyItemCount()>fh&&(v=v.compress(this.items.length-t.length)),v},z.prototype.emptyItemCount=function(){var e=0;return this.items.forEach(function(r){r.step||e++}),e},z.prototype.compress=function(e){void 0===e&&(e=this.items.length);var r=this.remapping(0,e),t=r.maps.length,i=[],n=0;return this.items.forEach(function($,a){if(a>=e)i.push($),$.selection&&n++;else if($.step){var s=$.step.map(r.slice(t)),o=s&&s.getMap();if(t--,o&&r.appendMap(o,t),s){var p=$.selection&&$.selection.map(r.slice(t));p&&n++;var y,v=new S(o.invert(),s,p),u=i.length-1;(y=i.length&&i[u].merge(v))?i[u]=y:i.push(v)}}else $.map&&t--},this.items.length,0),new z(Qe.from(i.reverse()),n)},z.empty=new z(Qe.empty,0);var S=function(e,r,t,i){this.map=e,this.step=r,this.selection=t,this.mirrorOffset=i};S.prototype.merge=function(e){if(this.step&&e.step&&!e.selection){var r=e.step.merge(this.step);if(r)return new S(r.getMap().invert(),r,this.selection)}};var Z=function(e,r,t,i){this.done=e,this.undone=r,this.prevRanges=t,this.prevTime=i},kh=20;function lh(e,r,t,i){var n,$=t.getMeta(Q);if($)return $.historyState;t.getMeta(Ve)&&(e=new Z(e.done,e.undone,null,0));var a=t.getMeta("appendedTransaction");if(0==t.steps.length)return e;if(a&&a.getMeta(Q))return a.getMeta(Q).redo?new Z(e.done.addTransform(t,null,i,Db(r)),e.undone,Se(t.mapping.maps[t.steps.length-1]),e.prevTime):new Z(e.done,e.undone.addTransform(t,null,i,Db(r)),null,e.prevTime);if(!1===t.getMeta("addToHistory")||a&&!1===a.getMeta("addToHistory"))return(n=t.getMeta("rebased"))?new Z(e.done.rebased(t,n),e.undone.rebased(t,n),xc(e.prevRanges,t.mapping),e.prevTime):new Z(e.done.addMaps(t.mapping.maps),e.undone.addMaps(t.mapping.maps),xc(e.prevRanges,t.mapping),e.prevTime);var s=e.prevTime<(t.time||0)-i.newGroupDelay||!a&&!mh(t,e.prevRanges),o=a?xc(e.prevRanges,t.mapping):Se(t.mapping.maps[t.steps.length-1]);return new Z(e.done.addTransform(t,s?r.selection.getBookmark():null,i,Db(r)),z.empty,o,t.time)}function mh(e,r){if(!r)return!1;if(!e.docChanged)return!0;var t=!1;return e.mapping.maps[0].forEach(function(e,i){for(var n=0;n<r.length;n+=2)e<=r[n+1]&&i>=r[n]&&(t=!0)}),t}function Se(e){var r=[];return e.forEach(function(e,t,i,n){return r.push(i,n)}),r}function xc(e,r){if(!e)return null;for(var t=[],i=0;i<e.length;i+=2){var n=r.map(e[i],1),$=r.map(e[i+1],-1);n<=$&&t.push(n,$)}return t}function Te(e,r,t,i){var n=Db(r),$=Q.get(r).spec.config,a=(i?e.undone:e.done).popEvent(r,n);if(a){var s=a.selection.resolve(a.transform.doc),o=(i?e.done:e.undone).addTransform(a.transform,r.selection.getBookmark(),$,n),p=new Z(i?o:a.remaining,i?a.remaining:o,null,0);t(a.transform.setSelection(s).setMeta(Q,{redo:i,historyState:p}).scrollIntoView())}}var qh=!1,rh=null;function Db(e){var r=e.plugins;if(rh!=r){qh=!1,rh=r;for(var t=0;t<r.length;t++)if(r[t].spec.historyPreserveItems){qh=!0;break}}return qh}function th(e){return e.setMeta(Ve,!0)}var Q=new Hc("history"),Ve=new Hc("closeHistory");function wh(e){return e={depth:e&&e.depth||100,newGroupDelay:e&&e.newGroupDelay||500},new Eb({key:Q,state:{init:function(){return new Z(z.empty,z.empty,null,0)},apply:function(r,t,i){return lh(t,i,r,e)}},config:e})}function xh(e,r){var t=Q.getState(e);return!(!t||0==t.done.eventCount)&&(r&&Te(t,e,r,!1),!0)}function yh(e,r){var t=Q.getState(e);return!(!t||0==t.undone.eventCount)&&(r&&Te(t,e,r,!0),!0)}function zh(e){var r=Q.getState(e);return r?r.done.eventCount:0}function Ah(e){var r=Q.getState(e);return r?r.undone.eventCount:0}var Bh=Z;ca.HistoryState=Bh;var Ch=th;ca.closeHistory=Ch;var We=wh;ca.history=We;var pc=xh;ca.undo=pc;var hc=yh;ca.redo=hc;var Gh=zh;ca.undoDepth=Gh;var Hh=Ah;ca.redoDepth=Hh;var Ih=function(r){var t=function(t){r[t]&&r[t]()};return{"Cmd-z":pc,"Cmd-Shift-z":hc,Enter:function(){t("onEnter")},"Shift-Enter":function(){t("onShiftEnter")},"Shift-Tab":function(){return t("onShiftTab"),!0},Tab:function(){return t("onTab"),!0}}};var Jh=function(n){var o=function(o){n[o]&&n[o]()};return{ArrowUp:function(n,r,t){if(t.endOfTextblock("up",n))return o("onPrev"),!0},ArrowDown:function(n,r,t){if(t.endOfTextblock("down",n))return o("onNext"),!0},Backspace:function(n){var r=n.selection.$cursor;if(!r||0!==r.pos)return!1;o("onBack")},"Cmd-b":function(){o("onBold")},"Cmd-i":function(){o("onItalic")},"Cmd-k":function(){o("onLink")},"Cmd-u":function(){o("onUnderline")},"Cmd-z":pc,"Cmd-Shift-s":function(){o("onStrikeThrough")},"Cmd-Shift-z":hc,Delete:function(n,r,t){return t.endOfTextblock("forward",n)&&o("onForward"),!1},Enter:function(n,r,t){n.selection.$cursor&&t.endOfTextblock("forward",n)?o("onEnter"):o("onSplit")},"Shift-Enter":function(){o("onShiftEnter")},"Shift-Tab":function(){if(o("onShiftTab"),n.onShiftTab)return!0},Tab:function(){if(o("onTab"),n.onTab)return!0}}};var Kh=function(e){return!0===e.code?Ih(e):Jh(e)};var Lh=function(){return new cc({nodes:{text:{},doc:{content:"code"},code:{content:"text*",marks:"",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM:function(){return["pre",["code",0]]}}}})};var Mh={toolbar:{icon:"code",label:"Code",action:"toggleMark",args:["code"]},parseDOM:[{tag:"code"}],toDOM:function(){return["code",0]}};var Nh={toolbar:{icon:"bold",label:"Bold",action:"toggleMark",args:["bold"]},parseDOM:[{tag:"strong"},{tag:"b",getAttrs:function(t){return"normal"!=t.style.fontWeight&&null}},{style:"font-weight",getAttrs:function(t){return /^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}}],toDOM:function(){return["strong",0]}};var Oh={toolbar:{icon:"italic",label:"Italic",action:"toggleMark",args:["italic"]},parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"}],toDOM:function(){return["em",0]}};var Ph={toolbar:{icon:"url",label:"Link",action:"link"},attrs:{href:{},title:{default:null},target:{default:null}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs:function(t){return{href:t.getAttribute("href"),title:t.getAttribute("title"),target:t.getAttribute("target")}}}],toDOM:function(t){var e=document.createElement("a");return t.attrs.title&&e.setAttribute("title",t.attrs.title),"_blank"===t.attrs.target&&(e.setAttribute("target","_blank"),e.setAttribute("rel","noopener noreferrer")),e.setAttribute("href",t.attrs.href),e.addEventListener("click",function(e){!0===e.altKey&&window.open(t.attrs.href)}),e}};var Qh={toolbar:{icon:"strikethrough",label:"Strike-through",action:"toggleMark",args:["strikeThrough"]},parseDOM:[{tag:"del"},{style:"text-decoration=line-through"}],toDOM:function(){return["del",0]}};var Rh={toolbar:{icon:"underline",label:"Underline",action:"toggleMark",args:["underline"]},parseDOM:[{tag:"u"},{style:"text-decoration=underline"}],toDOM:function(){return["u",0]}};var Sh=function(r){var e={code:Mh,bold:Nh,italic:Oh,link:Ph,underline:Rh,strikeThrough:Qh},$={};return r.forEach(function(r){$[r]=e[r]}),new cc({nodes:{text:{},doc:{content:"(text | hard_break )*"},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM:function(){return["br"]}}},marks:$})};var Th=function(e,$){return $?Lh():Sh(e)};for(var Uh={},ha={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",229:"q"},Pa={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:";",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:"\"",229:"Q"},Ze="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent),Yh="undefined"!=typeof navigator&&/Apple Computer/.test(navigator.vendor),Zh="undefined"!=typeof navigator&&/Gecko\/\d+/.test(navigator.userAgent),$e="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),_h=Ze&&($e||+Ze[1]<57)||Zh&&$e,F=0;F<10;F++)ha[48+F]=ha[96+F]=String(F);for(F=1;F<=24;F++)ha[F+111]="F"+F;for(F=65;F<=90;F++)ha[F]=String.fromCharCode(F+32),Pa[F]=String.fromCharCode(F);for(var Lc in ha)Pa.hasOwnProperty(Lc)||(Pa[Lc]=ha[Lc]);function Cc($){var e=!(_h&&($.ctrlKey||$.altKey||$.metaKey)||Yh&&$.shiftKey&&$.key&&1==$.key.length)&&$.key||($.shiftKey?Pa:ha)[$.keyCode]||$.key||"Unidentified";return"Esc"==e&&(e="Escape"),"Del"==e&&(e="Delete"),"Left"==e&&(e="ArrowLeft"),"Up"==e&&(e="ArrowUp"),"Right"==e&&(e="ArrowRight"),"Down"==e&&(e="ArrowDown"),e}Uh=Cc,Cc.base=ha,Cc.shift=Pa;var tc={};function ei(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(tc,"__esModule",{value:!0});var bf=ei(Uh),gi="undefined"!=typeof navigator&&/Mac/.test(navigator.platform);function hi(e){var r,$,a,t,n=e.split(/-(?!$)/),y=n[n.length-1];"Space"==y&&(y=" ");for(var o=0;o<n.length-1;o++){var i=n[o];if(/^(cmd|meta|m)$/i.test(i))t=!0;else if(/^a(lt)?$/i.test(i))r=!0;else if(/^(c|ctrl|control)$/i.test(i))$=!0;else if(/^s(hift)?$/i.test(i))a=!0;else{if(!/^mod$/i.test(i))throw new Error("Unrecognized modifier name: "+i);gi?t=!0:$=!0}}return r&&(y="Alt-"+y),$&&(y="Ctrl-"+y),t&&(y="Meta-"+y),a&&(y="Shift-"+y),y}function ii(e){var r=Object.create(null);for(var $ in e)r[hi($)]=e[$];return r}function cf(e,r,$){return r.altKey&&(e="Alt-"+e),r.ctrlKey&&(e="Ctrl-"+e),r.metaKey&&(e="Meta-"+e),!1!==$&&r.shiftKey&&(e="Shift-"+e),e}function ki(e){return new Eb({props:{handleKeyDown:df(e)}})}function df(e){var r=ii(e);return function(e,$){var a,t=bf($),n=1==t.length&&" "!=t,y=r[cf(t,$,!n)];if(y&&y(e.state,e.dispatch,e))return!0;if(n&&($.shiftKey||$.altKey||$.metaKey)&&(a=bf.base[$.keyCode])&&a!=t){var o=r[cf(a,$,!0)];if(o&&o(e.state,e.dispatch,e))return!0}return!1}}var ef=ki;tc.keymap=ef;var ni=df;tc.keydownHandler=ni;var J={};Object.defineProperty(J,"__esModule",{value:!0});var Y=function(e,$){this.match=e,this.handler="string"==typeof $?qi($):$};function qi(e){return function($,r,t,o){var n=e;if(r[1]){var u=r[0].lastIndexOf(r[1]);n+=r[0].slice(u+r[1].length);var p=(t+=u)-o;p>0&&(n=r[0].slice(u-p,u)+n,t=o)}return $.tr.insertText(n,t,o)}}var ri=500;function si(e){var $=e.rules,r=new Eb({state:{init:function(){return null},apply:function(e,$){var r=e.getMeta(this);return r||(e.selectionSet||e.docChanged?null:$)}},props:{handleTextInput:function(e,t,o,n){return hf(e,t,o,n,$,r)},handleDOMEvents:{compositionend:function(e){setTimeout(function(){var t=e.state.selection.$cursor;t&&hf(e,t.pos,t.pos,"",$,r)})}}},isInputRules:!0});return r}function hf(e,$,r,t,o,n){if(e.composing)return!1;var u=e.state,p=u.doc.resolve($);if(p.parent.type.spec.code)return!1;for(var a=p.parent.textBetween(Math.max(0,p.parentOffset-ri),p.parentOffset,null,"\uFFFC")+t,x=0;x<o.length;x++){var l=o[x].match.exec(a),s=l&&o[x].handler(u,l,$-(l[0].length-t.length),r);if(s)return e.dispatch(s.setMeta(n,{transform:s,from:$,to:r,text:t})),!0}return!1}function ui(e,$){for(var r=e.plugins,t=0;t<r.length;t++){var o=r[t],n=void 0;if(o.spec.isInputRules&&(n=o.getState(e))){if($){for(var u=e.tr,p=n.transform,a=p.steps.length-1;a>=0;a--)u.step(p.steps[a].invert(p.docs[a]));var x=u.doc.resolve(n.from).marks();$(u.replaceWith(n.from,n.to,e.schema.text(n.text,x)))}return!0}}return!1}var vi=new Y(/--$/,"\u2014"),wi=new Y(/\.\.\.$/,"\u2026"),jf=new Y(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"\u201C"),kf=new Y(/"$/,"\u201D"),lf=new Y(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"\u2018"),mf=new Y(/'$/,"\u2019"),Bi=[jf,kf,lf,mf];function Ci(e,$,r,t){return new Y(e,function(e,o,n,u){var p=r instanceof Function?r(o):r,a=e.tr.delete(n,u),x=a.doc.resolve(n).blockRange(),l=x&&uc(x,$,p);if(!l)return null;a.wrap(x,l);var s=a.doc.resolve(n-1).nodeBefore;return s&&s.type==$&&sa(a.doc,n-1)&&(!t||t(o,s))&&a.join(n-1),a})}function Di(e,$,r){return new Y(e,function(e,t,o,n){var u=e.doc.resolve(o),p=r instanceof Function?r(t):r;return u.node(-1).canReplaceWith(u.index(-1),u.indexAfter(-1),$)?e.tr.delete(o,n).setBlockType(o,o,$,p):null})}var Ta=Y;J.InputRule=Ta;var nf=si;J.inputRules=nf;var Gi=ui;J.undoInputRule=Gi;var Hi=vi;J.emDash=Hi;var of=wi;J.ellipsis=of;var Ji=jf;J.openDoubleQuote=Ji;var Ki=kf;J.closeDoubleQuote=Ki;var Li=lf;J.openSingleQuote=Li;var Mi=mf;J.closeSingleQuote=Mi;var Ni=Bi;J.smartQuotes=Ni;var Oi=Ci;J.wrappingInputRule=Oi;var Pi=Di;J.textblockTypeInputRule=Pi;var fa=function(e,r){return new Ta(e,function(e,t,$,o){return r(),e.tr.delete($,o)})},Ri=function(e,r,t){return hd.create({doc:e,plugins:[ef(r),We(),nf({rules:[of,new Ta(/\<\-/,"\u2190"),new Ta(/\-\>/,"\u2192"),new Ta(/\-\-/,"\u2013"),fa(/^\–\-/,function(){t.onConvert&&t.onConvert("hr")}),fa(/^\s*([-+*])\s$/,function(){t.onConvert&&t.onConvert("ul")}),fa(/^\d{1,}\.\s$/,function(){t.onConvert&&t.onConvert("ol")}),fa(/^```$/,function(){t.onConvert&&t.onConvert("code")}),fa(/^\>\s$/,function(){t.onConvert&&t.onConvert("blockquote")}),fa(/^\#\s$/,function(){t.onConvert&&t.onConvert("h1")}),fa(/^\#\#\s$/,function(){t.onConvert&&t.onConvert("h2")}),fa(/^\#\#\#\s$/,function(){t.onConvert&&t.onConvert("h3")})]})]})};var Si=function(e){var t=Th(e.marks,e.code),a=jd(t,e.content,e.code),r=Kh(e),o=Ri(a,r,e);return new Ne(e.element,{state:o,editable:function(){return!0!==e.disabled},dispatchTransaction:function(t){if(!0===e.disabled)return!1;var a=this.state,r=this.state.apply(t);this.updateState(r),!e.onUpdate||a&&a.doc.eq(this.state.doc)||e.onUpdate(),e.onSelect&&(a&&a.doc.eq(this.state.doc)&&a.selection.eq(this.state.selection)||e.onSelect())},handlePaste:function(t,a,r){if(e.code)return!1;var o=a.clipboardData.getData("text/html"),i=a.clipboardData.getData("text/plain");return!!e.onPaste&&(0===o.length?(o=(o=(o="<p>"+i+"</p>").replace(/[\n\r]{2}/g,"</p><p>")).replace(/[\n\r]{1}/g,"<br>"),e.onPaste(o,i)):e.onPaste(o,i),!0)}})};var e={};Object.defineProperty(e,"__esModule",{value:!0});function Ob(e,r){return!e.selection.empty&&(r&&r(e.tr.deleteSelection().scrollIntoView()),!0)}function sf(e,r,t){var o=e.selection.$cursor;if(!o||(t?!t.endOfTextblock("backward",e):o.parentOffset>0))return!1;var $=vf(o);if(!$){var a=o.blockRange(),n=a&&Ka(a);return null!=n&&(r&&r(e.tr.lift(a,n).scrollIntoView()),!0)}var i=$.nodeBefore;if(!i.type.spec.isolating&&Ff(e,$,r))return!0;if(0==o.parent.content.size&&(lb(i,"end")||f.isSelectable(i))){if(r){var p=e.tr.deleteRange(o.before(),o.after());p.setSelection(lb(i,"end")?_.findFrom(p.doc.resolve(p.mapping.map($.pos,-1)),-1):f.create(p.doc,$.pos-i.nodeSize)),r(p.scrollIntoView())}return!0}return!(!i.isAtom||$.depth!=o.depth-1)&&(r&&r(e.tr.delete($.pos-i.nodeSize,$.pos).scrollIntoView()),!0)}function lb(e,r){for(;e;e="start"==r?e.firstChild:e.lastChild)if(e.isTextblock)return!0;return!1}function uf(e,r,t){var o=e.selection.$cursor;if(!o||(t?!t.endOfTextblock("backward",e):o.parentOffset>0))return!1;var $=vf(o),a=$&&$.nodeBefore;return!(!a||!f.isSelectable(a))&&(r&&r(e.tr.setSelection(f.create(e.doc,$.pos-a.nodeSize)).scrollIntoView()),!0)}function vf(e){if(!e.parent.type.spec.isolating)for(var r=e.depth-1;r>=0;r--){if(e.index(r)>0)return e.doc.resolve(e.before(r+1));if(e.node(r).type.spec.isolating)break}return null}function wf(e,r,t){var o=e.selection.$cursor;if(!o||(t?!t.endOfTextblock("forward",e):o.parentOffset<o.parent.content.size))return!1;var $=yf(o);if(!$)return!1;var a=$.nodeAfter;if(Ff(e,$,r))return!0;if(0==o.parent.content.size&&(lb(a,"start")||f.isSelectable(a))){if(r){var n=e.tr.deleteRange(o.before(),o.after());n.setSelection(lb(a,"start")?_.findFrom(n.doc.resolve(n.mapping.map($.pos)),1):f.create(n.doc,n.mapping.map($.pos))),r(n.scrollIntoView())}return!0}return!(!a.isAtom||$.depth!=o.depth-1)&&(r&&r(e.tr.delete($.pos,$.pos+a.nodeSize).scrollIntoView()),!0)}function xf(e,r,t){var o=e.selection.$cursor;if(!o||(t?!t.endOfTextblock("forward",e):o.parentOffset<o.parent.content.size))return!1;var $=yf(o),a=$&&$.nodeAfter;return!(!a||!f.isSelectable(a))&&(r&&r(e.tr.setSelection(f.create(e.doc,$.pos)).scrollIntoView()),!0)}function yf(e){if(!e.parent.type.spec.isolating)for(var r=e.depth-1;r>=0;r--){var t=e.node(r);if(e.index(r)+1<t.childCount)return e.doc.resolve(e.after(r+1));if(t.type.spec.isolating)break}return null}function aj(e,r){var t,o=e.selection,$=o instanceof f;if($){if(o.node.isTextblock||!sa(e.doc,o.from))return!1;t=o.from}else if(null==(t=oc(e.doc,o.from,-1)))return!1;if(r){var a=e.tr.join(t);$&&a.setSelection(f.create(a.doc,t-e.doc.resolve(t).nodeBefore.nodeSize)),r(a.scrollIntoView())}return!0}function bj(e,r){var t,o=e.selection;if(o instanceof f){if(o.node.isTextblock||!sa(e.doc,o.to))return!1;t=o.to}else if(null==(t=oc(e.doc,o.to,1)))return!1;return r&&r(e.tr.join(t).scrollIntoView()),!0}function cj(e,r){var t=e.selection,o=t.$from,$=t.$to,a=o.blockRange($),n=a&&Ka(a);return null!=n&&(r&&r(e.tr.lift(a,n).scrollIntoView()),!0)}function zf(e,r){var t=e.selection,o=t.$head,$=t.$anchor;return!(!o.parent.type.spec.code||!o.sameParent($))&&(r&&r(e.tr.insertText("\n").scrollIntoView()),!0)}function Af(e,r){var t=e.selection,o=t.$head,$=t.$anchor;if(!o.parent.type.spec.code||!o.sameParent($))return!1;var a=o.node(-1),n=o.indexAfter(-1),i=a.contentMatchAt(n).defaultType;if(!a.canReplaceWith(n,n,i))return!1;if(r){var p=o.after(),c=e.tr.replaceWith(p,p,i.createAndFill());c.setSelection(_.near(c.doc.resolve(p),1)),r(c.scrollIntoView())}return!0}function Bf(e,r){var t=e.selection,o=t.$from,$=t.$to;if(o.parent.inlineContent||$.parent.inlineContent)return!1;var a=o.parent.contentMatchAt($.indexAfter()).defaultType;if(!a||!a.isTextblock)return!1;if(r){var n=(!o.parentOffset&&$.index()<$.parent.childCount?o:$).pos,i=e.tr.insert(n,a.createAndFill());i.setSelection(x.create(i.doc,n+1)),r(i.scrollIntoView())}return!0}function Cf(e,r){var t=e.selection.$cursor;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){var o=t.before();if(Ia(e.doc,o))return r&&r(e.tr.split(o).scrollIntoView()),!0}var $=t.blockRange(),a=$&&Ka($);return null!=a&&(r&&r(e.tr.lift($,a).scrollIntoView()),!0)}function $b(e,r){var t=e.selection,o=t.$from,$=t.$to;if(e.selection instanceof f&&e.selection.node.isBlock)return!(!o.parentOffset||!Ia(e.doc,o.pos))&&(r&&r(e.tr.split(o.pos).scrollIntoView()),!0);if(!o.parent.isBlock)return!1;if(r){var a=$.parentOffset==$.parent.content.size,n=e.tr;e.selection instanceof x&&n.deleteSelection();var i=0==o.depth?null:o.node(-1).contentMatchAt(o.indexAfter(-1)).defaultType,p=a&&i?[{type:i}]:null,c=Ia(n.doc,n.mapping.map(o.pos),1,p);p||c||!Ia(n.doc,n.mapping.map(o.pos),1,i&&[{type:i}])||(p=[{type:i}],c=!0),c&&(n.split(n.mapping.map(o.pos),1,p),a||o.parentOffset||o.parent.type==i||!o.node(-1).canReplace(o.index(-1),o.indexAfter(-1),g.from(i.create(),o.parent))||n.setNodeMarkup(n.mapping.map(o.before()),i)),r(n.scrollIntoView())}return!0}function ij(e,r){return $b(e,r&&function(t){var o=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();o&&t.ensureMarks(o),r(t)})}function jj(e,r){var t,o=e.selection,$=o.$from,a=o.to,n=$.sharedDepth(a);return 0!=n&&(t=$.before(n),r&&r(e.tr.setSelection(f.create(e.doc,t))),!0)}function Ef(e,r){return r&&r(e.tr.setSelection(new gd(e.doc))),!0}function lj(e,r,t){var o=r.nodeBefore,$=r.nodeAfter,a=r.index();return!!(o&&$&&o.type.compatibleContent($.type))&&(!o.content.size&&r.parent.canReplace(a-1,a)?(t&&t(e.tr.delete(r.pos-o.nodeSize,r.pos).scrollIntoView()),!0):!(!r.parent.canReplace(a,a+1)||!$.isTextblock&&!sa(e.doc,r.pos))&&(t&&t(e.tr.clearIncompatible(r.pos,o.type,o.contentMatchAt(o.childCount)).join(r.pos).scrollIntoView()),!0))}function Ff(e,r,t){var o,$,a=r.nodeBefore,n=r.nodeAfter;if(a.type.spec.isolating||n.type.spec.isolating)return!1;if(lj(e,r,t))return!0;if(r.parent.canReplace(r.index(),r.index()+1)&&(o=($=a.contentMatchAt(a.childCount)).findWrapping(n.type))&&$.matchType(o[0]||n.type).validEnd){if(t){for(var i=r.pos+n.nodeSize,p=g.empty,c=o.length-1;c>=0;c--)p=g.from(o[c].create(null,p));p=g.from(a.copy(p));var l=e.tr.step(new Bc(r.pos-1,i,r.pos,i,new k(p,1,0),o.length,!0)),s=i+2*o.length;sa(l.doc,s)&&l.join(s),t(l.scrollIntoView())}return!0}var B=_.findFrom(r,1),I=B&&B.$from.blockRange(B.$to),v=I&&Ka(I);return null!=v&&v>=r.depth&&(t&&t(e.tr.lift(I,v).scrollIntoView()),!0)}function nj(e,r){return function(t,o){var $=t.selection,a=$.$from,n=$.$to,i=a.blockRange(n),p=i&&uc(i,e,r);return!!p&&(o&&o(t.tr.wrap(i,p).scrollIntoView()),!0)}}function oj(e,r){return function(t,o){var $=t.selection,a=$.from,n=$.to,i=!1;return t.doc.nodesBetween(a,n,function(o,$){if(i)return!1;if(o.isTextblock&&!o.hasMarkup(e,r))if(o.type==e)i=!0;else{var a=t.doc.resolve($),n=a.index();i=a.parent.canReplaceWith(n,n+1,e)}}),!!i&&(o&&o(t.tr.setBlockType(a,n,e,r).scrollIntoView()),!0)}}function pj(e,r,t){for(var o=function(o){var $=r[o],a=$.$from,n=$.$to,i=0==a.depth&&e.type.allowsMarkType(t);if(e.nodesBetween(a.pos,n.pos,function(e){if(i)return!1;i=e.inlineContent&&e.type.allowsMarkType(t)}),i)return{v:!0}},$=0;$<r.length;$++){var a=o($);if(a)return a.v}return!1}function qj(e,r){return function(t,o){var $=t.selection,a=$.empty,n=$.$cursor,i=$.ranges;if(a&&!n||!pj(t.doc,i,e))return!1;if(o)if(n)e.isInSet(t.storedMarks||n.marks())?o(t.tr.removeStoredMark(e)):o(t.tr.addStoredMark(e.create(r)));else{for(var p=!1,c=t.tr,l=0;!p&&l<i.length;l++){var s=i[l],B=s.$from,I=s.$to;p=t.doc.rangeHasMark(B.pos,I.pos,e)}for(var v=0;v<i.length;v++){var d=i[v],f=d.$from,m=d.$to;p?c.removeMark(f.pos,m.pos,e):c.addMark(f.pos,m.pos,e.create(r))}o(c.scrollIntoView())}return!0}}function rj(e,r){return function(t){if(!t.isGeneric)return e(t);for(var o=[],$=0;$<t.mapping.maps.length;$++){for(var a=t.mapping.maps[$],n=0;n<o.length;n++)o[n]=a.map(o[n]);a.forEach(function(e,r,t,$){return o.push(t,$)})}for(var i=[],p=0;p<o.length;p+=2)for(var c=o[p],l=o[p+1],s=t.doc.resolve(c),B=s.sharedDepth(l),I=s.node(B),v=s.indexAfter(B),d=s.after(B+1);d<=l;++v){var f=I.maybeChild(v);if(!f)break;if(v&&-1==i.indexOf(d)){var m=I.child(v-1);m.type==f.type&&r(m,f)&&i.push(d)}d+=f.nodeSize}i.sort(function(e,r){return e-r});for(var u=i.length-1;u>=0;u--)sa(t.doc,i[u])&&t.join(i[u]);e(t)}}function sj(e,r){if(Array.isArray(r)){var t=r;r=function(e){return t.indexOf(e.type.name)>-1}}return function(t,o){return e(t,o&&rj(o,r))}}function eb(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return function(r,t,o){for(var $=0;$<e.length;$++)if(e[$](r,t,o))return!0;return!1}}var Hf=eb(Ob,sf,uf),If=eb(Ob,wf,xf),T={Enter:eb(zf,Bf,Cf,$b),"Mod-Enter":Af,Backspace:Hf,"Mod-Backspace":Hf,Delete:If,"Mod-Delete":If,"Mod-a":Ef},qc={"Ctrl-h":T.Backspace,"Alt-Backspace":T["Mod-Backspace"],"Ctrl-d":T.Delete,"Ctrl-Alt-Backspace":T["Mod-Delete"],"Alt-Delete":T["Mod-Delete"],"Alt-d":T["Mod-Delete"]};for(var Jf in T)qc[Jf]=T[Jf];var zj="undefined"!=typeof navigator?/Mac/.test(navigator.platform):"undefined"!=typeof os&&"darwin"==os.platform(),Aj=zj?qc:T,Bj=Ob;e.deleteSelection=Bj;var Cj=sf;e.joinBackward=Cj;var Dj=uf;e.selectNodeBackward=Dj;var Ej=wf;e.joinForward=Ej;var Fj=xf;e.selectNodeForward=Fj;var Gj=aj;e.joinUp=Gj;var Hj=bj;e.joinDown=Hj;var Ij=cj;e.lift=Ij;var Jj=zf;e.newlineInCode=Jj;var Kj=Af;e.exitCode=Kj;var Lj=Bf;e.createParagraphNear=Lj;var Mj=Cf;e.liftEmptyBlock=Mj;var Nj=$b;e.splitBlock=Nj;var Oj=ij;e.splitBlockKeepMarks=Oj;var Pj=jj;e.selectParentNode=Pj;var Qj=Ef;e.selectAll=Qj;var Rj=nj;e.wrapIn=Rj;var Sj=oj;e.setBlockType=Sj;var Kf=qj;e.toggleMark=Kf;var Uj=sj;e.autoJoin=Uj;var Vj=eb;e.chainCommands=Vj;var Wj=T;e.pcBaseKeymap=Wj;var Xj=qc;e.macBaseKeymap=Xj;var Yj=Aj;e.baseKeymap=Yj;function Lf(r){return ak(r)||_j(r)||$j()}function $j(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function _j(r){if(Symbol.iterator in Object(r)||"[object Arguments]"===Object.prototype.toString.call(r))return Array.from(r)}function ak(r){if(Array.isArray(r)){for(var e=0,t=new Array(r.length);e<r.length;e++)t[e]=r[e];return t}}function bk(r,e,t){var a=[];return t.forEach(function(t){var $=r.marks[t];$&&ck(e,$)&&a.push($.name)}),a}function ck(r,e){var t=r.selection,a=t.from,$=t.$from,o=t.to;return t.empty?!!e.isInSet(r.storedMarks||$.marks()):!!r.doc.rangeHasMark(a,o,e)}function dk(r,e){var t=document.createElement("div"),a=Ga.fromSchema(r.schema).serializeFragment(r.doc.content);return t.appendChild(a),e?t.innerText:t.innerHTML}function ek(r,e){var t=r.selection,a=t.from,$=t.to,o=[];r.doc.nodesBetween(a,$,function(r){o=[].concat(Lf(o),Lf(r.marks))});var n=o.find(function(r){return r.type.name===e});return n?n.attrs:{}}function Mf(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){gk(e,t,r[t])})}return e}function gk(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Gb={data:function(){return{link:{href:null,title:null,target:!1}}},computed:{fields:function(){return{href:{label:"URL",type:"text",icon:"url"},title:{label:"Title",type:"text",icon:"title"},target:{label:"Open in new window",type:"toggle",text:["no","yes"]}}}},methods:{open:function(e){this.link=Mf({title:null,target:!1},e),this.$refs.dialog.open()},submit:function(){this.$emit("submit",Mf({},this.link,{target:this.link.target?"_blank":null})),this.$refs.dialog.close()}}};if(typeof Gb==="function"){Gb=Gb.options}Object.assign(Gb,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("k-dialog",{ref:"dialog",attrs:{"size":"medium"},on:{"submit":_vm.submit}},[_c("k-form",{ref:"linkForm",attrs:{"fields":_vm.fields},on:{"submit":_vm.submit},model:{value:_vm.link,callback:function($$v){_vm.link=$$v},expression:"link"}})],1)};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());var Fb={props:{marks:{type:Array,default:function(){return[]}},options:Object}};if(typeof Fb==="function"){Fb=Fb.options}Object.assign(Fb,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",{staticClass:"k-editable-toolbar"},_vm._l(_vm.options,function(mark,markType){return _c("k-button",{key:markType,class:{"k-editable-toolbar-button":true,"k-editable-toolbar-button-active":_vm.marks.includes(markType)},attrs:{"icon":mark.spec.toolbar.icon},on:{"mousedown":function($event){$event.preventDefault();return _vm.$emit("option",mark.spec.toolbar)}}})}),1)};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());var Fa={inheritAttrs:!1,components:{"k-link-dialog":Gb,"k-editable-toolbar":Fb},props:{breaks:Boolean,code:Boolean,content:{type:String,default:""},disabled:Boolean,marks:{type:Array,default:function(){return["bold","italic","strikeThrough","underline","code","link"]}},paste:{type:Function,default:function(){return function(){}}},placeholder:String,spellcheck:Boolean},data:function(){return{editor:null,toolbar:!1}},mounted:function(){this.editor=Si({breaks:this.breaks,code:this.code,content:this.content,disabled:this.disabled,element:this.$el,marks:this.marks,onUpdate:this.onUpdate,onSplit:this.onSplit,onBack:this.onBack,onForward:this.onForward,onBold:this.onBold,onConvert:this.onConvert,onItalic:this.onItalic,onLink:this.onLink,onNext:this.onNext,onPaste:!!this.$listeners.paste&&this.onPaste,onPrev:this.onPrev,onEnter:this.onEnter,onSelect:this.onSelect,onShiftEnter:this.onShiftEnter,onShiftTab:!!this.$listeners.shiftTab&&this.onShiftTab,onStrikeThrough:this.onStrikeThrough,onTab:!!this.$listeners.tab&&this.onTab,onUnderline:this.onUnderline}),this.onUpdate()},destroyed:function(){this.editor.destroy()},computed:{info:function(){return this.editor?{top:this.coordsAtStart().top,bottom:this.coordsAtEnd().bottom}:{}}},methods:{addMark:function(t,o){var e=this.selection(),r=e.from,i=e.to,n=this.mark(t);if(n)return this.dispatch(this.tr().addMark(r,i,n.create(o)))},coordsAtPos:function(t){return this.editor.coordsAtPos(t)},coordsAtEnd:function(){return this.editor.coordsAtPos(this.cursorPositionAtEnd())},coordsAtStart:function(){return this.editor.coordsAtPos(0)},coordsAtCursor:function(){return this.coordsAtPos(this.cursorPosition())},posAtCoords:function(t){return this.editor.posAtCoords(t)},cursor:function(){return this.selection().$cursor},cursorAtEnd:function(){return this.selectionAtEnd().$cursor},cursorAtStart:function(){return this.selectionAtStart().$cursor},cursorPosition:function(){var t=this.cursor();return t?t.pos:0},cursorPositionAtEnd:function(){var t=this.cursorAtEnd();return t?t.pos:0},cursorPositionAtStart:function(){return 0},dispatch:function(t){this.editor.dispatch(t)},doc:function(){return this.editor.state.doc},focus:function(t){var o=this;if(t){if("object"===hk(t)){var e=t.at||"start",r="end"===e?this.coordsAtEnd():this.coordsAtStart(),i=this.posAtCoords({top:r.top+1,left:t.left||0});t=i&&i.pos?i.pos:e}var n=null;switch(t){case"start":n=x.atStart(this.doc());break;case"end":n=x.atEnd(this.doc());break;default:try{n=x.near(this.doc().resolve(t))}catch(s){n=x.atStart(this.doc())}}this.dispatch(this.tr().setSelection(n))}setTimeout(function(){o.editor.focus()},1)},getActiveMarks:function(){return bk(this.editor.state.schema,this.editor.state,this.marks)},getMarkAttrs:function(t){return ek(this.state(),t)},hasFocus:function(){return this.editor.hasFocus},hasMark:function(t){return void 0!==this.editor.state.schema.marks[t]},htmlAtSelection:function(t){return this.nodeToHtml(this.nodeAtSelection(t))},htmlBeforeCursor:function(){return this.htmlAtSelection(this.selectionBeforeCursor())},htmlAfterCursor:function(){return this.htmlAtSelection(this.selectionAfterCursor())},insertBreak:function(){if(!0!==this.breaks)return!1;this.code?this.dispatch(this.tr().insertText("\n").scrollIntoView()):this.dispatch(this.tr().replaceSelectionWith(this.schema().nodes.hard_break.create()).scrollIntoView())},insertHtml:function(t){var o=jd(this.schema(),t);this.dispatch(this.tr().replaceSelectionWith(o).scrollIntoView())},insertLink:function(t){t.href?this.addMark("link",t):this.removeMark("link")},insertText:function(t){this.dispatch(this.tr().insertText(t).scrollIntoView())},isEmpty:function(){return 0===this.doc().content.size},isSelected:function(){var t=this.selection(),o=this.cursorPositionAtEnd();return 0===t.from&&t.to===o},length:function(){return this.cursorAtEnd().pos},link:function(){var t=this.getMarkAttrs("link");this.$refs.link.open(t)},mark:function(t){return this.editor.state.schema.marks[t]},nodeAtSelection:function(t){return this.doc().cut(t.from,t.to)},nodeToHtml:function(t){var o=Ga.fromSchema(this.editor.state.schema).serializeFragment(t),e=document.createElement("div");return e.append(o),e.innerHTML},onBack:function(){this.$emit("back",{html:this.htmlAfterCursor()})},onBold:function(){this.toggleMark("bold")},onBlur:function(){this.toolbar=!1,this.$emit("blur")},onConvert:function(t){this.$emit("convert",t)},onEnter:function(){this.code&&this.insertBreak(),this.$emit("enter",event)},onFocus:function(){this.$emit("focus",event)},onForward:function(){this.$emit("forward")},onInput:function(t){this.$emit("input",t)},onItalic:function(){this.toggleMark("italic")},onLink:function(){this.link()},onNext:function(){var t=this.coordsAtCursor().left;this.$emit("next",{left:t,at:"start"})},onOption:function(t){if(!this[t.action])return!1;var o=t.args||[];this[t.action].apply(this,lk(o))},onPaste:function(t,o){this.$emit("paste",{html:t,text:o})},onPrev:function(){var t=this.coordsAtCursor().left;this.$emit("prev",{left:t,at:"end"})},onSelect:function(){var t=this.editor.state.selection;if(t.empty)this.toolbar=!1,this.$emit("deselect");else{var o=this.$refs.toolbar;if(!o)return!1;var e=t.from,r=t.to,i=this.coordsAtPos(e),n=this.coordsAtPos(r,!0),s=this.$el.getBoundingClientRect(),a=(o.$el.getBoundingClientRect(),(i.left+n.left)/2-s.left),c=Math.round(s.bottom-i.top);this.toolbar={left:a,bottom:c,marks:this.getActiveMarks()},this.$emit("select")}},onShiftEnter:function(){this.$emit("shiftEnter"),this.insertBreak()},onShiftTab:function(){this.$emit("shiftTab")},onStrikeThrough:function(){this.toggleMark("strikeThrough")},onSplit:function(){this.$emit("split",{cursor:this.cursorPosition(),before:this.htmlBeforeCursor(),after:this.htmlAfterCursor()})},onTab:function(){this.code&&this.insertText("\t"),this.$emit("tab")},onUnderline:function(){this.toggleMark("underline")},onUpdate:function(){this.onInput(this.toHTML())},removeMark:function(t){var o=this.selection(),e=o.from,r=o.to,i=this.mark(t);if(i)return this.dispatch(this.tr().removeMark(e,r,i))},schema:function(){return this.editor.state.schema},selection:function(){return this.editor.state.selection},selectionAtEnd:function(){return x.atEnd(this.doc())},selectionAtStart:function(){return x.atStart(this.doc())},selectionBeforeCursor:function(){return new x(this.doc().resolve(0),this.selection().$from)},selectionAfterCursor:function(){return new x(this.selection().$to,this.selectionAtEnd().$to)},state:function(){return this.editor.state},toggleMark:function(t,o){var e=this.mark(t);e&&Kf(e,o)(this.editor.state,this.editor.dispatch),this.editor.focus()},toHTML:function(){return dk(this.editor.state,this.code)},toJSON:function(){return this.doc().toJSON()},tr:function(){return this.editor.state.tr},view:function(){return this.editor}}};if(typeof Fa==="function"){Fa=Fa.options}Object.assign(Fa,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",{ref:"editor",class:{"k-editable":true,"k-editable-text":!_vm.code,"k-editable-code":_vm.code},attrs:{"spellcheck":_vm.spellcheck},on:{"focusin":_vm.onFocus,"focusout":_vm.onBlur}},[_vm.editor?_c("k-editable-toolbar",{directives:[{name:"show",rawName:"v-show",value:_vm.toolbar,expression:"toolbar"}],ref:"toolbar",style:{bottom:_vm.toolbar.bottom+"px",left:_vm.toolbar.left+"px"},attrs:{"marks":_vm.toolbar.marks,"options":_vm.editor.state.schema.marks},on:{"option":_vm.onOption}}):_vm._e(),_vm._v(" "),_vm.placeholder&&_vm.editor&&_vm.isEmpty()?_c("span",{staticClass:"k-editable-placeholder"},[_vm._v(_vm._s(_vm.placeholder))]):_vm._e(),_vm._v(" "),_c("k-link-dialog",{ref:"link",on:{"submit":_vm.insertLink}})],1)};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());var wb={extends:Fa,append:"paragraph",icon:"text",breaks:!0,code:!1,props:{attrs:{type:Object,default:function(){return{}}}},methods:{onEnter:function(){this.$emit("append",{type:this.$options.append})},onInput:function(e){this.$emit("input",{content:e})},onShiftTab:function(){this.$emit("prev")},onSplit:function(){var e=this.cursorPosition();0===e?this.$emit("prepend"):this.$emit("split",{cursor:e,before:this.htmlBeforeCursor(),after:this.htmlAfterCursor(),type:this.$options.append})},onTab:function(){this.$emit("next")}}};if(typeof wb==="function"){wb=wb.options}var La={extends:wb,icon:"title",breaks:!0,marks:["italic","strikeThrough","underline","code","link"]};if(typeof La==="function"){La=La.options}function mk(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},$=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&($=$.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),$.forEach(function(r){nk(e,r,t[r])})}return e}function nk(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}var Ac=mk({},La);if(typeof Ac==="function"){Ac=Ac.options}function pk(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},$=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&($=$.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),$.forEach(function(r){qk(e,r,t[r])})}return e}function qk(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}var nc=pk({},La);if(typeof nc==="function"){nc=nc.options}var mb={icon:"dots",methods:{focus:function(){this.$refs.hr.focus()}}};if(typeof mb==="function"){mb=mb.options}Object.assign(mb,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("hr",{ref:"hr",staticClass:"k-editor-hr-block-divider",attrs:{"tabindex":"0"},on:{"keydown":[function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"enter",13,$event.key,"Enter")){return null}return _vm.$emit("append")},function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"up",38,$event.key,["Up","ArrowUp"])){return null}return _vm.$emit("prev")},function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"down",40,$event.key,["Down","ArrowDown"])){return null}return _vm.$emit("next")},function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"delete",[8,46],$event.key,["Backspace","Delete","Del"])){return null}return _vm.$emit("remove")}]}})};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());function tk(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(t){return Object.getOwnPropertyDescriptor(i,t).enumerable}))),n.forEach(function(e){uk(t,e,i[e])})}return t}function uk(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}var ab={icon:"image",props:{attrs:{type:Object,default:function(){return{}}},endpoints:Object,spellcheck:Boolean},computed:{style:function(){if(this.attrs.ratio)return"padding-bottom:"+100/this.attrs.ratio+"%"},fields:function(){return{alt:{label:this.$t("editor.blocks.image.alt.label"),type:"text",icon:"text"},link:{label:this.$t("editor.blocks.image.link.label"),type:"text",icon:"url",placeholder:this.$t("editor.blocks.image.link.placeholder")},css:{label:this.$t("editor.blocks.image.css.label"),type:"text",icon:"code"}}}},methods:{caption:function(t){this.input({caption:t})},edit:function(){this.attrs.guid&&this.$router.push(this.attrs.guid)},focus:function(){this.attrs.src?this.$refs.element.focus():this.$refs.element.$el.focus()},input:function(t){this.$emit("input",{attrs:tk({},this.attrs,t)})},fetchFile:function(t){var e=this;this.$api.get(t).then(function(t){e.input({guid:t.link,src:t.url,id:t.id,ratio:t.dimensions.ratio})})},insertFile:function(t){var e=t[0];this.fetchFile(e.link)},insertUpload:function(t,e){this.fetchFile(e[0].link),this.$events.$emit("file.create"),this.$events.$emit("model.update"),this.$store.dispatch("notification/success",":)")},menu:function(){return this.attrs.src?[{icon:"open",label:this.$t("editor.blocks.image.open.browser"),click:this.open},{icon:"edit",label:this.$t("editor.blocks.image.open.panel"),click:this.edit,disabled:!this.attrs.guid},{icon:"cog",label:this.$t("editor.blocks.image.settings"),click:this.$refs.settings.open},{icon:"image",label:this.$t("editor.blocks.image.replace"),click:this.replace}]:[]},open:function(){window.open(this.attrs.src)},onDrop:function(t){this.$refs.fileUpload.drop(t,{url:window.panel.api+"/"+this.endpoints.field+"/upload",multiple:!1,accept:"image/*"})},onLoad:function(){var t=this.$refs.image;!this.attrs.ratio&&t&&t.width&&t.height&&this.input({ratio:t.width/t.height})},replace:function(){this.$emit("input",{attrs:{}})},selectFile:function(){this.$refs.fileDialog.open({endpoint:this.endpoints.field+"/files",multiple:!1,selected:[this.attrs.id]})},settings:function(){this.$refs.settings.open()},saveSettings:function(){this.$refs.settings.close(),this.input(this.attrs)},uploadFile:function(){this.$refs.fileUpload.open({url:window.panel.api+"/"+this.endpoints.field+"/upload",multiple:!1,accept:"image/*"})}}};if(typeof ab==="function"){ab=ab.options}Object.assign(ab,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",[_c("figure",[_vm.attrs.src?[_c("div",{ref:"element",staticClass:"k-editor-image-block-wrapper",style:_vm.style,attrs:{"data-responsive":_vm.attrs.ratio,"tabindex":"0"},on:{"keydown":[function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"delete",[8,46],$event.key,["Backspace","Delete","Del"])){return null}return _vm.$emit("remove")},function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"enter",13,$event.key,"Enter")){return null}return _vm.$emit("append")},function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"up",38,$event.key,["Up","ArrowUp"])){return null}return _vm.$emit("prev")},function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"down",40,$event.key,["Down","ArrowDown"])){return null}return _vm.$emit("next")}]}},[_c("img",{key:_vm.attrs.src,ref:"image",attrs:{"src":_vm.attrs.src},on:{"dblclick":_vm.selectFile,"load":_vm.onLoad}})]),_vm._v(" "),_c("figcaption",[_c("k-editable",{attrs:{"content":_vm.attrs.caption,"breaks":true,"placeholder":_vm.$t("editor.blocks.image.caption.placeholder")+"\u2026","spellcheck":_vm.spellcheck},on:{"prev":_vm.focus,"shiftTab":_vm.focus,"tab":function($event){return _vm.$emit("next",$event)},"next":function($event){return _vm.$emit("next",$event)},"split":function($event){return _vm.$emit("append")},"enter":function($event){return _vm.$emit("append")},"input":_vm.caption}})],1)]:[_c("k-dropzone",{ref:"element",staticClass:"k-editor-image-block-placeholder",attrs:{"tabindex":"0"},on:{"drop":_vm.onDrop},nativeOn:{"keydown":[function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"delete",[8,46],$event.key,["Backspace","Delete","Del"])){return null}return _vm.$emit("remove")},function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"enter",13,$event.key,"Enter")){return null}return _vm.$emit("append")},function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"up",38,$event.key,["Up","ArrowUp"])){return null}$event.preventDefault();return _vm.$emit("prev")},function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"down",40,$event.key,["Down","ArrowDown"])){return null}$event.preventDefault();return _vm.$emit("next")}]}},[_c("k-button",{attrs:{"icon":"upload"},on:{"click":_vm.uploadFile},nativeOn:{"keydown":function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"enter",13,$event.key,"Enter")){return null}$event.stopPropagation()}}},[_vm._v(_vm._s(_vm.$t("editor.blocks.image.upload")))]),_vm._v(" "+_vm._s(_vm.$t("editor.blocks.image.or"))+" "),_c("k-button",{attrs:{"icon":"image"},on:{"click":_vm.selectFile},nativeOn:{"keydown":function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"enter",13,$event.key,"Enter")){return null}$event.stopPropagation()}}},[_vm._v(_vm._s(_vm.$t("editor.blocks.image.select")))])],1)]],2),_vm._v(" "),_c("k-files-dialog",{ref:"fileDialog",on:{"submit":function($event){return _vm.insertFile($event)}}}),_vm._v(" "),_c("k-upload",{ref:"fileUpload",on:{"success":_vm.insertUpload}}),_vm._v(" "),_c("k-dialog",{ref:"settings",attrs:{"size":"medium"},on:{"submit":_vm.saveSettings}},[_c("k-form",{attrs:{"fields":_vm.fields},on:{"submit":_vm.saveSettings},model:{value:_vm.attrs,callback:function($$v){_vm.attrs=$$v},expression:"attrs"}})],1)],1)};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());var Zb={extends:Fa,icon:"markdown",breaks:!0,code:!0,props:{content:String,attrs:[Object,Array]},methods:{onInput:function(r){this.$emit("input",{content:r})}}};if(typeof Zb==="function"){Zb=Zb.options}var Ic={extends:"paragraph",append:"ul",icon:"list-bullet",breaks:!0,methods:{indent:function(t){this.$emit("update",{attrs:{indent:t}})},onEnter:function(){this.isEmpty()?this.$emit("convert","paragraph"):this.$emit("append",{type:this.$options.append,attrs:{indent:this.attrs.indent||0}})}}};if(typeof Ic==="function"){Ic=Ic.options}var gc={extends:"ul",append:"ol",icon:"list-numbers"};if(typeof gc==="function"){gc=gc.options}function zk(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),o.forEach(function(t){Ak(e,t,r[t])})}return e}function Ak(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Mb={inheritAttrs:!1,icon:"video",props:{attrs:{type:Object,default:function(){return{src:null}}},spellcheck:Boolean},computed:{embedSrc:function(){var e=this.attrs.src;if(!e)return!1;var t=e.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/);if(t)return"https://www.youtube.com/embed/"+t[2];var r=e.match(/vimeo\.com\/([0-9]+)/);return!!r&&"https://player.vimeo.com/video/"+r[1]},fields:function(){return{src:{label:this.$t("editor.blocks.video.src.label"),type:"text",icon:"video",placeholder:this.$t("editor.blocks.video.src.placeholder")},css:{label:this.$t("editor.blocks.video.css.label"),type:"text",icon:"code"}}}},methods:{caption:function(e){this.$emit("input",{attrs:zk({},this.attrs,{caption:e})})},focus:function(){this.$refs.element.focus()},menu:function(){return this.embedSrc?[{icon:"open",label:this.$t("editor.blocks.video.open"),click:this.open},{icon:"video",label:this.$t("editor.blocks.video.settings"),click:this.$refs.settings.open}]:[]},open:function(){window.open(this.attrs.src)},replace:function(){var e=this;this.$emit("input",{attrs:{src:null}}),this.$nextTick(function(){e.focus()})}}};if(typeof Mb==="function"){Mb=Mb.options}Object.assign(Mb,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("figure",[_vm.embedSrc?[_c("div",{ref:"element",staticClass:"k-editor-video-block-container",attrs:{"tabindex":"0"},on:{"keydown":[function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"backspace",undefined,$event.key,undefined)){return null}return _vm.$emit("remove")},function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"delete",[8,46],$event.key,["Backspace","Delete","Del"])){return null}return _vm.$emit("remove")},function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"enter",13,$event.key,"Enter")){return null}$event.preventDefault();return _vm.$emit("append")},function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"up",38,$event.key,["Up","ArrowUp"])){return null}return _vm.$emit("prev")},function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"down",40,$event.key,["Down","ArrowDown"])){return null}return _vm.$emit("next")}]}},[_c("iframe",{attrs:{"src":_vm.embedSrc}}),_vm._v(" "),_c("div",{staticClass:"k-editor-video-block-overlay"})]),_vm._v(" "),_c("figcaption",[_c("k-editable",{attrs:{"content":_vm.attrs.caption,"breaks":true,"placeholder":_vm.$t("editor.blocks.video.caption.placeholder")+"\u2026","spellcheck":_vm.spellcheck},on:{"prev":_vm.focus,"shiftTab":_vm.focus,"tab":function($event){return _vm.$emit("next",$event)},"next":function($event){return _vm.$emit("next",$event)},"split":function($event){return _vm.$emit("append")},"enter":function($event){return _vm.$emit("append")},"input":_vm.caption}})],1),_vm._v(" "),_c("k-dialog",{ref:"settings",attrs:{"size":"medium"},on:{"submit":function($event){return _vm.$refs.settings.close()}}},[_c("k-form",{attrs:{"fields":_vm.fields},on:{"submit":function($event){return _vm.$refs.settings.close()}},model:{value:_vm.attrs,callback:function($$v){_vm.attrs=$$v},expression:"attrs"}})],1)]:[_c("div",{staticClass:"k-editor-video-block-container"},[_c("input",{directives:[{name:"model",rawName:"v-model",value:_vm.attrs.src,expression:"attrs.src"}],ref:"element",staticClass:"k-editor-video-block-input",attrs:{"type":"text","placeholder":"Enter a Youtube or Vimeo URL \u2026"},domProps:{"value":_vm.attrs.src},on:{"keydown":[function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"up",38,$event.key,["Up","ArrowUp"])){return null}return _vm.$emit("prev")},function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"down",40,$event.key,["Down","ArrowDown"])){return null}return _vm.$emit("next")},function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"enter",13,$event.key,"Enter")){return null}$event.preventDefault();return _vm.$emit("append")}],"input":function($event){if($event.target.composing){return}_vm.$set(_vm.attrs,"src",$event.target.value)}}})])]],2)};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());window.editor.block("paragraph",wb),window.editor.block("h1",La),window.editor.block("h2",Ac),window.editor.block("h3",nc),window.editor.block("ul",Ic),window.editor.block("ol",gc),window.editor.block("blockquote",Fc),window.editor.block("hr",mb),window.editor.block("code",ub),window.editor.block("image",ab),window.editor.block("video",Mb),window.editor.block("kirbytext",Zb);var Bb={inheritAttrs:!1,components:{"k-editor-options":rb},blocks:{},props:{autofocus:Boolean,allowed:[Array,Object],disabled:Boolean,disallowed:[Array,Object],endpoints:Object,spellcheck:Boolean,value:{type:[Array,Object],default:function(){return[]}}},beforeCreate:function(){var t=this;Object.keys(window.editor.blocks).forEach(function(o){var e=window.editor.blocks[o];e.extends&&window.editor.blocks[e.extends]&&(e.extends=window.editor.blocks[e.extends]),t.$options.blocks[o]={label:t.$t("editor.blocks."+o+".label",e.label||e.type),icon:e.icon,type:e.type,bind:e.bind||{}},t.$options.blocks[o].bind.placeholder=t.$t("editor.blocks."+o+".placeholder",e.placeholder||""),t.$options.components["k-editor-"+o+"-block"]=e})},created:function(){var t=this;this.subscription=this.$store.subscribeAction({after:function(o,e){switch(o.type){case"content/revert":case"content/create":t.blocks=t.sanitize(t.value),t.modified=t.uuid();}}}),this.allowed&&this.allowed.length>0?Object.keys(this.$options.blocks).forEach(function(o){!0===t.allowed.includes(o)&&(t.blockTypes[o]=t.$options.blocks[o])}):this.disallowed&&this.disallowed.length>0?(this.blockTypes=this.$options.blocks,Object.keys(this.$options.blocks).forEach(function(o){!0===t.disallowed.includes(o)&&t.$delete(t.blockTypes,o)})):this.blockTypes=this.$options.blocks},destroyed:function(){this.subscription()},mounted:function(){!0===this.autofocus&&this.$nextTick(this.focus)},data:function(){return{blocks:this.sanitize(this.value),blockTypes:{},focused:0,revalue:!1,modified:this.uuid(),over:null}},computed:{focusedBlockDefinition:function(){return this.getFocusedBlockDefinition()},sortable:function(){return this.blocks.length>1}},watch:{blocks:{handler:function(t){this.$emit("input",t)},deep:!0}},methods:{add:function(t){this.appendAndFocus({type:t},this.focused)},append:function(t,o){t=this.createBlock(t);var e=0;return null==o?(this.blocks.push(t),e=this.blocks.length-1):(e=o+1,this.blocks.splice(e,0,t)),e},appendAndFocus:function(t,o){var e=this,n=this.append(t,o);this.$nextTick(function(){e.focus(n)})},blockTypeExists:function(t){return!(this.blockTypes&&!this.blockTypes[t])||(console.log("block component does not exist: "+t),!1)},closeOptions:function(t){var o=this.$refs["block-options-"+t];o&&o[0]&&o[0].close&&o[0].close()},convertTo:function(t){var o=this;if(!1===this.blockTypeExists(t))return!1;var e=this.getFocusedBlock(),n=this.getFocusedBlockComponent();if(!e)return!1;if(e.type===t)return!0;var i=0;n.cursorPosition&&(i=n.cursorPosition()),e.type=t,e.id=this.uuid(),this.$nextTick(function(){o.focus(o.focused,i)})},createBlock:function(t){return Nf({},{attrs:{},content:"",id:this.uuid(),type:"paragraph"},t)},duplicate:function(){var t=JSON.parse(JSON.stringify(this.getFocusedBlock()));t&&(t.id=this.uuid(),this.appendAndFocus(t,this.focused))},focus:function(t,o){var e=null;if((e=null==t?this.getFocusedBlockComponent()||this.getFirstBlockComponent():this.getBlockComponent(t)||this.getFirstBlockComponent())&&e.focus)try{e.focus(o)}catch(n){}},getBlock:function(t){return this.blocks[t]},getBlockComponent:function(t){if(null==t)return!1;var o=this.$refs["block-"+t];return!(!o||!o[0])&&o[0]},getBlockDefinition:function(t){var o=this.getBlock(t);if(o&&this.blockTypes[o.type])return this.blockTypes[o.type]},getBlockTextLength:function(t){var o=this.getBlockComponent(t);return o&&"function"==typeof o.length?o.length():0},getFirstBlockComponent:function(){return this.getBlockComponent(0)},getLastBlockComponent:function(){return this.getBlockComponent(this.blocks.length-1)},getNextBlock:function(t){return this.blocks[t+1]},getNextBlockComponent:function(){return this.getBlockComponent(this.focused+1)},getPreviousBlock:function(t){return this.blocks[t-1]},getPreviousBlockComponent:function(){return this.getBlockComponent(this.focused-1)},getFocusedBlock:function(){if(null!==this.focused&&void 0!==this.focused)return this.blocks[this.focused]},getFocusedBlockComponent:function(){return this.getBlockComponent(this.focused)},getFocusedBlockDefinition:function(){if(null!==this.focused&&void 0!==this.focused)return this.getBlockDefinition(this.focused)},importBlocks:function(t){this.blocks=this.blocks.concat(t)},hasNextBlock:function(t){return void 0!==this.blocks[t+1]},hasPreviousBlock:function(t){return void 0!==this.blocks[t-1]},menu:function(t){var o=this.getBlockComponent(t);return function(){return o&&o.menu?o.menu():[]}},mergeWithPreviousBlock:function(t){var o=this,e=this.getBlock(t),n=this.getPreviousBlock(t);if(!e||!n)return!1;this.getPreviousBlockComponent(t);var i=this.getBlockTextLength(t-1);n.content+=e.content,n.id=this.uuid(),this.removeBlock(t),this.$nextTick(function(){o.focus(t-1,i)})},onAppend:function(t,o){this.appendAndFocus(o,t)},onBack:function(t,o){0===o.html.length?this.onRemove(t):this.mergeWithPreviousBlock(t)},onBlur:function(t){this.focused=t},onConvert:function(t,o){var e=this;if(!1===this.blockTypeExists(o))return!1;var n=this.getBlockComponent(t),i=n.cursorPosition?n.cursorPosition():0;this.blocks[t].type=o,this.blocks[t].id=this.uuid(),this.$nextTick(function(){e.focus(t,i)})},onFocus:function(t){this.focused=t;this.getFocusedBlockComponent()},onForward:function(t){this.remove(t),this.focus(t+1,"start")},onInput:function(t,o){if(!this.blocks[t])return!1;void 0!==o.content&&(this.blocks[t].content=o.content),void 0!==o.attrs&&(this.blocks[t].attrs=o.attrs||{})},onMouseEnter:function(t){this.over=t},onMouseLeave:function(){this.over=null},onNext:function(t){this.hasNextBlock(this.focused)&&this.focus(this.focused+1,t)},onPaste:function(t,o){var e=this,n=o.html;o.text;this.$api.post(this.endpoints.field+"/paste",{html:n}).then(function(o){if(0!==o.length)if(1!==o.length){var i,s,c=e.getBlock(t);if(c&&"paragraph"===c.type&&""===c.content)(i=e.blocks).splice.apply(i,[t,1].concat(_c(o)));else(s=e.blocks).splice.apply(s,[t+1,0].concat(_c(o)))}else{e.getFocusedBlockComponent().insertHtml(n)}})},onPrepend:function(t,o){this.prepend(o,t),this.focused=t+1},onPrev:function(t){this.hasPreviousBlock(this.focused)&&this.focus(this.focused-1,t)},onRemove:function(t){this.remove(t)},onSort:function(t){var o=t.item,e=[].indexOf.call(o.parentNode.children,o);this.focus(e),this.over=e},onSplit:function(t,o){this.split(t,o)},onUpdate:function(t,o){var e=this,n=this.blocks[t],i=this.getFocusedBlockComponent(),s=i.cursorPosition?i.cursorPosition():0;this.$set(this.blocks,t,Nf({},n,o,{id:this.uuid()})),this.$nextTick(function(){e.focus(t,s)})},openOptions:function(t){var o=this.$refs["block-options-"+t];o&&o[0]&&o[0].close&&o[0].open()},prepend:function(t,o){return t=this.createBlock(t),this.blocks.splice(o,0,t),o},prependAndFocus:function(t,o){var e=this;this.prepend(t,o);this.$nextTick(function(){e.focus(o)})},remove:function(t){if(null==t&&(t=this.focused),this.removeBlock(t),this.blocks.length){var o=this.getPreviousBlockComponent();o?(this.focused=t-1,o.focus("end")):this.focused=null}},removeAll:function(){this.blocks=[]},removeBlock:function(t){this.blocks.splice(t,1)},removeFocusedBlock:function(){this.removeBlock(this.focused)},sanitize:function(t){var o=this;return 0===t.length?[]:(t.map(function(t){return t.id=t.id||o.uuid(),t.attrs=t.attrs||{},t.content=t.content||"",t.type=o.blockTypeExists(t.type)?t.type:"paragraph",t}),t)},showOptions:function(t){return!this.disabled&&!this.$store.state.drag&&this.over===t},split:function(t,o){var e=this,n=this.getFocusedBlock();this.append({type:o.type||n.type,content:o.after},t),n.content=o.before,n.id=this.uuid(),this.$nextTick(function(){e.focus(t+1,"start")})},uuid:function(){return"_"+Math.random().toString(36).substr(2,9)}}};if(typeof Bb==="function"){Bb=Bb.options}Object.assign(Bb,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",{ref:"editor",staticClass:"k-editor",on:{"mouseleave":_vm.onMouseLeave}},[_vm.blocks.length?_c("div",{key:_vm.modified,staticClass:"k-editor-blocks"},[_c("div",{staticClass:"k-editor-container"},[_c("k-draggable",{attrs:{"list":_vm.blocks,"handle":true},on:{"end":_vm.onSort}},_vm._l(_vm.blocks,function(block,index){return _vm.blockTypeExists(block.type)?_c("div",{key:block.id,class:["k-editor-block","k-editor-"+block.type+"-block"],on:{"click":function($event){return _vm.focus(index)},"focusin":function($event){return _vm.onFocus(index)},"focusout":function($event){return _vm.onBlur(index)},"keydown":[function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"d",undefined,$event.key,undefined)){return null}if(!$event.metaKey){return null}$event.preventDefault();return _vm.duplicate($event)},function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"o",undefined,$event.key,undefined)){return null}if(!$event.metaKey){return null}if(!$event.shiftKey){return null}return _vm.openOptions(index)}],"mouseenter":function($event){return _vm.onMouseEnter(index)}}},[_vm.showOptions(index)?_c("k-editor-options",{key:"block-options-"+block.id,ref:"block-options-"+index,refInFor:true,attrs:{"blocks":_vm.blockTypes,"block":_vm.blockTypes[block.type],"menu":_vm.menu(index),"sortable":_vm.sortable},on:{"add":function($event){return _vm.add($event)},"convert":function($event){return _vm.convertTo($event)},"duplicate":_vm.duplicate,"remove":_vm.remove,"focus":function($event){return _vm.focus(index)}}}):_vm._e(),_vm._v(" "),_c("div",{staticClass:"k-editor-block-container"},[_c("k-editor-"+block.type+"-block",_vm._b({ref:"block-"+index,refInFor:true,tag:"component",attrs:{"attrs":block.attrs,"content":block.content,"disabled":_vm.disabled,"endpoints":_vm.endpoints,"spellcheck":_vm.spellcheck},on:{"append":function($event){return _vm.onAppend(index,$event)},"back":function($event){return _vm.onBack(index,$event)},"forward":function($event){return _vm.onForward(index,$event)},"convert":function($event){return _vm.onConvert(index,$event)},"input":function($event){return _vm.onInput(index,$event)},"next":_vm.onNext,"paste":function($event){return _vm.onPaste(index,$event)},"prepend":function($event){return _vm.onPrepend(index,$event)},"prev":_vm.onPrev,"remove":function($event){return _vm.onRemove(index,$event)},"split":function($event){return _vm.onSplit(index,$event)},"update":function($event){return _vm.onUpdate(index,$event)}},nativeOn:{"click":function($event){$event.stopPropagation();return _vm.closeOptions(index)}}},"component",_vm.blockTypes[block.type].bind,false))],1)],1):_vm._e()}),0)],1)]):_c("div",{staticClass:"k-editor-placeholder"},[_c("nav",_vm._l(_vm.blockTypes,function(blockType){return _c("k-button",{key:blockType.type,attrs:{"disabled":_vm.disabled,"icon":blockType.icon},on:{"click":function($event){return _vm.appendAndFocus({type:blockType.type})}}},[_vm._v(" "+_vm._s(blockType.label)+" ")])}),1)])])};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());var Lb={props:{autofocus:Boolean,disabled:Boolean,placeholder:String,spellcheck:Boolean,value:String},data:function(){return{content:this.value,modified:new Date}},watch:{value:function(t){t!==this.content&&(this.content=t,this.modified=new Date)}},methods:{onEnter:function(){this.$refs.editor.insertBreak()},onInput:function(t){t!==this.content&&(this.content=t,this.$emit("input",t))}}};if(typeof Lb==="function"){Lb=Lb.options}Object.assign(Lb,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("k-input",{staticClass:"k-editor-inline",attrs:{"disabled":_vm.disabled,"theme":"field"}},[_c("k-editable",{key:_vm.modified,ref:"editor",attrs:{"autofocus":_vm.autofocus,"breaks":true,"content":_vm.content,"disabled":_vm.disabled,"placeholder":_vm.placeholder,"spellcheck":_vm.spellcheck},on:{"enter":_vm.onEnter,"split":_vm.onEnter,"input":_vm.onInput}})],1)};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());var vb={inheritAttrs:!1,components:{"k-editor":Bb,"k-editor-inline":Lb},downloadFields:{type:{label:"Download \u2026",type:"select",required:!0,empty:!1,options:[{value:"md",text:"Markdown"},{value:"html",text:"HTML"},{value:"json",text:"JSON"}]}},props:{allowed:[Array,Object],autofocus:Boolean,disabled:Boolean,disallowed:[Array,Object],endpoints:Object,inline:Boolean,label:String,name:String,placeholder:String,required:Boolean,spellcheck:Boolean,type:String,value:{type:[Array,Object],default:function(){return[]}}},data:function(){return{downloadOptions:{type:"md"}}},computed:{isEmpty:function(){return!Array.isArray(this.value)||0===this.value.length}},methods:{onDownload:function(){var e=this;this.$api.post(this.endpoints.field+"/export",{data:this.value,type:this.downloadOptions.type}).then(function(t){var o=document.createElement("a");document.body.appendChild(o),o.style="display: none";var r=new Blob([t.data],{type:"octet/stream"}),n=window.URL.createObjectURL(r);o.href=n,o.download=e.name+"."+e.downloadOptions.type,o.click(),window.URL.revokeObjectURL(n),document.body.removeChild(o),e.$refs.download.close(),e.$store.dispatch("notification/success","The file has been downloaded")}).catch(function(t){e.$refs.download.error(t.message)})},onInput:function(e){this.$emit("input",e)},onRemoveAll:function(){this.$refs.editor.removeAll(),this.$refs.removeAll.close()},onUpload:function(e,t){var o=Ek(t,1)[0];this.$refs.editor.importBlocks(o)},upload:function(){this.$refs.upload.open({url:window.panel.api+"/"+this.endpoints.field+"/import",accept:"text/plain,text/html,text/markdown,application/json",multiple:!1})}}};if(typeof vb==="function"){vb=vb.options}Object.assign(vb,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("k-field",{attrs:{"disabled":_vm.disabled,"label":_vm.label,"name":_vm.name,"required":_vm.required,"type":_vm.type}},[_vm.inline?[_c("k-editor-inline",{attrs:{"autofocus":_vm.autofocus,"disabled":_vm.disabled,"placeholder":_vm.placeholder,"spellcheck":_vm.spellcheck,"value":_vm.value},on:{"input":_vm.onInput}})]:[_c("k-dropdown",{attrs:{"slot":"options"},slot:"options"},[_c("k-button",{attrs:{"icon":"dots"},on:{"click":function($event){return _vm.$refs.settings.toggle()}}}),_vm._v(" "),_c("k-dropdown-content",{ref:"settings",attrs:{"align":"right"}},[_c("k-dropdown-item",{attrs:{"icon":"upload"},on:{"click":_vm.upload}},[_vm._v("Import content")]),_vm._v(" "),_c("k-dropdown-item",{attrs:{"disabled":_vm.isEmpty,"icon":"attachment"},on:{"click":function($event){return _vm.$refs.download.open()}}},[_vm._v("Export")]),_vm._v(" "),_c("hr"),_vm._v(" "),_c("k-dropdown-item",{attrs:{"disabled":_vm.isEmpty,"icon":"trash"},on:{"click":function($event){return _vm.$refs.removeAll.open()}}},[_vm._v("Delete blocks")])],1)],1),_vm._v(" "),_c("k-editor",{ref:"editor",attrs:{"autofocus":_vm.autofocus,"allowed":_vm.allowed,"disabled":_vm.disabled,"disallowed":_vm.disallowed,"endpoints":_vm.endpoints,"spellcheck":_vm.spellcheck,"value":_vm.value},on:{"input":_vm.onInput}}),_vm._v(" "),_c("k-dialog",{ref:"download",attrs:{"button":_vm.$t("download")},on:{"submit":_vm.onDownload}},[_c("k-form",{attrs:{"fields":_vm.$options.downloadFields},model:{value:_vm.downloadOptions,callback:function($$v){_vm.downloadOptions=$$v},expression:"downloadOptions"}})],1),_vm._v(" "),_c("k-dialog",{ref:"removeAll",attrs:{"button":_vm.$t("delete"),"theme":"negative"},on:{"submit":_vm.onRemoveAll}},[_c("k-text",[_vm._v("Do you really want to remove all blocks?")])],1),_vm._v(" "),_c("k-upload",{ref:"upload",on:{"success":_vm.onUpload}})]],2)};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());panel.plugin("getkirby/editor",{components:{"k-editable":Fa},fields:{editor:vb}});})();