This repository has been archived by the owner on Feb 11, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
index.js
1 lines (1 loc) · 251 KB
/
index.js
1
(function () {function yf(e,t){return Vf(e)||Ef(e,t)||Tf()}function Tf(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function Ef(e,t){var r=[],o=!0,n=!1,i=void 0;try{for(var a,l=e[Symbol.iterator]();!(o=(a=l.next()).done)&&(r.push(a.value),!t||r.length!==t);o=!0);}catch(d){n=!0,i=d}finally{try{o||null==l.return||l.return()}finally{if(n)throw i}}return r}function Vf(e){if(Array.isArray(e))return e}var Tb,Oa={};!function(t,e){if("object"==typeof Oa)Oa=e();else if("function"==typeof Tb&&Tb.amd)Tb([],e);else if("object"==typeof Oa){var n=e();Oa.ClipboardJS=n}else t.ClipboardJS=e()}(Oa,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=6)}([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,t.exports.TinyEmitter=n},function(t,e,n){var r=n(3),o=n(4);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(5);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(t,e,n){n.r(e);var r=n(0),o=n.n(r),i="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},a=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}}();var c=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 a(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=o()(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=o()(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(),document.activeElement.blur(),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":i(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}(),u=n(1),l=n.n(u),s=n(2),f=n.n(s),d="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},h=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}}();var p=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,l.a),h(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"===d(t.container)?t.container:document.body}},{key:"listenClick",value:function(t){var e=this;this.listener=f()(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 c({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 y("action",t)}},{key:"defaultTarget",value:function(t){var e=y("target",t);if(e)return document.querySelector(e)}},{key:"defaultText",value:function(t){return y("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 y(t,e){var n="data-clipboard-"+t;if(e.hasAttribute(n))return e.getAttribute(n)}e.default=p}]).default});function Ie(t){return tf(t)||kf(t)||_f()}function _f(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function kf(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}function tf(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 He(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){zf(t,o,e[o])})}return t}function zf(t,o,e){return o in t?Object.defineProperty(t,o,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[o]=e,t}var mb={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 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("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 If(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){Kf(e,r,t[r])})}return e}function Kf(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=If({},{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 Fb={icon:"quote",extends:"paragraph",breaks:!0};if(typeof Fb==="function"){Fb=Fb.options}var pb={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 pb==="function"){pb=pb.options}Object.assign(pb,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 dh(t){return Ne(t)||ji(t)||ii()}function ii(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function ji(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}function Ne(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 hf(t){return(hf="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)}function De(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),s=e.child(n);if(o!=s){if(!o.sameMarkup(s))return r;if(o.isText&&o.text!=s.text){for(var i=0;o.text[i]==s.text[i];i++)r++;return r}if(o.content.size||s.content.size){var a=De(o.content,s.content,r+1);if(null!=a)return a}r+=o.nodeSize}else r+=o.nodeSize}}function Ce(t,e,r,n){for(var o=t.childCount,s=e.childCount;;){if(0==o||0==s)return o==s?null:{a:r,b:n};var i=t.child(--o),a=e.child(--s),$=i.nodeSize;if(i!=a){if(!i.sameMarkup(a))return{a:r,b:n};if(i.isText&&i.text!=a.text){for(var f=0,p=Math.min(i.text.length,a.text.length);f<p&&i.text[i.text.length-f-1]==a.text[a.text.length-f-1];)f++,r--,n--;return{a:r,b:n}}if(i.content.size||a.content.size){var c=Ce(i.content,a.content,r-1,n-1);if(c)return c}r-=$,n-=$}else r-=$,n-=$}}function v(r){this.content=r}v.prototype={constructor:v,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 v(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 v(t)},addToStart:function(r,e){return new v([r,e].concat(this.remove(r).content))},addToEnd:function(r,e){var t=this.remove(r).content.slice();return t.push(r,e),new v(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 v(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=v.from(r)).size?new v(r.content.concat(this.subtract(r).content)):this},append:function(r){return(r=v.from(r)).size?new v(this.subtract(r).content.concat(r.content)):this},subtract:function(r){var e=this;r=v.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}},v.from=function(r){if(r instanceof v)return r;var e=[];if(r)for(var t in r)e.push(t,r[t]);return new v(e)};var Be=v;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},ab={firstChild:{configurable:!0},lastChild:{configurable:!0},childCount:{configurable:!0}};b.prototype.nodesBetween=function(t,e,r,n,o){void 0===n&&(n=0);for(var s=0,i=0;i<e;s++){var a=this.content[s],$=i+a.nodeSize;if($>t&&!1!==r(a,n+i,o,s)&&a.content.size){var f=i+1;a.nodesBetween(Math.max(0,t-f),Math.min(a.content.size,e-f),r,n+f)}i=$}},b.prototype.descendants=function(t){this.nodesBetween(0,this.size,t)},b.prototype.textBetween=function(t,e,r,n){var o="",s=!0;return this.nodesBetween(t,e,function(i,a){i.isText?(o+=i.text.slice(Math.max(t,a)-a,e-a),s=!r):i.isLeaf&&n?(o+=n,s=!r):!s&&i.isBlock&&(o+=r,s=!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,s=0;s<e;o++){var i=this.content[o],a=s+i.nodeSize;a>t&&((s<t||a>e)&&(i=i.isText?i.cut(Math.max(0,t-s),Math.min(i.text.length,e-s)):i.cut(Math.max(0,t-s-1),Math.min(i.content.size,e-s-1))),r.push(i),n+=i.nodeSize),s=a}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},ab.firstChild.get=function(){return this.content.length?this.content[0]:null},ab.lastChild.get=function(){return this.content.length?this.content[this.content.length-1]:null},ab.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),De(this,t,e)},b.prototype.findDiffEnd=function(t,e,r){return void 0===e&&(e=this.size),void 0===r&&(r=t.size),Ce(this,t,e,r)},b.prototype.findIndex=function(t,e){if(void 0===e&&(e=-1),0==t)return ib(0,t);if(t==this.size)return ib(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?ib(r+1,o):ib(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,ab);var Gb={index:0,offset:0};function ib(t,e){return Gb.index=t,Gb.offset=e,Gb}function jb(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(!jb(t[n],e[n]))return!1}else{for(var o in t)if(!(o in e&&jb(t[o],e[o])))return!1;for(var s in e)if(!(s in t))return!1}return!0}b.empty=new b([],0);var c=function(t,e){this.type=t,this.attrs=e};function J(t){var e=Error.call(this,t);return e.__proto__=J.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&&jb(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=[],J.prototype=Object.create(Error.prototype),J.prototype.constructor=J,J.prototype.name="ReplaceError";var k=function(t,e,r){this.content=t,this.openStart=e,this.openEnd=r},ue={size:{configurable:!0}};function me(t,e,r){var n=t.findIndex(e),o=n.index,s=n.offset,i=t.maybeChild(o),a=t.findIndex(r),$=a.index,f=a.offset;if(s==e||i.isText){if(f!=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(me(i.content,e-s-1,r-s-1)))}function ke(t,e,r,n){var o=t.findIndex(e),s=o.index,i=o.offset,a=t.maybeChild(s);if(i==e||a.isText)return n&&!n.canReplace(s,s,r)?null:t.cut(0,e).append(r).append(t.cut(e));var $=ke(a.content,e-i-1,r);return $&&t.replaceChild(s,a.copy($))}function nf(t,e,r){if(r.openStart>t.depth)throw new J("Inserted content deeper than insertion position");if(t.depth-r.openStart!=e.depth-r.openEnd)throw new J("Inconsistent open depths");return je(t,e,r,0)}function je(t,e,r,n){var o=t.index(n),s=t.node(n);if(o==e.index(n)&&n<t.depth-r.openStart){var i=je(t,e,r,n+1);return s.copy(s.content.replaceChild(o,i))}if(r.content.size){if(r.openStart||r.openEnd||t.depth!=n||e.depth!=n){var a=ah(r,t);return ja(s,fe(t,a.start,a.end,e,n))}var $=t.parent,f=$.content;return ja($,f.cut(0,t.parentOffset).append(r.content).append(f.cut(e.parentOffset)))}return ja(s,bb(t,e,n))}function ie(t,e){if(!e.type.compatibleContent(t.type))throw new J("Cannot join "+e.type.name+" onto "+t.type.name)}function Mb(t,e,r){var n=t.node(r);return ie(n,e.node(r)),n}function ha(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 Ma(t,e,r,n){var o=(e||t).node(r),s=0,i=e?e.index(r):o.childCount;t&&(s=t.index(r),t.depth>r?s++:t.textOffset&&(ha(t.nodeAfter,n),s++));for(var a=s;a<i;a++)ha(o.child(a),n);e&&e.depth==r&&e.textOffset&&ha(e.nodeBefore,n)}function ja(t,e){if(!t.type.validContent(e))throw new J("Invalid content for node "+t.type.name);return t.copy(e)}function fe(t,e,r,n,o){var s=t.depth>o&&Mb(t,e,o+1),i=n.depth>o&&Mb(r,n,o+1),a=[];return Ma(null,t,o,a),s&&i&&e.index(o)==r.index(o)?(ie(s,i),ha(ja(s,fe(t,e,r,n,o+1)),a)):(s&&ha(ja(s,bb(t,e,o+1)),a),Ma(e,r,o,a),i&&ha(ja(i,bb(r,n,o+1)),a)),Ma(n,null,o,a),new b(a)}function bb(t,e,r){var n=[];(Ma(null,t,r,n),t.depth>r)&&ha(ja(Mb(t,e,r+1),bb(t,e,r+1)),n);return Ma(e,null,r,n),new b(n)}function ah(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)}}ue.size.get=function(){return this.content.size-this.openStart-this.openEnd},k.prototype.insertAt=function(t,e){var r=ke(this.content,t+this.openStart,e,null);return r&&new k(r,this.openStart,this.openEnd)},k.prototype.removeBetween=function(t,e){return new k(me(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)},k.prototype.eq=function(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd},k.prototype.toString=function(){return this.content+"("+this.openStart+","+this.openEnd+")"},k.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},k.fromJSON=function(t,e){if(!e)return k.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 k(b.fromJSON(t,e.content),e.openStart||0,e.openEnd||0)},k.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 s=t.lastChild;s&&!s.isLeaf&&(e||!s.type.spec.isolating);s=s.lastChild)n++;return new k(t,r,n)},Object.defineProperties(k.prototype,ue),k.empty=new k(b.empty,0,0);var h=function(t,e,r){this.pos=t,this.path=e,this.depth=e.length/3-1,this.parentOffset=r},ra={parent:{configurable:!0},doc:{configurable:!0},textOffset:{configurable:!0},nodeAfter:{configurable:!0},nodeBefore:{configurable:!0}};h.prototype.resolveDepth=function(t){return null==t?this.depth:t<0?this.depth+t:t},ra.parent.get=function(){return this.node(this.depth)},ra.doc.get=function(){return this.node(0)},h.prototype.node=function(t){return this.path[3*this.resolveDepth(t)]},h.prototype.index=function(t){return this.path[3*this.resolveDepth(t)+1]},h.prototype.indexAfter=function(t){return t=this.resolveDepth(t),this.index(t)+(t!=this.depth||this.textOffset?1:0)},h.prototype.start=function(t){return 0==(t=this.resolveDepth(t))?0:this.path[3*t-1]+1},h.prototype.end=function(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size},h.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]},h.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},ra.textOffset.get=function(){return this.pos-this.path[this.path.length-1]},ra.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},ra.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)},h.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 s=r.marks,i=0;i<s.length;i++)!1!==s[i].type.spec.inclusive||n&&s[i].isInSet(n.marks)||(s=s[i--].removeFromSet(s));return s},h.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},h.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},h.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 $d(this,t,r)},h.prototype.sameParent=function(t){return this.pos-this.parentOffset==t.pos-t.parentOffset},h.prototype.max=function(t){return t.pos>this.pos?t:this},h.prototype.min=function(t){return t.pos<this.pos?t:this},h.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},h.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,s=t;;){var i=s.content.findIndex(o),a=i.index,$=i.offset,f=o-$;if(r.push(s,a,n+$),!f)break;if((s=s.child(a)).isText)break;o=f-1,n+=$+1}return new h(e,r,o)},h.resolveCached=function(t,e){for(var r=0;r<Rb.length;r++){var n=Rb[r];if(n.pos==e&&n.doc==t)return n}var o=Rb[_d]=h.resolve(t,e);return _d=(_d+1)%gf,o},Object.defineProperties(h.prototype,ra);var Rb=[],_d=0,gf=12,$d=function(t,e,r){this.$from=t,this.$to=e,this.depth=r},oa={start:{configurable:!0},end:{configurable:!0},parent:{configurable:!0},startIndex:{configurable:!0},endIndex:{configurable:!0}};oa.start.get=function(){return this.$from.before(this.depth+1)},oa.end.get=function(){return this.$to.after(this.depth+1)},oa.parent.get=function(){return this.$from.node(this.depth)},oa.startIndex.get=function(){return this.$from.index(this.depth)},oa.endIndex.get=function(){return this.$to.indexAfter(this.depth)},Object.defineProperties($d.prototype,oa);var lf=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},t={nodeSize:{configurable:!0},childCount:{configurable:!0},textContent:{configurable:!0},firstChild:{configurable:!0},lastChild:{configurable:!0},isBlock:{configurable:!0},isTextblock:{configurable:!0},inlineContent:{configurable:!0},isInline:{configurable:!0},isText:{configurable:!0},isLeaf:{configurable:!0},isAtom:{configurable:!0}};t.nodeSize.get=function(){return this.isLeaf?1:2+this.content.size},t.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)},t.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)},t.firstChild.get=function(){return this.content.firstChild},t.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&&jb(this.attrs,e||t.defaultAttrs||lf)&&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 k.empty;var n=this.resolve(t),o=this.resolve(e),s=r?0:n.sharedDepth(e),i=n.start(s),a=n.node(s).content.cut(n.pos-i,o.pos-i);return new k(a,n.depth-s,o.depth-s)},a.prototype.replace=function(t,e,r){return nf(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 h.resolveCached(this,t)},a.prototype.resolveNoCache=function(t){return h.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},t.isBlock.get=function(){return this.type.isBlock},t.isTextblock.get=function(){return this.type.isTextblock},t.inlineContent.get=function(){return this.type.inlineContent},t.isInline.get=function(){return this.type.isInline},t.isText.get=function(){return this.type.isText},t.isLeaf.get=function(){return this.type.isLeaf},t.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()+")"),Xd(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 s=this.contentMatchAt(t).matchFragment(r,n,o),i=s&&s.matchFragment(this.content,e);if(!i||!i.validEnd)return!1;for(var a=n;a<o;a++)if(!this.type.allowsMarks(r.child(a).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),s=o&&o.matchFragment(this.content,e);return!!s&&s.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.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,t);var wf=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:{configurable:!0},nodeSize:{configurable:!0}};return e.prototype.toString=function(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Xd(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 Xd(t,e){for(var r=t.length-1;r>=0;r--)e=t[r].type.name+"("+e+")";return e}var A=function(t){this.validEnd=t,this.next=[],this.wrapCache=[]},Pa={inlineContent:{configurable:!0},defaultType:{configurable:!0},edgeCount:{configurable:!0}};A.parse=function(t,e){var r=new Qa(t,e);if(null==r.next)return A.empty;var n=Sd(r);r.next&&r.err("Unexpected trailing text");var o=th(Pg(n));return Lh(o,r),o},A.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},A.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},Pa.inlineContent.get=function(){var t=this.next[0];return!!t&&t.isInline},Pa.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}},A.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},A.prototype.fillBefore=function(t,e,r){void 0===e&&(e=!1),void 0===r&&(r=0);var n=[this];return function o(s,i){var a=s.matchFragment(t,r);if(a&&(!e||a.validEnd))return b.from(i.map(function(t){return t.createAndFill()}));for(var $=0;$<s.next.length;$+=2){var f=s.next[$],p=s.next[$+1];if(!f.isText&&!f.hasRequiredAttrs()&&-1==n.indexOf(p)){n.push(p);var c=o(p,i.concat(f));if(c)return c}}}(this,[])},A.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},A.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 s=[],i=n;i.type;i=i.via)s.push(i.type);return s.reverse()}for(var a=0;a<o.next.length;a+=2){var $=o.next[a];$.isLeaf||$.hasRequiredAttrs()||$.name in e||n.type&&!o.next[a+1].validEnd||(r.push({match:$.contentMatch,type:$,via:n}),e[$.name]=!0)}}},Pa.edgeCount.get=function(){return this.next.length>>1},A.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]}},A.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(A.prototype,Pa),A.empty=new A(!0);var Qa=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()},Wd={next:{configurable:!0}};function Sd(t){var e=[];do{e.push(Xf(t))}while(t.eat("|"));return 1==e.length?e[0]:{type:"choice",exprs:e}}function Xf(t){var e=[];do{e.push(Zf(t))}while(t.next&&")"!=t.next&&"|"!=t.next);return 1==e.length?e[0]:{type:"seq",exprs:e}}function Zf(t){for(var e=Ig(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=bg(t,e)}return e}function Rd(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");var e=Number(t.next);return t.pos++,e}function bg(t,e){var r=Rd(t),n=r;return t.eat(",")&&(n="}"!=t.next?Rd(t):-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:r,max:n,expr:e}}function lg(t,e){var r=t.nodeTypes,n=r[e];if(n)return[n];var o=[];for(var s in r){var i=r[s];i.groups.indexOf(e)>-1&&o.push(i)}return 0==o.length&&t.err("No node type or group '"+e+"' found"),o}function Ig(t){if(t.eat("(")){var e=Sd(t);return t.eat(")")||t.err("Missing closing paren"),e}if(!/\W/.test(t.next)){var r=lg(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 Pg(t){var e=[[]];return o(function t(e,s){if("choice"==e.type)return e.exprs.reduce(function(e,r){return e.concat(t(r,s))},[]);if("seq"==e.type)for(var i=0;;i++){var a=t(e.exprs[i],s);if(i==e.exprs.length-1)return a;o(a,s=r())}else{if("star"==e.type){var $=r();return n(s,$),o(t(e.expr,$),$),[n($)]}if("plus"==e.type){var f=r();return o(t(e.expr,s),f),o(t(e.expr,f),f),[n(f)]}if("opt"==e.type)return[n(s)].concat(t(e.expr,s));if("range"==e.type){for(var p=s,c=0;c<e.min;c++){var h=r();o(t(e.expr,p),h),p=h}if(-1==e.max)o(t(e.expr,p),p);else for(var u=e.min;u<e.max;u++){var l=r();n(p,l),o(t(e.expr,p),l),p=l}return[n(p)]}if("name"==e.type)return[n(s,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 Qd(t,e){return e-t}function Nd(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 s=0;s<o.length;s++){var i=o[s],a=i.term,$=i.to;a||-1!=r.indexOf($)||e($)}}(e),r.sort(Qd)}function th(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 s=o.indexOf(r),i=s>-1&&o[s+1];Nd(t,n).forEach(function(t){i||o.push(r,i=[]),-1==i.indexOf(t)&&i.push(t)})}})});var s=e[n.join(",")]=new A(n.indexOf(t.length-1)>-1);for(var i=0;i<o.length;i+=2){var a=o[i+1].sort(Qd);s.next.push(o[i],e[a.join(",")]||r(a))}return s}(Nd(t,0))}function Lh(t,e){for(var r=0,n=[t];r<n.length;r++){for(var o=n[r],s=!o.validEnd,i=[],a=0;a<o.next.length;a+=2){var $=o.next[a],f=o.next[a+1];i.push($.name),!s||$.isText||$.hasRequiredAttrs()||(s=!1),-1==n.indexOf(f)&&n.push(f)}s&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Md(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 Fd(t,e){var r=Object.create(null);for(var n in t){var o=e&&e[n];if(void 0===o){var s=t[n];if(!s.hasDefault)throw new RangeError("No value supplied for attribute "+n);o=s.default}r[n]=o}return r}function Bd(t){var e=Object.create(null);if(t)for(var r in t)e[r]=new Ad(t[r]);return e}Wd.next.get=function(){return this.tokens[this.pos]},Qa.prototype.eat=function(t){return this.next==t&&(this.pos++||!0)},Qa.prototype.err=function(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")},Object.defineProperties(Qa.prototype,Wd);var B=function(t,e,r){this.name=t,this.schema=e,this.spec=r,this.groups=r.group?r.group.split(" "):[],this.attrs=Bd(r.attrs),this.defaultAttrs=Md(this.attrs),this.contentMatch=null,this.markSet=null,this.inlineContent=null,this.isBlock=!(r.inline||"text"==t),this.isText="text"==t},La={isInline:{configurable:!0},isTextblock:{configurable:!0},isLeaf:{configurable:!0},isAtom:{configurable:!0}};La.isInline.get=function(){return!this.isBlock},La.isTextblock.get=function(){return this.isBlock&&this.inlineContent},La.isLeaf.get=function(){return this.contentMatch==A.empty},La.isAtom.get=function(){return this.isLeaf||this.spec.atom},B.prototype.hasRequiredAttrs=function(){for(var t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1},B.prototype.compatibleContent=function(t){return this==t||this.contentMatch.compatible(t.contentMatch)},B.prototype.computeAttrs=function(t){return!t&&this.defaultAttrs?this.defaultAttrs:Fd(this.attrs,t)},B.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))},B.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))},B.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},B.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},B.prototype.allowsMarkType=function(t){return null==this.markSet||this.markSet.indexOf(t)>-1},B.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},B.prototype.allowedMarks=function(t){if(null==this.markSet)return t;for(var e,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},B.compile=function(t,e){var r=Object.create(null);t.forEach(function(t,n){return r[t]=new B(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(B.prototype,La);var Ad=function(t){this.hasDefault=Object.prototype.hasOwnProperty.call(t,"default"),this.default=t.default},wd={isRequired:{configurable:!0}};wd.isRequired.get=function(){return!this.hasDefault},Object.defineProperties(Ad.prototype,wd);var U=function(t,e,r,n){this.name=t,this.schema=r,this.spec=n,this.attrs=Bd(n.attrs),this.rank=e,this.excluded=null;var o=Md(this.attrs);this.instance=o&&new c(this,o)};U.prototype.create=function(t){return!t&&this.instance?this.instance:new c(this,Fd(this.attrs,t))},U.compile=function(t,e){var r=Object.create(null),n=0;return t.forEach(function(t,o){return r[t]=new U(t,n++,e,o)}),r},U.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},U.prototype.isInSet=function(t){for(var e=0;e<t.length;e++)if(t[e].type==this)return t[e]},U.prototype.excludes=function(t){return this.excluded.indexOf(t)>-1};var ba=function(t){for(var e in this.spec={},t)this.spec[e]=t[e];this.spec.nodes=Be.from(t.nodes),this.spec.marks=Be.from(t.marks),this.nodes=B.compile(this.spec.nodes,this),this.marks=U.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],s=o.spec.content||"",i=o.spec.marks;o.contentMatch=r[s]||(r[s]=A.parse(s,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.markSet="_"==i?null:i?vd(this,i.split(" ")):""!=i&&o.inlineContent?null:[]}for(var a in this.marks){var $=this.marks[a],f=$.spec.excludes;$.excluded=null==f?[$]:""==f?[]:vd(this,f.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 vd(t,e){for(var r=[],n=0;n<e.length;n++){var o=e[n],s=t.marks[o],i=s;if(s)r.push(s);else for(var a in t.marks){var $=t.marks[a];("_"==o||$.spec.group&&$.spec.group.split(" ").indexOf(o)>-1)&&r.push(i=$)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[n]+"'")}return r}ba.prototype.node=function(t,e,r,n){if("string"==typeof t)t=this.nodeType(t);else{if(!(t instanceof B))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)},ba.prototype.text=function(t,e){var r=this.nodes.text;return new wf(r,r.defaultAttrs,t,c.setFrom(e))},ba.prototype.mark=function(t,e){return"string"==typeof t&&(t=this.marks[t]),t.create(e)},ba.prototype.nodeFromJSON=function(t){return a.fromJSON(this,t)},ba.prototype.markFromJSON=function(t){return c.fromJSON(this,t)},ba.prototype.nodeType=function(t){var e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e};var H=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)}),this.normalizeLists=!this.tags.some(function(e){if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return!1;var r=t.nodes[e.node];return r.contentMatch.matchType(r)})};H.prototype.parse=function(t,e){void 0===e&&(e={});var r=new g(this,e,!1);return r.addAll(t,null,e.from,e.to),r.finish()},H.prototype.parseSlice=function(t,e){void 0===e&&(e={});var r=new g(this,e,!0);return r.addAll(t,null,e.from,e.to),k.maxOpen(r.finish())},H.prototype.matchTag=function(t,e){for(var r=0;r<this.tags.length;r++){var n=this.tags[r];if(fg(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}}},H.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 s=o.getAttrs(e);if(!1===s)continue;o.attrs=s}return o}}},H.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=nd(t)),t.mark=e})};for(var o in t.marks)n(o);var s;for(var i in t.nodes)s=void 0,(s=t.nodes[i].spec.parseDOM)&&s.forEach(function(t){r(t=nd(t)),t.node=i});return e},H.fromSchema=function(t){return t.cached.domParser||(t.cached.domParser=new H(t,H.schemaRules(t)))};var ud={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},Cf={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},td={ol:!0,ul:!0},Xb=1,qd=2,Ka=4;function pd(t){return(t?Xb:0)|("full"===t?qd:0)}var qa=function(t,e,r,n,o,s,i){this.type=t,this.attrs=e,this.solid=o,this.match=s||(i&Ka?null:t.contentMatch),this.options=i,this.content=[],this.marks=r,this.activeMarks=c.none,this.pendingMarks=n};qa.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)},qa.prototype.finish=function(t){if(!(this.options&Xb)){var e,r=this.content[this.content.length-1];r&&r.isText&&(e=/[ \t\r\n\u000c]+$/.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},qa.prototype.applyPending=function(t){for(var e=0,r=this.pendingMarks;e<r.length;e++){var n=r[e];(this.type?this.type.allowsMarkType(n.type):mg(n.type,t))&&!n.isInSet(this.activeMarks)&&(this.activeMarks=n.addToSet(this.activeMarks),this.pendingMarks=n.removeFromSet(this.pendingMarks))}};var g=function(t,e,r){this.parser=t,this.options=e,this.isOpen=r;var n,o=e.topNode,s=pd(e.preserveWhitespace)|(r?Ka:0);n=o?new qa(o.type,o.attrs,c.none,c.none,!0,e.topMatch||o.type.contentMatch,s):new qa(r?null:t.schema.topNodeType,null,c.none,c.none,!0,null,s),this.nodes=[n],this.open=0,this.find=e.findPositions,this.needsBlock=!1},Yb={top:{configurable:!0},currentPos:{configurable:!0}};function dg(t){for(var e=t.firstChild,r=null;e;e=e.nextSibling){var n=1==e.nodeType?e.nodeName.toLowerCase():null;n&&td.hasOwnProperty(n)&&r?(r.appendChild(e),e=r):"li"==n?r=e:n&&(r=null)}}function fg(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function gg(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 nd(t){var e={};for(var r in t)e[r]=t[r];return e}function mg(t,e){var r=e.schema.nodes,n=function(n){var o=r[n];if(o.allowsMarkType(t)){var s=[],i=function(t){s.push(t);for(var r=0;r<t.edgeCount;r++){var n=t.edge(r),o=n.type,a=n.next;if(o==e)return!0;if(s.indexOf(a)<0&&i(a))return!0}};return i(o.contentMatch)?{v:!0}:void 0}};for(var o in r){var s=n(o);if(s)return s.v}}Yb.top.get=function(){return this.nodes[this.open]},g.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(gg(e)):null,n=this.top;if(null!=r)for(var o=0;o<r.length;o++)this.addPendingMark(r[o]);if(this.addElement(t),null!=r)for(var s=0;s<r.length;s++)this.removePendingMark(r[s],n)}},g.prototype.addTextNode=function(t){var e=t.nodeValue,r=this.top;if((r.type?r.type.inlineContent:r.content.length&&r.content[0].isInline)||/[^ \t\r\n\u000c]/.test(e)){if(r.options&Xb)r.options&qd||(e=e.replace(/\r?\n|\r/g," "));else if(e=e.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.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&&/[ \t\r\n\u000c]$/.test(n.text))&&(e=e.slice(1))}e&&this.insertNode(this.parser.schema.text(e)),this.findInText(t)}else this.findInside(t)},g.prototype.addElement=function(t){var e=t.nodeName.toLowerCase();td.hasOwnProperty(e)&&this.normalizeLists&&dg(t);var r=this.options.ruleFromNode&&this.options.ruleFromNode(t)||this.parser.matchTag(t,this);if(r?r.ignore:Cf.hasOwnProperty(e))this.findInside(t);else if(!r||r.skip||r.closeParent){r&&r.closeParent?this.open=Math.max(0,this.open-1):r&&r.skip.nodeType&&(t=r.skip);var n,o=this.top,s=this.needsBlock;if(ud.hasOwnProperty(e))n=!0,o.type||(this.needsBlock=!0);else if(!t.firstChild)return void this.leafFallback(t);this.addAll(t),n&&this.sync(o),this.needsBlock=s}else this.addElementByRule(t,r)},g.prototype.leafFallback=function(t){"BR"==t.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode("\n"))},g.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},g.prototype.addElementByRule=function(t,e){var r,n,o,s=this;e.node?(n=this.parser.schema.nodes[e.node]).isLeaf?this.insertNode(n.create(e.attrs))||this.leafFallback(t):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 s.insertNode(t)});else{var a=e.contentElement;"string"==typeof a?a=t.querySelector(a):"function"==typeof a&&(a=a(t)),a||(a=t),this.findAround(t,a,!0),this.addAll(a,r)}r&&(this.sync(i),this.open--),o&&this.removePendingMark(o,i)},g.prototype.addAll=function(t,e,r,n){for(var o=r||0,s=r?t.childNodes[r]:t.firstChild,i=null==n?null:t.childNodes[n];s!=i;s=s.nextSibling,++o)this.findAtPoint(t,o),this.addDOM(s),e&&ud.hasOwnProperty(s.nodeName.toLowerCase())&&this.sync(e);this.findAtPoint(t,o)},g.prototype.findPlace=function(t){for(var e,r,n=this.open;n>=0;n--){var o=this.nodes[n],s=o.findWrapping(t);if(s&&(!e||e.length>s.length)&&(e=s,r=o,!s.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},g.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;r.applyPending(t.type),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));return r.content.push(t.mark(n)),!0}return!1},g.prototype.enter=function(t,e,r){var n=this.findPlace(t.create(e));return n&&this.enterInner(t,e,!0,r),n},g.prototype.enterInner=function(t,e,r,n){this.closeExtra();var o=this.top;o.applyPending(t),o.match=o.match&&o.match.matchType(t,e);var s=null==n?o.options&~Ka:pd(n);o.options&Ka&&0==o.content.length&&(s|=Ka),this.nodes.push(new qa(t,e,o.activeMarks,o.pendingMarks,r,null,s)),this.open++},g.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}},g.prototype.finish=function(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)},g.prototype.sync=function(t){for(var e=this.open;e>=0;e--)if(this.nodes[e]==t)return void(this.open=e)},Yb.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},g.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)},g.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)},g.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)}},g.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))},g.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),s=-(n?n.depth+1:0)+(o?0:1),i=function(t,a){for(;t>=0;t--){var $=r[t];if(""==$){if(t==r.length-1||0==t)continue;for(;a>=s;a--)if(i(t-1,a))return!0;return!1}var f=a>0||0==a&&o?e.nodes[a].type:n&&a>=s?n.node(a-s).type:null;if(!f||f.name!=$&&-1==f.groups.indexOf($))return!1;a--}return!0};return i(r.length-1,this.open)},g.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}},g.prototype.addPendingMark=function(t){this.top.pendingMarks=t.addToSet(this.top.pendingMarks)},g.prototype.removePendingMark=function(t,e){for(var r=this.open;r>=0;r--){var n=this.nodes[r];if(n.pendingMarks.lastIndexOf(t)>-1?n.pendingMarks=t.removeFromSet(n.pendingMarks):n.activeMarks=t.removeFromSet(n.activeMarks),n==e)break}},Object.defineProperties(g.prototype,Yb);var y=function(t,e){this.nodes=t||{},this.marks=e||{}};function md(t){var e={};for(var r in t){var n=t[r].spec.toDOM;n&&(e[r]=n)}return e}function _b(t){return t.document||window.document}y.prototype.serializeFragment=function(t,e,r){var n=this;void 0===e&&(e={}),r||(r=_b(e).createDocumentFragment());var o=r,s=null;return t.forEach(function(t){if(s||t.marks.length){s||(s=[]);for(var r=0,i=0;r<s.length&&i<t.marks.length;){var a=t.marks[i];if(n.marks[a.type.name]){if(!a.eq(s[r])||!1===a.type.spec.spanning)break;r+=2,i++}else i++}for(;r<s.length;)o=s.pop(),s.pop();for(;i<t.marks.length;){var $=t.marks[i++],f=n.serializeMark($,t.isInline,e);f&&(s.push($,o),o.appendChild(f.dom),o=f.contentDOM||f.dom)}}o.appendChild(n.serializeNode(t,e))}),r},y.prototype.serializeNode=function(t,e){void 0===e&&(e={});var r=y.renderSpec(_b(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},y.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},y.prototype.serializeMark=function(t,e,r){void 0===r&&(r={});var n=this.marks[t.type.name];return n&&y.renderSpec(_b(r),n(t,e))},y.renderSpec=function(t,e,r){if(void 0===r&&(r=null),"string"==typeof e)return{dom:t.createTextNode(e)};if(null!=e.nodeType)return{dom:e};var n=e[0],o=n.indexOf(" ");o>0&&(r=n.slice(0,o),n=n.slice(o+1));var s=null,i=r?t.createElementNS(r,n):t.createElement(n),a=e[1],$=1;if(a&&"object"==typeof a&&null==a.nodeType&&!Array.isArray(a))for(var f in $=2,a)if(null!=a[f]){var p=f.indexOf(" ");p>0?i.setAttributeNS(f.slice(0,p),f.slice(p+1),a[f]):i.setAttribute(f,a[f])}for(var c=$;c<e.length;c++){var h=e[c];if(0===h){if(c<e.length-1||c>$)throw new RangeError("Content hole must be the only child of its parent node");return{dom:i,contentDOM:i}}var u=y.renderSpec(t,h,r),l=u.dom,d=u.contentDOM;if(i.appendChild(l),d){if(s)throw new RangeError("Multiple content holes");s=d}}return{dom:i,contentDOM:s}},y.fromSchema=function(t){return t.cached.domSerializer||(t.cached.domSerializer=new y(this.nodesFromSchema(t),this.marksFromSchema(t)))},y.nodesFromSchema=function(t){var e=md(t.nodes);return e.text||(e.text=function(t){return t.text}),e},y.marksFromSchema=function(t){return md(t.marks)};var id=65535,fd=Math.pow(2,16);function Eh(t,e){return t+e*fd}function cd(t){return t&id}function Zh(t){return(t-(t&id))/fd}var ec=function(t,e,r){void 0===e&&(e=!1),void 0===r&&(r=null),this.pos=t,this.deleted=e,this.recover=r},m=function(t,e){void 0===e&&(e=!1),this.ranges=t,this.inverted=e};m.prototype.recover=function(t){var e=0,r=cd(t);if(!this.inverted)for(var n=0;n<r;n++)e+=this.ranges[3*n+2]-this.ranges[3*n+1];return this.ranges[3*r]+e+Zh(t)},m.prototype.mapResult=function(t,e){return void 0===e&&(e=1),this._map(t,e,!1)},m.prototype.map=function(t,e){return void 0===e&&(e=1),this._map(t,e,!0)},m.prototype._map=function(t,e,r){for(var n=0,o=this.inverted?2:1,i=this.inverted?1:2,p=0;p<this.ranges.length;p+=3){var a=this.ranges[p]-(this.inverted?n:0);if(a>t)break;var $=this.ranges[p+o],s=this.ranges[p+i],c=a+$;if(t<=c){var h=a+n+(($?t==a?-1:t==c?1:e:e)<0?0:s);if(r)return h;var f=t==(e<0?a:c)?null:Eh(p/3,t-a);return new ec(h,e<0?t!=a:t!=c,f)}n+=s-$}return r?t+n:new ec(t+n)},m.prototype.touches=function(t,e){for(var r=0,n=cd(e),o=this.inverted?2:1,i=this.inverted?1:2,p=0;p<this.ranges.length;p+=3){var a=this.ranges[p]-(this.inverted?r:0);if(a>t)break;var $=this.ranges[p+o];if(t<=a+$&&p==3*n)return!0;r+=this.ranges[p+i]-$}return!1},m.prototype.forEach=function(t){for(var e=this.inverted?2:1,r=this.inverted?1:2,n=0,o=0;n<this.ranges.length;n+=3){var i=this.ranges[n],p=i-(this.inverted?o:0),a=i+(this.inverted?0:o),$=this.ranges[n+e],s=this.ranges[n+r];t(p,p+$,a,a+s),o+=s-$}},m.prototype.invert=function(){return new m(this.ranges,!this.inverted)},m.prototype.toString=function(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)},m.offset=function(t){return 0==t?m.empty:new m(t<0?[0,-t,0]:[0,0,t])},m.empty=new m([]);var n=function(t,e,r,n){this.maps=t||[],this.from=r||0,this.to=null==n?this.maps.length:n,this.mirror=e};function sa(t){var e=Error.call(this,t);return e.__proto__=sa.prototype,e}n.prototype.slice=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.maps.length),new n(this.maps,this.mirror,t,e)},n.prototype.copy=function(){return new n(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)},n.prototype.appendMap=function(t,e){this.to=this.maps.push(t),null!=e&&this.setMirror(this.maps.length-1,e)},n.prototype.appendMapping=function(t){for(var e=0,r=this.maps.length;e<t.maps.length;e++){var n=t.getMirror(e);this.appendMap(t.maps[e],null!=n&&n<e?r+n:null)}},n.prototype.getMirror=function(t){if(this.mirror)for(var e=0;e<this.mirror.length;e++)if(this.mirror[e]==t)return this.mirror[e+(e%2?-1:1)]},n.prototype.setMirror=function(t,e){this.mirror||(this.mirror=[]),this.mirror.push(t,e)},n.prototype.appendMappingInverted=function(t){for(var e=t.maps.length-1,r=this.maps.length+t.maps.length;e>=0;e--){var n=t.getMirror(e);this.appendMap(t.maps[e].invert(),null!=n&&n>e?r-n-1:null)}},n.prototype.invert=function(){var t=new n;return t.appendMappingInverted(this),t},n.prototype.map=function(t,e){if(void 0===e&&(e=1),this.mirror)return this._map(t,e,!0);for(var r=this.from;r<this.to;r++)t=this.maps[r].map(t,e);return t},n.prototype.mapResult=function(t,e){return void 0===e&&(e=1),this._map(t,e,!1)},n.prototype._map=function(t,e,r){for(var n=!1,o=this.from;o<this.to;o++){var i=this.maps[o].mapResult(t,e);if(null!=i.recover){var p=this.getMirror(o);if(null!=p&&p>o&&p<this.to){o=p,t=this.maps[p].recover(i.recover);continue}}i.deleted&&(n=!0),t=i.pos}return r?t:new ec(t,n)},sa.prototype=Object.create(Error.prototype),sa.prototype.constructor=sa,sa.prototype.name="TransformError";var e=function(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new n},jc={before:{configurable:!0},docChanged:{configurable:!0}};function eb(){throw new Error("Override me")}jc.before.get=function(){return this.docs.length?this.docs[0]:this.doc},e.prototype.step=function(t){var e=this.maybeStep(t);if(e.failed)throw new sa(e.failed);return this},e.prototype.maybeStep=function(t){var e=t.apply(this.doc);return e.failed||this.addStep(t,e.doc),e},jc.docChanged.get=function(){return this.steps.length>0},e.prototype.addStep=function(t,e){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=e},Object.defineProperties(e.prototype,jc);var lc=Object.create(null),o=function(){};o.prototype.apply=function(t){return eb()},o.prototype.getMap=function(){return m.empty},o.prototype.invert=function(t){return eb()},o.prototype.map=function(t){return eb()},o.prototype.merge=function(t){return null},o.prototype.toJSON=function(){return eb()},o.fromJSON=function(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");var r=lc[e.stepType];if(!r)throw new RangeError("No step type "+e.stepType+" defined");return r.fromJSON(t,e)},o.jsonID=function(t,e){if(t in lc)throw new RangeError("Duplicate use of step JSON ID "+t);return lc[t]=e,e.prototype.jsonID=t,e};var D=function(t,e){this.doc=t,this.failed=e};D.ok=function(t){return new D(t,null)},D.fail=function(t){return new D(null,t)},D.fromReplace=function(t,e,r,n){try{return D.ok(t.replace(e,r,n))}catch(o){if(o instanceof J)return D.fail(o.message);throw o}};var V=function(t){function e(e,r,n,o){t.call(this),this.from=e,this.to=r,this.slice=n,this.structure=!!o}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){return this.structure&&mc(t,this.from,this.to)?D.fail("Structure replace would overwrite content"):D.fromReplace(t,this.from,this.to,this.slice)},e.prototype.getMap=function(){return new m([this.from,this.to-this.from,this.slice.size])},e.prototype.invert=function(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))},e.prototype.map=function(t){var r=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return r.deleted&&n.deleted?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice)},e.prototype.merge=function(t){if(!(t instanceof e)||t.structure!=this.structure)return null;if(this.from+this.slice.size!=t.from||this.slice.openEnd||t.slice.openStart){if(t.to!=this.from||this.slice.openStart||t.slice.openEnd)return null;var r=this.slice.size+t.slice.size==0?k.empty:new k(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,r,this.structure)}var n=this.slice.size+t.slice.size==0?k.empty:new k(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)},e.prototype.toJSON=function(){var t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t},e.fromJSON=function(t,r){if("number"!=typeof r.from||"number"!=typeof r.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new e(r.from,r.to,k.fromJSON(t,r.slice),!!r.structure)},e}(o);o.jsonID("replace",V);var W=function(t){function e(e,r,n,o,i,p,a){t.call(this),this.from=e,this.to=r,this.gapFrom=n,this.gapTo=o,this.slice=i,this.insert=p,this.structure=!!a}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){if(this.structure&&(mc(t,this.from,this.gapFrom)||mc(t,this.gapTo,this.to)))return D.fail("Structure gap-replace would overwrite content");var e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return D.fail("Gap is not a flat range");var r=this.slice.insertAt(this.insert,e.content);return r?D.fromReplace(t,this.from,this.to,r):D.fail("Content does not fit in gap")},e.prototype.getMap=function(){return new m([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])},e.prototype.invert=function(t){var r=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+r,this.from+this.insert,this.from+this.insert+r,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)},e.prototype.map=function(t){var r=t.mapResult(this.from,1),n=t.mapResult(this.to,-1),o=t.map(this.gapFrom,-1),i=t.map(this.gapTo,1);return r.deleted&&n.deleted||o<r.pos||i>n.pos?null:new e(r.pos,n.pos,o,i,this.slice,this.insert,this.structure)},e.prototype.toJSON=function(){var t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t},e.fromJSON=function(t,r){if("number"!=typeof r.from||"number"!=typeof r.to||"number"!=typeof r.gapFrom||"number"!=typeof r.gapTo||"number"!=typeof r.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new e(r.from,r.to,r.gapFrom,r.gapTo,k.fromJSON(t,r.slice),r.insert,!!r.structure)},e}(o);function mc(t,e,r){for(var n=t.resolve(e),o=r-e,i=n.depth;o>0&&i>0&&n.indexAfter(i)==n.node(i).childCount;)i--,o--;if(o>0)for(var p=n.node(i).maybeChild(n.indexAfter(i));o>0;){if(!p||p.isLeaf)return!0;p=p.firstChild,o--}return!1}function Df(t,e,r){return(0==e||t.canReplace(e,t.childCount))&&(r==t.childCount||t.canReplace(0,r))}function pc(t){for(var e=t.parent.content.cutByIndex(t.startIndex,t.endIndex),r=t.depth;;--r){var n=t.$from.node(r),o=t.$from.index(r),i=t.$to.indexAfter(r);if(r<t.depth&&n.canReplace(o,i,e))return r;if(0==r||n.type.spec.isolating||!Df(n,o,i))break}}function Gf(t,e,r){var n=t.resolve(e),o=n.index();return n.parent.canReplaceWith(o,o+1,r)}function rb(t,e,r,n){void 0===r&&(r=1);var o=t.resolve(e),i=o.depth-r,p=n&&n[n.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!p.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(var a=o.depth-1,$=r-2;a>i;a--,$--){var s=o.node(a),c=o.index(a);if(s.type.spec.isolating)return!1;var h=s.content.cutByIndex(c,s.childCount),f=n&&n[$]||s;if(f!=s&&(h=h.replaceChild(0,f.type.create(f.attrs))),!s.canReplace(c+1,s.childCount)||!f.type.validContent(h))return!1}var l=o.indexAfter(i),u=n&&n[0];return o.node(i).canReplaceWith(l,l,u?u.type:o.node(i+1).type)}function Ec(t,e){var r=t.resolve(e),n=r.index();return Lf(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(n,n+1)}function Lf(t,e){return t&&e&&!t.isLeaf&&t.canAppend(e)}function Mf(t,e,r){var n=t.resolve(e);if(n.parent.canReplaceWith(n.index(),n.index(),r))return e;if(0==n.parentOffset)for(var o=n.depth-1;o>=0;o--){var i=n.index(o);if(n.node(o).canReplaceWith(i,i,r))return n.before(o+1);if(i>0)return null}if(n.parentOffset==n.parent.content.size)for(var p=n.depth-1;p>=0;p--){var a=n.indexAfter(p);if(n.node(p).canReplaceWith(a,a,r))return n.after(p+1);if(a<n.node(p).childCount)return null}}function Nf(t,e,r){var n=t.resolve(e);if(!r.content.size)return e;for(var o=r.content,i=0;i<r.openStart;i++)o=o.firstChild.content;for(var p=1;p<=(0==r.openStart&&r.size?2:1);p++)for(var a=n.depth;a>=0;a--){var $=a==n.depth?0:n.pos<=(n.start(a+1)+n.end(a+1))/2?-1:1,s=n.index(a)+($>0?1:0);if(1==p?n.node(a).canReplace(s,s,o):n.node(a).contentMatchAt(s).findWrapping(o.firstChild.type))return 0==$?n.pos:$<0?n.before(a+1):n.after(a+1)}return null}function sc(t,e,r){for(var n=[],o=0;o<t.childCount;o++){var i=t.child(o);i.content.size&&(i=i.copy(sc(i.content,e,i))),i.isInline&&(i=e(i,r,o)),n.push(i)}return b.fromArray(n)}o.jsonID("replaceAround",W),e.prototype.lift=function(t,e){for(var r=t.$from,n=t.$to,o=t.depth,i=r.before(o+1),p=n.after(o+1),a=i,$=p,s=b.empty,c=0,h=o,f=!1;h>e;h--)f||r.index(h)>0?(f=!0,s=b.from(r.node(h).copy(s)),c++):a--;for(var l=b.empty,u=0,d=o,m=!1;d>e;d--)m||n.after(d+1)<n.end(d)?(m=!0,l=b.from(n.node(d).copy(l)),u++):$++;return this.step(new W(a,$,i,p,new k(s.append(l),c,u),s.size-c,!0))},e.prototype.wrap=function(t,e){for(var r=b.empty,n=e.length-1;n>=0;n--)r=b.from(e[n].type.create(e[n].attrs,r));var o=t.start,i=t.end;return this.step(new W(o,i,o,i,new k(r,0,0),e.length,!0))},e.prototype.setBlockType=function(t,e,r,n){var o=this;if(void 0===e&&(e=t),!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");var i=this.steps.length;return this.doc.nodesBetween(t,e,function(t,e){if(t.isTextblock&&!t.hasMarkup(r,n)&&Gf(o.doc,o.mapping.slice(i).map(e),r)){o.clearIncompatible(o.mapping.slice(i).map(e,1),r);var p=o.mapping.slice(i),a=p.map(e,1),$=p.map(e+t.nodeSize,1);return o.step(new W(a,$,a+1,$-1,new k(b.from(r.create(n,null,t.marks)),0,0),1,!0)),!1}}),this},e.prototype.setNodeMarkup=function(t,e,r,n){var o=this.doc.nodeAt(t);if(!o)throw new RangeError("No node at given position");e||(e=o.type);var i=e.create(r,null,n||o.marks);if(o.isLeaf)return this.replaceWith(t,t+o.nodeSize,i);if(!e.validContent(o.content))throw new RangeError("Invalid content for node type "+e.name);return this.step(new W(t,t+o.nodeSize,t+1,t+o.nodeSize-1,new k(b.from(i),0,0),1,!0))},e.prototype.split=function(t,e,r){void 0===e&&(e=1);for(var n=this.doc.resolve(t),o=b.empty,i=b.empty,p=n.depth,a=n.depth-e,$=e-1;p>a;p--,$--){o=b.from(n.node(p).copy(o));var s=r&&r[$];i=b.from(s?s.type.create(s.attrs,i):n.node(p).copy(i))}return this.step(new V(t,t,new k(o.append(i),e,e),!0))},e.prototype.join=function(t,e){void 0===e&&(e=1);var r=new V(t-e,t+e,k.empty,!0);return this.step(r)};var rc=function(t){function e(e,r,n){t.call(this),this.from=e,this.to=r,this.mark=n}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){var e=this,r=t.slice(this.from,this.to),n=t.resolve(this.from),o=n.node(n.sharedDepth(this.to)),i=new k(sc(r.content,function(t,r){return r.type.allowsMarkType(e.mark.type)?t.mark(e.mark.addToSet(t.marks)):t},o),r.openStart,r.openEnd);return D.fromReplace(t,this.from,this.to,i)},e.prototype.invert=function(){return new Ba(this.from,this.to,this.mark)},e.prototype.map=function(t){var r=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return r.deleted&&n.deleted||r.pos>=n.pos?null:new e(r.pos,n.pos,this.mark)},e.prototype.merge=function(t){if(t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark)},e.prototype.toJSON=function(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}},e.fromJSON=function(t,r){if("number"!=typeof r.from||"number"!=typeof r.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new e(r.from,r.to,t.markFromJSON(r.mark))},e}(o);o.jsonID("addMark",rc);var Ba=function(t){function e(e,r,n){t.call(this),this.from=e,this.to=r,this.mark=n}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){var e=this,r=t.slice(this.from,this.to),n=new k(sc(r.content,function(t){return t.mark(e.mark.removeFromSet(t.marks))}),r.openStart,r.openEnd);return D.fromReplace(t,this.from,this.to,n)},e.prototype.invert=function(){return new rc(this.from,this.to,this.mark)},e.prototype.map=function(t){var r=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return r.deleted&&n.deleted||r.pos>=n.pos?null:new e(r.pos,n.pos,this.mark)},e.prototype.merge=function(t){if(t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark)},e.prototype.toJSON=function(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}},e.fromJSON=function(t,r){if("number"!=typeof r.from||"number"!=typeof r.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new e(r.from,r.to,t.markFromJSON(r.mark))},e}(o);function $f(t,e,r,n){if(void 0===r&&(r=e),void 0===n&&(n=k.empty),e==r&&!n.size)return null;var o=t.resolve(e),i=t.resolve(r);return Wc(o,i,n)?new V(e,r,n):new G(o,i,n).fit()}function Wc(t,e,r){return!r.openStart&&!r.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),r.content)}o.jsonID("removeMark",Ba),e.prototype.addMark=function(t,e,r){var n=this,o=[],i=[],p=null,a=null;return this.doc.nodesBetween(t,e,function(n,$,s){if(n.isInline){var c=n.marks;if(!r.isInSet(c)&&s.type.allowsMarkType(r.type)){for(var h=Math.max($,t),f=Math.min($+n.nodeSize,e),l=r.addToSet(c),u=0;u<c.length;u++)c[u].isInSet(l)||(p&&p.to==h&&p.mark.eq(c[u])?p.to=f:o.push(p=new Ba(h,f,c[u])));a&&a.to==h?a.to=f:i.push(a=new rc(h,f,r))}}}),o.forEach(function(t){return n.step(t)}),i.forEach(function(t){return n.step(t)}),this},e.prototype.removeMark=function(t,e,r){var n=this;void 0===r&&(r=null);var o=[],i=0;return this.doc.nodesBetween(t,e,function(n,p){if(n.isInline){i++;var a=null;if(r instanceof U){var $=r.isInSet(n.marks);$&&(a=[$])}else r?r.isInSet(n.marks)&&(a=[r]):a=n.marks;if(a&&a.length)for(var s=Math.min(p+n.nodeSize,e),c=0;c<a.length;c++){for(var h=a[c],f=void 0,l=0;l<o.length;l++){var u=o[l];u.step==i-1&&h.eq(o[l].style)&&(f=u)}f?(f.to=s,f.step=i):o.push({style:h,from:Math.max(p,t),to:s,step:i})}}}),o.forEach(function(t){return n.step(new Ba(t.from,t.to,t.style))}),this},e.prototype.clearIncompatible=function(t,e,r){void 0===r&&(r=e.contentMatch);for(var n=this.doc.nodeAt(t),o=[],i=t+1,p=0;p<n.childCount;p++){var a=n.child(p),$=i+a.nodeSize,s=r.matchType(a.type,a.attrs);if(s){r=s;for(var c=0;c<a.marks.length;c++)e.allowsMarkType(a.marks[c].type)||this.step(new Ba(i,$,a.marks[c]))}else o.push(new V(i,$,k.empty));i=$}if(!r.validEnd){var h=r.fillBefore(b.empty,!0);this.replace(i,i,new k(h,0,0))}for(var f=o.length-1;f>=0;f--)this.step(o[f]);return this},e.prototype.replace=function(t,e,r){void 0===e&&(e=t),void 0===r&&(r=k.empty);var n=$f(this.doc,t,e,r);return n&&this.step(n),this},e.prototype.replaceWith=function(t,e,r){return this.replace(t,e,new k(b.from(r),0,0))},e.prototype.delete=function(t,e){return this.replace(t,e,k.empty)},e.prototype.insert=function(t,e){return this.replaceWith(t,t,e)};var G=function(t,e,r){this.$to=e,this.$from=t,this.unplaced=r,this.frontier=[];for(var n=0;n<=t.depth;n++){var o=t.node(n);this.frontier.push({type:o.type,match:o.contentMatchAt(t.indexAfter(n))})}this.placed=b.empty;for(var i=t.depth;i>0;i--)this.placed=b.from(t.node(i).copy(this.placed))},Xc={depth:{configurable:!0}};function Aa(t,e,r){return 0==e?t.cutByIndex(r):t.replaceChild(0,t.firstChild.copy(Aa(t.firstChild.content,e-1,r)))}function za(t,e,r){return 0==e?t.append(r):t.replaceChild(t.childCount-1,t.lastChild.copy(za(t.lastChild.content,e-1,r)))}function gc(t,e){for(var r=0;r<e;r++)t=t.firstChild.content;return t}function _c(t,e,r){if(e<=0)return t;var n=t.content;return e>1&&(n=n.replaceChild(0,_c(n.firstChild,e-1,1==n.childCount?r-1:0))),e>0&&(n=t.type.contentMatch.fillBefore(n).append(n),r<=0&&(n=n.append(t.type.contentMatch.matchFragment(n).fillBefore(b.empty,!0)))),t.copy(n)}function bc(t,e,r,n,o){var i=t.node(e),p=o?t.indexAfter(e):t.index(e);if(p==i.childCount&&!r.compatibleContent(i.type))return null;var a=n.fillBefore(i.content,!0,p);return a&&!Jg(r,i.content,p)?a:null}function Jg(t,e,r){for(var n=r;n<e.childCount;n++)if(!t.allowsMarks(e.child(n).marks))return!0;return!1}function jd(t,e,r,n,o){if(e<r){var i=t.firstChild;t=t.replaceChild(0,i.copy(jd(i.content,e+1,r,n,i)))}if(e>n){var p=o.contentMatchAt(0),a=p.fillBefore(t).append(t);t=a.append(p.matchFragment(a).fillBefore(b.empty,!0))}return t}function kd(t,e){for(var r=[],n=Math.min(t.depth,e.depth);n>=0;n--){var o=t.start(n);if(o<t.pos-(t.depth-n)||e.end(n)>e.pos+(e.depth-n)||t.node(n).type.spec.isolating||e.node(n).type.spec.isolating)break;o==e.start(n)&&r.push(n)}return r}Xc.depth.get=function(){return this.frontier.length-1},G.prototype.fit=function(){for(;this.unplaced.size;){var t=this.findFittable();t?this.placeNodes(t):this.openMore()||this.dropNode()}var e=this.mustMoveInline(),r=this.placed.size-this.depth-this.$from.depth,n=this.$from,o=this.close(e<0?this.$to:n.doc.resolve(e));if(!o)return null;for(var i=this.placed,p=n.depth,a=o.depth;p&&a&&1==i.childCount;)i=i.firstChild.content,p--,a--;var $=new k(i,p,a);return e>-1?new W(n.pos,e,this.$to.pos,this.$to.end(),$,r):$.size||n.pos!=this.$to.pos?new V(n.pos,o.pos,$):void 0},G.prototype.findFittable=function(){for(var t=1;t<=2;t++)for(var e=this.unplaced.openStart;e>=0;e--)for(var r=void 0,n=(e?(r=gc(this.unplaced.content,e-1).firstChild).content:this.unplaced.content).firstChild,o=this.depth;o>=0;o--){var i=this.frontier[o],p=i.type,a=i.match,$=void 0,s=void 0;if(1==t&&(n?a.matchType(n.type)||(s=a.fillBefore(b.from(n),!1)):p.compatibleContent(r.type)))return{sliceDepth:e,frontierDepth:o,parent:r,inject:s};if(2==t&&n&&($=a.findWrapping(n.type)))return{sliceDepth:e,frontierDepth:o,parent:r,wrap:$};if(r&&a.matchType(r.type))break}},G.prototype.openMore=function(){var t=this.unplaced,e=t.content,r=t.openStart,n=t.openEnd,o=gc(e,r);return!(!o.childCount||o.firstChild.isLeaf)&&(this.unplaced=new k(e,r+1,Math.max(n,o.size+r>=e.size-n?r+1:0)),!0)},G.prototype.dropNode=function(){var t=this.unplaced,e=t.content,r=t.openStart,n=t.openEnd,o=gc(e,r);if(o.childCount<=1&&r>0){var i=e.size-r<=r+o.size;this.unplaced=new k(Aa(e,r-1,1),r-1,i?r-1:n)}else this.unplaced=new k(Aa(e,r,1),r,n)},G.prototype.placeNodes=function(t){for(var e=t.sliceDepth,r=t.frontierDepth,n=t.parent,o=t.inject,i=t.wrap;this.depth>r;)this.closeFrontierNode();if(i)for(var p=0;p<i.length;p++)this.openFrontierNode(i[p]);var a=this.unplaced,$=n?n.content:a.content,s=a.openStart-e,c=0,h=[],f=this.frontier[r],l=f.match,u=f.type;if(o){for(var d=0;d<o.childCount;d++)h.push(o.child(d));l=l.matchFragment(o)}for(var m=$.size+e-(a.content.size-a.openEnd);c<$.childCount;){var v=$.child(c),C=l.matchType(v.type);if(!C)break;(++c>1||0==s||v.content.size)&&(l=C,h.push(_c(v.mark(u.allowedMarks(v.marks)),1==c?s:0,c==$.childCount?m:-1)))}var U=c==$.childCount;U||(m=-1),U&&m<0&&n&&n.type==this.frontier[this.depth].type?this.closeFrontierNode():this.frontier[r].match=l;for(var y=0,x=$;y<m;y++){var g=x.lastChild;this.frontier.push({type:g.type,match:g.contentMatchAt(g.childCount)}),x=g.content}this.unplaced=U?0==e?k.empty:new k(Aa(a.content,e-1,1),e-1,m<0?a.openEnd:e-1):new k(Aa(a.content,e,c),a.openStart,a.openEnd),this.placed=za(this.placed,r,b.from(h))},G.prototype.mustMoveInline=function(){if(!this.$to.parent.isTextblock||this.$to.end()==this.$to.pos)return-1;var t,e=this.frontier[this.depth];if(!e.type.isTextblock||!bc(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;for(var r=this.$to.depth,n=this.$to.after(r);r>1&&n==this.$to.end(--r);)++n;return n},G.prototype.findCloseLevel=function(t){t:for(var e=Math.min(this.depth,t.depth);e>=0;e--){var r=this.frontier[e],n=r.match,o=r.type,i=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1)),p=bc(t,e,o,n,i);if(p){for(var a=e-1;a>=0;a--){var $=this.frontier[a],s=$.match,c=bc(t,a,$.type,s,!0);if(!c||c.childCount)continue t}return{depth:e,fit:p,move:i?t.doc.resolve(t.after(e+1)):t}}}},G.prototype.close=function(t){var e=this.findCloseLevel(t);if(!e)return null;for(;this.depth>e.depth;)this.closeFrontierNode();e.fit.childCount&&(this.placed=za(this.placed,e.depth,e.fit)),t=e.move;for(var r=e.depth+1;r<=t.depth;r++){var n=t.node(r),o=n.type.contentMatch.fillBefore(n.content,!0,t.index(r));this.openFrontierNode(n.type,n.attrs,o)}return t},G.prototype.openFrontierNode=function(t,e,r){var n=this.frontier[this.depth];n.match=n.match.matchType(t),this.placed=za(this.placed,this.depth,b.from(t.create(e,r))),this.frontier.push({type:t,match:t.contentMatch})},G.prototype.closeFrontierNode=function(){var t=this.frontier.pop().match.fillBefore(b.empty,!0);t.childCount&&(this.placed=za(this.placed,this.frontier.length,t))},Object.defineProperties(G.prototype,Xc),e.prototype.replaceRange=function(t,e,r){if(!r.size)return this.deleteRange(t,e);var n=this.doc.resolve(t),o=this.doc.resolve(e);if(Wc(n,o,r))return this.step(new V(t,e,r));var i=kd(n,this.doc.resolve(e));0==i[i.length-1]&&i.pop();var p=-(n.depth+1);i.unshift(p);for(var a=n.depth,$=n.pos-1;a>0;a--,$--){var s=n.node(a).type.spec;if(s.defining||s.isolating)break;i.indexOf(a)>-1?p=a:n.before(a)==$&&i.splice(1,0,-a)}for(var c=i.indexOf(p),h=[],f=r.openStart,l=r.content,u=0;;u++){var d=l.firstChild;if(h.push(d),u==r.openStart)break;l=d.content}f>0&&h[f-1].type.spec.defining&&n.node(c).type!=h[f-1].type?f-=1:f>=2&&h[f-1].isTextblock&&h[f-2].type.spec.defining&&n.node(c).type!=h[f-2].type&&(f-=2);for(var m=r.openStart;m>=0;m--){var v=(m+f+1)%(r.openStart+1),C=h[v];if(C)for(var U=0;U<i.length;U++){var y=i[(U+c)%i.length],x=!0;y<0&&(x=!1,y=-y);var g=n.node(y-1),S=n.index(y-1);if(g.canReplaceWith(S,S,C.type,C.marks))return this.replace(n.before(y),x?o.after(y):e,new k(jd(r.content,0,r.openStart,v),v,r.openEnd))}}for(var M=this.steps.length,w=i.length-1;w>=0&&(this.replace(t,e,r),!(this.steps.length>M));w--){var R=i[w];w<0||(t=n.before(R),e=o.after(R))}return this},e.prototype.replaceRangeWith=function(t,e,r){if(!r.isInline&&t==e&&this.doc.resolve(t).parent.content.size){var n=Mf(this.doc,t,r.type);null!=n&&(t=e=n)}return this.replaceRange(t,e,new k(b.from(r),0,0))},e.prototype.deleteRange=function(t,e){for(var r=this.doc.resolve(t),n=this.doc.resolve(e),o=kd(r,n),i=0;i<o.length;i++){var p=o[i],a=i==o.length-1;if(a&&0==p||r.node(p).type.contentMatch.validEnd)return this.delete(r.start(p),n.end(p));if(p>0&&(a||r.node(p-1).canReplace(r.index(p-1),n.indexAfter(p-1))))return this.delete(r.before(p),n.after(p))}for(var $=1;$<=r.depth&&$<=n.depth;$++)if(t-r.start($)==r.depth-$&&e>r.end($)&&n.end($)-e!=n.depth-$)return this.delete(r.before($),e);return this.delete(t,e)};var Zb=Object.create(null),q=function(e,t,r){this.ranges=r||[new Hh(e.min(t),e.max(t))],this.$anchor=e,this.$head=t},$={anchor:{configurable:!0},head:{configurable:!0},from:{configurable:!0},to:{configurable:!0},$from:{configurable:!0},$to:{configurable:!0},empty:{configurable:!0}};$.anchor.get=function(){return this.$anchor.pos},$.head.get=function(){return this.$head.pos},$.from.get=function(){return this.$from.pos},$.to.get=function(){return this.$to.pos},$.$from.get=function(){return this.ranges[0].$from},$.$to.get=function(){return this.ranges[0].$to},$.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},q.prototype.content=function(){return this.$from.node(0).slice(this.from,this.to,!0)},q.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,p=this.ranges,s=0;s<p.length;s++){var $=p[s],a=$.$from,c=$.$to,l=e.mapping.slice(i);e.replaceRange(l.map(a.pos),l.map(c.pos),s?k.empty:t),0==s&&od(e,i,(r?r.isInline:o&&o.isTextblock)?-1:1)}},q.prototype.replaceWith=function(e,t){for(var r=e.steps.length,o=this.ranges,n=0;n<o.length;n++){var i=o[n],p=i.$from,s=i.$to,$=e.mapping.slice(r),a=$.map(p.pos),c=$.map(s.pos);n?e.deleteRange(a,c):(e.replaceRangeWith(a,c,t),od(e,r,t.isInline?-1:1))}},q.findFrom=function(e,t,r){var o=e.parent.inlineContent?new z(e):va(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?va(e.node(0),e.node(n),e.before(n+1),e.index(n),t,r):va(e.node(0),e.node(n),e.after(n+1),e.index(n)+1,t,r);if(i)return i}},q.near=function(e,t){return void 0===t&&(t=1),this.findFrom(e,t)||this.findFrom(e,-t)||new na(e.node(0))},q.atStart=function(e){return va(e,e,0,0,1)||new na(e)},q.atEnd=function(e){return va(e,e,e.content.size,e.childCount,-1)||new na(e)},q.fromJSON=function(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");var r=Zb[t.type];if(!r)throw new RangeError("No selection type "+t.type+" defined");return r.fromJSON(e,t)},q.jsonID=function(e,t){if(e in Zb)throw new RangeError("Duplicate use of selection JSON ID "+e);return Zb[e]=t,t.prototype.jsonID=e,t},q.prototype.getBookmark=function(){return z.between(this.$anchor,this.$head).getBookmark()},Object.defineProperties(q.prototype,$),q.prototype.visible=!0;var Hh=function(e,t){this.$from=e,this.$to=t},z=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:{configurable:!0}};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 ya(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 p=e.findFrom(o,n,!0)||e.findFrom(o,-n,!0);if(!p)return e.near(o,n);o=p.$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}(q);q.jsonID("text",z);var ya=function(e,t){this.anchor=e,this.head=t};ya.prototype.map=function(e){return new ya(e.map(this.anchor),e.map(this.head))},ya.prototype.resolve=function(e){return z.between(e.resolve(this.anchor),e.resolve(this.head))};var f=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,p=n.pos,s=r.resolve(p);return i?e.near(s):new t(s)},t.prototype.content=function(){return new k(b.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}(q);f.prototype.visible=!1,q.jsonID("node",f);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 ya(o,o):new cb(o)},cb.prototype.resolve=function(e){var t=e.resolve(this.anchor),r=t.nodeAfter;return r&&f.isSelectable(r)?new f(t):q.near(t)};var na=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.replace=function(t,r){if(void 0===r&&(r=k.empty),r==k.empty){t.delete(0,t.doc.content.size);var o=e.atStart(t.doc);o.eq(t.selection)||t.setSelection(o)}else e.prototype.replace.call(this,t,r)},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 Qe},t}(q);q.jsonID("all",na);var Qe={map:function(){return this},resolve:function(e){return new na(e)}};function va(e,t,r,o,n,i){if(t.inlineContent)return z.create(e,r);for(var p=o-(n>0?0:1);n>0?p<t.childCount:p>=0;p+=n){var s=t.child(p);if(s.isAtom){if(!i&&f.isSelectable(s))return f.create(e,r-(n<0?s.nodeSize:0))}else{var $=va(e,s,r+n,n<0?s.childCount:0,n,i);if($)return $}r+=s.nodeSize*n}}function od(e,t,r){var o=e.steps.length-1;if(!(o<t)){var n,i=e.steps[o];if(i instanceof V||i instanceof W)e.mapping.maps[o].forEach(function(e,t,r,o){null==n&&(n=o)}),e.setSelection(q.near(e.doc.resolve(n),r))}}var sd=1,hb=2,Ed=4,qf=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:{configurable:!0},selectionSet:{configurable:!0},storedMarksSet:{configurable:!0},isGeneric:{configurable:!0},scrolledIntoView:{configurable:!0}};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){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|sd)&~hb,this.storedMarks=null,this},r.selectionSet.get=function(){return(this.updated&sd)>0},t.prototype.setStoredMarks=function(e){return this.storedMarks=e,this.updated|=hb,this},t.prototype.ensureMarks=function(e){return c.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&hb)>0},t.prototype.addStep=function(t,r){e.prototype.addStep.call(this,t,r),this.updated=this.updated&~hb,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)||c.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(q.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|=Ed,this},r.scrolledIntoView.get=function(){return(this.updated&Ed)>0},Object.defineProperties(t.prototype,r),t}(e);function ce(e,t){return t&&e?e.bind(t):e}var wa=function(e,t,r){this.name=e,this.init=ce(t.init,r),this.apply=ce(t.apply,r)},xf=[new wa("doc",{init:function(e){return e.doc||e.schema.topNodeType.createAndFill()},apply:function(e){return e.doc}}),new wa("selection",{init:function(e,t){return e.selection||q.atStart(t.doc)},apply:function(e){return e.selection}}),new wa("storedMarks",{init:function(e){return e.storedMarks||null},apply:function(e,t,r,o){return o.selection.$cursor?e.storedMarks:null}}),new wa("scrollToSelection",{init:function(){return 0},apply:function(e,t){return e.scrolledIntoView?t+1:t}})],Nb=function(e,t){var r=this;this.schema=e,this.fields=xf.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 wa(e.key,e.spec.state,e))})},s=function(e){this.config=e},nb={schema:{configurable:!0},plugins:{configurable:!0},tr:{configurable:!0}};nb.schema.get=function(){return this.config.schema},nb.plugins.get=function(){return this.config.plugins},s.prototype.apply=function(e){return this.applyTransaction(e).state},s.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},s.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 p=this.config.plugins[i];if(p.spec.appendTransaction){var s=o?o[i].n:0,$=o?o[i].state:this,a=s<t.length&&p.spec.appendTransaction.call(p,s?t.slice(s):t,$,r);if(a&&r.filterTransaction(a,i)){if(a.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(a),r=r.applyInner(a),n=!0}o&&(o[i]={state:r,n:t.length})}}if(!n)return{state:r,transactions:t}}},s.prototype.applyInner=function(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");for(var t=new s(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<Ha.length;i++)Ha[i](this,e,t);return t},nb.tr.get=function(){return new qf(this)},s.create=function(e){for(var t=new Nb(e.schema||e.doc.type.schema,e.plugins),r=new s(t),o=0;o<t.fields.length;o++)r[t.fields[o].name]=t.fields[o].init(e,r);return r},s.prototype.reconfigure=function(e){for(var t=new Nb(e.schema||this.schema,e.plugins),r=t.fields,o=new s(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},s.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},s.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 Nb(e.schema,e.plugins),n=new s(o);return o.fields.forEach(function(o){if("doc"==o.name)n.doc=a.fromJSON(e.schema,t.doc);else if("selection"==o.name)n.selection=q.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 p=r[i],s=p.spec.state;if(p.key==o.name&&s&&s.fromJSON&&Object.prototype.hasOwnProperty.call(t,i))return void(n[o.name]=s.fromJSON.call(p,e,t[i],n))}n[o.name]=o.init(e,n)}}),n},s.addApplyListener=function(e){Ha.push(e)},s.removeApplyListener=function(e){var t=Ha.indexOf(e);t>-1&&Ha.splice(t,1)},Object.defineProperties(s.prototype,nb);var Ha=[];function xe(e,t,r){for(var o in e){var n=e[o];n instanceof Function?n=n.bind(t):"handleDOMEvents"==o&&(n=xe(n,t,{})),r[o]=n}return r}var qb=function(e){this.props={},e.props&&xe(e.props,this,this.props),this.spec=e,this.key=e.key?e.key.key:Ae("plugin")};qb.prototype.getState=function(e){return e[this.key]};var Ib=Object.create(null);function Ae(e){return e in Ib?e+"$"+ ++Ib[e]:(Ib[e]=0,e+"$")}var tb=function(e){void 0===e&&(e="key"),this.key=Ae(e)};tb.prototype.get=function(e){return e.config.pluginsByKey[this.key]},tb.prototype.getState=function(e){return e[this.key]};var Fe=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,H.fromSchema(e).parse(o)};var j={};if("undefined"!=typeof navigator&&"undefined"!=typeof document){var Db=/Edge\/(\d+)/.exec(navigator.userAgent),Je=/MSIE \d/.test(navigator.userAgent),zb=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);j.mac=/Mac/.test(navigator.platform);var cc=j.ie=!!(Je||zb||Db);j.ie_version=Je?document.documentMode||6:zb?+zb[1]:Db?+Db[1]:null,j.gecko=!cc&&/gecko\/(\d+)/i.test(navigator.userAgent),j.gecko_version=j.gecko&&+(/Firefox\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];var Ab=!cc&&/Chrome\/(\d+)/.exec(navigator.userAgent);j.chrome=!!Ab,j.chrome_version=Ab&&+Ab[1],j.ios=!cc&&/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),j.android=/Android \d/.test(navigator.userAgent),j.webkit="webkitFontSmoothing"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 O=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},Ge=function(e){var t=e.parentNode;return t&&11==t.nodeType?t.host:t},N=function(e,t,r){var o=document.createRange();return o.setEnd(e,null==r?e.nodeValue.length:r),o.setStart(e,t||0),o},ub=function(e,t,r,o){return r&&(Ee(e,t,r,o,-1)||Ee(e,t,r,o,1))},kg=/^(img|br|input|textarea|hr)$/i;function Ee(e,t,r,o,n){for(;;){if(e==r&&t==o)return!0;if(t==(n<0?0:ma(e))){var i=e.parentNode;if(1!=i.nodeType||Hg(e)||kg.test(e.nodeName)||"false"==e.contentEditable)return!1;t=O(e)+(n<0?0:1),e=i}else{if(1!=e.nodeType)return!1;if("false"==(e=e.childNodes[t+(n<0?-1:0)]).contentEditable)return!1;t=n<0?ma(e):0}}}function ma(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function pg(e,t,r){for(var o=0==t,n=t==ma(e);o||n;){if(e==r)return!0;var i=O(e);if(!(e=e.parentNode))return!1;o=o&&0==i,n=n&&i==ma(e)}}function Hg(e){for(var t,r=e;r&&!(t=r.pmViewDesc);r=r.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}var Hb=function(e){var t=e.isCollapsed;return t&&j.chrome&&e.rangeCount&&!e.getRangeAt(0).collapsed&&(t=!1),t};function Ja(e,t){var r=document.createEvent("Event");return r.initEvent("keydown",!0,!0),r.keyCode=e,r.key=r.code=t,r}function Mg(e){return{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function Y(e,t){return"number"==typeof e?e:e[t]}function Qg(e){var t=e.getBoundingClientRect();return{left:t.left,right:t.left+e.clientWidth,top:t.top,bottom:t.top+e.clientHeight}}function re(e,t,r){for(var o=e.someProp("scrollThreshold")||0,n=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument,a=r||e.dom;a;a=Ge(a))if(1==a.nodeType){var s=a==i.body||1!=a.nodeType,$=s?Mg(i):Qg(a),c=0,l=0;if(t.top<$.top+Y(o,"top")?l=-($.top-t.top+Y(n,"top")):t.bottom>$.bottom-Y(o,"bottom")&&(l=t.bottom-$.bottom+Y(n,"bottom")),t.left<$.left+Y(o,"left")?c=-($.left-t.left+Y(n,"left")):t.right>$.right-Y(o,"right")&&(c=t.right-$.right+Y(n,"right")),c||l)if(s)i.defaultView.scrollBy(c,l);else{var d=a.scrollLeft,p=a.scrollTop;l&&(a.scrollTop+=l),c&&(a.scrollLeft+=c);var v=a.scrollLeft-d,u=a.scrollTop-p;t={left:t.left-v,top:t.top-u,right:t.right-v,bottom:t.bottom-u}}if(s)break}}function bh(e){for(var t,r,o=e.dom.getBoundingClientRect(),n=Math.max(0,o.top),i=(o.left+o.right)/2,a=n+1;a<Math.min(innerHeight,o.bottom);a+=5){var s=e.root.elementFromPoint(i,a);if(s!=e.dom&&e.dom.contains(s)){var $=s.getBoundingClientRect();if($.top>=n-20){t=s,r=$.top;break}}}return{refDOM:t,refTop:r,stack:pe(e.dom)}}function pe(e){for(var t=[],r=e.ownerDocument;e&&(t.push({dom:e,top:e.scrollTop,left:e.scrollLeft}),e!=r);e=Ge(e));return t}function hh(e){var t=e.refDOM,r=e.refTop,o=e.stack,n=t?t.getBoundingClientRect().top:0;he(o,0==n?0:n-r)}function he(e,t){for(var r=0;r<e.length;r++){var o=e[r],n=o.dom,i=o.top,a=o.left;n.scrollTop!=i+t&&(n.scrollTop=i+t),n.scrollLeft!=a&&(n.scrollLeft=a)}}var lb=null;function Gh(e){if(e.setActive)return e.setActive();if(lb)return e.focus(lb);var t=pe(e);e.focus(null==lb?{get preventScroll(){return lb={preventScroll:!0},!0}}:void 0),lb||(lb=!1,he(t,0))}function ee(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=N($).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?Kh(r,o):!r||n&&1==r.nodeType?{node:e,offset:i}:ee(r,o)}function Kh(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=ga(o,1);if(i.top!=i.bottom&&Pb(t,i))return{node:e,offset:n+(t.left>=(i.left+i.right)/2?1:0)}}return{node:e,offset:0}}function Pb(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function Th(e,t){var r=e.parentNode;return r&&/^li$/i.test(r.nodeName)&&t.left<e.getBoundingClientRect().left?r:e}function Vh(e,t,r){var o=ee(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 Xh(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 de(e,t,r){var o=e.childNodes.length;if(o&&r.top<r.bottom)for(var n=Math.max(0,Math.min(o-1,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(Pb(t,c))return de(a,t,c)}if((i=(i+1)%o)==n)break}return e}function hi(e,t){var r,o,n,i,a=e.root;if(a.caretPositionFromPoint)try{var s=a.caretPositionFromPoint(t.left,t.top);s&&(n=(r=s).offsetNode,i=r.offset)}catch(h){}if(!n&&a.caretRangeFromPoint){var $=a.caretRangeFromPoint(t.left,t.top);$&&(n=(o=$).startContainer,i=o.startOffset)}var c,l=a.elementFromPoint(t.left,t.top+1);if(!l||!e.dom.contains(1!=l.nodeType?l.parentNode:l)){var d=e.dom.getBoundingClientRect();if(!Pb(t,d))return null;if(!(l=de(e.dom,t,d)))return null}if(j.safari&&l.draggable&&(n=i=null),l=Th(l,t),n){if(j.gecko&&1==n.nodeType&&(i=Math.min(i,n.childNodes.length))<n.childNodes.length){var p,v=n.childNodes[i];"IMG"==v.nodeName&&(p=v.getBoundingClientRect()).right<=t.left&&p.bottom>t.top&&i++}n==e.dom&&i==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?c=e.state.doc.content.size:0!=i&&1==n.nodeType&&"BR"==n.childNodes[i-1].nodeName||(c=Xh(e,n,i,t))}null==c&&(c=Vh(e,l,t));var u=e.docView.nearestDesc(l,!0);return{pos:c,inside:u?u.posAtStart-u.border:-1}}function ga(e,t){var r=e.getClientRects();return r.length?r[t<0?0:r.length-1]:e.getBoundingClientRect()}function Ud(e,t){var r=e.docView.domFromPos(t),o=r.node,n=r.offset;if(3==o.nodeType&&(j.webkit||j.gecko)){var i=ga(N(o,n,n),0);if(j.gecko&&n&&/\s/.test(o.nodeValue[n-1])&&n<o.nodeValue.length){var a=ga(N(o,n-1,n-1),-1);if(a.top==i.top){var s=ga(N(o,n,n+1),-1);if(s.top!=i.top)return Na(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 Oe($||o.getBoundingClientRect(),c)}for(var p=-1;p<2;p+=2)if(p<0&&n){var v=void 0,u=3==o.nodeType?N(o,n-1,n):3==(v=o.childNodes[n-1]).nodeType?N(v):1==v.nodeType&&"BR"!=v.nodeName?v:null;if(u){var h=ga(u,1);if(h.top<h.bottom)return Na(h,!1)}}else if(p>0&&n<ma(o)){var f=void 0,M=3==o.nodeType?N(o,n,n+1):3==(f=o.childNodes[n]).nodeType?N(f):1==f.nodeType?f:null;if(M){var E=ga(M,-1);if(E.top<E.bottom)return Na(E,!0)}}return Na(ga(3==o.nodeType?N(o):o,0),!1)}function Na(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 Oe(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 Ke(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&&n.focus()}}function Se(e,t,r){var o=t.selection,n="up"==r?o.$anchor.min(o.$head):o.$anchor.max(o.$head);return Ke(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=Ud(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=N(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 Te=/[\u0590-\u08ac]/;function We(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 Te.test(o.parent.textContent)&&s.modify?Ke(e,t,function(){var t=s.getRangeAt(0),n=s.focusNode,i=s.focusOffset,a=s.caretBidiLevel;s.modify("move",r,"character");var $=!(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),null!=a&&(s.caretBidiLevel=a),$}):"left"==r||"backward"==r?i:a}var Ye=null,Ze=null,ef=!1;function ff(e,t,r){return Ye==t&&Ze==r?ef:(Ye=t,Ze=r,ef="up"==r||"down"==r?Se(e,t,r):We(e,t,r))}var I=0,Cd=1,gb=2,ea=3,d=function(e,t,r,o){this.parent=e,this.children=t,this.dom=r,r.pmViewDesc=this,this.contentDOM=o,this.dirty=I},S={beforePosition:{configurable:!0},size:{configurable:!0},border:{configurable:!0},posBefore:{configurable:!0},posAtStart:{configurable:!0},posAfter:{configurable:!0},posAtEnd:{configurable:!0},contentLost:{configurable:!0}};d.prototype.matchesWidget=function(){return!1},d.prototype.matchesMark=function(){return!1},d.prototype.matchesNode=function(){return!1},d.prototype.matchesHack=function(){return!1},S.beforePosition.get=function(){return!1},d.prototype.parseRule=function(){return null},d.prototype.stopEvent=function(){return!1},S.size.get=function(){for(var e=0,t=0;t<this.children.length;t++)e+=this.children[t].size;return e},S.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}},S.posBefore.get=function(){return this.parent.posBeforeChild(this)},S.posAtStart.get=function(){return this.parent?this.parent.posBeforeChild(this)+this.border:0},S.posAfter.get=function(){return this.posBefore+this.size},S.posAtEnd.get=function(){return this.posAtStart+this.size-2*this.border},d.prototype.localPosFromDOM=function(e,t,r){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(r<0){var o,n;if(e==this.contentDOM)o=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&(!(n=o.pmViewDesc)||n.parent!=this);)o=o.previousSibling;return o?this.posBeforeChild(n)+n.size:this.posAtStart}var i,a;if(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&(!(a=i.pmViewDesc)||a.parent!=this);)i=i.nextSibling;return i?this.posBeforeChild(a):this.posAtEnd}var s;if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(var $=e;;$=$.parentNode){if($==this.dom){s=!1;break}if($.parentNode.firstChild!=$)break}if(null==s&&t==e.childNodes.length)for(var c=e;;c=c.parentNode){if(c==this.dom){s=!0;break}if(c.parentNode.lastChild!=c)break}}return(null==s?r>0:s)?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(1==e.nodeType?e:e.parentNode):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=o.parentNode){var n=this.getDesc(o);if(n)return n.localPosFromDOM(e,t,r)}return-1},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:O(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=O(d.dom)+1;break}e-=d.size}-1==o&&(o=0)}if(o>-1&&($>t||a==this.children.length-1)){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=O(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();if(o||!ub(l.node,l.offset,p.anchorNode,p.anchorOffset)||!ub(d.node,d.offset,p.focusNode,p.focusOffset)){var v=!1;if(p.extend||e==t){p.collapse(l.node,l.offset);try{e!=t&&p.extend(d.node,d.offset),v=!0}catch(f){if(!(f instanceof DOMException))throw f}}if(!v){if(e>t){var u=l;l=d,d=u}var h=document.createRange();h.setEnd(d.node,d.offset),h.setStart(l.node,l.offset),p.removeAllRanges(),p.addRange(h)}}},d.prototype.ignoreMutation=function(e){return!this.contentDOM&&"selection"!=e.type},S.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?gb:Cd,void(e!=a||t!=s||!n.contentLost&&n.dom.parentNode==this.contentDOM?n.markDirty(e-a,t-a):n.dirty=ea);n.dirty=ea}r=i}this.dirty=gb},d.prototype.markParentsDirty=function(){for(var e=1,t=this.parent;t;t=t.parent,e++){var r=1==e?gb:Cd;t.dirty<r&&(t.dirty=r)}},Object.defineProperties(d.prototype,S);var aa=[],uf=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,aa,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:{configurable:!0}};return r.beforePosition.get=function(){return this.widget.type.side<0},t.prototype.matchesWidget=function(e){return this.dirty==I&&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)},t.prototype.ignoreMutation=function(e){return"selection"!=e.type||this.widget.spec.ignoreSelection},Object.defineProperties(t.prototype,r),t}(d),vf=function(e){function t(t,r,o,n){e.call(this,t,aa,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:{configurable:!0}};return r.size.get=function(){return this.text.length},t.prototype.localPosFromDOM=function(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t},t.prototype.domFromPos=function(e){return{node:this.textDOM,offset:e}},t.prototype.ignoreMutation=function(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue},Object.defineProperties(t.prototype,r),t}(d),ac=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=y.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!=ea&&this.mark.eq(e)},t.prototype.markDirty=function(t,r){if(e.prototype.markDirty.call(this,t,r),this.dirty!=I){for(var o=this.parent;!o.node;)o=o.parent;o.dirty<this.dirty&&(o.dirty=this.dirty),this.dirty=I}},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=nc(i,r,a,o)),e>0&&(i=nc(i,0,e,o));for(var s=0;s<i.length;s++)i[s].parent=n;return n.children=i,n},t}(d),xa=function(e){function t(t,r,o,n,i,a,s,$,c){e.call(this,t,r.isLeaf?aa:[],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:{configurable:!0},border:{configurable:!0}};return t.create=function(e,r,o,n,i,a){var s,$,c=i.nodeViews[r.type.name],l=c&&c(r,i,function(){return $?$.parent?$.parent.posBeforeChild($):void 0:a},o),d=l&&l.dom,p=l&&l.contentDOM;if(r.isText){if(d){if(3!=d.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else d=document.createTextNode(r.text);}else d||(d=(s=y.renderSpec(document,r.type.spec.toDOM(r))).dom,p=s.contentDOM);p||r.isText||"BR"==d.nodeName||(d.hasAttribute("contenteditable")||(d.contentEditable=!1),r.type.spec.draggable&&(d.draggable=!0));var v=d;return d=Zc(d,o,r),l?$=new Bf(e,r,o,n,d,p,v,l,i,a+1):r.isText?new bd(e,r,o,n,d,v,i):new t(e,r,o,n,d,p,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?b.empty:e.node.content},t},t.prototype.matchesNode=function(e,t,r){return this.dirty==I&&e.eq(this.node)&&kc(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 Q(this,i&&i.node);Qf(this.node,this.innerDeco,function(t,i,s){t.spec.marks?a.syncToMarks(t.spec.marks,o,e):t.type.side>=0&&!s&&a.syncToMarks(i==r.node.childCount?c.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(aa,o,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==gb)&&(i&&this.protectLocalComposition(e,i),this.renderChildren())},t.prototype.renderChildren=function(){ad(this.contentDOM,this.children),j.ios&&Rf(this.dom)},t.prototype.localCompositionNode=function(e,t){var r=e.state.selection,o=r.from,n=r.to;if(!(!(e.state.selection instanceof z)||o<t||n>t+this.node.content.size)){var i=e.root.getSelection(),a=Sf(i.focusNode,i.focusOffset);if(a&&this.dom.contains(a.parentNode)){var s=a.nodeValue,$=ki(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 vf(this,i,r,n);e.compositionNodes.push(a),this.children=nc(this.children,o,o+n.length,e,a)}},t.prototype.update=function(e,t,r,o){return!(this.dirty==ea||!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=I},t.prototype.updateOuterDeco=function(e){if(!kc(e,this.outerDeco)){var t=1!=this.nodeDOM.nodeType,r=this.dom;this.dom=$c(this.dom,this.nodeDOM,hc(this.outerDeco,this.node,t),hc(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.removeAttribute("draggable")},Object.defineProperties(t.prototype,r),t}(d);function dd(e,t,r,o,n){return Zc(o,t,e),new xa(null,e,t,r,o,o,o,n,0)}var bd=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(){for(var e=this.nodeDOM.parentNode;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}},t.prototype.update=function(e,t){return!(this.dirty==ea||this.dirty!=I&&!this.inParent()||!e.sameMarkup(this.node))&&(this.updateOuterDeco(t),this.dirty==I&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text),this.node=e,this.dirty=I,!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&&"selection"!=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}(xa),Af=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==I},t}(d),Bf=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==ea)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}(xa);function ad(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=Yc(r);r=r.nextSibling}else e.insertBefore(i,r);if(n instanceof ac){var a=r?r.previousSibling:e.lastChild;ad(n.contentDOM,n.children),r=a?a.nextSibling:e.firstChild}}for(;r;)r=Yc(r)}function Fa(e){e&&(this.nodeName=e)}Fa.prototype=Object.create(null);var da=[new Fa];function hc(e,t,r){if(0==e.length)return da;for(var o=r?da[0]:new Fa,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 Fa(a.nodeName)),a){var c=a[$];null!=c&&(r&&1==n.length&&n.push(s=o=new Fa(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 $c(e,t,r,o){if(r==da&&o==da)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&&($=n.parentNode)&&$.tagName.toLowerCase()==a.nodeName?n=$:(($=document.createElement(a.nodeName)).pmIsDeco=!0,$.appendChild(n),s=da[0],n=$)}Jf(n,s||da[0],a)}return n}function Jf(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(" "):aa,a=r.class?r.class.split(" "):aa,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.removeProperty(c[1]);r.style&&(e.style.cssText+=r.style)}}function Zc(e,t,r){return $c(e,e,da,hc(t,r,1!=e.nodeType))}function kc(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 Yc(e){var t=e.nextSibling;return e.parentNode.removeChild(e),t}var Q=function(e,t){this.top=e,this.lock=t,this.index=0,this.stack=[],this.changed=!1;var r=Of(e.node.content,e.children);this.preMatched=r.nodes,this.preMatchOffset=r.offset};function Of(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 Pf(e,t){return e.type.side-t.type.side}function Qf(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(Pf);for(var p=0;p<d.length;p++)r(d[p],c,!!$)}else r(l,c,!!$)}var v=void 0,u=void 0;if($)u=-1,v=$,$=null;else{if(!(c<e.childCount))break;u=c,v=e.child(c++)}for(var h=0;h<s.length;h++)s[h].to<=i&&s.splice(h--,1);for(;a<n.length&&n[a].from<=i&&n[a].to>i;)s.push(n[a++]);var f=i+v.nodeSize;if(v.isText){var M=f;a<n.length&&n[a].from<M&&(M=n[a].from);for(var E=0;E<s.length;E++)s[E].to<M&&(M=s[E].to);M<f&&($=v.cut(M-i),v=v.cut(0,M-i),f=M,u=-1)}o(v,s.length?s.slice():aa,t.forChild(i,v),u),i=f}else for(var m=0;m<e.childCount;m++){var g=e.child(m);o(g,n,t.forChild(i,g),m),i+=g.nodeSize}}function Rf(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 Sf(e,t){for(;;){if(3==e.nodeType)return e;if(1==e.nodeType&&t>0){if(e.childNodes.length>t&&3==e.childNodes[t].nodeType)return e.childNodes[t];t=ma(e=e.childNodes[t-1])}else{if(!(1==e.nodeType&&t<e.childNodes.length))return null;e=e.childNodes[t],t=0}}}function ki(e,t,r,o){for(var n=0,i=0;n<e.childCount&&i<=o;){var a=e.child(n++),s=i;if(i+=a.nodeSize,a.isText){for(var $=a.text;n<e.childCount;){var c=e.child(n++);if(i+=c.nodeSize,!c.isText)break;$+=c.text}if(i>=r){var l=$.lastIndexOf(t,o-s);if(l>=0&&l+t.length+s>=r)return s+l}}}return-1}function nc(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 oc(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&&q.findFrom(a,t)}function ca(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Vc(e,t,r){var o=e.state.selection;if(!(o instanceof z)){if(o instanceof f&&o.node.isInline)return ca(e,new z(t>0?o.$to:o.$from));var n=oc(e.state,t);return!!n&&ca(e,n)}if(!o.empty||r.indexOf("s")>-1)return!1;if(e.endOfTextblock(t>0?"right":"left")){var i=oc(e.state,t);return!!(i&&i instanceof f)&&ca(e,i)}if(!(j.mac&&r.indexOf("m")>-1)){var a,s=o.$head,$=s.textOffset?null:t<0?s.nodeBefore:s.nodeAfter;if(!$||$.isText)return!1;var c=t<0?s.pos-$.nodeSize:s.pos;return!!($.isAtom||(a=e.docView.descAt(c))&&!a.contentDOM)&&(f.isSelectable($)?ca(e,new f(t<0?e.state.doc.resolve(s.pos-$.nodeSize):s)):!!j.webkit&&ca(e,new z(e.state.doc.resolve(t<0?c:c+$.nodeSize))))}}function wb(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Ca(e){var t=e.pmViewDesc;return t&&0==t.size&&(e.nextSibling||"BR"!=e.nodeName)}function tc(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<wb(r)&&Ca(r.childNodes[o])&&(a=!0);;)if(o>0){if(1!=r.nodeType)break;var s=r.childNodes[o-1];if(Ca(s))n=r,i=--o;else{if(3!=s.nodeType)break;o=(r=s).nodeValue.length}}else{if(Uc(r))break;for(var $=r.previousSibling;$&&Ca($);)n=r.parentNode,i=O($),$=$.previousSibling;if($)o=wb(r=$);else{if((r=r.parentNode)==e.dom)break;o=0}}a?wc(e,t,r,o):n&&wc(e,t,n,i)}}function uc(e){var t=e.root.getSelection(),r=t.focusNode,o=t.focusOffset;if(r){for(var n,i,a=wb(r);;)if(o<a){if(1!=r.nodeType)break;if(!Ca(r.childNodes[o]))break;n=r,i=++o}else{if(Uc(r))break;for(var s=r.nextSibling;s&&Ca(s);)n=s.parentNode,i=O(s)+1,s=s.nextSibling;if(s)o=0,a=wb(r=s);else{if((r=r.parentNode)==e.dom)break;o=a=0}}n&&wc(e,t,n,i)}}function Uc(e){var t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function wc(e,t,r,o){if(Hb(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 Rc(e,t,r){var o=e.state.selection;if(o instanceof z&&!o.empty||r.indexOf("s")>-1)return!1;if(j.mac&&r.indexOf("m")>-1)return!1;var n=o.$from,i=o.$to;if(!n.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){var a=oc(e.state,t);if(a&&a instanceof f)return ca(e,a)}if(!n.parent.inlineContent){var s=q.findFrom(t<0?n:i,t);return!s||ca(e,s)}return!1}function Lc(e,t){if(!(e.state.selection instanceof z))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 Jc(e,t,r){e.domObserver.stop(),t.contentEditable=r,e.domObserver.start()}function qg(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;Jc(e,n,!0),setTimeout(function(){return Jc(e,n,!1)},20)}}}function tg(e){var t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}function ug(e,t){var r=t.keyCode,o=tg(t);return 8==r||j.mac&&72==r&&"c"==o?Lc(e,-1)||tc(e):46==r||j.mac&&68==r&&"c"==o?Lc(e,1)||uc(e):13==r||27==r||(37==r?Vc(e,-1,o)||tc(e):39==r?Vc(e,1,o)||uc(e):38==r?Rc(e,-1,o)||tc(e):40==r?qg(e)||Rc(e,1,o)||uc(e):o==(j.mac?"m":"c")&&(66==r||73==r||89==r||90==r))}function Ic(e,t){var r=e.root.getSelection(),o=e.state.doc;if(!r.focusNode)return null;var n=e.docView.nearestDesc(r.focusNode),i=n&&0==n.size,a=e.docView.posFromDOM(r.focusNode,r.focusOffset);if(a<0)return null;var s,$,c=o.resolve(a);if(Hb(r)){for(s=c;n&&!n.node;)n=n.parent;if(n&&n.node.isAtom&&f.isSelectable(n.node)&&n.parent&&(!n.node.isInline||!pg(r.focusNode,r.focusOffset,n.dom))){var l=n.posBefore;$=new f(a==l?c:o.resolve(l))}}else{var d=e.docView.posFromDOM(r.anchorNode,r.anchorOffset);if(d<0)return null;s=o.resolve(d)}$||($=Ac(e,s,c,"pointer"==t||e.state.selection.head<c.pos&&!i?1:-1));return $}function ta(e,t){var r=e.state.selection;if(Gc(e,r),e.editable?e.hasFocus():zc(e)&&document.activeElement&&document.activeElement.contains(e.dom)){if(e.domObserver.disconnectSelection(),e.cursorWrapper)Yg(e);else{var o,n,i=r.anchor,a=r.head;!Dc||r instanceof z||(r.$from.parent.inlineContent||(o=Gd(e,r.from)),r.empty||r.$from.parent.inlineContent||(n=Gd(e,r.to))),e.docView.setSelection(i,a,e.root,t),Dc&&(o&&Fc(o),n&&Fc(n)),r.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Vg(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}Q.prototype.getPreMatch=function(e){return e>=this.preMatchOffset?this.preMatched[e-this.preMatchOffset]:null},Q.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}},Q.prototype.destroyRest=function(){this.destroyBetween(this.index,this.top.children.length)},Q.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=I,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.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{var $=ac.create(this.top,e[n],t,r);this.top.children.splice(this.index,0,$),this.top=$,this.changed=!0}this.index=0,n++}},Q.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)},Q.prototype.updateNextNode=function(e,t,r,o,n){for(var i=this.index;i<this.top.children.length;i++){var a=this.top.children[i];if(a instanceof xa){var s=this.preMatched.indexOf(a);if(s>-1&&s+this.preMatchOffset!=n)return!1;var $=a.dom;if(!(this.lock&&($==this.lock||1==$.nodeType&&$.contains(this.lock.parentNode))&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=ea&&kc(t,a.outerDeco)))&&a.update(e,t,r,o))return this.destroyBetween(this.index,i),a.dom!=$&&(this.changed=!0),this.index++,!0;break}}return!1},Q.prototype.addNode=function(e,t,r,o,n){this.top.children.splice(this.index++,0,xa.create(this.top,e,t,r,o,n)),this.changed=!0},Q.prototype.placeWidget=function(e,t,r){var o=this.index<this.top.children.length?this.top.children[this.index]:null;if(!o||!o.matchesWidget(e)||e!=o.widget&&o.widget.type.toDOM.parentNode){var n=new uf(this.top,e,t,r);this.top.children.splice(this.index++,0,n),this.changed=!0}else this.index++},Q.prototype.addTextblockHacks=function(){for(var e=this.top.children[this.index-1];e instanceof ac;)e=e.children[e.children.length-1];if(!e||!(e instanceof bd)||/\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 Af(this.top,aa,t,null)),this.changed=!0}};var Dc=j.safari||j.chrome&&j.chrome_version<63;function Gd(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(j.safari&&i&&"false"==i.contentEditable)return Bc(i);if(!(i&&"false"!=i.contentEditable||a&&"false"!=a.contentEditable)){if(i)return Bc(i);if(a)return Bc(a)}}function Bc(e){return e.contentEditable="true",j.safari&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function Fc(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function Vg(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 Yg(e){var t=e.root.getSelection(),r=document.createRange(),o=e.cursorWrapper.dom,n="IMG"==o.nodeName;n?r.setEnd(o.parentNode,O(o)+1):r.setEnd(o,0),r.collapse(!1),t.removeAllRanges(),t.addRange(r),!n&&!e.state.selection.visible&&j.ie&&j.ie_version<=11&&(o.disabled=!0,o.disabled=!1)}function Gc(e,t){if(t instanceof f){var r=e.docView.descAt(t.from);r!=e.lastSelectedViewDesc&&(Hc(e),r&&r.selectNode(),e.lastSelectedViewDesc=r)}else Hc(e)}function Hc(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=null)}function Ac(e,t,r,o){return e.someProp("createSelectionBetween",function(o){return o(e,t,r)})||z.between(t,r,o)}function eh(e){return(!e.editable||e.root.activeElement==e.dom)&&zc(e)}function zc(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 kh(e){var t=e.docView.domFromPos(e.state.selection.anchor),r=e.root.getSelection();return ub(t.node,t.offset,r.anchorNode,r.anchorOffset)}function mh(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}],Hb(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],u=v.pmViewDesc;if("BR"==v.nodeType&&!u){a=p;break}if(!u||u.size)break}var h=e.state.doc,f=e.someProp("domParser")||H.fromSchema(e.state.schema),M=h.resolve(s),E=null,m=f.parse(n,{topNode:M.parent,topMatch:M.parent.contentMatchAt(M.index()),topOpen:!0,from:i,to:a,preserveWhitespace:!M.parent.type.spec.code||"full",editableContent:!0,findPositions:l,ruleFromNode:oh,context:M});if(l&&null!=l[0].pos){var g=l[0].pos,y=l[1]&&l[1].pos;null==y&&(y=g),E={anchor:g+s,head:y+s}}return{doc:m,sel:E,from:s,to:$}}function oh(e){var t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(j.safari&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){var r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}if(e.parentNode.lastChild==e||j.safari&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0}}function rh(e,t,r,o,n){if(t<0){var i=e.lastSelectionTime>Date.now()-50?e.lastSelectionOrigin:null,a=Ic(e,i);if(a&&!e.state.selection.eq(a)){var s=e.state.tr.setSelection(a);"pointer"==i?s.setMeta("pointer",!0):"key"==i&&s.scrollIntoView(),e.dispatch(s)}}else{var $=e.state.doc.resolve(t),c=$.sharedDepth(r);t=$.before(c+1),r=e.state.doc.resolve(r).after(c+1);var l,d,p=e.state.selection,v=mh(e,t,r),u=e.state.doc,h=u.slice(v.from,v.to);8===e.lastKeyCode&&Date.now()-100<e.lastKeyCodeTime?(l=e.state.selection.to,d="end"):(l=e.state.selection.from,d="start"),e.lastKeyCode=null;var f=Fh(h.content,v.doc.content,v.from,l,d);if(!f){if(!(o&&p instanceof z&&!p.empty&&p.$head.sameParent(p.$anchor))||e.composing||v.sel&&v.sel.anchor!=v.sel.head){if(v.sel){var M=Kc(e,e.state.doc,v.sel);M&&!M.eq(e.state.selection)&&e.dispatch(e.state.tr.setSelection(M))}return}f={start:p.from,endA:p.to,endB:p.to}}e.domChangeCount++,e.state.selection.from<e.state.selection.to&&f.start==f.endB&&e.state.selection instanceof z&&(f.start>e.state.selection.from&&f.start<=e.state.selection.from+2?f.start=e.state.selection.from:f.endA<e.state.selection.to&&f.endA>=e.state.selection.to-2&&(f.endB+=e.state.selection.to-f.endA,f.endA=e.state.selection.to)),j.ie&&j.ie_version<=11&&f.endB==f.start+1&&f.endA==f.start&&f.start>v.from&&" \xA0"==v.doc.textBetween(f.start-v.from-1,f.start-v.from+1)&&(f.start--,f.endA--,f.endB--);var E,m=v.doc.resolveNoCache(f.start-v.from),g=v.doc.resolveNoCache(f.endB-v.from),y=m.sameParent(g)&&m.parent.inlineContent;if((j.ios&&e.lastIOSEnter>Date.now()-225&&(!y||n.some(function(e){return"DIV"==e.nodeName||"P"==e.nodeName}))||!y&&m.pos<v.doc.content.size&&(E=q.findFrom(v.doc.resolve(m.pos+1),1,!0))&&E.head==g.pos)&&e.someProp("handleKeyDown",function(t){return t(e,Ja(13,"Enter"))}))e.lastIOSEnter=0;else if(e.state.selection.anchor>f.start&&Dh(u,f.start,f.endA,m,g)&&e.someProp("handleKeyDown",function(t){return t(e,Ja(8,"Backspace"))}))j.android&&j.chrome&&e.domObserver.suppressSelectionUpdates();else{j.android&&!y&&m.start()!=g.start()&&0==g.parentOffset&&m.depth==g.depth&&v.sel&&v.sel.anchor==v.sel.head&&v.sel.head==f.endA&&(f.endB-=2,g=v.doc.resolveNoCache(f.endB-v.from),setTimeout(function(){e.someProp("handleKeyDown",function(t){return t(e,Ja(13,"Enter"))})},20));var D,b,S,w,O=f.start,N=f.endA;if(y)if(m.pos==g.pos)j.ie&&j.ie_version<=11&&0==m.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout(function(){return ta(e)},20)),D=e.state.tr.delete(O,N),b=u.resolve(f.start).marksAcross(u.resolve(f.endA));else if(f.endA==f.endB&&(w=u.resolve(f.start))&&(S=Ah(m.parent.content.cut(m.parentOffset,g.parentOffset),w.parent.content.cut(w.parentOffset,f.endA-w.start()))))D=e.state.tr,"add"==S.type?D.addMark(O,N,S.mark):D.removeMark(O,N,S.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){var C=m.parent.textBetween(m.parentOffset,g.parentOffset);if(e.someProp("handleTextInput",function(t){return t(e,O,N,C)}))return;D=e.state.tr.insertText(C,O,N)}if(D||(D=e.state.tr.replace(O,N,v.doc.slice(f.start-v.from,f.endB-v.from))),v.sel){var x=Kc(e,D.doc,v.sel);x&&!(j.chrome&&j.android&&e.composing&&x.empty&&(x.head==O||x.head==D.mapping.map(N)-1)||j.ie&&x.empty&&x.head==O)&&D.setSelection(x)}b&&D.ensureMarks(b),e.dispatch(D.scrollIntoView())}}}function Kc(e,t,r){return Math.max(r.anchor,r.head)>t.content.size?null:Ac(e,t.resolve(r.anchor),t.resolve(r.head))}function Ah(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(b.from(d).eq(e))return{mark:o,type:r}}function Dh(e,t,r,o,n){if(!o.parent.isTextblock||r-t<=n.pos-o.pos||yc(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(yc(i,!0,!0));return!(!a.parent.isTextblock||a.pos>r||yc(a,!0,!1)<r)&&o.parent.content.cut(o.parentOffset).eq(a.parent.content)}function yc(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 Fh(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 Mc(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")||y.fromSchema(e.state.schema),$=Tc(),c=$.createElement("div");c.appendChild(s.serializeFragment(o,{document:$}));for(var l,d=c.firstChild;d&&1==d.nodeType&&(l=Sc[d.nodeName.toLowerCase()]);){for(var p=l.length-1;p>=0;p--){for(var v=$.createElement(l[p]);c.firstChild;)v.appendChild(c.firstChild);c.appendChild(v)}d=c.firstChild}return d&&1==d.nodeType&&d.setAttribute("data-pm-slice",n+" "+i+" "+JSON.stringify(r)),{dom:c,text:e.someProp("clipboardTextSerializer",function(e){return e(t)})||t.content.textBetween(0,t.content.size,"\n\n")}}function Nc(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||o)}),s)return new k(b.from(e.state.schema.text(t)),0,0);var c=e.someProp("clipboardTextParser",function(e){return e(t,n,o)});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=ai(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")||H.fromSchema(e.state.schema);a=p.parseSlice(i,{preserveWhitespace:!(!$&&!d),context:n})}return a=d?di(Wh(a,+d[1],+d[2]),d[3]):k.maxOpen(Ih(a.content,n),!1),e.someProp("transformPasted",function(e){a=e(a)}),a}function Ih(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&&Pc(r,n,e,i[i.length-1],0))i[i.length-1]=t;else{i.length&&(i[i.length-1]=Qc(i[i.length-1],n.length));var a=Oc(e,r);i.push(a),o=o.matchType(a.type,a.attrs),n=r}}}),i)return{v:b.from(i)}},o=t.depth;o>=0;o--){var n=r(o);if(n)return n.v}return e}function Oc(e,t,r){void 0===r&&(r=0);for(var o=t.length-1;o>=r;o--)e=t[o].create(null,b.from(e));return e}function Pc(e,t,r,o,n){if(n<e.length&&n<t.length&&e[n]==t[n]){var i=Pc(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(b.from(Oc(r,e,n+1))))}}function Qc(e,t){if(0==t)return e;var r=e.content.replaceChild(e.childCount-1,Qc(e.lastChild,t-1)),o=e.contentMatchAt(e.childCount).fillBefore(b.empty,!0);return e.copy(r.append(o))}function xc(e,t,r,o,n,i){var a=t<0?e.firstChild:e.lastChild,s=a.content;return n<o-1&&(s=xc(s,t,r,o,n+1,i)),n>=r&&(s=t<0?a.contentMatchAt(0).fillBefore(s,e.childCount>1||i<=n).append(s):s.append(a.contentMatchAt(a.childCount).fillBefore(b.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,a.copy(s))}function Wh(e,t,r){return t<e.openStart&&(e=new k(xc(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),r<e.openEnd&&(e=new k(xc(e.content,1,r,e.openEnd,0,0),e.openStart,r)),e}var Sc={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},Yh=null;function Tc(){return Yh||(Yh=document.implementation.createHTMLDocument("title"))}function ai(e){var t=/(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));var r,o=Tc().createElement("div"),n=/(?:<meta [^>]*>)*<([a-z][^>\s]+)/i.exec(e),i=0;(r=n&&Sc[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 di(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=b.from($.create(r[s+1],n)),i++,a++}return new k(n,i,a)}var ei={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},vc=j.ie&&j.ie_version<=11,qc=function(){this.anchorNode=this.anchorOffset=this.focusNode=this.focusOffset=null};qc.prototype.set=function(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset},qc.prototype.eq=function(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset};var F=function(e,t){var r=this;this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=window.MutationObserver&&new window.MutationObserver(function(e){for(var t=0;t<e.length;t++)r.queue.push(e[t]);j.ie&&j.ie_version<=11&&e.some(function(e){return"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length})?r.flushSoon():r.flush()}),this.currentSelection=new qc,vc&&(this.onCharData=function(e){r.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),r.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.suppressingSelectionUpdates=!1};F.prototype.flushSoon=function(){var e=this;this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(function(){e.flushingSoon=-1,e.flush()},20))},F.prototype.forceFlush=function(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())},F.prototype.start=function(){this.observer&&this.observer.observe(this.view.dom,ei),vc&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()},F.prototype.stop=function(){var e=this;if(this.observer){var t=this.observer.takeRecords();if(t.length){for(var r=0;r<t.length;r++)this.queue.push(t[r]);window.setTimeout(function(){return e.flush()},20)}this.observer.disconnect()}vc&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()},F.prototype.connectSelection=function(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)},F.prototype.disconnectSelection=function(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)},F.prototype.suppressSelectionUpdates=function(){var e=this;this.suppressingSelectionUpdates=!0,setTimeout(function(){return e.suppressingSelectionUpdates=!1},50)},F.prototype.onSelectionChange=function(){if(eh(this.view)){if(this.suppressingSelectionUpdates)return ta(this.view);if(j.ie&&j.ie_version<=11&&!this.view.state.selection.empty){var e=this.view.root.getSelection();if(e.focusNode&&ub(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}},F.prototype.setCurSelection=function(){this.currentSelection.set(this.view.root.getSelection())},F.prototype.ignoreSelectionChange=function(e){if(0==e.rangeCount)return!0;var t=e.getRangeAt(0).commonAncestorContainer,r=this.view.docView.nearestDesc(t);return r&&r.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0},F.prototype.flush=function(){if(this.view.docView&&!(this.flushingSoon>-1)){var e=this.observer?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)&&zc(this.view)&&!this.ignoreSelectionChange(t),o=-1,n=-1,i=!1,a=[];if(this.view.editable)for(var s=0;s<e.length;s++){var $=this.registerMutation(e[s],a);$&&(o=o<0?$.from:Math.min($.from,o),n=n<0?$.to:Math.max($.to,n),$.typeOver&&(i=!0))}if(j.gecko&&a.length>1){var c=a.filter(function(e){return"BR"==e.nodeName});if(2==c.length){var l=c[0],d=c[1];l.parentNode&&l.parentNode.parentNode==d.parentNode?d.remove():l.remove()}}(o>-1||r)&&(o>-1&&(this.view.docView.markDirty(o,n),Me(this.view)),this.handleDOMChange(o,n,i,a),this.view.docView.dirty?this.view.updateState(this.view.state):this.currentSelection.eq(t)||ta(this.view))}},F.prototype.registerMutation=function(e,t){if(t.indexOf(e.target)>-1)return null;var r=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(r==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!r||r.ignoreMutation(e))return null;if("childList"==e.type){var o=e.previousSibling,n=e.nextSibling;if(j.ie&&j.ie_version<=11&&e.addedNodes.length)for(var i=0;i<e.addedNodes.length;i++){var a=e.addedNodes[i],s=a.previousSibling,$=a.nextSibling;(!s||Array.prototype.indexOf.call(e.addedNodes,s)<0)&&(o=s),(!$||Array.prototype.indexOf.call(e.addedNodes,$)<0)&&(n=$)}for(var c=o&&o.parentNode==e.target?O(o)+1:0,l=r.localPosFromDOM(e.target,c,-1),d=n&&n.parentNode==e.target?O(n):e.target.childNodes.length,p=0;p<e.addedNodes.length;p++)t.push(e.addedNodes[p]);return{from:l,to:r.localPosFromDOM(e.target,d,1)}}return"attributes"==e.type?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}};var Le=!1;function Me(e){Le||(Le=!0,"normal"==getComputedStyle(e.dom).whiteSpace&&console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."))}var E={},C={};function Pe(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.lastIOSEnter=0,e.lastIOSEnterFallbackTimeout=null,e.composing=!1,e.composingTimeout=null,e.compositionNodes=[],e.compositionEndedAt=-2e8,e.domObserver=new F(e,function(t,r,o,n){return rh(e,t,r,o,n)}),e.domObserver.start(),e.domChangeCount=0,e.eventHandlers=Object.create(null);var t=function(t){var r=E[t];e.dom.addEventListener(t,e.eventHandlers[t]=function(t){!Ue(e,t)||fc(e,t)||!e.editable&&t.type in C||r(e,t)})};for(var r in E)t(r);j.safari&&e.dom.addEventListener("input",function(){return null}),ic(e)}function fa(e,t){e.lastSelectionOrigin=t,e.lastSelectionTime=Date.now()}function Re(e){for(var t in e.domObserver.stop(),e.eventHandlers)e.dom.removeEventListener(t,e.eventHandlers[t]);clearTimeout(e.composingTimeout),clearTimeout(e.lastIOSEnterFallbackTimeout)}function ic(e){e.someProp("handleDOMEvents",function(t){for(var r in t)e.eventHandlers[r]||e.dom.addEventListener(r,e.eventHandlers[r]=function(t){return fc(e,t)})})}function fc(e,t){return e.someProp("handleDOMEvents",function(r){var o=r[t.type];return!!o&&(o(e,t)||t.defaultPrevented)})}function Ue(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 Ve(e,t){fc(e,t)||!E[t.type]||!e.editable&&t.type in C||E[t.type](e,t)}function Za(e){return{left:e.clientX,top:e.clientY}}function Xe(e,t){var r=t.x-e.clientX,o=t.y-e.clientY;return r*r+o*o<100}function dc(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 pa(e,t,r){e.focused||e.focus();var o=e.state.tr.setSelection(t);"pointer"==r&&o.setMeta("pointer",!0),e.dispatch(o)}function $e(e,t){if(-1==t)return!1;var r=e.state.doc.resolve(t),o=r.nodeAfter;return!!(o&&o.isAtom&&f.isSelectable(o))&&(pa(e,new f(r),"pointer"),!0)}function _e(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&&(pa(e,f.create(e.state.doc,o),"pointer"),!0)}function af(e,t,r,o,n){return dc(e,"handleClickOn",t,r,o)||e.someProp("handleClick",function(r){return r(e,t,o)})||(n?_e(e,r):$e(e,r))}function bf(e,t,r,o){return dc(e,"handleDoubleClickOn",t,r,o)||e.someProp("handleDoubleClick",function(r){return r(e,t,o)})}function cf(e,t,r,o){return dc(e,"handleTripleClickOn",t,r,o)||e.someProp("handleTripleClick",function(r){return r(e,t,o)})||df(e,r)}function df(e,t){var r=e.state.doc;if(-1==t)return!!r.inlineContent&&(pa(e,z.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)pa(e,z.create(r,a+1,a+1+i.content.size),"pointer");else{if(!f.isSelectable(i))continue;pa(e,f.create(r,a),"pointer")}return!0}}function yb(e){return Wa(e)}C.keydown=function(e,t){if(e.shiftKey=16==t.keyCode||t.shiftKey,!gd(e,t))if(e.domObserver.forceFlush(),e.lastKeyCode=t.keyCode,e.lastKeyCodeTime=Date.now(),!j.ios||13!=t.keyCode||t.ctrlKey||t.altKey||t.metaKey)e.someProp("handleKeyDown",function(r){return r(e,t)})||ug(e,t)?t.preventDefault():fa(e,"key");else{var r=Date.now();e.lastIOSEnter=r,e.lastIOSEnterFallbackTimeout=setTimeout(function(){e.lastIOSEnter==r&&(e.someProp("handleKeyDown",function(t){return t(e,Ja(13,"Enter"))}),e.lastIOSEnter=0)},200)}},C.keyup=function(e,t){16==t.keyCode&&(e.shiftKey=!1)},C.keypress=function(e,t){if(!(gd(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 z&&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 ed=j.mac?"metaKey":"ctrlKey";E.mousedown=function(e,t){e.shiftKey=t.shiftKey;var r=yb(e),o=Date.now(),n="singleClick";o-e.lastClick.time<500&&Xe(t,e.lastClick)&&!t[ed]&&("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(Za(t));i&&("singleClick"==n?e.mouseDown=new Xa(e,i,t,r):("doubleClick"==n?bf:cf)(e,i.pos,i.inside,t)?t.preventDefault():fa(e,"pointer"))};var Xa=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[ed],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)),fa(e,"pointer")};function gd(e,t){return!!e.composing||!!(j.safari&&Math.abs(t.timeStamp-e.compositionEndedAt)<500)&&(e.compositionEndedAt=-2e8,!0)}Xa.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.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.view.mouseDown=null},Xa.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(Za(e))),this.allowDefault||!t?fa(this.view,"pointer"):af(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():this.flushed||j.safari&&this.mightDrag&&!this.mightDrag.node.isAtom||j.chrome&&!(this.view.state.selection instanceof z)&&(t.pos==this.view.state.selection.from||t.pos==this.view.state.selection.to)?(pa(this.view,q.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):fa(this.view,"pointer")}},Xa.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),fa(this.view,"pointer")},E.touchdown=function(e){yb(e),fa(e,"pointer")},E.contextmenu=function(e){return yb(e)};var jf=j.android?5e3:-1;function hd(e,t){clearTimeout(e.composingTimeout),t>-1&&(e.composingTimeout=setTimeout(function(){return Wa(e)},t))}function Wa(e,t){for(e.domObserver.forceFlush(),e.composing=!1;e.compositionNodes.length>0;)e.compositionNodes.pop().markParentsDirty();if(t||e.docView.dirty){var r=Ic(e);return r&&!r.eq(e.state.selection)?e.dispatch(e.state.tr.setSelection(r)):e.updateState(e.state),!0}return!1}function mf(e,t){if(e.dom.parentNode){var r=e.dom.parentNode.appendChild(document.createElement("div"));r.appendChild(t),r.style.cssText="position: fixed; left: -10000px; top: 10px";var o=getSelection(),n=document.createRange();n.selectNodeContents(t),e.dom.blur(),o.removeAllRanges(),o.addRange(n),setTimeout(function(){r.parentNode&&r.parentNode.removeChild(r),e.focus()},50)}}C.compositionstart=C.compositionupdate=function(e){if(!e.composing){e.domObserver.flush();var t=e.state,r=t.selection.$from;if(t.selection.empty&&(t.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some(function(e){return!1===e.type.spec.inclusive})))e.markCursor=e.state.storedMarks||r.marks(),Wa(e,!0),e.markCursor=null;else if(Wa(e),j.gecko&&t.selection.empty&&r.parentOffset&&!r.textOffset&&r.nodeBefore.marks.length)for(var o=e.root.getSelection(),n=o.focusNode,i=o.focusOffset;n&&1==n.nodeType&&0!=i;){var a=i<0?n.lastChild:n.childNodes[i-1];if(!a)break;if(3==a.nodeType){o.collapse(a,a.nodeValue.length);break}n=a,i=-1}e.composing=!0}hd(e,jf)},C.compositionend=function(e,t){e.composing&&(e.composing=!1,e.compositionEndedAt=t.timeStamp,hd(e,20))};var ua=j.ie&&j.ie_version<15||j.ios&&j.webkit_version<604;function of(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}function pf(e,t){if(e.dom.parentNode){var r=e.shiftKey||e.state.selection.$from.parent.type.spec.code,o=e.dom.parentNode.appendChild(document.createElement(r?"textarea":"div"));r||(o.contentEditable="true"),o.style.cssText="position: fixed; left: -10000px; top: 10px",o.focus(),setTimeout(function(){e.focus(),o.parentNode&&o.parentNode.removeChild(o),r?$b(e,o.value,null,t):$b(e,o.textContent,o.innerHTML,t)},50)}}function $b(e,t,r,o){var n=Nc(e,t,r,e.shiftKey,e.state.selection.$from);if(!e.someProp("handlePaste",function(t){return t(e,o,n||k.empty)})&&n){var i=of(n),a=i?e.state.tr.replaceSelectionWith(i,e.shiftKey):e.state.tr.replaceSelection(n);e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste"))}}E.copy=C.cut=function(e,t){var r=e.state.selection,o="cut"==t.type;if(!r.empty){var n=ua?null:t.clipboardData,i=Mc(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)):mf(e,a),o&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))}},C.paste=function(e,t){var r=ua?null:t.clipboardData,o=r&&r.getData("text/html"),n=r&&r.getData("text/plain");r&&(o||n||r.files.length)?($b(e,n,o,t),t.preventDefault()):pf(e,t)};var rf=function(e,t){this.slice=e,this.move=t},sf=j.mac?"altKey":"ctrlKey";for(var ld in E.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(Za(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=Mc(e,a),$=s.dom,c=s.text;t.dataTransfer.clearData(),t.dataTransfer.setData(ua?"Text":"text/html",$.innerHTML),ua||t.dataTransfer.setData("text/plain",c),e.dragging=new rf(a,!t[sf])}},E.dragend=function(e){window.setTimeout(function(){return e.dragging=null},50)},C.dragover=C.dragenter=function(e,t){return t.preventDefault()},C.drop=function(e,t){var r=e.dragging;if(e.dragging=null,t.dataTransfer){var o=e.posAtCoords(Za(t));if(o){var n=e.state.doc.resolve(o.pos);if(n){var i=r&&r.slice||Nc(e,t.dataTransfer.getData(ua?"Text":"text/plain"),ua?null:t.dataTransfer.getData("text/html"),!1,n);if(e.someProp("handleDrop",function(o){return o(e,t,i||k.empty,r&&r.move)}))t.preventDefault();else if(i){t.preventDefault();var a=i?Nf(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(Ac(e,d,s.doc.resolve(s.mapping.map(a)))),e.focus(),e.dispatch(s.setMeta("uiEvent","drop"))}}}}}},E.focus=function(e){e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(function(){e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.root.getSelection())&&ta(e)},20))},E.blur=function(e){e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),e.domObserver.currentSelection.set({}),e.focused=!1)},E.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,Ja(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)}},C)E[ld]=C[ld];function Ea(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 Ga=function(e,t){this.spec=t||ka,this.side=this.spec.side||0,this.toDOM=e};Ga.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 p(i-r,i-r,this)},Ga.prototype.valid=function(){return!0},Ga.prototype.eq=function(e){return this==e||e instanceof Ga&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Ea(this.spec,e.spec))};var K=function(e,t){this.spec=t||ka,this.attrs=e};K.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 p(n,i,this)},K.prototype.valid=function(e,t){return t.from<t.to},K.prototype.eq=function(e){return this==e||e instanceof K&&Ea(this.attrs,e.attrs)&&Ea(this.spec,e.spec)},K.is=function(e){return e.type instanceof K};var Ia=function(e,t){this.spec=t||ka,this.attrs=e};Ia.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 p(n.pos-r,i.pos-r,this)},Ia.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},Ia.prototype.eq=function(e){return this==e||e instanceof Ia&&Ea(this.attrs,e.attrs)&&Ea(this.spec,e.spec)};var p=function(e,t,r){this.from=e,this.to=t,this.type=r},rd={spec:{configurable:!0}};p.prototype.copy=function(e,t){return new p(e,t,this.type)},p.prototype.eq=function(e,t){return void 0===t&&(t=0),this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to},p.prototype.map=function(e,t,r){return this.type.map(e,this,t,r)},p.widget=function(e,t,r){return new p(e,e,new Ga(t,r))},p.inline=function(e,t,r,o){return new p(e,t,new K(r,o))},p.node=function(e,t,r,o){return new p(e,t,new Ia(r,o))},rd.spec.get=function(){return this.type.spec},Object.defineProperties(p.prototype,rd);var sb=[],ka={},w=function(e,t){this.local=e&&e.length?e:sb,this.children=t&&t.length?t:sb};w.create=function(e,t){return t.length?db(t,e,0,ka):x},w.prototype.find=function(e,t,r){var o=[];return this.findInner(null==e?0:e,null==t?1e9:t,o,0,r),o},w.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)}},w.prototype.map=function(e,t,r){return this==x||0==e.maps.length?this:this.mapInner(e,t,0,0,r||ka)},w.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?Ff(this.children,i,e,t,r,o,n):i?new w(i.sort(ia)):x},w.prototype.add=function(e,t){return t.length?this==x?w.create(e,t):this.addInner(e,t,0):this},w.prototype.addInner=function(e,t,r){var o,n=this,i=0;e.forEach(function(e,a){var s,$=a+r;if(s=yd(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,db(s,e,$+1,ka)),i+=3}});var a=xd(i?zd(t):t,-r);return new w(a.length?this.local.concat(a).sort(ia):this.local,o||this.children)},w.prototype.remove=function(e){return 0==e.length||this==x?this:this.removeInner(e,0)},w.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!=x?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].eq(p,t)&&(o==this.local&&(o=this.local.slice()),o.splice(v--,1));return r==this.children&&o==this.local?this:o.length||r.length?new w(o,r):x},w.prototype.forChild=function(e,t){if(this==x)return this;if(t.isLeaf)return w.empty;for(var r,o,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 K){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 w(o.sort(ia));return r?new P([d,r]):d}return r||x},w.prototype.eq=function(e){if(this==e)return!0;if(!(e instanceof w)||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!0},w.prototype.locals=function(e){return Wb(this.localsInner(e))},w.prototype.localsInner=function(e){if(this==x)return sb;if(e.inlineContent||!this.local.some(K.is))return this.local;for(var t=[],r=0;r<this.local.length;r++)this.local[r].type instanceof K||t.push(this.local[r]);return t};var x=new w;w.empty=x,w.removeOverlap=Wb;var P=function(e){this.members=e};function Ff(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:r>=n&&(c=o-r-(t-e))&&(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 u=r.map(e[d+1]+i,-1)-n,h=o.content.findIndex(v),f=h.index,M=h.offset,E=o.maybeChild(f);if(E&&M==v&&M+E.nodeSize==u){var m=s[d+2].mapInner(r,E,p+1,s[d]+i+1,a);m!=x?(s[d]=v,s[d+1]=u,s[d+2]=m):(s[d+1]=-2,l=!0)}else l=!0}if(l){var g=db(Hf(s,e,t||[],r,n,i,a),o,0,a);t=g.local;for(var y=0;y<s.length;y+=3)s[y+1]<0&&(s.splice(y,3),y-=3);for(var D=0,b=0;D<g.children.length;D+=3){for(var S=g.children[D];b<s.length&&s[b]<S;)b+=3;s.splice(b,0,g.children[D],g.children[D+1],g.children[D+2])}}return new w(t&&t.sort(ia),s)}function xd(e,t){if(!t||!e.length)return e;for(var r=[],o=0;o<e.length;o++){var n=e[o];r.push(new p(n.from+t,n.to+t,n.type))}return r}function Hf(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 yd(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 zd(e){for(var t=[],r=0;r<e.length;r++)null!=e[r]&&t.push(e[r]);return t}function db(e,t,r,o){var n=[],i=!1;t.forEach(function(t,a){var s=yd(e,t,a+r);if(s){i=!0;var $=db(s,t,r+a+1,o);$!=x&&n.push(a,a+t.nodeSize,$)}});for(var a=xd(i?zd(e):e,-r).sort(ia),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 w(a,n):x}function ia(e,t){return e.from-t.from||e.to-t.to}function Wb(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),Dd(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),Dd(t,n+1,i.copy(o.to,i.to)))}}return t}function Dd(e,t,r){for(;t<e.length&&ia(r,e[t])>0;)t++;e.splice(t,0,r)}function Vb(e){var t=[];return e.someProp("decorations",function(r){var o=r(e.state);o&&o!=x&&t.push(o)}),e.cursorWrapper&&t.push(w.create(e.state.doc,[e.cursorWrapper.deco])),P.from(t)}P.prototype.forChild=function(e,t){if(t.isLeaf)return w.empty;for(var r=[],o=0;o<this.members.length;o++){var n=this.members[o].forChild(e,t);n!=x&&(n instanceof P?r=r.concat(n.members):r.push(n))}return P.from(r)},P.prototype.eq=function(e){if(!(e instanceof P)||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},P.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?Wb(r?t:t.sort(ia)):sb},P.from=function(e){switch(e.length){case 0:return x;case 1:return e[0];default:return new P(e);}};var i=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=Jd(this),this.markCursor=null,this.cursorWrapper=null,Id(this),this.nodeViews=Kd(this),this.docView=dd(this.state.doc,Hd(this),Vb(this),this.dom,this),this.lastSelectedViewDesc=null,this.dragging=null,Pe(this),this.pluginViews=[],this.updatePluginViews()},Ub={props:{configurable:!0},root:{configurable:!0}};function Hd(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]))}),[p.node(0,e.state.doc.content.size,t)]}function Id(e){if(e.markCursor){var t=document.createElement("img");t.setAttribute("mark-placeholder","true"),e.cursorWrapper={dom:t,deco:p.widget(e.state.selection.head,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Jd(e){return!e.someProp("editable",function(t){return!1===t(e.state)})}function Uf(e,t){var r=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(r)!=t.$anchor.start(r)}function Kd(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 Wf(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}function Ld(e){var t=e.getSelection(),r=t.focusOffset,o=t.focusNode;return o&&1==o.nodeType?[o,r,o.childNodes[r-1],o.childNodes[r]]:null}function Yf(e,t){var r=Ld(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}Ub.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},i.prototype.update=function(e){e.handleDOMEvents!=this._props.handleDOMEvents&&ic(this),this._props=e,this.updateStateInner(e.state,!0)},i.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)},i.prototype.updateState=function(e){this.updateStateInner(e,this.state.plugins!=e.plugins)},i.prototype.updateStateInner=function(e,t){var r=this,o=this.state,n=!1;if(this.state=e,t){var i=Kd(this);Wf(i,this.nodeViews)&&(this.nodeViews=i,n=!0),ic(this)}this.editable=Jd(this),Id(this);var a=Vb(this),s=Hd(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&&bh(this);if(l){this.domObserver.stop();var p=c&&(j.ie||j.chrome)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&Uf(o.selection,e.selection);if(c){var v=j.chrome&&Ld(this.root);!n&&this.docView.update(e.doc,s,a,this)||(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=dd(e.doc,s,a,this.dom,this)),v&&Yf(v,this.root)&&(p=!0)}p||!(this.mouseDown&&this.domObserver.currentSelection.eq(this.root.getSelection())&&kh(this))?ta(this,p):(Gc(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}if(this.updatePluginViews(o),"reset"==$)this.dom.scrollTop=0;else if("to selection"==$){var u=this.root.getSelection().focusNode;this.someProp("handleScrollToSelection",function(e){return e(r)})||(e.selection instanceof f?re(this,this.docView.domAfterPos(e.selection.from).getBoundingClientRect(),u):re(this,this.coordsAtPos(e.selection.head),u))}else d&&hh(d)},i.prototype.destroyPluginViews=function(){for(var e;e=this.pluginViews.pop();)e.destroy&&e.destroy()},i.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))}}},i.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}},i.prototype.hasFocus=function(){return this.root.activeElement==this.dom},i.prototype.focus=function(){this.domObserver.stop(),this.editable&&Gh(this.dom),ta(this),this.domObserver.start()},Ub.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 t.getSelection||(Object.getPrototypeOf(t).getSelection=function(){return document.getSelection()}),this._root=t;return e||document},i.prototype.posAtCoords=function(e){return hi(this,e)},i.prototype.coordsAtPos=function(e){return Ud(this,e)},i.prototype.domAtPos=function(e){return this.docView.domFromPos(e)},i.prototype.nodeDOM=function(e){var t=this.docView.descAt(e);return t?t.nodeDOM:null},i.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},i.prototype.endOfTextblock=function(e,t){return ff(this,t||this.state,e)},i.prototype.destroy=function(){this.docView&&(Re(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Vb(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)},i.prototype.dispatchEvent=function(e){return Ve(this,e)},i.prototype.dispatch=function(e){var t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))},Object.defineProperties(i.prototype,Ub);var Ya=200,l=function(){};l.prototype.append=function(e){return e.length?(e=l.from(e),!this.length&&e||e.length<Ya&&this.leafAppend(e)||this.length<Ya&&e.leafPrepend(this)||this.appendInner(e)):this},l.prototype.prepend=function(e){return e.length?l.from(e).append(this):this},l.prototype.appendInner=function(e){return new ag(this,e)},l.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?l.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},l.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},l.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)},l.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},l.from=function(e){return e instanceof l?e:e&&e.length?new Od(e):l.empty};var Od=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 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<=Ya)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=Ya)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}(l);l.empty=new Od([]);var ag=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}(l),Pd=l;var cg=500,u=function(e,t){this.items=e,this.eventCount=t};function eg(e,t){var r;return e.forEach(function(e,n){if(e.selection&&0==t--)return r=n,!1}),e.slice(r)}u.prototype.popEvent=function(e,t){var r=this;if(0==this.eventCount)return null;for(var n,$,a=this.items.length;;a--){if(this.items.get(a-1).selection){--a;break}}t&&(n=this.remapping(a,this.items.length),$=n.maps.length);var s,o,i=e.tr,p=[],y=[];return this.items.forEach(function(e,t){if(!e.step)return n||(n=r.remapping(a,t+1),$=n.maps.length),$--,void y.push(e);if(n){y.push(new M(e.map));var v,m=e.step.map(n.slice($));m&&i.maybeStep(m).doc&&(v=i.mapping.maps[i.mapping.maps.length-1],p.push(new M(v,null,null,p.length+y.length))),$--,v&&n.appendMap(v,$)}else i.maybeStep(e.step);return e.selection?(s=n?e.selection.map(n.slice($)):e.selection,o=new u(r.items.slice(0,a).append(y.reverse().concat(p)),r.eventCount-1),!1):void 0},this.items.length,0),{remaining:o,transform:i,selection:s}},u.prototype.addTransform=function(e,t,r,n){for(var $=[],a=this.eventCount,s=this.items,o=!n&&s.length?s.get(s.length-1):null,i=0;i<e.steps.length;i++){var p,y=e.steps[i].invert(e.docs[i]),v=new M(e.mapping.maps[i],y,t);(p=o&&o.merge(v))&&(v=p,i?$.pop():s=s.slice(0,s.length-1)),$.push(v),t&&(a++,t=null),n||(o=v)}var m=a-r.depth;return m>hg&&(s=eg(s,m),a-=m),new u(s.append($),a)},u.prototype.remapping=function(e,t){var r=new n;return this.items.forEach(function(t,n){var $=null!=t.mirrorOffset&&n-t.mirrorOffset>=e?r.maps.length-t.mirrorOffset:null;r.appendMap(t.map,$)},e,t),r},u.prototype.addMaps=function(e){return 0==this.eventCount?this:new u(this.items.append(e.map(function(e){return new M(e)})),this.eventCount)},u.prototype.rebased=function(e,t){if(!this.eventCount)return this;var r=[],n=Math.max(0,this.items.length-t),$=e.mapping,a=e.steps.length,s=this.eventCount;this.items.forEach(function(e){e.selection&&s--},n);var o=t;this.items.forEach(function(t){var n=$.getMirror(--o);if(null!=n){a=Math.min(a,n);var i=$.maps[n];if(t.step){var p=e.steps[n].invert(e.docs[n]),y=t.selection&&t.selection.map($.slice(o+1,n));y&&s++,r.push(new M(i,p,y))}else r.push(new M(i))}},n);for(var i=[],p=t;p<a;p++)i.push(new M($.maps[p]));var y=this.items.slice(0,n).append(i).append(r),v=new u(y,s);return v.emptyItemCount()>cg&&(v=v.compress(this.items.length-r.length)),v},u.prototype.emptyItemCount=function(){var e=0;return this.items.forEach(function(t){t.step||e++}),e},u.prototype.compress=function(e){void 0===e&&(e=this.items.length);var t=this.remapping(0,e),r=t.maps.length,n=[],$=0;return this.items.forEach(function(a,s){if(s>=e)n.push(a),a.selection&&$++;else if(a.step){var o=a.step.map(t.slice(r)),i=o&&o.getMap();if(r--,i&&t.appendMap(i,r),o){var p=a.selection&&a.selection.map(t.slice(r));p&&$++;var y,v=new M(i.invert(),o,p),m=n.length-1;(y=n.length&&n[m].merge(v))?n[m]=y:n.push(v)}}else a.map&&r--},this.items.length,0),new u(Pd.from(n.reverse()),$)},u.empty=new u(Pd.empty,0);var M=function(e,t,r,n){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=n};M.prototype.merge=function(e){if(this.step&&e.step&&!e.selection){var t=e.step.merge(this.step);if(t)return new M(t.getMap().invert(),t,this.selection)}};var X=function(e,t,r,n){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=n},hg=20;function ig(e,t,r,n){var $,a=r.getMeta(T);if(a)return a.historyState;r.getMeta(rg)&&(e=new X(e.done,e.undone,null,0));var s=r.getMeta("appendedTransaction");if(0==r.steps.length)return e;if(s&&s.getMeta(T))return s.getMeta(T).redo?new X(e.done.addTransform(r,null,n,Ra(t)),e.undone,Td(r.mapping.maps[r.steps.length-1]),e.prevTime):new X(e.done,e.undone.addTransform(r,null,n,Ra(t)),null,e.prevTime);if(!1===r.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return($=r.getMeta("rebased"))?new X(e.done.rebased(r,$),e.undone.rebased(r,$),Sb(e.prevRanges,r.mapping),e.prevTime):new X(e.done.addMaps(r.mapping.maps),e.undone.addMaps(r.mapping.maps),Sb(e.prevRanges,r.mapping),e.prevTime);var o=0==e.prevTime||!s&&(e.prevTime<(r.time||0)-n.newGroupDelay||!jg(r,e.prevRanges)),i=s?Sb(e.prevRanges,r.mapping):Td(r.mapping.maps[r.steps.length-1]);return new X(e.done.addTransform(r,o?t.selection.getBookmark():null,n,Ra(t)),u.empty,i,r.time)}function jg(e,t){if(!t)return!1;if(!e.docChanged)return!0;var r=!1;return e.mapping.maps[0].forEach(function(e,n){for(var $=0;$<t.length;$+=2)e<=t[$+1]&&n>=t[$]&&(r=!0)}),r}function Td(e){var t=[];return e.forEach(function(e,r,n,$){return t.push(n,$)}),t}function Sb(e,t){if(!e)return null;for(var r=[],n=0;n<e.length;n+=2){var $=t.map(e[n],1),a=t.map(e[n+1],-1);$<=a&&r.push($,a)}return r}function Vd(e,t,r,n){var $=Ra(t),a=T.get(t).spec.config,s=(n?e.undone:e.done).popEvent(t,$);if(s){var o=s.selection.resolve(s.transform.doc),i=(n?e.done:e.undone).addTransform(s.transform,t.selection.getBookmark(),a,$),p=new X(n?i:s.remaining,n?s.remaining:i,null,0);r(s.transform.setSelection(o).setMeta(T,{redo:n,historyState:p}).scrollIntoView())}}var ng=!1,og=null;function Ra(e){var t=e.plugins;if(og!=t){ng=!1,og=t;for(var r=0;r<t.length;r++)if(t[r].spec.historyPreserveItems){ng=!0;break}}return ng}var T=new tb("history"),rg=new tb("closeHistory");function sg(e){return e={depth:e&&e.depth||100,newGroupDelay:e&&e.newGroupDelay||500},new qb({key:T,state:{init:function(){return new X(u.empty,u.empty,null,0)},apply:function(t,r,n){return ig(r,n,t,e)}},config:e})}function Yd(e,t){var r=T.getState(e);return!(!r||0==r.done.eventCount)&&(t&&Vd(r,e,t,!1),!0)}function Zd(e,t){var r=T.getState(e);return!(!r||0==r.undone.eventCount)&&(t&&Vd(r,e,t,!0),!0)}var vg=function(r){var t=function(t){r[t]&&r[t]()};return{"Cmd-z":Yd,"Cmd-Shift-z":Zd,Enter:function(){t("onEnter")},"Shift-Enter":function(){t("onShiftEnter")},"Shift-Tab":function(){return t("onShiftTab"),!0},Tab:function(){return t("onTab"),!0}}};var wg=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":Yd,"Cmd-Shift-s":function(){o("onStrikeThrough")},"Cmd-Shift-z":Zd,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 xg=function(e){return!0===e.code?vg(e):wg(e)};var yg=function(){return new ba({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 zg={toolbar:{icon:"code",label:"Code",action:"toggleMark",args:["code"]},parseDOM:[{tag:"code"}],toDOM:function(){return["code",0]}};var Ag={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 Bg={toolbar:{icon:"italic",label:"Italic",action:"toggleMark",args:["italic"]},parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"}],toDOM:function(){return["em",0]}};var Cg={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 Dg={toolbar:{icon:"strikethrough",label:"Strike-through",action:"toggleMark",args:["strikeThrough"]},parseDOM:[{tag:"del"},{style:"text-decoration=line-through"}],toDOM:function(){return["del",0]}};var Eg={toolbar:{icon:"underline",label:"Underline",action:"toggleMark",args:["underline"]},parseDOM:[{tag:"u"},{style:"text-decoration=underline"}],toDOM:function(){return["u",0]}};var Fg=function(r){var e={code:zg,bold:Ag,italic:Bg,link:Cg,underline:Eg,strikeThrough:Dg},$={};return r.forEach(function(r){$[r]=e[r]}),new ba({nodes:{text:{},doc:{content:"(text | hard_break )*"},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM:function(){return["br"]}}},marks:$})};var Gg=function(e,$){return $?yg():Fg(e)};var _={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"};var kb={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"};for(var ae="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent),Kg="undefined"!=typeof navigator&&/Apple Computer/.test(navigator.vendor),Lg="undefined"!=typeof navigator&&/Gecko\/\d+/.test(navigator.userAgent),be="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Ng="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Og=ae&&(be||+ae[1]<57)||Lg&&be,r=0;r<10;r++)_[48+r]=_[96+r]=String(r);for(r=1;r<=24;r++)_[r+111]="F"+r;for(r=65;r<=90;r++)_[r]=String.fromCharCode(r+32),kb[r]=String.fromCharCode(r);for(var Qb in _)kb.hasOwnProperty(Qb)||(kb[Qb]=_[Qb]);function Rg($){var r=!(Og&&($.ctrlKey||$.altKey||$.metaKey)||(Kg||Ng)&&$.shiftKey&&$.key&&1==$.key.length)&&$.key||($.shiftKey?kb:_)[$.keyCode]||$.key||"Unidentified";return"Esc"==r&&(r="Escape"),"Del"==r&&(r="Delete"),"Left"==r&&(r="ArrowLeft"),"Up"==r&&(r="ArrowUp"),"Right"==r&&(r="ArrowRight"),"Down"==r&&(r="ArrowDown"),r}var Sg="undefined"!=typeof navigator&&/Mac/.test(navigator.platform);function Tg(e){var t,r,i,$,a=e.split(/-(?!$)/),n=a[a.length-1];"Space"==n&&(n=" ");for(var o=0;o<a.length-1;o++){var l=a[o];if(/^(cmd|meta|m)$/i.test(l))$=!0;else if(/^a(lt)?$/i.test(l))t=!0;else if(/^(c|ctrl|control)$/i.test(l))r=!0;else if(/^s(hift)?$/i.test(l))i=!0;else{if(!/^mod$/i.test(l))throw new Error("Unrecognized modifier name: "+l);Sg?$=!0:r=!0}}return t&&(n="Alt-"+n),r&&(n="Ctrl-"+n),$&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function Ug(e){var t=Object.create(null);for(var r in e)t[Tg(r)]=e[r];return t}function Ob(e,t,r){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),!1!==r&&t.shiftKey&&(e="Shift-"+e),e}function Wg(e){return new qb({props:{handleKeyDown:Xg(e)}})}function Xg(e){var t=Ug(e);return function(e,r){var i,$=Rg(r),a=1==$.length&&" "!=$,n=t[Ob($,r,!a)];if(n&&n(e.state,e.dispatch,e))return!0;if(a&&(r.shiftKey||r.altKey||r.metaKey||$.charCodeAt(0)>127)&&(i=_[r.keyCode])&&i!=$){var o=t[Ob(i,r,!0)];if(o&&o(e.state,e.dispatch,e))return!0}else if(a&&r.shiftKey){var l=t[Ob($,r,!0)];if(l&&l(e.state,e.dispatch,e))return!0}return!1}}var L=function(e,r){this.match=e,this.handler="string"==typeof r?Zg(r):r};function Zg(e){return function(r,t,$,o){var n=e;if(t[1]){var u=t[0].lastIndexOf(t[1]);n+=t[0].slice(u+t[1].length);var p=($+=u)-o;p>0&&(n=t[0].slice(u-p,u)+n,$=o)}return r.tr.insertText(n,$,o)}}var $g=500;function _g(e){var r=e.rules,t=new qb({state:{init:function(){return null},apply:function(e,r){var t=e.getMeta(this);return t||(e.selectionSet||e.docChanged?null:r)}},props:{handleTextInput:function(e,$,o,n){return ge(e,$,o,n,r,t)},handleDOMEvents:{compositionend:function(e){setTimeout(function(){var $=e.state.selection.$cursor;$&&ge(e,$.pos,$.pos,"",r,t)})}}},isInputRules:!0});return t}function ge(e,r,t,$,o,n){if(e.composing)return!1;var u=e.state,p=u.doc.resolve(r);if(p.parent.type.spec.code)return!1;for(var l=p.parent.textBetween(Math.max(0,p.parentOffset-$g),p.parentOffset,null,"\uFFFC")+$,s=0;s<o.length;s++){var i=o[s].match.exec(l),a=i&&o[s].handler(u,i,r-(i[0].length-$.length),t);if(a)return e.dispatch(a.setMeta(n,{transform:a,from:r,to:t,text:$})),!0}return!1}var qi=new L(/--$/,"\u2014"),ch=new L(/\.\.\.$/,"\u2026"),pi=new L(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"\u201C"),oi=new L(/"$/,"\u201D"),ni=new L(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"\u2018"),mi=new L(/'$/,"\u2019");var Z=function(e,r){return new L(e,function(e,t,$,o){return r(),e.tr.delete($,o)})},ih=function(e,r,t){return s.create({doc:e,plugins:[Wg(r),sg(),_g({rules:[ch,new L(/\<\-/,"\u2190"),new L(/\-\>/,"\u2192"),new L(/\-\-/,"\u2013"),Z(/^\–\-/,function(){t.onConvert&&t.onConvert("hr")}),Z(/^\s*([-+*])\s$/,function(){t.onConvert&&t.onConvert("ul")}),Z(/^\d{1,}\.\s$/,function(){t.onConvert&&t.onConvert("ol")}),Z(/^```$/,function(){t.onConvert&&t.onConvert("code")}),Z(/^\>\s$/,function(){t.onConvert&&t.onConvert("blockquote")}),Z(/^\#\s$/,function(){t.onConvert&&t.onConvert("h1")}),Z(/^\#\#\s$/,function(){t.onConvert&&t.onConvert("h2")}),Z(/^\#\#\#\s$/,function(){t.onConvert&&t.onConvert("h3")})]})]})};var jh=function(e){var t=Gg(e.marks,e.code),a=Fe(t,e.content,e.code),r=xg(e),o=ih(a,r,e);return new i(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)}})};function le(e,t){return!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0)}function lh(e,t,r){var o=e.selection.$cursor;if(!o||(r?!r.endOfTextblock("backward",e):o.parentOffset>0))return!1;var n=ne(o);if(!n){var $=o.blockRange(),a=$&&pc($);return null!=a&&(t&&t(e.tr.lift($,a).scrollIntoView()),!0)}var i=n.nodeBefore;if(!i.type.spec.isolating&&qe(e,n,t))return!0;if(0==o.parent.content.size&&(xb(i,"end")||f.isSelectable(i))){if(t){var p=e.tr.deleteRange(o.before(),o.after());p.setSelection(xb(i,"end")?q.findFrom(p.doc.resolve(p.mapping.map(n.pos,-1)),-1):f.create(p.doc,n.pos-i.nodeSize)),t(p.scrollIntoView())}return!0}return!(!i.isAtom||n.depth!=o.depth-1)&&(t&&t(e.tr.delete(n.pos-i.nodeSize,n.pos).scrollIntoView()),!0)}function xb(e,t){for(;e;e="start"==t?e.firstChild:e.lastChild)if(e.isTextblock)return!0;return!1}function nh(e,t,r){var o=e.selection,n=o.$head,$=n;if(!o.empty)return!1;if(n.parent.isTextblock){if(r?!r.endOfTextblock("backward",e):n.parentOffset>0)return!1;$=ne(n)}var a=$&&$.nodeBefore;return!(!a||!f.isSelectable(a))&&(t&&t(e.tr.setSelection(f.create(e.doc,$.pos-a.nodeSize)).scrollIntoView()),!0)}function ne(e){if(!e.parent.type.spec.isolating)for(var t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function ph(e,t,r){var o=e.selection.$cursor;if(!o||(r?!r.endOfTextblock("forward",e):o.parentOffset<o.parent.content.size))return!1;var n=oe(o);if(!n)return!1;var $=n.nodeAfter;if(qe(e,n,t))return!0;if(0==o.parent.content.size&&(xb($,"start")||f.isSelectable($))){if(t){var a=e.tr.deleteRange(o.before(),o.after());a.setSelection(xb($,"start")?q.findFrom(a.doc.resolve(a.mapping.map(n.pos)),1):f.create(a.doc,a.mapping.map(n.pos))),t(a.scrollIntoView())}return!0}return!(!$.isAtom||n.depth!=o.depth-1)&&(t&&t(e.tr.delete(n.pos,n.pos+$.nodeSize).scrollIntoView()),!0)}function qh(e,t,r){var o=e.selection,n=o.$head,$=n;if(!o.empty)return!1;if(n.parent.isTextblock){if(r?!r.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)return!1;$=oe(n)}var a=$&&$.nodeAfter;return!(!a||!f.isSelectable(a))&&(t&&t(e.tr.setSelection(f.create(e.doc,$.pos)).scrollIntoView()),!0)}function oe(e){if(!e.parent.type.spec.isolating)for(var t=e.depth-1;t>=0;t--){var r=e.node(t);if(e.index(t)+1<r.childCount)return e.doc.resolve(e.after(t+1));if(r.type.spec.isolating)break}return null}function sh(e,t){var r=e.selection,o=r.$head,n=r.$anchor;return!(!o.parent.type.spec.code||!o.sameParent(n))&&(t&&t(e.tr.insertText("\n").scrollIntoView()),!0)}function Lb(e){for(var t=0;t<e.edgeCount;t++){var r=e.edge(t).type;if(r.isTextblock&&!r.hasRequiredAttrs())return r}return null}function uh(e,t){var r=e.selection,o=r.$head,n=r.$anchor;if(!o.parent.type.spec.code||!o.sameParent(n))return!1;var $=o.node(-1),a=o.indexAfter(-1),i=Lb($.contentMatchAt(a));if(!$.canReplaceWith(a,a,i))return!1;if(t){var p=o.after(),c=e.tr.replaceWith(p,p,i.createAndFill());c.setSelection(q.near(c.doc.resolve(p),1)),t(c.scrollIntoView())}return!0}function vh(e,t){var r=e.selection,o=r.$from,n=r.$to;if(o.parent.inlineContent||n.parent.inlineContent)return!1;var $=Lb(o.parent.contentMatchAt(n.indexAfter()));if(!$||!$.isTextblock)return!1;if(t){var a=(!o.parentOffset&&n.index()<n.parent.childCount?o:n).pos,i=e.tr.insert(a,$.createAndFill());i.setSelection(z.create(i.doc,a+1)),t(i.scrollIntoView())}return!0}function wh(e,t){var r=e.selection.$cursor;if(!r||r.parent.content.size)return!1;if(r.depth>1&&r.after()!=r.end(-1)){var o=r.before();if(rb(e.doc,o))return t&&t(e.tr.split(o).scrollIntoView()),!0}var n=r.blockRange(),$=n&&pc(n);return null!=$&&(t&&t(e.tr.lift(n,$).scrollIntoView()),!0)}function xh(e,t){var r=e.selection,o=r.$from,n=r.$to;if(e.selection instanceof f&&e.selection.node.isBlock)return!(!o.parentOffset||!rb(e.doc,o.pos))&&(t&&t(e.tr.split(o.pos).scrollIntoView()),!0);if(!o.parent.isBlock)return!1;if(t){var $=n.parentOffset==n.parent.content.size,a=e.tr;e.selection instanceof z&&a.deleteSelection();var i=0==o.depth?null:Lb(o.node(-1).contentMatchAt(o.indexAfter(-1))),p=$&&i?[{type:i}]:null,c=rb(a.doc,a.mapping.map(o.pos),1,p);p||c||!rb(a.doc,a.mapping.map(o.pos),1,i&&[{type:i}])||(p=[{type:i}],c=!0),c&&(a.split(a.mapping.map(o.pos),1,p),$||o.parentOffset||o.parent.type==i||!o.node(-1).canReplace(o.index(-1),o.indexAfter(-1),b.from(i.create(),o.parent))||a.setNodeMarkup(a.mapping.map(o.before()),i)),t(a.scrollIntoView())}return!0}function yh(e,t){return t&&t(e.tr.setSelection(new na(e.doc))),!0}function zh(e,t,r){var o=t.nodeBefore,n=t.nodeAfter,$=t.index();return!!(o&&n&&o.type.compatibleContent(n.type))&&(!o.content.size&&t.parent.canReplace($-1,$)?(r&&r(e.tr.delete(t.pos-o.nodeSize,t.pos).scrollIntoView()),!0):!(!t.parent.canReplace($,$+1)||!n.isTextblock&&!Ec(e.doc,t.pos))&&(r&&r(e.tr.clearIncompatible(t.pos,o.type,o.contentMatchAt(o.childCount)).join(t.pos).scrollIntoView()),!0))}function qe(e,t,r){var o,n,$=t.nodeBefore,a=t.nodeAfter;if($.type.spec.isolating||a.type.spec.isolating)return!1;if(zh(e,t,r))return!0;if(t.parent.canReplace(t.index(),t.index()+1)&&(o=(n=$.contentMatchAt($.childCount)).findWrapping(a.type))&&n.matchType(o[0]||a.type).validEnd){if(r){for(var i=t.pos+a.nodeSize,p=b.empty,c=o.length-1;c>=0;c--)p=b.from(o[c].create(null,p));p=b.from($.copy(p));var l=e.tr.step(new W(t.pos-1,i,t.pos,i,new k(p,1,0),o.length,!0)),s=i+2*o.length;Ec(l.doc,s)&&l.join(s),r(l.scrollIntoView())}return!0}var f=q.findFrom(t,1),d=f&&f.$from.blockRange(f.$to),z=d&&pc(d);return null!=z&&z>=t.depth&&(r&&r(e.tr.lift(d,z).scrollIntoView()),!0)}function Bh(e,t,r){for(var o=function(o){var n=t[o],$=n.$from,a=n.$to,i=0==$.depth&&e.type.allowsMarkType(r);if(e.nodesBetween($.pos,a.pos,function(e){if(i)return!1;i=e.inlineContent&&e.type.allowsMarkType(r)}),i)return{v:!0}},n=0;n<t.length;n++){var $=o(n);if($)return $.v}return!1}function Ch(e,t){return function(r,o){var n=r.selection,$=n.empty,a=n.$cursor,i=n.ranges;if($&&!a||!Bh(r.doc,i,e))return!1;if(o)if(a)e.isInSet(r.storedMarks||a.marks())?o(r.tr.removeStoredMark(e)):o(r.tr.addStoredMark(e.create(t)));else{for(var p=!1,c=r.tr,l=0;!p&&l<i.length;l++){var s=i[l],f=s.$from,d=s.$to;p=r.doc.rangeHasMark(f.pos,d.pos,e)}for(var z=0;z<i.length;z++){var u=i[z],m=u.$from,x=u.$to;p?c.removeMark(m.pos,x.pos,e):c.addMark(m.pos,x.pos,e.create(t))}o(c.scrollIntoView())}return!0}}function Kb(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return function(t,r,o){for(var n=0;n<e.length;n++)if(e[n](t,r,o))return!0;return!1}}var se=Kb(le,lh,nh),te=Kb(le,ph,qh),R={Enter:Kb(sh,vh,wh,xh),"Mod-Enter":uh,Backspace:se,"Mod-Backspace":se,Delete:te,"Mod-Delete":te,"Mod-a":yh},ve={"Ctrl-h":R.Backspace,"Alt-Backspace":R["Mod-Backspace"],"Ctrl-d":R.Delete,"Ctrl-Alt-Backspace":R["Mod-Delete"],"Alt-Delete":R["Mod-Delete"],"Alt-d":R["Mod-Delete"]};for(var we in R)ve[we]=R[we];var Jh="undefined"!=typeof navigator?/Mac/.test(navigator.platform):"undefined"!=typeof os&&"darwin"==os.platform(),li=Jh?ve:R;function ye(r){return Oh(r)||Nh(r)||Mh()}function Mh(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function Nh(r){if(Symbol.iterator in Object(r)||"[object Arguments]"===Object.prototype.toString.call(r))return Array.from(r)}function Oh(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 Ph(r,e,t){var a=[];return t.forEach(function(t){var $=r.marks[t];$&&Qh(e,$)&&a.push($.name)}),a}function Qh(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 Rh(r,e){var t=document.createElement("div"),a=y.fromSchema(r.schema).serializeFragment(r.doc.content);return t.appendChild(a),e?t.innerText:t.innerHTML}function Sh(r,e){var t=r.selection,a=t.from,$=t.to,o=[];r.doc.nodesBetween(a,$,function(r){o=[].concat(ye(o),ye(r.marks))});var n=o.find(function(r){return r.type.name===e});return n?n.attrs:{}}function ze(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){Uh(e,t,r[t])})}return e}function Uh(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var fb={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=ze({title:null,target:!1},e),this.$refs.dialog.open()},submit:function(){this.$emit("submit",ze({},this.link,{target:this.link.target?"_blank":null})),this.$refs.dialog.close()}}};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("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 $a={props:{marks:{type:Array,default:function(){return[]}},options:Object}};if(typeof $a==="function"){$a=$a.options}Object.assign($a,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 la={inheritAttrs:!1,components:{"k-link-dialog":fb,"k-editable-toolbar":$a},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=jh({breaks:this.breaks,code:this.code,content:this.content,disabled:this.disabled,element:this.$el,marks:this.marks,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,onSplit:this.onSplitBlock,onStrikeThrough:this.onStrikeThrough,onTab:!!this.$listeners.tab&&this.onTab,onUnderline:this.onUnderline,onUpdate:this.onUpdate}),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"===hf(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=z.atStart(this.doc());break;case"end":n=z.atEnd(this.doc());break;default:try{n=z.near(this.doc().resolve(t))}catch(s){n=z.atStart(this.doc())}}this.dispatch(this.tr().setSelection(n))}setTimeout(function(){o.editor.focus()},1)},getActiveMarks:function(){return Ph(this.editor.state.schema,this.editor.state,this.marks)},getMarkAttrs:function(t){return Sh(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=Fe(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=y.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,dh(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")},onSplitBlock: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 z.atEnd(this.doc())},selectionAtStart:function(){return z.atStart(this.doc())},selectionBeforeCursor:function(){return new z(this.doc().resolve(0),this.selection().$from)},selectionAfterCursor:function(){return new z(this.selection().$to,this.selectionAtEnd().$to)},state:function(){return this.editor.state},toggleMark:function(t,o){var e=this.mark(t);e&&Ch(e,o)(this.editor.state,this.editor.dispatch),this.editor.focus()},toHTML:function(){return Rh(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 la==="function"){la=la.options}Object.assign(la,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 vb={extends:la,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 vb==="function"){vb=vb.options}var Da={extends:vb,icon:"title",breaks:!0,marks:["italic","strikeThrough","underline","code","link"]};if(typeof Da==="function"){Da=Da.options}function $h(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){_h(e,r,t[r])})}return e}function _h(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}var Eb=$h({},Da);if(typeof Eb==="function"){Eb=Eb.options}function bi(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){ci(e,r,t[r])})}return e}function ci(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}var Cb=bi({},Da);if(typeof Cb==="function"){Cb=Cb.options}var _a={icon:"dots",methods:{focus:function(){this.$refs.hr.focus()}}};if(typeof _a==="function"){_a=_a.options}Object.assign(_a,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 fi(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){gi(t,e,i[e])})}return t}function gi(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}var Va={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:fi({},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,filename:t.filename,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 Va==="function"){Va=Va.options}Object.assign(Va,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 Bb={extends:la,icon:"markdown",breaks:!0,code:!0,props:{content:String,attrs:[Object,Array]},methods:{onInput:function(r){this.$emit("input",{content:r})}}};if(typeof Bb==="function"){Bb=Bb.options}var Cc={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 Cc==="function"){Cc=Cc.options}var Jb={extends:"ul",append:"ol",icon:"list-numbers"};if(typeof Jb==="function"){Jb=Jb.options}function gh(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){fh(e,t,r[t])})}return e}function fh(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Sa={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:gh({},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 Sa==="function"){Sa=Sa.options}Object.assign(Sa,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",vb),window.editor.block("h1",Da),window.editor.block("h2",Eb),window.editor.block("h3",Cb),window.editor.block("ul",Cc),window.editor.block("ol",Jb),window.editor.block("blockquote",Fb),window.editor.block("hr",_a),window.editor.block("code",pb),window.editor.block("image",Va),window.editor.block("video",Sa),window.editor.block("kirbytext",Bb);var Ta={inheritAttrs:!1,components:{"k-editor-options":mb},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 He({},{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.mergeWithPreviousBlock(t+1)},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(Ie(o)));else(s=e.blocks).splice.apply(s,[t+1,0].concat(Ie(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,He({},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 Ta==="function"){Ta=Ta.options}Object.assign(Ta,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 Ua={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 Ua==="function"){Ua=Ua.options}Object.assign(Ua,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 ob={inheritAttrs:!1,components:{"k-editor":Ta,"k-editor-inline":Ua},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,help:String,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 r=document.createElement("a");document.body.appendChild(r),r.style="display: none";var o=new Blob([t.data],{type:"octet/stream"}),n=window.URL.createObjectURL(o);r.href=n,r.download=e.name+"."+e.downloadOptions.type,r.click(),window.URL.revokeObjectURL(n),document.body.removeChild(r),e.$refs.download.close(),e.$store.dispatch("notification/success",e.$t("editor.downloadSuccess"))}).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 r=yf(t,1)[0];this.$refs.editor.importBlocks(r)},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 ob==="function"){ob=ob.options}Object.assign(ob,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,"help":_vm.help,"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(_vm._s(_vm.$t("editor.import")))]),_vm._v(" "),_c("k-dropdown-item",{attrs:{"disabled":_vm.isEmpty,"icon":"attachment"},on:{"click":function($event){return _vm.$refs.download.open()}}},[_vm._v(_vm._s(_vm.$t("editor.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(_vm._s(_vm.$t("editor.deleteBlocks")))])],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(_vm._s(_vm.$t("editor.deleteConfirm")))])],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":la},fields:{editor:ob}});})();