")+'"');throw t.mode=A,t}if("end"===r.type){const t=k(r);if(t!==bt)return t}if("illegal"===r.type&&""===s)return 1;if(I>1e5&&I>3*r.index){const t=new Error("potential infinite loop, way more iterations than matches");throw t}return R+=s,s.length}const O=$(t);if(!O)throw mt(a.replace("{}",t)),new Error('Unknown language: "'+t+'"');const N=ot(O,{plugins:r});let E="",A=l||N;const D={},T=new h.__emitter(h);S();let R="",z=0,_=0,I=0,P=!1;try{for(A.matcher.considerAll();;){I++,P?P=!1:A.matcher.considerAll(),A.matcher.lastIndex=_;const t=A.matcher.exec(n);if(!t)break;const e=n.substring(_,t.index),r=M(e,t);_=t.index+r}return M(n.substr(_)),T.closeAllNodes(),T.finalize(),E=T.toHTML(),{relevance:Math.floor(z),value:E,language:t,illegal:!1,emitter:T,top:A}}catch(B){if(B.message&&B.message.includes("Illegal"))return{illegal:!0,illegalBy:{msg:B.message,context:n.slice(_-100,_+100),mode:B.mode},sofar:E,relevance:0,value:wt(n),emitter:T};if(i)return{illegal:!1,relevance:0,value:wt(n),emitter:T,language:t,top:A,errorRaised:B};throw B}}function y(t){const e={relevance:0,emitter:new h.__emitter(h),value:wt(t),illegal:!1,top:c};return e.emitter.addText(t),e}function w(t,n){n=n||h.languages||Object.keys(e);const r=y(t),o=n.filter($).filter(B).map((e=>g(e,t,!1)));o.unshift(r);const i=o.sort(((t,e)=>{if(t.relevance!==e.relevance)return e.relevance-t.relevance;if(t.language&&e.language){if($(t.language).supersetOf===e.language)return 1;if($(e.language).supersetOf===t.language)return-1}return 0})),[s,l]=i,a=s;return a.second_best=l,a}function b(t){return h.tabReplace||h.useBR?t.replace(l,(t=>"\n"===t?h.useBR?"
":t:h.tabReplace?t.replace(/\t/g,h.tabReplace):t)):t}function x(t,e,r){const o=e?n[e]:r;t.classList.add("hljs"),o&&t.classList.add(o)}const k={"before:highlightElement":({el:t})=>{h.useBR&&(t.innerHTML=t.innerHTML.replace(/\n/g,"").replace(/
/g,"\n"))},"after:highlightElement":({result:t})=>{h.useBR&&(t.value=t.value.replace(/\n/g,"
"))}},S=/^(<[^>]+>|\t)+/gm,C={"after:highlightElement":({result:t})=>{h.tabReplace&&(t.value=t.value.replace(S,(t=>t.replace(/\t/g,h.tabReplace))))}};function M(t){let e=null;const n=u(t);if(d(n))return;L("before:highlightElement",{el:t,language:n}),e=t;const r=e.textContent,o=n?m(r,{language:n,ignoreIllegals:!0}):w(r);L("after:highlightElement",{el:t,result:o,text:r}),t.innerHTML=o.value,x(t,n,o.language),t.result={language:o.language,re:o.relevance,relavance:o.relevance},o.second_best&&(t.second_best={language:o.second_best.language,re:o.second_best.relevance,relavance:o.second_best.relevance})}function O(t){t.useBR&&(yt("10.3.0","'useBR' will be removed entirely in v11.0"),yt("10.3.0","Please see https://github.com/highlightjs/highlight.js/issues/2559")),h=vt(h,t)}const N=()=>{if(N.called)return;N.called=!0,yt("10.6.0","initHighlighting() is deprecated. Use highlightAll() instead.");const t=document.querySelectorAll("pre code");t.forEach(M)};function E(){yt("10.6.0","initHighlightingOnLoad() is deprecated. Use highlightAll() instead."),A=!0}let A=!1;function D(){if("loading"===document.readyState)return void(A=!0);const t=document.querySelectorAll("pre code");t.forEach(M)}function T(){A&&D()}function R(n,r){let o=null;try{o=r(t)}catch(s){if(mt("Language definition for '{}' could not be registered.".replace("{}",n)),!i)throw s;mt(s),o=c}o.name||(o.name=n),e[n]=o,o.rawDefinition=r.bind(null,t),o.aliases&&P(o.aliases,{languageName:n})}function z(t){delete e[t];for(const e of Object.keys(n))n[e]===t&&delete n[e]}function _(){return Object.keys(e)}function I(t){yt("10.4.0","requireLanguage will be removed entirely in v11."),yt("10.4.0","Please see https://github.com/highlightjs/highlight.js/pull/2844");const e=$(t);if(e)return e;const n=new Error("The '{}' language is required, but not loaded.".replace("{}",t));throw n}function $(t){return t=(t||"").toLowerCase(),e[t]||e[n[t]]}function P(t,{languageName:e}){"string"===typeof t&&(t=[t]),t.forEach((t=>{n[t.toLowerCase()]=e}))}function B(t){const e=$(t);return e&&!e.disableAutodetect}function V(t){t["before:highlightBlock"]&&!t["before:highlightElement"]&&(t["before:highlightElement"]=e=>{t["before:highlightBlock"](Object.assign({block:e.el},e))}),t["after:highlightBlock"]&&!t["after:highlightElement"]&&(t["after:highlightElement"]=e=>{t["after:highlightBlock"](Object.assign({block:e.el},e))})}function F(t){V(t),r.push(t)}function L(t,e){const n=t;r.forEach((function(t){t[n]&&t[n](e)}))}function j(t){return yt("10.2.0","fixMarkup will be removed entirely in v11.0"),yt("10.2.0","Please see https://github.com/highlightjs/highlight.js/issues/2534"),b(t)}function H(t){return yt("10.7.0","highlightBlock will be removed entirely in v12.0"),yt("10.7.0","Please use highlightElement now."),M(t)}"undefined"!==typeof window&&window.addEventListener&&window.addEventListener("DOMContentLoaded",T,!1),Object.assign(t,{highlight:m,highlightAuto:w,highlightAll:D,fixMarkup:j,highlightElement:M,highlightBlock:H,configure:O,initHighlighting:N,initHighlightingOnLoad:E,registerLanguage:R,unregisterLanguage:z,listLanguages:_,getLanguage:$,registerAliases:P,requireLanguage:I,autoDetection:B,inherit:vt,addPlugin:F,vuePlugin:ct(t).VuePlugin}),t.debugMode=function(){i=!1},t.safeMode=function(){i=!0},t.versionString=lt;for(const s in K)"object"===typeof K[s]&&o(K[s]);return Object.assign(t,K),t.addPlugin(k),t.addPlugin(ht),t.addPlugin(C),t};var kt=xt({});t.exports=kt},4304:function(t,e,n){"use strict";n(7658);var r=n(1154),o=n(5785);d.prototype.addText=f,d.prototype.addKeyword=u,d.prototype.addSublanguage=p,d.prototype.openNode=m,d.prototype.closeNode=g,d.prototype.closeAllNodes=w,d.prototype.finalize=w,d.prototype.toHTML=y;var i="hljs-";function s(t,e,n){var s,l=r.configure({}),a=n||{},c=a.prefix;if("string"!==typeof t)throw o("Expected `string` for name, got `%s`",t);if(!r.getLanguage(t))throw o("Unknown language: `%s` is not registered",t);if("string"!==typeof e)throw o("Expected `string` for value, got `%s`",e);if(null!==c&&void 0!==c||i,r.configure({__emitter:d,classPrefix:c}),r.highlight(e,{language:t,ignoreIllegals:!0}),r.configure(l||{}),s.errorRaised)throw s.errorRaised;return{relevance:s.relevance,language:s.language,value:s.emitter.rootNode.children}}function l(t,e){var n,l,a,c,h=e||{},d=h.subset||r.listLanguages(),u=h.prefix,p=d.length,f=-1;if(null!==u&&void 0!==u||i,"string"!==typeof t)throw o("Expected `string` for value, got `%s`",t);({relevance:0,language:null,value:[]}),{relevance:0,language:null,value:[]};while(++fl.relevance&&a,a.relevance>n.relevance&&(n,a));return l.language&&(n.secondBest=l),n}function a(t,e){r.registerLanguage(t,e)}function c(){return r.listLanguages()}function h(t,e){var n,o=t;for(n in e&&({},o[t]=e),o)r.registerAliases(o[n],{languageName:n})}function d(t){this.options=t,this.rootNode={children:[]},this.stack=[this.rootNode]}function u(t,e){this.openNode(e),this.addText(t),this.closeNode()}function p(t,e){var n=this.stack,r=n[n.length-1],o=t.rootNode.children,i=e?{type:"element",tagName:"span",properties:{className:[e]},children:o}:o;r.children=r.children.concat(i)}function f(t){var e,n,r=this.stack;""!==t&&(e=r[r.length-1],n=e.children[e.children.length-1],n&&"text"===n.type?n.value+=t:e.children.push({type:"text",value:t}))}function m(t){var e=this.stack,n=this.options.classPrefix+t,r=e[e.length-1],o={type:"element",tagName:"span",properties:{className:[n]},children:[]};r.children.push(o),e.push(o)}function g(){this.stack.pop()}function y(){return""}function w(){}},9662:function(t,e,n){var r=n(614),o=n(6330),i=TypeError;t.exports=function(t){if(r(t))return t;throw i(o(t)+" is not a function")}},9670:function(t,e,n){var r=n(111),o=String,i=TypeError;t.exports=function(t){if(r(t))return t;throw i(o(t)+" is not an object")}},1318:function(t,e,n){var r=n(5656),o=n(1400),i=n(6244),s=function(t){return function(e,n,s){var l,a=r(e),c=i(a),h=o(s,c);if(t&&n!=n){while(c>h)if(l=a[h++],l!=l)return!0}else for(;c>h;h++)if((t||h in a)&&a[h]===n)return t||h||0;return!t&&-1}};t.exports={includes:s(!0),indexOf:s(!1)}},3658:function(t,e,n){"use strict";var r=n(9781),o=n(3157),i=TypeError,s=Object.getOwnPropertyDescriptor,l=r&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(t){return t instanceof TypeError}}();t.exports=l?function(t,e){if(o(t)&&!s(t,"length").writable)throw i("Cannot set read only .length");return t.length=e}:function(t,e){return t.length=e}},4326:function(t,e,n){var r=n(1702),o=r({}.toString),i=r("".slice);t.exports=function(t){return i(o(t),8,-1)}},9920:function(t,e,n){var r=n(2597),o=n(3887),i=n(1236),s=n(3070);t.exports=function(t,e,n){for(var l=o(e),a=s.f,c=i.f,h=0;hn)throw e("Maximum allowed index exceeded");return t}},8113:function(t){t.exports="undefined"!=typeof navigator&&String(navigator.userAgent)||""},7392:function(t,e,n){var r,o,i=n(7854),s=n(8113),l=i.process,a=i.Deno,c=l&&l.versions||a&&a.version,h=c&&c.v8;h&&(r=h.split("."),o=r[0]>0&&r[0]<4?1:+(r[0]+r[1])),!o&&s&&(r=s.match(/Edge\/(\d+)/),(!r||r[1]>=74)&&(r=s.match(/Chrome\/(\d+)/),r&&(o=+r[1]))),t.exports=o},748:function(t){t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},2109:function(t,e,n){var r=n(7854),o=n(1236).f,i=n(8880),s=n(8052),l=n(3072),a=n(9920),c=n(4705);t.exports=function(t,e){var n,h,d,u,p,f,m=t.target,g=t.global,y=t.stat;if(h=g?r:y?r[m]||l(m,{}):(r[m]||{}).prototype,h)for(d in e){if(p=e[d],t.dontCallGetSet?(f=o(h,d),u=f&&f.value):u=h[d],n=c(g?d:m+(y?".":"#")+d,t.forced),!n&&void 0!==u){if(typeof p==typeof u)continue;a(p,u)}(t.sham||u&&u.sham)&&i(p,"sham",!0),s(h,d,p,t)}}},7293:function(t){t.exports=function(t){try{return!!t()}catch(e){return!0}}},4374:function(t,e,n){var r=n(7293);t.exports=!r((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")}))},6916:function(t,e,n){var r=n(4374),o=Function.prototype.call;t.exports=r?o.bind(o):function(){return o.apply(o,arguments)}},6530:function(t,e,n){var r=n(9781),o=n(2597),i=Function.prototype,s=r&&Object.getOwnPropertyDescriptor,l=o(i,"name"),a=l&&"something"===function(){}.name,c=l&&(!r||r&&s(i,"name").configurable);t.exports={EXISTS:l,PROPER:a,CONFIGURABLE:c}},1702:function(t,e,n){var r=n(4374),o=Function.prototype,i=o.call,s=r&&o.bind.bind(i,i);t.exports=r?s:function(t){return function(){return i.apply(t,arguments)}}},5005:function(t,e,n){var r=n(7854),o=n(614),i=function(t){return o(t)?t:void 0};t.exports=function(t,e){return arguments.length<2?i(r[t]):r[t]&&r[t][e]}},8173:function(t,e,n){var r=n(9662),o=n(8554);t.exports=function(t,e){var n=t[e];return o(n)?void 0:r(n)}},7854:function(t,e,n){var r=function(t){return t&&t.Math==Math&&t};t.exports=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof n.g&&n.g)||function(){return this}()||Function("return this")()},2597:function(t,e,n){var r=n(1702),o=n(7908),i=r({}.hasOwnProperty);t.exports=Object.hasOwn||function(t,e){return i(o(t),e)}},3501:function(t){t.exports={}},4664:function(t,e,n){var r=n(9781),o=n(7293),i=n(317);t.exports=!r&&!o((function(){return 7!=Object.defineProperty(i("div"),"a",{get:function(){return 7}}).a}))},8361:function(t,e,n){var r=n(1702),o=n(7293),i=n(4326),s=Object,l=r("".split);t.exports=o((function(){return!s("z").propertyIsEnumerable(0)}))?function(t){return"String"==i(t)?l(t,""):s(t)}:s},2788:function(t,e,n){var r=n(1702),o=n(614),i=n(5465),s=r(Function.toString);o(i.inspectSource)||(i.inspectSource=function(t){return s(t)}),t.exports=i.inspectSource},9909:function(t,e,n){var r,o,i,s=n(4811),l=n(7854),a=n(111),c=n(8880),h=n(2597),d=n(5465),u=n(6200),p=n(3501),f="Object already initialized",m=l.TypeError,g=l.WeakMap,y=function(t){return i(t)?o(t):r(t,{})},w=function(t){return function(e){var n;if(!a(e)||(n=o(e)).type!==t)throw m("Incompatible receiver, "+t+" required");return n}};if(s||d.state){var v=d.state||(d.state=new g);v.get=v.get,v.has=v.has,v.set=v.set,r=function(t,e){if(v.has(t))throw m(f);return e.facade=t,v.set(t,e),e},o=function(t){return v.get(t)||{}},i=function(t){return v.has(t)}}else{var b=u("state");p[b]=!0,r=function(t,e){if(h(t,b))throw m(f);return e.facade=t,c(t,b,e),e},o=function(t){return h(t,b)?t[b]:{}},i=function(t){return h(t,b)}}t.exports={set:r,get:o,has:i,enforce:y,getterFor:w}},3157:function(t,e,n){var r=n(4326);t.exports=Array.isArray||function(t){return"Array"==r(t)}},614:function(t,e,n){var r=n(4154),o=r.all;t.exports=r.IS_HTMLDDA?function(t){return"function"==typeof t||t===o}:function(t){return"function"==typeof t}},4705:function(t,e,n){var r=n(7293),o=n(614),i=/#|\.prototype\./,s=function(t,e){var n=a[l(t)];return n==h||n!=c&&(o(e)?r(e):!!e)},l=s.normalize=function(t){return String(t).replace(i,".").toLowerCase()},a=s.data={},c=s.NATIVE="N",h=s.POLYFILL="P";t.exports=s},8554:function(t){t.exports=function(t){return null===t||void 0===t}},111:function(t,e,n){var r=n(614),o=n(4154),i=o.all;t.exports=o.IS_HTMLDDA?function(t){return"object"==typeof t?null!==t:r(t)||t===i}:function(t){return"object"==typeof t?null!==t:r(t)}},1913:function(t){t.exports=!1},2190:function(t,e,n){var r=n(5005),o=n(614),i=n(7976),s=n(3307),l=Object;t.exports=s?function(t){return"symbol"==typeof t}:function(t){var e=r("Symbol");return o(e)&&i(e.prototype,l(t))}},6244:function(t,e,n){var r=n(7466);t.exports=function(t){return r(t.length)}},6339:function(t,e,n){var r=n(1702),o=n(7293),i=n(614),s=n(2597),l=n(9781),a=n(6530).CONFIGURABLE,c=n(2788),h=n(9909),d=h.enforce,u=h.get,p=String,f=Object.defineProperty,m=r("".slice),g=r("".replace),y=r([].join),w=l&&!o((function(){return 8!==f((function(){}),"length",{value:8}).length})),v=String(String).split("String"),b=t.exports=function(t,e,n){"Symbol("===m(p(e),0,7)&&(e="["+g(p(e),/^Symbol\(([^)]*)\)/,"$1")+"]"),n&&n.getter&&(e="get "+e),n&&n.setter&&(e="set "+e),(!s(t,"name")||a&&t.name!==e)&&(l?f(t,"name",{value:e,configurable:!0}):t.name=e),w&&n&&s(n,"arity")&&t.length!==n.arity&&f(t,"length",{value:n.arity});try{n&&s(n,"constructor")&&n.constructor?l&&f(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch(o){}var r=d(t);return s(r,"source")||(r.source=y(v,"string"==typeof e?e:"")),t};Function.prototype.toString=b((function(){return i(this)&&u(this).source||c(this)}),"toString")},4758:function(t){var e=Math.ceil,n=Math.floor;t.exports=Math.trunc||function(t){var r=+t;return(r>0?n:e)(r)}},3070:function(t,e,n){var r=n(9781),o=n(4664),i=n(3353),s=n(9670),l=n(4948),a=TypeError,c=Object.defineProperty,h=Object.getOwnPropertyDescriptor,d="enumerable",u="configurable",p="writable";e.f=r?i?function(t,e,n){if(s(t),e=l(e),s(n),"function"===typeof t&&"prototype"===e&&"value"in n&&p in n&&!n[p]){var r=h(t,e);r&&r[p]&&(t[e]=n.value,n={configurable:u in n?n[u]:r[u],enumerable:d in n?n[d]:r[d],writable:!1})}return c(t,e,n)}:c:function(t,e,n){if(s(t),e=l(e),s(n),o)try{return c(t,e,n)}catch(r){}if("get"in n||"set"in n)throw a("Accessors not supported");return"value"in n&&(t[e]=n.value),t}},1236:function(t,e,n){var r=n(9781),o=n(6916),i=n(5296),s=n(9114),l=n(5656),a=n(4948),c=n(2597),h=n(4664),d=Object.getOwnPropertyDescriptor;e.f=r?d:function(t,e){if(t=l(t),e=a(e),h)try{return d(t,e)}catch(n){}if(c(t,e))return s(!o(i.f,t,e),t[e])}},8006:function(t,e,n){var r=n(6324),o=n(748),i=o.concat("length","prototype");e.f=Object.getOwnPropertyNames||function(t){return r(t,i)}},5181:function(t,e){e.f=Object.getOwnPropertySymbols},7976:function(t,e,n){var r=n(1702);t.exports=r({}.isPrototypeOf)},6324:function(t,e,n){var r=n(1702),o=n(2597),i=n(5656),s=n(1318).indexOf,l=n(3501),a=r([].push);t.exports=function(t,e){var n,r=i(t),c=0,h=[];for(n in r)!o(l,n)&&o(r,n)&&a(h,n);while(e.length>c)o(r,n=e[c++])&&(~s(h,n)||a(h,n));return h}},5296:function(t,e){"use strict";var n={}.propertyIsEnumerable,r=Object.getOwnPropertyDescriptor,o=r&&!n.call({1:2},1);e.f=o?function(t){var e=r(this,t);return!!e&&e.enumerable}:n},2140:function(t,e,n){var r=n(6916),o=n(614),i=n(111),s=TypeError;t.exports=function(t,e){var n,l;if("string"===e&&o(n=t.toString)&&!i(l=r(n,t)))return l;if(o(n=t.valueOf)&&!i(l=r(n,t)))return l;if("string"!==e&&o(n=t.toString)&&!i(l=r(n,t)))return l;throw s("Can't convert object to primitive value")}},3887:function(t,e,n){var r=n(5005),o=n(1702),i=n(8006),s=n(5181),l=n(9670),a=o([].concat);t.exports=r("Reflect","ownKeys")||function(t){var e=i.f(l(t)),n=s.f;return n?a(e,n(t)):e}},4488:function(t,e,n){var r=n(8554),o=TypeError;t.exports=function(t){if(r(t))throw o("Can't call method on "+t);return t}},6200:function(t,e,n){var r=n(2309),o=n(9711),i=r("keys");t.exports=function(t){return i[t]||(i[t]=o(t))}},5465:function(t,e,n){var r=n(7854),o=n(3072),i="__core-js_shared__",s=r[i]||o(i,{});t.exports=s},2309:function(t,e,n){var r=n(1913),o=n(5465);(t.exports=function(t,e){return o[t]||(o[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.29.1",mode:r?"pure":"global",copyright:"© 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.29.1/LICENSE",source:"https://github.com/zloirock/core-js"})},6293:function(t,e,n){var r=n(7392),o=n(7293);t.exports=!!Object.getOwnPropertySymbols&&!o((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&r&&r<41}))},1400:function(t,e,n){var r=n(9303),o=Math.max,i=Math.min;t.exports=function(t,e){var n=r(t);return n<0?o(n+e,0):i(n,e)}},5656:function(t,e,n){var r=n(8361),o=n(4488);t.exports=function(t){return r(o(t))}},9303:function(t,e,n){var r=n(4758);t.exports=function(t){var e=+t;return e!==e||0===e?0:r(e)}},7466:function(t,e,n){var r=n(9303),o=Math.min;t.exports=function(t){return t>0?o(r(t),9007199254740991):0}},7908:function(t,e,n){var r=n(4488),o=Object;t.exports=function(t){return o(r(t))}},7593:function(t,e,n){var r=n(6916),o=n(111),i=n(2190),s=n(8173),l=n(2140),a=n(5112),c=TypeError,h=a("toPrimitive");t.exports=function(t,e){if(!o(t)||i(t))return t;var n,a=s(t,h);if(a){if(void 0===e&&(e="default"),n=r(a,t,e),!o(n)||i(n))return n;throw c("Can't convert object to primitive value")}return void 0===e&&(e="number"),l(t,e)}},4948:function(t,e,n){var r=n(7593),o=n(2190);t.exports=function(t){var e=r(t,"string");return o(e)?e:e+""}},6330:function(t){var e=String;t.exports=function(t){try{return e(t)}catch(n){return"Object"}}},9711:function(t,e,n){var r=n(1702),o=0,i=Math.random(),s=r(1..toString);t.exports=function(t){return"Symbol("+(void 0===t?"":t)+")_"+s(++o+i,36)}},3307:function(t,e,n){var r=n(6293);t.exports=r&&!Symbol.sham&&"symbol"==typeof Symbol.iterator},3353:function(t,e,n){var r=n(9781),o=n(7293);t.exports=r&&o((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))},4811:function(t,e,n){var r=n(7854),o=n(614),i=r.WeakMap;t.exports=o(i)&&/native code/.test(String(i))},5112:function(t,e,n){var r=n(7854),o=n(2309),i=n(2597),s=n(9711),l=n(6293),a=n(3307),c=r.Symbol,h=o("wks"),d=a?c["for"]||c:c&&c.withoutSetter||s;t.exports=function(t){return i(h,t)||(h[t]=l&&i(c,t)?c[t]:d("Symbol."+t)),h[t]}},7658:function(t,e,n){"use strict";var r=n(2109),o=n(7908),i=n(6244),s=n(3658),l=n(7207),a=n(7293),c=a((function(){return 4294967297!==[].push.call({length:4294967296},1)})),h=function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(t){return t instanceof TypeError}},d=c||!h();r({target:"Array",proto:!0,arity:1,forced:d},{push:function(t){var e=o(this),n=i(e),r=arguments.length;l(n+r);for(var a=0;a>1}},i.from=function(t){if(t instanceof i)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new i(e)};var s=i;function l(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let o=t.child(r),i=e.child(r);if(o!=i){if(!o.sameMarkup(i))return n;if(o.isText&&o.text!=i.text){for(let t=0;o.text[t]==i.text[t];t++)n++;return n}if(o.content.size||i.content.size){let t=l(o.content,i.content,n+1);if(null!=t)return t}n+=o.nodeSize}else n+=o.nodeSize}}function a(t,e,n,r){for(let o=t.childCount,i=e.childCount;;){if(0==o||0==i)return o==i?null:{a:n,b:r};let s=t.child(--o),l=e.child(--i),c=s.nodeSize;if(s!=l){if(!s.sameMarkup(l))return{a:n,b:r};if(s.isText&&s.text!=l.text){let t=0,e=Math.min(s.text.length,l.text.length);while(tt&&!1!==n(l,r+s,o||null,i)&&l.content.size){let o=s+1;l.nodesBetween(Math.max(0,t-o),Math.min(l.content.size,e-o),n,r+o)}s=a}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,n,r){let o="",i=!0;return this.nodesBetween(t,e,((s,l)=>{s.isText?(o+=s.text.slice(Math.max(t,l)-l,e-l),i=!n):s.isLeaf?(r?o+="function"===typeof r?r(s):r:s.type.spec.leafText&&(o+=s.type.spec.leafText(s)),i=!n):!i&&s.isBlock&&(o+=n,i=!0)}),0),o}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,n=t.firstChild,r=this.content.slice(),o=0;for(e.isText&&e.sameMarkup(n)&&(r[r.length-1]=e.withText(e.text+n.text),o=1);ot)for(let o=0,i=0;it&&((ie)&&(s=s.isText?s.cut(Math.max(0,t-i),Math.min(s.text.length,e-i)):s.cut(Math.max(0,t-i-1),Math.min(s.content.size,e-i-1))),n.push(s),r+=s.nodeSize),i=l}return new c(n,r)}cutByIndex(t,e){return t==e?c.empty:0==t&&e==this.content.length?this:new c(this.content.slice(t,e))}replaceChild(t,e){let n=this.content[t];if(n==e)return this;let r=this.content.slice(),o=this.size+e.nodeSize-n.nodeSize;return r[t]=e,new c(r,o)}addToStart(t){return new c([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new c(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let e=0;ethis.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let n=0,r=0;;n++){let o=this.child(n),i=r+o.nodeSize;if(i>=t)return i==t||e>0?d(n+1,i):d(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((t=>t.toJSON())):null}static fromJSON(t,e){if(!e)return c.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new c(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return c.empty;let e,n=0;for(let r=0;rthis.type.rank&&(e||(e=t.slice(0,r)),e.push(this),n=!0),e&&e.push(o)}}return e||(e=t.slice()),n||e.push(this),e}removeFromSet(t){for(let e=0;et.type.rank-e.type.rank)),e}}p.none=[];class f extends Error{}class m{constructor(t,e,n){this.content=t,this.openStart=e,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,e){let n=y(this.content,t+this.openStart,e);return n&&new m(n,this.openStart,this.openEnd)}removeBetween(t,e){return new m(g(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,e){if(!e)return m.empty;let n=e.openStart||0,r=e.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new m(c.fromJSON(t,e.content),n,r)}static maxOpen(t,e=!0){let n=0,r=0;for(let o=t.firstChild;o&&!o.isLeaf&&(e||!o.type.spec.isolating);o=o.firstChild)n++;for(let o=t.lastChild;o&&!o.isLeaf&&(e||!o.type.spec.isolating);o=o.lastChild)r++;return new m(t,n,r)}}function g(t,e,n){let{index:r,offset:o}=t.findIndex(e),i=t.maybeChild(r),{index:s,offset:l}=t.findIndex(n);if(o==e||i.isText){if(l!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(g(i.content,e-o-1,n-o-1)))}function y(t,e,n,r){let{index:o,offset:i}=t.findIndex(e),s=t.maybeChild(o);if(i==e||s.isText)return r&&!r.canReplace(o,o,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=y(s.content,e-i-1,n);return l&&t.replaceChild(o,s.copy(l))}function w(t,e,n){if(n.openStart>t.depth)throw new f("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new f("Inconsistent open depths");return v(t,e,n,0)}function v(t,e,n,r){let o=t.index(r),i=t.node(r);if(o==e.index(r)&&r=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function S(t,e,n,r){let o=(e||t).node(n),i=0,s=e?e.index(n):o.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(k(t.nodeAfter,r),i++));for(let l=i;lo&&x(t,e,o+1),s=r.depth>o&&x(n,r,o+1),l=[];return S(null,t,o,l),i&&s&&e.index(o)==n.index(o)?(b(i,s),k(C(i,M(t,e,n,r,o+1)),l)):(i&&k(C(i,O(t,e,o+1)),l),S(e,n,o,l),s&&k(C(s,O(n,r,o+1)),l)),S(r,null,o,l),new c(l)}function O(t,e,n){let r=[];if(S(null,t,n,r),t.depth>n){let o=x(t,e,n+1);k(C(o,O(t,e,n+1)),r)}return S(e,null,n,r),new c(r)}function N(t,e){let n=e.depth-t.openStart,r=e.node(n),o=r.copy(t.content);for(let i=n-1;i>=0;i--)o=e.node(i).copy(c.from(o));return{start:o.resolveNoCache(t.openStart+n),end:o.resolveNoCache(o.content.size-t.openEnd-n)}}m.empty=new m(c.empty,0,0);class E{constructor(t,e,n){this.pos=t,this.path=e,this.parentOffset=n,this.depth=e.length/3-1}resolveDepth(t){return null==t?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[3*this.resolveDepth(t)]}index(t){return this.path[3*this.resolveDepth(t)+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t!=this.depth||this.textOffset?1:0)}start(t){return t=this.resolveDepth(t),0==t?0:this.path[3*t-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]}after(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]+this.path[3*t].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=t.child(e);return n?t.child(e).cut(n):r}get nodeBefore(){let t=this.index(this.depth),e=this.pos-this.path[this.path.length-1];return e?this.parent.child(t).cut(0,e):0==t?null:this.parent.child(t-1)}posAtIndex(t,e){e=this.resolveDepth(e);let n=this.path[3*e],r=0==e?0:this.path[3*e-1]+1;for(let o=0;o0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0}blockRange(t=this,e){if(t.pos=0;n--)if(t.pos<=this.end(n)&&(!e||e(this.node(n))))return new R(this,t,n);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");let n=[],r=0,o=e;for(let i=t;;){let{index:t,offset:e}=i.content.findIndex(o),s=o-e;if(n.push(i,t,r+e),!s)break;if(i=i.child(t),i.isText)break;o=s-1,r+=e+1}return new E(e,n,o)}static resolveCached(t,e){for(let r=0;rt&&this.nodesBetween(t,e,(t=>(n.isInSet(t.marks)&&(r=!0),!r))),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),$(this.marks,t)}contentMatchAt(t){let e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e}canReplace(t,e,n=c.empty,r=0,o=n.childCount){let i=this.contentMatchAt(t).matchFragment(n,r,o),s=i&&i.matchFragment(this.content,e);if(!s||!s.validEnd)return!1;for(let l=r;lt.type.name))}`);this.content.forEach((t=>t.check()))}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map((t=>t.toJSON()))),t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");let n=null;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=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,n)}let r=c.fromJSON(t,e.content);return t.nodeType(e.type).create(e.attrs,r,n)}}_.prototype.text=void 0;class I extends _{constructor(t,e,n,r){if(super(t,e,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):$(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,e){return this.text.slice(t,e)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new I(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new I(this.type,this.attrs,t,this.marks)}cut(t=0,e=this.text.length){return 0==t&&e==this.text.length?this:this.withText(this.text.slice(t,e))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}}function $(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class P{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,e){let n=new B(t,e);if(null==n.next)return P.empty;let r=V(n);n.next&&n.err("Unexpected trailing text");let o=G(q(r));return X(o,n),o}matchType(t){for(let e=0;et.createAndFill())));for(let t=0;t=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];function e(n){t.push(n);for(let r=0;r{let r=n+(e.validEnd?"*":" ")+" ";for(let o=0;o"+t.indexOf(e.next[o].next);return r})).join("\n")}}P.empty=new P(!0);class B{constructor(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}}function V(t){let e=[];do{e.push(F(t))}while(t.eat("|"));return 1==e.length?e[0]:{type:"choice",exprs:e}}function F(t){let e=[];do{e.push(L(t))}while(t.next&&")"!=t.next&&"|"!=t.next);return 1==e.length?e[0]:{type:"seq",exprs:e}}function L(t){let e=W(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else{if(!t.eat("{"))break;e=H(t,e)}return e}function j(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function H(t,e){let n=j(t),r=n;return t.eat(",")&&(r="}"!=t.next?j(t):-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function J(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let o=[];for(let i in n){let t=n[i];t.groups.indexOf(e)>-1&&o.push(t)}return 0==o.length&&t.err("No node type or group '"+e+"' found"),o}function W(t){if(t.eat("(")){let e=V(t);return t.eat(")")||t.err("Missing closing paren"),e}if(!/\W/.test(t.next)){let e=J(t,t.next).map((e=>(null==t.inline?t.inline=e.isInline:t.inline!=e.isInline&&t.err("Mixing inline and block content"),{type:"name",value:e})));return t.pos++,1==e.length?e[0]:{type:"choice",exprs:e}}t.err("Unexpected token '"+t.next+"'")}function q(t){let e=[[]];return o(i(t,0),n()),e;function n(){return e.push([])-1}function r(t,n,r){let o={term:r,to:n};return e[t].push(o),o}function o(t,e){t.forEach((t=>t.to=e))}function i(t,e){if("choice"==t.type)return t.exprs.reduce(((t,n)=>t.concat(i(n,e))),[]);if("seq"!=t.type){if("star"==t.type){let s=n();return r(e,s),o(i(t.expr,s),s),[r(s)]}if("plus"==t.type){let s=n();return o(i(t.expr,e),s),o(i(t.expr,s),s),[r(s)]}if("opt"==t.type)return[r(e)].concat(i(t.expr,e));if("range"==t.type){let s=e;for(let e=0;e{t[e].forEach((({term:e,to:n})=>{if(!e)return;let r;for(let t=0;t{r||o.push([e,r=[]]),-1==r.indexOf(t)&&r.push(t)}))}))}));let i=e[r.join(",")]=new P(r.indexOf(t.length-1)>-1);for(let t=0;t-1}allowsMarks(t){if(null==this.markSet)return!0;for(let e=0;en[t]=new tt(t,e,r)));let r=e.spec.topNode||"doc";if(!n[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let o in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}}class et{constructor(t){this.hasDefault=Object.prototype.hasOwnProperty.call(t,"default"),this.default=t.default}get isRequired(){return!this.hasDefault}}class nt{constructor(t,e,n,r){this.name=t,this.rank=e,this.schema=n,this.spec=r,this.attrs=Q(r.attrs),this.excluded=null;let o=Y(this.attrs);this.instance=o?new p(this,o):null}create(t=null){return!t&&this.instance?this.instance:new p(this,Z(this.attrs,t))}static compile(t,e){let n=Object.create(null),r=0;return t.forEach(((t,o)=>n[t]=new nt(t,r++,e,o))),n}removeFromSet(t){for(var e=0;e-1}}class rt{constructor(t){this.cached=Object.create(null);let e=this.spec={};for(let r in t)e[r]=t[r];e.nodes=s.from(t.nodes),e.marks=s.from(t.marks||{}),this.nodes=tt.compile(this.spec.nodes,this),this.marks=nt.compile(this.spec.marks,this);let n=Object.create(null);for(let r in this.nodes){if(r in this.marks)throw new RangeError(r+" can not be both a node and a mark");let t=this.nodes[r],e=t.spec.content||"",o=t.spec.marks;t.contentMatch=n[e]||(n[e]=P.parse(e,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.markSet="_"==o?null:o?ot(this,o.split(" ")):""!=o&&t.inlineContent?null:[]}for(let r in this.marks){let t=this.marks[r],e=t.spec.excludes;t.excluded=null==e?[t]:""==e?[]:ot(this,e.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(t,e=null,n,r){if("string"==typeof t)t=this.nodeType(t);else{if(!(t instanceof tt))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,n,r)}text(t,e){let n=this.nodes.text;return new I(n,n.defaultAttrs,t,p.setFrom(e))}mark(t,e){return"string"==typeof t&&(t=this.marks[t]),t.create(e)}nodeFromJSON(t){return _.fromJSON(this,t)}markFromJSON(t){return p.fromJSON(this,t)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}}function ot(t,e){let n=[];for(let r=0;r-1)&&n.push(s=r)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}class it{constructor(t,e){this.schema=t,this.rules=e,this.tags=[],this.styles=[],e.forEach((t=>{t.tag?this.tags.push(t):t.style&&this.styles.push(t)})),this.normalizeLists=!this.tags.some((e=>{if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return!1;let n=t.nodes[e.node];return n.contentMatch.matchType(n)}))}parse(t,e={}){let n=new ft(this,e,!1);return n.addAll(t,e.from,e.to),n.finish()}parseSlice(t,e={}){let n=new ft(this,e,!0);return n.addAll(t,e.from,e.to),m.maxOpen(n.finish())}matchTag(t,e,n){for(let r=n?this.tags.indexOf(n)+1:0;rt.length&&(61!=i.charCodeAt(t.length)||i.slice(t.length+1)!=e))){if(r.getAttrs){let t=r.getAttrs(e);if(!1===t)continue;r.attrs=t||void 0}return r}}}static schemaRules(t){let e=[];function n(t){let n=null==t.priority?50:t.priority,r=0;for(;r{n(t=wt(t)),t.mark||t.ignore||t.clearMark||(t.mark=r)}))}for(let r in t.nodes){let e=t.nodes[r].spec.parseDOM;e&&e.forEach((t=>{n(t=wt(t)),t.node||t.ignore||t.mark||(t.node=r)}))}return e}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new it(t,it.schemaRules(t)))}}const st={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},lt={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},at={ol:!0,ul:!0},ct=1,ht=2,dt=4;function ut(t,e,n){return null!=e?(e?ct:0)|("full"===e?ht:0):t&&"pre"==t.whitespace?ct|ht:n&~dt}class pt{constructor(t,e,n,r,o,i,s){this.type=t,this.attrs=e,this.marks=n,this.pendingMarks=r,this.solid=o,this.options=s,this.content=[],this.activeMarks=p.none,this.stashMarks=[],this.match=i||(s&dt?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(c.from(t));if(!e){let e,n=this.type.contentMatch;return(e=n.findWrapping(t.type))?(this.match=n,e):null}this.match=this.type.contentMatch.matchFragment(e)}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&ct)){let t,e=this.content[this.content.length-1];if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let e=c.from(this.content);return!t&&this.match&&(e=e.append(this.match.fillBefore(c.empty,!0))),this.type?this.type.create(this.attrs,e,this.marks):e}popFromStashMark(t){for(let e=this.stashMarks.length-1;e>=0;e--)if(t.eq(this.stashMarks[e]))return this.stashMarks.splice(e,1)[0]}applyPending(t){for(let e=0,n=this.pendingMarks;e{i.clearMark(t)&&(n=t.addToSet(n))})):e=this.parser.schema.marks[i.mark].create(i.attrs).addToSet(e),!1!==i.consuming)break;o=i}return[e,n]}addElementByRule(t,e,n){let r,o,i;if(e.node)o=this.parser.schema.nodes[e.node],o.isLeaf?this.insertNode(o.create(e.attrs))||this.leafFallback(t):r=this.enter(o,e.attrs||null,e.preserveWhitespace);else{let t=this.parser.schema.marks[e.mark];i=t.create(e.attrs),this.addPendingMark(i)}let s=this.top;if(o&&o.isLeaf)this.findInside(t);else if(n)this.addElement(t,n);else if(e.getContent)this.findInside(t),e.getContent(t,this.parser.schema).forEach((t=>this.insertNode(t)));else{let n=t;"string"==typeof e.contentElement?n=t.querySelector(e.contentElement):"function"==typeof e.contentElement?n=e.contentElement(t):e.contentElement&&(n=e.contentElement),this.findAround(t,n,!0),this.addAll(n)}r&&this.sync(s)&&this.open--,i&&this.removePendingMark(i,s)}addAll(t,e,n){let r=e||0;for(let o=e?t.childNodes[e]:t.firstChild,i=null==n?null:t.childNodes[n];o!=i;o=o.nextSibling,++r)this.findAtPoint(t,r),this.addDOM(o);this.findAtPoint(t,r)}findPlace(t){let e,n;for(let r=this.open;r>=0;r--){let o=this.nodes[r],i=o.findWrapping(t);if(i&&(!e||e.length>i.length)&&(e=i,n=o,!i.length))break;if(o.solid)break}if(!e)return!1;this.sync(n);for(let r=0;rthis.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(t){for(let e=this.open;e>=0;e--)if(this.nodes[e]==t)return this.open=e,!0;return!1}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let n=this.nodes[e].content;for(let e=n.length-1;e>=0;e--)t+=n[e].nodeSize;e&&t++}return t}findAtPoint(t,e){if(this.find)for(let n=0;n-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let e=t.split("/"),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),o=-(n?n.depth+1:0)+(r?0:1),i=(t,s)=>{for(;t>=0;t--){let l=e[t];if(""==l){if(t==e.length-1||0==t)continue;for(;s>=o;s--)if(i(t-1,s))return!0;return!1}{let t=s>0||0==s&&r?this.nodes[s].type:n&&s>=o?n.node(s-o).type:null;if(!t||t.name!=l&&-1==t.groups.indexOf(l))return!1;s--}}return!0};return i(e.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let e=t.depth;e>=0;e--){let n=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}addPendingMark(t){let e=bt(t,this.top.pendingMarks);e&&this.top.stashMarks.push(e),this.top.pendingMarks=t.addToSet(this.top.pendingMarks)}removePendingMark(t,e){for(let n=this.open;n>=0;n--){let r=this.nodes[n],o=r.pendingMarks.lastIndexOf(t);if(o>-1)r.pendingMarks=t.removeFromSet(r.pendingMarks);else{r.activeMarks=t.removeFromSet(r.activeMarks);let e=r.popFromStashMark(t);e&&r.type&&r.type.allowsMarkType(e.type)&&(r.activeMarks=e.addToSet(r.activeMarks))}if(r==e)break}}}function mt(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let t=1==e.nodeType?e.nodeName.toLowerCase():null;t&&at.hasOwnProperty(t)&&n?(n.appendChild(e),e=n):"li"==t?n=e:t&&(n=null)}}function gt(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function yt(t){let e,n=/\s*([\w-]+)\s*:\s*([^;]+)/g,r=[];while(e=n.exec(t))r.push(e[1],e[2].trim());return r}function wt(t){let e={};for(let n in t)e[n]=t[n];return e}function vt(t,e){let n=e.schema.nodes;for(let r in n){let o=n[r];if(!o.allowsMarkType(t))continue;let i=[],s=t=>{i.push(t);for(let n=0;n{if(o.length||t.marks.length){let n=0,i=0;while(n=0;r--){let o=this.serializeMark(t.marks[r],t.isInline,e);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(t,e,n={}){let r=this.marks[t.type.name];return r&&xt.renderSpec(St(n),r(t,e))}static renderSpec(t,e,n=null){if("string"==typeof e)return{dom:t.createTextNode(e)};if(null!=e.nodeType)return{dom:e};if(e.dom&&null!=e.dom.nodeType)return e;let r,o=e[0],i=o.indexOf(" ");i>0&&(n=o.slice(0,i),o=o.slice(i+1));let s=n?t.createElementNS(n,o):t.createElement(o),l=e[1],a=1;if(l&&"object"==typeof l&&null==l.nodeType&&!Array.isArray(l)){a=2;for(let t in l)if(null!=l[t]){let e=t.indexOf(" ");e>0?s.setAttributeNS(t.slice(0,e),t.slice(e+1),l[t]):s.setAttribute(t,l[t])}}for(let c=a;ca)throw new RangeError("Content hole must be the only child of its parent node");return{dom:s,contentDOM:s}}{let{dom:e,contentDOM:i}=xt.renderSpec(t,o,n);if(s.appendChild(e),i){if(r)throw new RangeError("Multiple content holes");r=i}}}return{dom:s,contentDOM:r}}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new xt(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let e=kt(t.nodes);return e.text||(e.text=t=>t.text),e}static marksFromSchema(t){return kt(t.marks)}}function kt(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function St(t){return t.document||window.document}r(541);const Ct=65535,Mt=Math.pow(2,16);function Ot(t,e){return t+e*Mt}function Nt(t){return t&Ct}function Et(t){return(t-(t&Ct))/Mt}const At=1,Dt=2,Tt=4,Rt=8;class zt{constructor(t,e,n){this.pos=t,this.delInfo=e,this.recover=n}get deleted(){return(this.delInfo&Rt)>0}get deletedBefore(){return(this.delInfo&(At|Tt))>0}get deletedAfter(){return(this.delInfo&(Dt|Tt))>0}get deletedAcross(){return(this.delInfo&Tt)>0}}class _t{constructor(t,e=!1){if(this.ranges=t,this.inverted=e,!t.length&&_t.empty)return _t.empty}recover(t){let e=0,n=Nt(t);if(!this.inverted)for(let r=0;rt)break;let a=this.ranges[s+o],c=this.ranges[s+i],h=l+a;if(t<=h){let o=a?t==l?-1:t==h?1:e:e,i=l+r+(o<0?0:c);if(n)return i;let d=t==(e<0?l:h)?null:Ot(s/3,t-l),u=t==l?Dt:t==h?At:Tt;return(e<0?t!=l:t!=h)&&(u|=Rt),new zt(i,u,d)}r+=c-a}return n?t+r:new zt(t+r,0,null)}touches(t,e){let n=0,r=Nt(e),o=this.inverted?2:1,i=this.inverted?1:2;for(let s=0;st)break;let l=this.ranges[s+o],a=e+l;if(t<=a&&s==3*r)return!0;n+=this.ranges[s+i]-l}return!1}forEach(t){let e=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,o=0;r=0;e--){let r=t.getMirror(e);this.appendMap(t.maps[e].invert(),null!=r&&r>e?n-r-1:void 0)}}invert(){let t=new It;return t.appendMappingInverted(this),t}map(t,e=1){if(this.mirror)return this._map(t,e,!0);for(let n=this.from;no&&et.isAtom&&e.type.allowsMarkType(this.mark.type)?t.mark(this.mark.addToSet(t.marks)):t),r),e.openStart,e.openEnd);return Bt.fromReplace(t,this.from,this.to,o)}invert(){return new Lt(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deleted&&n.deleted||e.pos>=n.pos?null:new Ft(e.pos,n.pos,this.mark)}merge(t){return t instanceof Ft&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new Ft(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Ft(e.from,e.to,t.markFromJSON(e.mark))}}Pt.jsonID("addMark",Ft);class Lt extends Pt{constructor(t,e,n){super(),this.from=t,this.to=e,this.mark=n}apply(t){let e=t.slice(this.from,this.to),n=new m(Vt(e.content,(t=>t.mark(this.mark.removeFromSet(t.marks))),t),e.openStart,e.openEnd);return Bt.fromReplace(t,this.from,this.to,n)}invert(){return new Ft(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deleted&&n.deleted||e.pos>=n.pos?null:new Lt(e.pos,n.pos,this.mark)}merge(t){return t instanceof Lt&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new Lt(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Lt(e.from,e.to,t.markFromJSON(e.mark))}}Pt.jsonID("removeMark",Lt);class jt extends Pt{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return Bt.fail("No node at mark step's position");let n=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return Bt.fromReplace(t,this.pos,this.pos+1,new m(c.from(n),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(e){let t=this.mark.addToSet(e.marks);if(t.length==e.marks.length){for(let n=0;nn.pos?null:new Wt(e.pos,n.pos,r,o,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to||"number"!=typeof e.gapFrom||"number"!=typeof e.gapTo||"number"!=typeof e.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Wt(e.from,e.to,e.gapFrom,e.gapTo,m.fromJSON(t,e.slice),e.insert,!!e.structure)}}function qt(t,e,n){let r=t.resolve(e),o=n-e,i=r.depth;while(o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount)i--,o--;if(o>0){let t=r.node(i).maybeChild(r.indexAfter(i));while(o>0){if(!t||t.isLeaf)return!0;t=t.firstChild,o--}}return!1}function Kt(t,e,n,r){let o,i,s=[],l=[];t.doc.nodesBetween(e,n,((t,a,c)=>{if(!t.isInline)return;let h=t.marks;if(!r.isInSet(h)&&c.type.allowsMarkType(r.type)){let c=Math.max(a,e),d=Math.min(a+t.nodeSize,n),u=r.addToSet(h);for(let t=0;tt.step(e))),l.forEach((e=>t.step(e)))}function Ut(t,e,n,r){let o=[],i=0;t.doc.nodesBetween(e,n,((t,s)=>{if(!t.isInline)return;i++;let l=null;if(r instanceof nt){let e,n=t.marks;while(e=r.isInSet(n))(l||(l=[])).push(e),n=e.removeFromSet(n)}else r?r.isInSet(t.marks)&&(l=[r]):l=t.marks;if(l&&l.length){let r=Math.min(s+t.nodeSize,n);for(let t=0;tt.step(new Lt(e.from,e.to,e.style))))}function Gt(t,e,n,r=n.contentMatch){let o=t.doc.nodeAt(e),i=[],s=e+1;for(let l=0;l=0;l--)t.step(i[l])}function Xt(t,e,n){return(0==e||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Yt(t){let e=t.parent,n=e.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth;;--r){let e=t.$from.node(r),o=t.$from.index(r),i=t.$to.indexAfter(r);if(rn;m--)g||r.index(m)>0?(g=!0,d=c.from(r.node(m).copy(d)),u++):a--;let p=c.empty,f=0;for(let m=i,g=!1;m>n;m--)g||o.after(m+1)=0;s--){if(r.size){let t=n[s].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=c.from(n[s].type.create(n[s].attrs,r))}let o=e.start,i=e.end;t.step(new Wt(o,i,o,i,new m(r,0,0),n.length,!0))}function oe(t,e,n,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,((e,n)=>{if(e.isTextblock&&!e.hasMarkup(r,o)&&ie(t.doc,t.mapping.slice(i).map(n),r)){t.clearIncompatible(t.mapping.slice(i).map(n,1),r);let s=t.mapping.slice(i),l=s.map(n,1),a=s.map(n+e.nodeSize,1);return t.step(new Wt(l,a,l+1,a-1,new m(c.from(r.create(o,null,e.marks)),0,0),1,!0)),!1}}))}function ie(t,e,n){let r=t.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}function se(t,e,n,r,o){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let s=n.create(r,null,o||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,s);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Wt(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new m(c.from(s),0,0),1,!0))}function le(t,e,n=1,r){let o=t.resolve(e),i=o.depth-n,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,h=n-2;c>i;c--,h--){let t=o.node(c),e=o.index(c);if(t.type.spec.isolating)return!1;let n=t.content.cutByIndex(e,t.childCount),i=r&&r[h]||t;if(i!=t&&(n=n.replaceChild(0,i.type.create(i.attrs))),!t.canReplace(e+1,t.childCount)||!i.type.validContent(n))return!1}let l=o.indexAfter(i),a=r&&r[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function ae(t,e,n=1,r){let o=t.doc.resolve(e),i=c.empty,s=c.empty;for(let l=o.depth,a=o.depth-n,h=n-1;l>a;l--,h--){i=c.from(o.node(l).copy(i));let t=r&&r[h];s=c.from(t?t.type.create(t.attrs,s):o.node(l).copy(s))}t.step(new Jt(e,e,new m(i.append(s),n,n),!0))}function ce(t,e){let n=t.resolve(e),r=n.index();return he(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function he(t,e){return!(!t||!e||t.isLeaf||!t.canAppend(e))}function de(t,e,n){let r=new Jt(e-n,e+n,m.empty,!0);t.step(r)}function ue(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(0==r.parentOffset)for(let o=r.depth-1;o>=0;o--){let t=r.index(o);if(r.node(o).canReplaceWith(t,t,n))return r.before(o+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let t=r.indexAfter(o);if(r.node(o).canReplaceWith(t,t,n))return r.after(o+1);if(t=0;t--){let e=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,n=r.index(t)+(e>0?1:0),s=r.node(t),l=!1;if(1==i)l=s.canReplace(n,n,o);else{let t=s.contentMatchAt(n).findWrapping(o.firstChild.type);l=t&&s.canReplaceWith(n,n,t[0])}if(l)return 0==e?r.pos:e<0?r.before(t+1):r.after(t+1)}return null}function fe(t,e,n=e,r=m.empty){if(e==n&&!r.size)return null;let o=t.resolve(e),i=t.resolve(n);return me(o,i,r)?new Jt(e,n,r):new ge(o,i,r).fit()}function me(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}Pt.jsonID("replaceAround",Wt);class ge{constructor(t,e,n){this.$from=t,this.$to=e,this.unplaced=n,this.frontier=[],this.placed=c.empty;for(let r=0;r<=t.depth;r++){let e=t.node(r);this.frontier.push({type:e.type,match:e.contentMatchAt(t.indexAfter(r))})}for(let r=t.depth;r>0;r--)this.placed=c.from(t.node(r).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){while(this.unplaced.size){let t=this.findFittable();t?this.placeNodes(t):this.openMore()||this.dropNode()}let t=this.mustMoveInline(),e=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(t<0?this.$to:n.doc.resolve(t));if(!r)return null;let o=this.placed,i=n.depth,s=r.depth;while(i&&s&&1==o.childCount)o=o.firstChild.content,i--,s--;let l=new m(o,i,s);return t>-1?new Wt(n.pos,t,this.$to.pos,this.$to.end(),l,e):l.size||n.pos!=this.$to.pos?new Jt(n.pos,r.pos,l):null}findFittable(){let t=this.unplaced.openStart;for(let e=this.unplaced.content,n=0,r=this.unplaced.openEnd;n1&&(r=0),o.type.spec.isolating&&r<=n){t=n;break}e=o.content}for(let e=1;e<=2;e++)for(let n=1==e?t:this.unplaced.openStart;n>=0;n--){let t,r=null;n?(r=ve(this.unplaced.content,n-1).firstChild,t=r.content):t=this.unplaced.content;let o=t.firstChild;for(let i=this.depth;i>=0;i--){let t,{type:s,match:l}=this.frontier[i],a=null;if(1==e&&(o?l.matchType(o.type)||(a=l.fillBefore(c.from(o),!1)):r&&s.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:i,parent:r,inject:a};if(2==e&&o&&(t=l.findWrapping(o.type)))return{sliceDepth:n,frontierDepth:i,parent:r,wrap:t};if(r&&l.matchType(r.type))break}}}openMore(){let{content:t,openStart:e,openEnd:n}=this.unplaced,r=ve(t,e);return!(!r.childCount||r.firstChild.isLeaf)&&(this.unplaced=new m(t,e+1,Math.max(n,r.size+e>=t.size-n?e+1:0)),!0)}dropNode(){let{content:t,openStart:e,openEnd:n}=this.unplaced,r=ve(t,e);if(r.childCount<=1&&e>0){let o=t.size-e<=e+r.size;this.unplaced=new m(ye(t,e-1,1),e-1,o?e-1:n)}else this.unplaced=new m(ye(t,e,1),e,n)}placeNodes({sliceDepth:t,frontierDepth:e,parent:n,inject:r,wrap:o}){while(this.depth>e)this.closeFrontierNode();if(o)for(let c=0;c1||0==l||t.content.size)&&(d=e,h.push(be(t.mark(u.allowedMarks(t.marks)),1==a?l:0,a==s.childCount?p:-1)))}let f=a==s.childCount;f||(p=-1),this.placed=we(this.placed,e,c.from(h)),this.frontier[e].match=d,f&&p<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let c=0,m=s;c1&&r==this.$to.end(--n))++r;return r}findCloseLevel(t){t:for(let e=Math.min(this.depth,t.depth);e>=0;e--){let{match:n,type:r}=this.frontier[e],o=e=0;n--){let{match:e,type:r}=this.frontier[n],o=xe(t,n,r,e,!0);if(!o||o.childCount)continue t}return{depth:e,fit:i,move:o?t.doc.resolve(t.after(e+1)):t}}}}close(t){let e=this.findCloseLevel(t);if(!e)return null;while(this.depth>e.depth)this.closeFrontierNode();e.fit.childCount&&(this.placed=we(this.placed,e.depth,e.fit)),t=e.move;for(let n=e.depth+1;n<=t.depth;n++){let e=t.node(n),r=e.type.contentMatch.fillBefore(e.content,!0,t.index(n));this.openFrontierNode(e.type,e.attrs,r)}return t}openFrontierNode(t,e=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(t),this.placed=we(this.placed,this.depth,c.from(t.create(e,n))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let t=this.frontier.pop(),e=t.match.fillBefore(c.empty,!0);e.childCount&&(this.placed=we(this.placed,this.frontier.length,e))}}function ye(t,e,n){return 0==e?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(ye(t.firstChild.content,e-1,n)))}function we(t,e,n){return 0==e?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(we(t.lastChild.content,e-1,n)))}function ve(t,e){for(let n=0;n1&&(r=r.replaceChild(0,be(r.firstChild,e-1,1==r.childCount?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(c.empty,!0)))),t.copy(r)}function xe(t,e,n,r,o){let i=t.node(e),s=o?t.indexAfter(e):t.index(e);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,s);return l&&!ke(n,i.content,s)?l:null}function ke(t,e,n){for(let r=n;r0;u--,p--){let t=o.node(u).type.spec;if(t.defining||t.definingAsContext||t.isolating)break;s.indexOf(u)>-1?l=u:o.before(u)==p&&s.splice(1,0,-u)}let a=s.indexOf(l),c=[],h=r.openStart;for(let u=r.content,p=0;;p++){let t=u.firstChild;if(c.push(t),p==r.openStart)break;u=t.content}for(let u=h-1;u>=0;u--){let t=c[u].type,e=Se(t);if(e&&o.node(a).type!=t)h=u;else if(e||!t.isTextblock)break}for(let u=r.openStart;u>=0;u--){let e=(u+h+1)%(r.openStart+1),l=c[e];if(l)for(let c=0;c=0;u--){if(t.replace(e,n,r),t.steps.length>d)break;let l=s[u];l<0||(e=o.before(l),n=i.after(l))}}function Me(t,e,n,r,o){if(er){let e=o.contentMatchAt(0),n=e.fillBefore(t).append(t);t=n.append(e.matchFragment(n).fillBefore(c.empty,!0))}return t}function Oe(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let o=ue(t.doc,e,r.type);null!=o&&(e=n=o)}t.replaceRange(e,n,new m(c.from(r),0,0))}function Ne(t,e,n){let r=t.doc.resolve(e),o=t.doc.resolve(n),i=Ee(r,o);for(let s=0;s0&&(n||r.node(e-1).canReplace(r.index(e-1),o.indexAfter(e-1))))return t.delete(r.before(e),o.after(e))}for(let s=1;s<=r.depth&&s<=o.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&o.end(s)-n!=o.depth-s)return t.delete(r.before(s),n);t.delete(e,n)}function Ee(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let o=r;o>=0;o--){let r=t.start(o);if(re.pos+(e.depth-o)||t.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(r==e.start(o)||o==t.depth&&o==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==r-1)&&n.push(o)}return n}class Ae extends Pt{constructor(t,e,n){super(),this.pos=t,this.attr=e,this.value=n}apply(t){let e=t.nodeAt(this.pos);if(!e)return Bt.fail("No node at attribute step's position");let n=Object.create(null);for(let o in e.attrs)n[o]=e.attrs[o];n[this.attr]=this.value;let r=e.type.create(n,null,e.marks);return Bt.fromReplace(t,this.pos,this.pos+1,new m(c.from(r),0,e.isLeaf?0:1))}getMap(){return _t.empty}invert(t){return new Ae(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Ae(e.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,e){if("number"!=typeof e.pos||"string"!=typeof e.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new Ae(e.pos,e.attr,e.value)}}Pt.jsonID("attr",Ae);let De=class extends Error{};De=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n},De.prototype=Object.create(Error.prototype),De.prototype.constructor=De,De.prototype.name="TransformError";class Te{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new It}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new De(e.failed);return this}maybeStep(t){let e=t.apply(this.doc);return e.failed||this.addStep(t,e.doc),e}get docChanged(){return this.steps.length>0}addStep(t,e){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=e}replace(t,e=t,n=m.empty){let r=fe(this.doc,t,e,n);return r&&this.step(r),this}replaceWith(t,e,n){return this.replace(t,e,new m(c.from(n),0,0))}delete(t,e){return this.replace(t,e,m.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,n){return Ce(this,t,e,n),this}replaceRangeWith(t,e,n){return Oe(this,t,e,n),this}deleteRange(t,e){return Ne(this,t,e),this}lift(t,e){return Zt(this,t,e),this}join(t,e=1){return de(this,t,e),this}wrap(t,e){return re(this,t,e),this}setBlockType(t,e=t,n,r=null){return oe(this,t,e,n,r),this}setNodeMarkup(t,e,n=null,r){return se(this,t,e,n,r),this}setNodeAttribute(t,e,n){return this.step(new Ae(t,e,n)),this}addNodeMark(t,e){return this.step(new jt(t,e)),this}removeNodeMark(t,e){if(!(e instanceof p)){let n=this.doc.nodeAt(t);if(!n)throw new RangeError("No node at position "+t);if(e=e.isInSet(n.marks),!e)return this}return this.step(new Ht(t,e)),this}split(t,e=1,n){return ae(this,t,e,n),this}addMark(t,e,n){return Kt(this,t,e,n),this}removeMark(t,e,n){return Ut(this,t,e,n),this}clearIncompatible(t,e,n){return Gt(this,t,e,n),this}}const Re=Object.create(null);class ze{constructor(t,e,n){this.$anchor=t,this.$head=e,this.ranges=n||[new _e(t.min(e),t.max(e))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let e=0;e=0;o--){let r=e<0?He(t.node(0),t.node(o),t.before(o+1),t.index(o),e,n):He(t.node(0),t.node(o),t.after(o+1),t.index(o)+1,e,n);if(r)return r}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new Le(t.node(0))}static atStart(t){return He(t,t,0,0,1)||new Le(t)}static atEnd(t){return He(t,t,t.content.size,t.childCount,-1)||new Le(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Re[e.type];if(!n)throw new RangeError(`No selection type ${e.type} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in Re)throw new RangeError("Duplicate use of selection JSON ID "+t);return Re[t]=e,e.prototype.jsonID=t,e}getBookmark(){return Pe.between(this.$anchor,this.$head).getBookmark()}}ze.prototype.visible=!0;class _e{constructor(t,e){this.$from=t,this.$to=e}}let Ie=!1;function $e(t){Ie||t.parent.inlineContent||(Ie=!0,console["warn"]("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Pe extends ze{constructor(t,e=t){$e(t),$e(e),super(t,e)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,e){let n=t.resolve(e.map(this.head));if(!n.parent.inlineContent)return ze.near(n);let r=t.resolve(e.map(this.anchor));return new Pe(r.parent.inlineContent?r:n,n)}replace(t,e=m.empty){if(super.replace(t,e),e==m.empty){let e=this.$from.marksAcross(this.$to);e&&t.ensureMarks(e)}}eq(t){return t instanceof Pe&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Be(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,e){if("number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new Pe(t.resolve(e.anchor),t.resolve(e.head))}static create(t,e,n=e){let r=t.resolve(e);return new this(r,n==e?r:t.resolve(n))}static between(t,e,n){let r=t.pos-e.pos;if(n&&!r||(n=r>=0?1:-1),!e.parent.inlineContent){let t=ze.findFrom(e,n,!0)||ze.findFrom(e,-n,!0);if(!t)return ze.near(e,n);e=t.$head}return t.parent.inlineContent||(0==r?t=e:(t=(ze.findFrom(t,-n,!0)||ze.findFrom(t,n,!0)).$anchor,t.pos0?0:1);o>0?s=0;s+=o){let r=e.child(s);if(r.isAtom){if(!i&&Ve.isSelectable(r))return Ve.create(t,n-(o<0?r.nodeSize:0))}else{let e=He(t,r,n+o,o<0?r.childCount:0,o,i);if(e)return e}n+=r.nodeSize*o}return null}function Je(t,e,n){let r=t.steps.length-1;if(r{null==i&&(i=r)})),t.setSelection(ze.near(t.doc.resolve(i),n))}const We=1,qe=2,Ke=4;class Ue extends Te{constructor(t){super(t.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=t.selection,this.storedMarks=t.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(t){return this.storedMarks=t,this.updated|=qe,this}ensureMarks(t){return p.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&qe)>0}addStep(t,e){super.addStep(t,e),this.updated=this.updated&~qe,this.storedMarks=null}setTime(t){return this.time=t,this}replaceSelection(t){return this.selection.replace(this,t),this}replaceSelectionWith(t,e=!0){let n=this.selection;return e&&(t=t.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||p.none))),n.replaceWith(this,t),this}deleteSelection(){return this.selection.replace(this),this}insertText(t,e,n){let r=this.doc.type.schema;if(null==e)return t?this.replaceSelectionWith(r.text(t),!0):this.deleteSelection();{if(null==n&&(n=e),n=null==n?e:n,!t)return this.deleteRange(e,n);let o=this.storedMarks;if(!o){let t=this.doc.resolve(e);o=n==e?t.marks():t.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(e,n,r.text(t,o)),this.selection.empty||this.setSelection(ze.near(this.selection.$to)),this}}setMeta(t,e){return this.meta["string"==typeof t?t:t.key]=e,this}getMeta(t){return this.meta["string"==typeof t?t:t.key]}get isGeneric(){for(let t in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Ke,this}get scrolledIntoView(){return(this.updated&Ke)>0}}function Ge(t,e){return e&&t?t.bind(e):t}class Xe{constructor(t,e,n){this.name=t,this.init=Ge(e.init,n),this.apply=Ge(e.apply,n)}}const Ye=[new Xe("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Xe("selection",{init(t,e){return t.selection||ze.atStart(e.doc)},apply(t){return t.selection}}),new Xe("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Xe("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Ze{constructor(t,e){this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Ye.slice(),e&&e.forEach((t=>{if(this.pluginsByKey[t.key])throw new RangeError("Adding different instances of a keyed plugin ("+t.key+")");this.plugins.push(t),this.pluginsByKey[t.key]=t,t.spec.state&&this.fields.push(new Xe(t.key,t.spec.state,t))}))}}class Qe{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,e=-1){for(let n=0;nt.toJSON()))),t&&"object"==typeof t)for(let n in t){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=t[n],o=r.spec.state;o&&o.toJSON&&(e[n]=o.toJSON.call(r,this[r.key]))}return e}static fromJSON(t,e,n){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let r=new Ze(t.schema,t.plugins),o=new Qe(r);return r.fields.forEach((r=>{if("doc"==r.name)o.doc=_.fromJSON(t.schema,e.doc);else if("selection"==r.name)o.selection=ze.fromJSON(o.doc,e.selection);else if("storedMarks"==r.name)e.storedMarks&&(o.storedMarks=e.storedMarks.map(t.schema.markFromJSON));else{if(n)for(let i in n){let s=n[i],l=s.spec.state;if(s.key==r.name&&l&&l.fromJSON&&Object.prototype.hasOwnProperty.call(e,i))return void(o[r.name]=l.fromJSON.call(s,t,e[i],o))}o[r.name]=r.init(t,o)}})),o}}function tn(t,e,n){for(let r in t){let o=t[r];o instanceof Function?o=o.bind(e):"handleDOMEvents"==r&&(o=tn(o,e,{})),n[r]=o}return n}class en{constructor(t){this.spec=t,this.props={},t.props&&tn(t.props,this,this.props),this.key=t.key?t.key.key:rn("plugin")}getState(t){return t[this.key]}}const nn=Object.create(null);function rn(t){return t in nn?t+"$"+ ++nn[t]:(nn[t]=0,t+"$")}class on{constructor(t="key"){this.key=rn(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const sn=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},ln=function(t){let e=t.assignedSlot||t.parentNode;return e&&11==e.nodeType?e.host:e};let an=null;const cn=function(t,e,n){let r=an||(an=document.createRange());return r.setEnd(t,null==n?t.nodeValue.length:n),r.setStart(t,e||0),r},hn=function(t,e,n,r){return n&&(un(t,e,n,r,-1)||un(t,e,n,r,1))},dn=/^(img|br|input|textarea|hr)$/i;function un(t,e,n,r,o){for(;;){if(t==n&&e==r)return!0;if(e==(o<0?0:pn(t))){let n=t.parentNode;if(!n||1!=n.nodeType||mn(t)||dn.test(t.nodeName)||"false"==t.contentEditable)return!1;e=sn(t)+(o<0?0:1),t=n}else{if(1!=t.nodeType)return!1;if(t=t.childNodes[e+(o<0?-1:0)],"false"==t.contentEditable)return!1;e=o<0?pn(t):0}}}function pn(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function fn(t,e,n){for(let r=0==e,o=e==pn(t);r||o;){if(t==n)return!0;let e=sn(t);if(t=t.parentNode,!t)return!1;r=r&&0==e,o=o&&e==pn(t)}}function mn(t){let e;for(let n=t;n;n=n.parentNode)if(e=n.pmViewDesc)break;return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const gn=function(t){return t.focusNode&&hn(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function yn(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function wn(t){let e=t.activeElement;while(e&&e.shadowRoot)e=e.shadowRoot.activeElement;return e}const vn="undefined"!=typeof navigator?navigator:null,bn="undefined"!=typeof document?document:null,xn=vn&&vn.userAgent||"",kn=/Edge\/(\d+)/.exec(xn),Sn=/MSIE \d/.exec(xn),Cn=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(xn),Mn=!!(Sn||Cn||kn),On=Sn?document.documentMode:Cn?+Cn[1]:kn?+kn[1]:0,Nn=!Mn&&/gecko\/(\d+)/i.test(xn);Nn&&(/Firefox\/(\d+)/.exec(xn)||[0,0])[1];const En=!Mn&&/Chrome\/(\d+)/.exec(xn),An=!!En,Dn=En?+En[1]:0,Tn=!Mn&&!!vn&&/Apple Computer/.test(vn.vendor),Rn=Tn&&(/Mobile\/\w+/.test(xn)||!!vn&&vn.maxTouchPoints>2),zn=Rn||!!vn&&/Mac/.test(vn.platform),_n=/Android \d/.test(xn),In=!!bn&&"webkitFontSmoothing"in bn.documentElement.style,$n=In?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Pn(t){return{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Bn(t,e){return"number"==typeof t?t:t[e]}function Vn(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function Fn(t,e,n){let r=t.someProp("scrollThreshold")||0,o=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let s=n||t.dom;;s=ln(s)){if(!s)break;if(1!=s.nodeType)continue;let t=s,n=t==i.body,l=n?Pn(i):Vn(t),a=0,c=0;if(e.topl.bottom-Bn(r,"bottom")&&(c=e.bottom-l.bottom+Bn(o,"bottom")),e.leftl.right-Bn(r,"right")&&(a=e.right-l.right+Bn(o,"right")),a||c)if(n)i.defaultView.scrollBy(a,c);else{let n=t.scrollLeft,r=t.scrollTop;c&&(t.scrollTop+=c),a&&(t.scrollLeft+=a);let o=t.scrollLeft-n,i=t.scrollTop-r;e={left:e.left-o,top:e.top-i,right:e.right-o,bottom:e.bottom-i}}if(n)break}}function Ln(t){let e,n,r=t.dom.getBoundingClientRect(),o=Math.max(0,r.top);for(let i=(r.left+r.right)/2,s=o+1;s=o-20){e=r,n=l.top;break}}return{refDOM:e,refTop:n,stack:jn(t.dom)}}function jn(t){let e=[],n=t.ownerDocument;for(let r=t;r;r=ln(r))if(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t==n)break;return e}function Hn({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Jn(n,0==r?0:r-e)}function Jn(t,e){for(let n=0;n=l){s=Math.max(d.bottom,s),l=Math.min(d.top,l);let t=d.left>e.left?d.left-e.left:d.right=(d.left+d.right)/2?1:0));continue}}!n&&(e.left>=d.right&&e.top>=d.top||e.left>=d.left&&e.top>=d.bottom)&&(i=c+1)}}return n&&3==n.nodeType?Un(n,r):!n||o&&1==n.nodeType?{node:t,offset:i}:Kn(n,r)}function Un(t,e){let n=t.nodeValue.length,r=document.createRange();for(let o=0;o=(n.left+n.right)/2?1:0)}}return{node:t,offset:0}}function Gn(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Xn(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left(t.left+t.right)/2?1:-1}return t.docView.posFromDOM(r,o,i)}function Zn(t,e,n,r){let o=-1;for(let i=e,s=!1;;){if(i==t.dom)break;let e=t.docView.nearestDesc(i,!0);if(!e)return null;if(1==e.dom.nodeType&&(e.node.isBlock&&e.parent&&!s||!e.contentDOM)){let t=e.dom.getBoundingClientRect();if(e.node.isBlock&&e.parent&&!s&&(s=!0,t.left>r.left||t.top>r.top?o=e.posBefore:(t.right-1?o:t.docView.posFromDOM(e,n,-1)}function Qn(t,e,n){let r=t.childNodes.length;if(r&&n.tope.top&&o++}n==t.dom&&o==n.childNodes.length-1&&1==n.lastChild.nodeType&&e.top>n.lastChild.getBoundingClientRect().bottom?i=t.state.doc.content.size:0!=o&&1==n.nodeType&&"BR"==n.childNodes[o-1].nodeName||(i=Zn(t,n,o,e))}null==i&&(i=Yn(t,s,e));let l=t.docView.nearestDesc(s,!0);return{pos:i,inside:l?l.posAtStart-l.border:-1}}function er(t,e){let n=t.getClientRects();return n.length?n[e<0?0:n.length-1]:t.getBoundingClientRect()}const nr=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function rr(t,e,n){let{node:r,offset:o,atom:i}=t.docView.domFromPos(e,n<0?-1:1),s=In||Nn;if(3==r.nodeType){if(!s||!nr.test(r.nodeValue)&&(n<0?o:o!=r.nodeValue.length)){let t=o,e=o,i=n<0?1:-1;return n<0&&!o?(e++,i=-1):n>=0&&o==r.nodeValue.length?(t--,i=1):n<0?t--:e++,or(er(cn(r,t,e),1),i<0)}{let t=er(cn(r,o,o),n);if(Nn&&o&&/\s/.test(r.nodeValue[o-1])&&o=0)}if(null==i&&o&&(n<0||o==pn(r))){let t=r.childNodes[o-1],e=3==t.nodeType?cn(t,pn(t)-(s?0:1)):1!=t.nodeType||"BR"==t.nodeName&&t.nextSibling?null:t;if(e)return or(er(e,1),!1)}if(null==i&&o=0)}function or(t,e){if(0==t.width)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function ir(t,e){if(0==t.height)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function sr(t,e,n){let r=t.state,o=t.root.activeElement;r!=e&&t.updateState(e),o!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),o!=t.dom&&o&&o.focus()}}function lr(t,e,n){let r=e.selection,o="up"==n?r.$from:r.$to;return sr(t,e,(()=>{let{node:e}=t.docView.domFromPos(o.pos,"up"==n?-1:1);for(;;){let n=t.docView.nearestDesc(e,!0);if(!n)break;if(n.node.isBlock){e=n.contentDOM||n.dom;break}e=n.dom.parentNode}let r=rr(t,o.pos,1);for(let t=e.firstChild;t;t=t.nextSibling){let e;if(1==t.nodeType)e=t.getClientRects();else{if(3!=t.nodeType)continue;e=cn(t,0,t.nodeValue.length).getClientRects()}for(let t=0;to.top+1&&("up"==n?r.top-o.top>2*(o.bottom-r.top):o.bottom-r.bottom>2*(r.bottom-o.top)))return!1}}return!0}))}const ar=/[\u0590-\u08ac]/;function cr(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=t.domSelection();return ar.test(r.parent.textContent)&&l.modify?sr(t,e,(()=>{let{focusNode:e,focusOffset:o,anchorNode:i,anchorOffset:s}=t.domSelectionRange(),a=l.caretBidiLevel;l.modify("move",n,"character");let c=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:h,focusOffset:d}=t.domSelectionRange(),u=h&&!c.contains(1==h.nodeType?h:h.parentNode)||e==h&&o==d;try{l.collapse(i,s),e&&(e!=i||o!=s)&&l.extend&&l.extend(e,o)}catch(p){}return null!=a&&(l.caretBidiLevel=a),u})):"left"==n||"backward"==n?i:s}let hr=null,dr=null,ur=!1;function pr(t,e,n){return hr==e&&dr==n?ur:(hr=e,dr=n,ur="up"==n||"down"==n?lr(t,e,n):cr(t,e,n))}const fr=0,mr=1,gr=2,yr=3;class wr{constructor(t,e,n,r){this.parent=t,this.children=e,this.dom=n,this.contentDOM=r,this.dirty=fr,n.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,e,n){return!1}matchesHack(t){return!1}parseRule(){return null}stopEvent(t){return!1}get size(){let t=0;for(let e=0;esn(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=2&t.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==e)for(let e=t;;e=e.parentNode){if(e==this.dom){r=!1;break}if(e.previousSibling)break}if(null==r&&e==t.childNodes.length)for(let e=t;;e=e.parentNode){if(e==this.dom){r=!0;break}if(e.nextSibling)break}}return(null==r?n>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(t,e=!1){for(let n=!0,r=t;r;r=r.parentNode){let o,i=this.getDesc(r);if(i&&(!e||i.node)){if(!n||!(o=i.nodeDOM)||(1==o.nodeType?o.contains(1==t.nodeType?t:t.parentNode):o==t))return i;n=!1}}}getDesc(t){let e=t.pmViewDesc;for(let n=e;n;n=n.parent)if(n==this)return e}posFromDOM(t,e,n){for(let r=t;r;r=r.parentNode){let o=this.getDesc(r);if(o)return o.localPosFromDOM(t,e,n)}return-1}descAt(t){for(let e=0,n=0;et||e instanceof Mr){r=t-o;break}o=i}if(r)return this.children[n].domFromPos(r-this.children[n].border,e);for(let o;n&&!(o=this.children[n-1]).size&&o instanceof vr&&o.side>=0;n--);if(e<=0){let t,r=!0;for(;;n--,r=!1)if(t=n?this.children[n-1]:null,!t||t.dom.parentNode==this.contentDOM)break;return t&&e&&r&&!t.border&&!t.domAtom?t.domFromPos(t.size,e):{node:this.contentDOM,offset:t?sn(t.dom)+1:0}}{let t,r=!0;for(;;n++,r=!1)if(t=n=o&&e<=l-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(t,e,o);t=i;for(let e=s;e>0;e--){let n=this.children[e-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=sn(n.dom)+1;break}t-=n.size}-1==r&&(r=0)}if(r>-1&&(l>e||s==this.children.length-1)){e=l;for(let t=s+1;tp&&ie){let t=s;s=l,l=t}let n=document.createRange();n.setEnd(l.node,l.offset),n.setStart(s.node,s.offset),a.removeAllRanges(),a.addRange(n)}}ignoreMutation(t){return!this.contentDOM&&"selection"!=t.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,e){for(let n=0,r=0;r=n:tn){let r=n+o.border,s=i-o.border;if(t>=r&&e<=s)return this.dirty=t==n||e==i?gr:mr,void(t!=r||e!=s||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(t-r,e-r):o.dirty=yr);o.dirty=o.dom!=o.contentDOM||o.dom.parentNode!=this.contentDOM||o.children.length?yr:gr}n=i}this.dirty=gr}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let n=1==t?gr:mr;e.dirtyo?o.parent?o.parent.posBeforeChild(o):void 0:r))),!e.type.spec.raw){if(1!=i.nodeType){let t=document.createElement("span");t.appendChild(i),i=t}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(t,[],i,null),this.widget=e,this.widget=e,o=this}matchesWidget(t){return this.dirty==fr&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){let e=this.widget.spec.stopEvent;return!!e&&e(t)}ignoreMutation(t){return"selection"!=t.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class br extends wr{constructor(t,e,n,r){super(t,[],e,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(t,e){return t!=this.textDOM?this.posAtStart+(e?this.size:0):this.posAtStart+e}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return"characterData"===t.type&&t.target.nodeValue==t.oldValue}}class xr extends wr{constructor(t,e,n,r){super(t,[],n,r),this.mark=e}static create(t,e,n,r){let o=r.nodeViews[e.type.name],i=o&&o(e,r,n);return i&&i.dom||(i=xt.renderSpec(document,e.type.spec.toDOM(e,n))),new xr(t,e,i.dom,i.contentDOM||i.dom)}parseRule(){return this.dirty&yr||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM||void 0}}matchesMark(t){return this.dirty!=yr&&this.mark.eq(t)}markDirty(t,e){if(super.markDirty(t,e),this.dirty!=fr){let t=this.parent;while(!t.node)t=t.parent;t.dirty0&&(o=Hr(o,0,t,n));for(let s=0;ss?s.parent?s.parent.posBeforeChild(s):void 0:i),n,r),c=a&&a.dom,h=a&&a.contentDOM;if(e.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(e.text);else c||({dom:c,contentDOM:h}=xt.renderSpec(document,e.type.spec.toDOM(e)));h||e.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),e.type.spec.draggable&&(c.draggable=!0));let d=c;return c=zr(c,n,e),a?s=new Or(t,e,n,r,c,h||null,d,a,o,i+1):e.isText?new Cr(t,e,n,r,c,d,o):new kr(t,e,n,r,c,h||null,d,o,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(t.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let e=this.children.length-1;e>=0;e--){let n=this.children[e];if(this.dom.contains(n.dom.parentNode)){t.contentElement=n.dom.parentNode;break}}t.contentElement||(t.getContent=()=>c.empty)}else t.contentElement=this.contentDOM;else t.getContent=()=>this.node.content;return t}matchesNode(t,e,n){return this.dirty==fr&&t.eq(this.node)&&_r(e,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,e){let n=this.node.inlineContent,r=e,o=t.composing?this.localCompositionInfo(t,e):null,i=o&&o.pos>-1?o:null,s=o&&o.pos<0,l=new $r(this,i&&i.node,t);Vr(this.node,this.innerDeco,((e,o,i)=>{e.spec.marks?l.syncToMarks(e.spec.marks,n,t):e.type.side>=0&&!i&&l.syncToMarks(o==this.node.childCount?p.none:this.node.child(o).marks,n,t),l.placeWidget(e,t,r)}),((e,i,a,c)=>{let h;l.syncToMarks(e.marks,n,t),l.findNodeMatch(e,i,a,c)||s&&t.state.selection.from>r&&t.state.selection.to-1&&l.updateNodeAt(e,i,a,h,t)||l.updateNextNode(e,i,a,t,c)||l.addNode(e,i,a,t,r),r+=e.nodeSize})),l.syncToMarks([],n,t),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==gr)&&(i&&this.protectLocalComposition(t,i),Nr(this.contentDOM,this.children,t),Rn&&Fr(this.dom))}localCompositionInfo(t,e){let{from:n,to:r}=t.state.selection;if(!(t.state.selection instanceof Pe)||ne+this.node.content.size)return null;let o=t.domSelectionRange(),i=Lr(o.focusNode,o.focusOffset);if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let t=i.nodeValue,o=jr(this.node.content,t,n-e,r-e);return o<0?null:{node:i,pos:o,text:t}}return{node:i,pos:-1,text:""}}protectLocalComposition(t,{node:e,pos:n,text:r}){if(this.getDesc(e))return;let o=e;for(;;o=o.parentNode){if(o.parentNode==this.contentDOM)break;while(o.previousSibling)o.parentNode.removeChild(o.previousSibling);while(o.nextSibling)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let i=new br(this,o,e,r);t.input.compositionNodes.push(i),this.children=Hr(this.children,n,n+r.length,t,i)}update(t,e,n,r){return!(this.dirty==yr||!t.sameMarkup(this.node))&&(this.updateInner(t,e,n,r),!0)}updateInner(t,e,n,r){this.updateOuterDeco(e),this.node=t,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=fr}updateOuterDeco(t){if(_r(t,this.outerDeco))return;let e=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=Tr(this.dom,this.nodeDOM,Dr(this.outerDeco,this.node,e),Dr(t,this.node,e)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}selectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)}deselectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable")}get domAtom(){return this.node.isAtom}}function Sr(t,e,n,r,o){return zr(r,e,t),new kr(void 0,t,e,n,r,r,r,o,0)}class Cr extends kr{constructor(t,e,n,r,o,i,s){super(t,e,n,r,o,null,i,s,0)}parseRule(){let t=this.nodeDOM.parentNode;while(t&&t!=this.dom&&!t.pmIsDeco)t=t.parentNode;return{skip:t||!0}}update(t,e,n,r){return!(this.dirty==yr||this.dirty!=fr&&!this.inParent()||!t.sameMarkup(this.node))&&(this.updateOuterDeco(e),this.dirty==fr&&t.text==this.node.text||t.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=t.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=t,this.dirty=fr,!0)}inParent(){let t=this.parent.contentDOM;for(let e=this.nodeDOM;e;e=e.parentNode)if(e==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,e,n){return t==this.nodeDOM?this.posAtStart+Math.min(e,this.node.text.length):super.localPosFromDOM(t,e,n)}ignoreMutation(t){return"characterData"!=t.type&&"selection"!=t.type}slice(t,e,n){let r=this.node.cut(t,e),o=document.createTextNode(r.text);return new Cr(this.parent,r,this.outerDeco,this.innerDeco,o,o,n)}markDirty(t,e){super.markDirty(t,e),this.dom==this.nodeDOM||0!=t&&e!=this.nodeDOM.nodeValue.length||(this.dirty=yr)}get domAtom(){return!1}}class Mr extends wr{parseRule(){return{ignore:!0}}matchesHack(t){return this.dirty==fr&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class Or extends kr{constructor(t,e,n,r,o,i,s,l,a,c){super(t,e,n,r,o,i,s,a,c),this.spec=l}update(t,e,n,r){if(this.dirty==yr)return!1;if(this.spec.update){let o=this.spec.update(t,e,n);return o&&this.updateInner(t,e,n,r),o}return!(!this.contentDOM&&!t.isLeaf)&&super.update(t,e,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,e,n,r){this.spec.setSelection?this.spec.setSelection(t,e,n):super.setSelection(t,e,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return!!this.spec.stopEvent&&this.spec.stopEvent(t)}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function Nr(t,e,n){let r=t.firstChild,o=!1;for(let i=0;i>1,i=Math.min(o,t.length);while(r-1)r>this.index&&(this.changed=!0,this.destroyBetween(this.index,r)),this.top=this.top.children[this.index];else{let r=xr.create(this.top,t[o],e,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,o++}}findNodeMatch(t,e,n,r){let o,i=-1;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(t,e,n))i=this.top.children.indexOf(o,this.index);else for(let s=this.index,l=Math.min(this.top.children.length,s+5);s0){let l;for(;;)if(r){let t=n.children[r-1];if(!(t instanceof xr)){l=t,r--;break}n=t,r=t.children.length}else{if(n==e)break t;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(o-1))break;--o,i.set(l,o),s.push(l)}}return{index:o,matched:i,matches:s.reverse()}}function Br(t,e){return t.type.side-e.type.side}function Vr(t,e,n,r){let o=e.locals(t),i=0;if(0==o.length){for(let n=0;ni)l.push(o[s++]);let u=i+h.nodeSize;if(h.isText){let t=u;s!t.inline)):l.slice();r(h,p,e.forChild(i,h),d),i=u}}function Fr(t){if("UL"==t.nodeName||"OL"==t.nodeName){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function Lr(t,e){for(;;){if(3==t.nodeType)return t;if(1==t.nodeType&&e>0){if(t.childNodes.length>e&&3==t.childNodes[e].nodeType)return t.childNodes[e];t=t.childNodes[e-1],e=pn(t)}else{if(!(1==t.nodeType&&e=n){let t=l=0&&t+e.length+l>=n)return l+t;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Hr(t,e,n,r,o){let i=[];for(let s=0,l=0;s=n||h<=e?i.push(a):(cn&&i.push(a.slice(n-c,a.size,r)))}return i}function Jr(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let o=t.docView.nearestDesc(n.focusNode),i=o&&0==o.size,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l,a,c=r.resolve(s);if(gn(n)){l=c;while(o&&!o.node)o=o.parent;let t=o.node;if(o&&t.isAtom&&Ve.isSelectable(t)&&o.parent&&(!t.isInline||!fn(n.focusNode,n.focusOffset,o.dom))){let t=o.posBefore;a=new Ve(s==t?c:r.resolve(t))}}else{let e=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(e<0)return null;l=r.resolve(e)}if(!a){let n="pointer"==e||t.state.selection.head{n.anchorNode==r&&n.anchorOffset==o||(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout((()=>{Wr(t)&&!t.state.selection.visible||t.dom.classList.remove("ProseMirror-hideselection")}),20))})}function Zr(t){let e=t.domSelection(),n=document.createRange(),r=t.cursorWrapper.dom,o="IMG"==r.nodeName;o?n.setEnd(r.parentNode,sn(r)+1):n.setEnd(r,0),n.collapse(!1),e.removeAllRanges(),e.addRange(n),!o&&!t.state.selection.visible&&Mn&&On<=11&&(r.disabled=!0,r.disabled=!1)}function Qr(t,e){if(e instanceof Ve){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(to(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else to(t)}function to(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function eo(t,e,n,r){return t.someProp("createSelectionBetween",(r=>r(t,e,n)))||Pe.between(e,n,r)}function no(t){return!(t.editable&&!t.hasFocus())&&ro(t)}function ro(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(3==e.anchorNode.nodeType?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(3==e.focusNode.nodeType?e.focusNode.parentNode:e.focusNode))}catch(n){return!1}}function oo(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return hn(e.node,e.offset,n.anchorNode,n.anchorOffset)}function io(t,e){let{$anchor:n,$head:r}=t.selection,o=e>0?n.max(r):n.min(r),i=o.parent.inlineContent?o.depth?t.doc.resolve(e>0?o.after():o.before()):null:o;return i&&ze.findFrom(i,e)}function so(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function lo(t,e,n){let r=t.state.selection;if(!(r instanceof Pe)){if(r instanceof Ve&&r.node.isInline)return so(t,new Pe(e>0?r.$to:r.$from));{let n=io(t.state,e);return!!n&&so(t,n)}}if(!r.empty||n.indexOf("s")>-1)return!1;if(t.endOfTextblock(e>0?"right":"left")){let n=io(t.state,e);return!!(n&&n instanceof Ve)&&so(t,n)}if(!(zn&&n.indexOf("m")>-1)){let n,o=r.$head,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText)return!1;let s=e<0?o.pos-i.nodeSize:o.pos;return!!(i.isAtom||(n=t.docView.descAt(s))&&!n.contentDOM)&&(Ve.isSelectable(i)?so(t,new Ve(e<0?t.state.doc.resolve(o.pos-i.nodeSize):o)):!!In&&so(t,new Pe(t.state.doc.resolve(e<0?s:s+i.nodeSize))))}}function ao(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function co(t){let e=t.pmViewDesc;return e&&0==e.size&&(t.nextSibling||"BR"!=t.nodeName)}function ho(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o,i,s=!1;for(Nn&&1==n.nodeType&&r0){if(1!=n.nodeType)break;{let t=n.childNodes[r-1];if(co(t))o=n,i=--r;else{if(3!=t.nodeType)break;n=t,r=n.nodeValue.length}}}else{if(po(n))break;{let e=n.previousSibling;while(e&&co(e))o=n.parentNode,i=sn(e),e=e.previousSibling;if(e)n=e,r=ao(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?fo(t,n,r):o&&fo(t,o,i)}function uo(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o,i,s=ao(n);for(;;)if(r{t.state==o&&qr(t)}),50)}function mo(t,e,n){let r=t.state.selection;if(r instanceof Pe&&!r.empty||n.indexOf("s")>-1)return!1;if(zn&&n.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let n=io(t.state,e);if(n&&n instanceof Ve)return so(t,n)}if(!o.parent.inlineContent){let n=e<0?o:i,s=r instanceof Le?ze.near(n,e):ze.findFrom(n,e);return!!s&&so(t,s)}return!1}function go(t,e){if(!(t.state.selection instanceof Pe))return!0;let{$head:n,$anchor:r,empty:o}=t.state.selection;if(!n.sameParent(r))return!0;if(!o)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let r=t.state.tr;return e<0?r.delete(n.pos-i.nodeSize,n.pos):r.delete(n.pos,n.pos+i.nodeSize),t.dispatch(r),!0}return!1}function yo(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function wo(t){if(!Tn||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&1==e.nodeType&&0==n&&e.firstChild&&"false"==e.firstChild.contentEditable){let n=e.firstChild;yo(t,n,"true"),setTimeout((()=>yo(t,n,"false")),20)}return!1}function vo(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function bo(t,e){let n=e.keyCode,r=vo(e);return 8==n||zn&&72==n&&"c"==r?go(t,-1)||ho(t):46==n||zn&&68==n&&"c"==r?go(t,1)||uo(t):13==n||27==n||(37==n||zn&&66==n&&"c"==r?lo(t,-1,r)||ho(t):39==n||zn&&70==n&&"c"==r?lo(t,1,r)||uo(t):38==n||zn&&80==n&&"c"==r?mo(t,-1,r)||ho(t):40==n||zn&&78==n&&"c"==r?wo(t)||mo(t,1,r)||uo(t):r==(zn?"m":"c")&&(66==n||73==n||89==n||90==n))}function xo(t,e){t.someProp("transformCopied",(n=>{e=n(e,t)}));let n=[],{content:r,openStart:o,openEnd:i}=e;while(o>1&&i>1&&1==r.childCount&&1==r.firstChild.childCount){o--,i--;let t=r.firstChild;n.push(t.type.name,t.attrs!=t.type.defaultAttrs?t.attrs:null),r=t.content}let s=t.someProp("clipboardSerializer")||xt.fromSchema(t.state.schema),l=Ro(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c,h=a.firstChild,d=0;while(h&&1==h.nodeType&&(c=Do[h.nodeName.toLowerCase()])){for(let t=c.length-1;t>=0;t--){let e=l.createElement(c[t]);while(a.firstChild)e.appendChild(a.firstChild);a.appendChild(e),d++}h=a.firstChild}h&&1==h.nodeType&&h.setAttribute("data-pm-slice",`${o} ${i}${d?` -${d}`:""} ${JSON.stringify(n)}`);let u=t.someProp("clipboardTextSerializer",(n=>n(e,t)))||e.content.textBetween(0,e.content.size,"\n\n");return{dom:a,text:u}}function ko(t,e,n,r,o){let i,s,l=o.parent.type.spec.code;if(!n&&!e)return null;let a=e&&(r||l||!n);if(a){if(t.someProp("transformPastedText",(n=>{e=n(e,l||r,t)})),l)return e?new m(c.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0):m.empty;let n=t.someProp("clipboardTextParser",(n=>n(e,o,r,t)));if(n)s=n;else{let n=o.marks(),{schema:r}=t.state,s=xt.fromSchema(r);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach((t=>{let e=i.appendChild(document.createElement("p"));t&&e.appendChild(s.serializeNode(r.text(t,n)))}))}}else t.someProp("transformPastedHTML",(e=>{n=e(n,t)})),i=zo(n),In&&_o(i);let h=i&&i.querySelector("[data-pm-slice]"),d=h&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(h.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let c=+d[3];c>0;c--){let t=i.firstChild;while(t&&1!=t.nodeType)t=t.nextSibling;if(!t)break;i=t}if(!s){let e=t.someProp("clipboardParser")||t.someProp("domParser")||it.fromSchema(t.state.schema);s=e.parseSlice(i,{preserveWhitespace:!(!a&&!d),context:o,ruleFromNode(t){return"BR"!=t.nodeName||t.nextSibling||!t.parentNode||So.test(t.parentNode.nodeName)?null:{ignore:!0}}})}if(d)s=Io(Ao(s,+d[1],+d[2]),d[4]);else if(s=m.maxOpen(Co(s.content,o),!0),s.openStart||s.openEnd){let t=0,e=0;for(let n=s.content.firstChild;t{s=e(s,t)})),s}const So=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Co(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let r,o=e.node(n),i=o.contentMatchAt(e.index(n)),s=[];if(t.forEach((t=>{if(!s)return;let e,n=i.findWrapping(t.type);if(!n)return s=null;if(e=s.length&&r.length&&Oo(n,r,t,s[s.length-1],0))s[s.length-1]=e;else{s.length&&(s[s.length-1]=No(s[s.length-1],r.length));let e=Mo(t,n);s.push(e),i=i.matchType(e.type),r=n}})),s)return c.from(s)}return t}function Mo(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,c.from(t));return t}function Oo(t,e,n,r,o){if(o=n&&(l=e<0?s.contentMatchAt(0).fillBefore(l,t.childCount>1||i<=o).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(c.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(l))}function Ao(t,e,n){return e]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n,r=Ro().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(t);if((n=o&&Do[o[1].toLowerCase()])&&(t=n.map((t=>"<"+t+">")).join("")+t+n.map((t=>""+t+">")).reverse().join("")),r.innerHTML=t,n)for(let i=0;i=0;a-=2){let t=r.nodes[n[a]];if(!t||t.hasRequiredAttrs())break;o=c.from(t.create(n[a+1],o)),i++,s++}return new m(o,i,s)}const $o={},Po={},Bo={touchstart:!0,touchmove:!0};class Vo{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Fo(t){for(let e in $o){let n=$o[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=e=>{!Wo(t,e)||Jo(t,e)||!t.editable&&e.type in Po||n(t,e)},Bo[e]?{passive:!0}:void 0)}Tn&&t.dom.addEventListener("input",(()=>null)),Ho(t)}function Lo(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function jo(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function Ho(t){t.someProp("handleDOMEvents",(e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=e=>Jo(t,e))}))}function Jo(t,e){return t.someProp("handleDOMEvents",(n=>{let r=n[e.type];return!!r&&(r(t,e)||e.defaultPrevented)}))}function Wo(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function qo(t,e){Jo(t,e)||!$o[e.type]||!t.editable&&e.type in Po||$o[e.type](t,e)}function Ko(t){return{left:t.clientX,top:t.clientY}}function Uo(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Go(t,e,n,r,o){if(-1==r)return!1;let i=t.state.doc.resolve(r);for(let s=i.depth+1;s>0;s--)if(t.someProp(e,(e=>s>i.depth?e(t,n,i.nodeAfter,i.before(s),o,!0):e(t,n,i.node(s),i.before(s),o,!1))))return!0;return!1}function Xo(t,e,n){t.focused||t.focus();let r=t.state.tr.setSelection(e);"pointer"==n&&r.setMeta("pointer",!0),t.dispatch(r)}function Yo(t,e){if(-1==e)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return!!(r&&r.isAtom&&Ve.isSelectable(r))&&(Xo(t,new Ve(n),"pointer"),!0)}function Zo(t,e){if(-1==e)return!1;let n,r,o=t.state.selection;o instanceof Ve&&(n=o.node);let i=t.state.doc.resolve(e);for(let s=i.depth+1;s>0;s--){let t=s>i.depth?i.nodeAfter:i.node(s);if(Ve.isSelectable(t)){r=n&&o.$from.depth>0&&s>=o.$from.depth&&i.before(o.$from.depth+1)==o.$from.pos?i.before(o.$from.depth):i.before(s);break}}return null!=r&&(Xo(t,Ve.create(t.state.doc,r),"pointer"),!0)}function Qo(t,e,n,r,o){return Go(t,"handleClickOn",e,n,r)||t.someProp("handleClick",(n=>n(t,e,r)))||(o?Zo(t,n):Yo(t,n))}function ti(t,e,n,r){return Go(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",(n=>n(t,e,r)))}function ei(t,e,n,r){return Go(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",(n=>n(t,e,r)))||ni(t,n,r)}function ni(t,e,n){if(0!=n.button)return!1;let r=t.state.doc;if(-1==e)return!!r.inlineContent&&(Xo(t,Pe.create(r,0,r.content.size),"pointer"),!0);let o=r.resolve(e);for(let i=o.depth+1;i>0;i--){let e=i>o.depth?o.nodeAfter:o.node(i),n=o.before(i);if(e.inlineContent)Xo(t,Pe.create(r,n+1,n+1+e.content.size),"pointer");else{if(!Ve.isSelectable(e))continue;Xo(t,Ve.create(r,n),"pointer")}return!0}}function ri(t){return di(t)}Po.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=16==n.keyCode||n.shiftKey,!si(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!_n||!An||13!=n.keyCode))if(229!=n.keyCode&&t.domObserver.forceFlush(),!Rn||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)t.someProp("handleKeyDown",(e=>e(t,n)))||bo(t,n)?n.preventDefault():Lo(t,"key");else{let e=Date.now();t.input.lastIOSEnter=e,t.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{t.input.lastIOSEnter==e&&(t.someProp("handleKeyDown",(e=>e(t,yn(13,"Enter")))),t.input.lastIOSEnter=0)}),200)}},Po.keyup=(t,e)=>{16==e.keyCode&&(t.input.shiftKey=!1)},Po.keypress=(t,e)=>{let n=e;if(si(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||zn&&n.metaKey)return;if(t.someProp("handleKeyPress",(e=>e(t,n))))return void n.preventDefault();let r=t.state.selection;if(!(r instanceof Pe)||!r.$from.sameParent(r.$to)){let e=String.fromCharCode(n.charCode);/[\r\n]/.test(e)||t.someProp("handleTextInput",(n=>n(t,r.$from.pos,r.$to.pos,e)))||t.dispatch(t.state.tr.insertText(e).scrollIntoView()),n.preventDefault()}};const oi=zn?"metaKey":"ctrlKey";$o.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=ri(t),o=Date.now(),i="singleClick";o-t.input.lastClick.time<500&&Uo(n,t.input.lastClick)&&!n[oi]&&("singleClick"==t.input.lastClick.type?i="doubleClick":"doubleClick"==t.input.lastClick.type&&(i="tripleClick")),t.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i};let s=t.posAtCoords(Ko(n));s&&("singleClick"==i?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new ii(t,s,n,!!r)):("doubleClick"==i?ti:ei)(t,s.pos,s.inside,n)?n.preventDefault():Lo(t,"pointer"))};class ii{constructor(t,e,n,r){let o,i;if(this.view=t,this.pos=e,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!n[oi],this.allowDefault=n.shiftKey,e.inside>-1)o=t.state.doc.nodeAt(e.inside),i=e.inside;else{let n=t.state.doc.resolve(e.pos);o=n.parent,i=n.depth?n.before():0}const s=r?null:n.target,l=s?t.docView.nearestDesc(s,!0):null;this.target=l?l.dom:null;let{selection:a}=t.state;(0==n.button&&o.type.spec.draggable&&!1!==o.type.spec.selectable||a instanceof Ve&&a.from<=i&&a.to>i)&&(this.mightDrag={node:o,pos:i,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!Nn||this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout((()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")}),20),this.view.domObserver.start()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),Lo(t,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout((()=>qr(this.view))),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let e=this.pos;this.view.state.doc!=this.startDoc&&(e=this.view.posAtCoords(Ko(t))),this.updateAllowDefault(t),this.allowDefault||!e?Lo(this.view,"pointer"):Qo(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():0==t.button&&(this.flushed||Tn&&this.mightDrag&&!this.mightDrag.node.isAtom||An&&!this.view.state.selection.visible&&Math.min(Math.abs(e.pos-this.view.state.selection.from),Math.abs(e.pos-this.view.state.selection.to))<=2)?(Xo(this.view,ze.near(this.view.state.doc.resolve(e.pos)),"pointer"),t.preventDefault()):Lo(this.view,"pointer")}move(t){this.updateAllowDefault(t),Lo(this.view,"pointer"),0==t.buttons&&this.done()}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}}function si(t,e){return!!t.composing||!!(Tn&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500)&&(t.input.compositionEndedAt=-2e8,!0)}$o.touchstart=t=>{t.input.lastTouch=Date.now(),ri(t),Lo(t,"pointer")},$o.touchmove=t=>{t.input.lastTouch=Date.now(),Lo(t,"pointer")},$o.contextmenu=t=>ri(t);const li=_n?5e3:-1;function ai(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout((()=>di(t)),e))}function ci(t){t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=hi());while(t.input.compositionNodes.length>0)t.input.compositionNodes.pop().markParentsDirty()}function hi(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function di(t,e=!1){if(!(_n&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),ci(t),e||t.docView&&t.docView.dirty){let e=Jr(t);return e&&!e.eq(t.state.selection)?t.dispatch(t.state.tr.setSelection(e)):t.updateState(t.state),!0}return!1}}function ui(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout((()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()}),50)}Po.compositionstart=Po.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((t=>!1===t.type.spec.inclusive))))t.markCursor=t.state.storedMarks||n.marks(),di(t,!0),t.markCursor=null;else if(di(t),Nn&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let e=t.domSelectionRange();for(let n=e.focusNode,r=e.focusOffset;n&&1==n.nodeType&&0!=r;){let e=r<0?n.lastChild:n.childNodes[r-1];if(!e)break;if(3==e.nodeType){t.domSelection().collapse(e,e.nodeValue.length);break}n=e,r=-1}}t.input.composing=!0}ai(t,li)},Po.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,ai(t,20))};const pi=Mn&&On<15||Rn&&$n<604;function fi(t){return 0==t.openStart&&0==t.openEnd&&1==t.content.childCount?t.content.firstChild:null}function mi(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus(),setTimeout((()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?gi(t,r.value,null,t.input.shiftKey,e):gi(t,r.textContent,r.innerHTML,t.input.shiftKey,e)}),50)}function gi(t,e,n,r,o){let i=ko(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",(e=>e(t,o,i||m.empty))))return!0;if(!i)return!1;let s=fi(i),l=s?t.state.tr.replaceSelectionWith(s,t.input.shiftKey):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}$o.copy=Po.cut=(t,e)=>{let n=e,r=t.state.selection,o="cut"==n.type;if(r.empty)return;let i=pi?null:n.clipboardData,s=r.content(),{dom:l,text:a}=xo(t,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):ui(t,l),o&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},Po.paste=(t,e)=>{let n=e;if(t.composing&&!_n)return;let r=pi?null:n.clipboardData;r&&gi(t,r.getData("text/plain"),r.getData("text/html"),t.input.shiftKey,n)?n.preventDefault():mi(t,n)};class yi{constructor(t,e){this.slice=t,this.move=e}}const wi=zn?"altKey":"ctrlKey";$o.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let o=t.state.selection,i=o.empty?null:t.posAtCoords(Ko(n));if(i&&i.pos>=o.from&&i.pos<=(o instanceof Ve?o.to-1:o.to));else if(r&&r.mightDrag)t.dispatch(t.state.tr.setSelection(Ve.create(t.state.doc,r.mightDrag.pos)));else if(n.target&&1==n.target.nodeType){let e=t.docView.nearestDesc(n.target,!0);e&&e.node.type.spec.draggable&&e!=t.docView&&t.dispatch(t.state.tr.setSelection(Ve.create(t.state.doc,e.posBefore)))}let s=t.state.selection.content(),{dom:l,text:a}=xo(t,s);n.dataTransfer.clearData(),n.dataTransfer.setData(pi?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",pi||n.dataTransfer.setData("text/plain",a),t.dragging=new yi(s,!n[wi])},$o.dragend=t=>{let e=t.dragging;window.setTimeout((()=>{t.dragging==e&&(t.dragging=null)}),50)},Po.dragover=Po.dragenter=(t,e)=>e.preventDefault(),Po.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let o=t.posAtCoords(Ko(n));if(!o)return;let i=t.state.doc.resolve(o.pos),s=r&&r.slice;s?t.someProp("transformPasted",(e=>{s=e(s,t)})):s=ko(t,n.dataTransfer.getData(pi?"Text":"text/plain"),pi?null:n.dataTransfer.getData("text/html"),!1,i);let l=!(!r||n[wi]);if(t.someProp("handleDrop",(e=>e(t,n,s||m.empty,l))))return void n.preventDefault();if(!s)return;n.preventDefault();let a=s?pe(t.state.doc,i.pos,s):i.pos;null==a&&(a=i.pos);let c=t.state.tr;l&&c.deleteSelection();let h=c.mapping.map(a),d=0==s.openStart&&0==s.openEnd&&1==s.content.childCount,u=c.doc;if(d?c.replaceRangeWith(h,h,s.content.firstChild):c.replaceRange(h,h,s),c.doc.eq(u))return;let p=c.doc.resolve(h);if(d&&Ve.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new Ve(p));else{let e=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach(((t,n,r,o)=>e=o)),c.setSelection(eo(t,p,c.doc.resolve(e)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))},$o.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout((()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&qr(t)}),20))},$o.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)},$o.beforeinput=(t,e)=>{let n=e;if(An&&_n&&"deleteContentBackward"==n.inputType){t.domObserver.flushSoon();let{domChangeCount:e}=t.input;setTimeout((()=>{if(t.input.domChangeCount!=e)return;if(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",(e=>e(t,yn(8,"Backspace")))))return;let{$cursor:n}=t.state.selection;n&&n.pos>0&&t.dispatch(t.state.tr.delete(n.pos-1,n.pos).scrollIntoView())}),50)}};for(let r in Po)$o[r]=Po[r];function vi(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class bi{constructor(t,e){this.toDOM=t,this.spec=e||Mi,this.side=this.spec.side||0}map(t,e,n,r){let{pos:o,deleted:i}=t.mapResult(e.from+r,this.side<0?-1:1);return i?null:new Si(o-n,o-n,this)}valid(){return!0}eq(t){return this==t||t instanceof bi&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&vi(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}}class xi{constructor(t,e){this.attrs=t,this.spec=e||Mi}map(t,e,n,r){let o=t.map(e.from+r,this.spec.inclusiveStart?-1:1)-n,i=t.map(e.to+r,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new Si(o,i,this)}valid(t,e){return e.from=t&&(!o||o(s.spec))&&n.push(s.copy(s.from+r,s.to+r))}for(let i=0;it){let s=this.children[i]+1;this.children[i+2].findInner(t-s,e-s,n,r+s,o)}}map(t,e,n){return this==Ni||0==t.maps.length?this:this.mapInner(t,e,0,0,n||Mi)}mapInner(t,e,n,r,o){let i;for(let s=0;s{let s,l=i+n;if(s=Ri(e,t,l)){r||(r=this.children.slice());while(oi&&e.to=t){this.children[s]==t&&(n=this.children[s+2]);break}let o=t+1,i=o+e.content.size;for(let s=0;so&&t.type instanceof xi){let e=Math.max(o,t.from)-o,n=Math.min(i,t.to)-o;en.map(t,e,Mi)));return Ei.from(n)}forChild(t,e){if(e.isLeaf)return Oi.empty;let n=[];for(let r=0;rt instanceof Oi))?t:t.reduce(((t,e)=>t.concat(e instanceof Oi?e:e.members)),[]))}}}function Ai(t,e,n,r,o,i,s){let l=t.slice();for(let c=0,h=i;c{let s=i-r-(n-e);for(let a=0;ai+h-t)continue;let c=l[a]+h-t;n>=c?l[a+1]=e<=c?-2:-1:r>=o&&s&&(l[a]+=s,l[a+1]+=s)}t+=s})),h=n.maps[c].map(h,-1)}let a=!1;for(let c=0;c=r.content.size){a=!0;continue}let d=n.map(t[c+1]+i,-1),u=d-o,{index:p,offset:f}=r.content.findIndex(h),m=r.maybeChild(p);if(m&&f==h&&f+m.nodeSize==u){let r=l[c+2].mapInner(n,m,e+1,t[c]+i+1,s);r!=Ni?(l[c]=h,l[c+1]=u,l[c+2]=r):(l[c+1]=-2,a=!0)}else a=!0}if(a){let a=Ti(l,t,e,n,o,i,s),c=_i(a,r,0,s);e=c.local;for(let t=0;tn&&i.to{let l=Ri(t,e,s+n);if(l){i=!0;let t=_i(l,e,n+s+1,r);t!=Ni&&o.push(s,s+e.nodeSize,t)}}));let s=Di(i?zi(t):t,-n).sort(Ii);for(let l=0;l0)e++;t.splice(e,0,n)}function Bi(t){let e=[];return t.someProp("decorations",(n=>{let r=n(t.state);r&&r!=Ni&&e.push(r)})),t.cursorWrapper&&e.push(Oi.create(t.state.doc,[t.cursorWrapper.deco])),Ei.from(e)}const Vi={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Fi=Mn&&On<=11;class Li{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}}class ji{constructor(t,e){this.view=t,this.handleDOMChange=e,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Li,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver((t=>{for(let e=0;e"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length))?this.flushSoon():this.flush()})),Fi&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout((()=>{this.flushingSoon=-1,this.flush()}),20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Vi)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let e=0;ethis.flush()),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout((()=>this.suppressingSelectionUpdates=!1),50)}onSelectionChange(){if(no(this.view)){if(this.suppressingSelectionUpdates)return qr(this.view);if(Mn&&On<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&hn(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return!0;let e,n=new Set;for(let o=t.focusNode;o;o=ln(o))n.add(o);for(let o=t.anchorNode;o;o=ln(o))if(n.has(o)){e=o;break}let r=e&&this.view.docView.nearestDesc(e);return r&&r.ignoreMutation({type:"selection",target:3==e.nodeType?e.parentNode:e})?(this.setCurSelection(),!0):void 0}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let e=this.observer?this.observer.takeRecords():[];this.queue.length&&(e=this.queue.concat(e),this.queue.length=0);let n=t.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&no(t)&&!this.ignoreSelectionChange(n),o=-1,i=-1,s=!1,l=[];if(t.editable)for(let c=0;c1){let t=l.filter((t=>"BR"==t.nodeName));if(2==t.length){let e=t[0],n=t[1];e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}}let a=null;o<0&&r&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)-1||r)&&(o>-1&&(t.docView.markDirty(o,i),Wi(t)),this.handleDOMChange(o,i,s,l),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(n)||qr(t),this.currentSelection.set(n))}registerMutation(t,e){if(e.indexOf(t.target)>-1)return null;let n=this.view.docView.nearestDesc(t.target);if("attributes"==t.type&&(n==this.view.docView||"contenteditable"==t.attributeName||"style"==t.attributeName&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(t))return null;if("childList"==t.type){for(let n=0;ni;g--){let t=o.childNodes[g-1],e=t.pmViewDesc;if("BR"==t.nodeName&&!e){s=g;break}if(!e||e.size)break}let d=t.state.doc,u=t.someProp("domParser")||it.fromSchema(t.state.schema),p=d.resolve(l),f=null,m=u.parse(o,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:s,preserveWhitespace:"pre"!=p.parent.type.whitespace||"full",findPositions:r,ruleFromNode:Ui,context:p});if(r&&null!=r[0].pos){let t=r[0].pos,e=r[1]&&r[1].pos;null==e&&(e=t),f={anchor:t+l,head:e+l}}return{doc:m,sel:f,from:l,to:a}}function Ui(t){let e=t.pmViewDesc;if(e)return e.parseRule();if("BR"==t.nodeName&&t.parentNode){if(Tn&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}if(t.parentNode.lastChild==t||Tn&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if("IMG"==t.nodeName&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Gi=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Xi(t,e,n,r,o){if(e<0){let e=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,n=Jr(t,e);if(n&&!t.state.selection.eq(n)){if(An&&_n&&13===t.input.lastKeyCode&&Date.now()-100e(t,yn(13,"Enter")))))return;let r=t.state.tr.setSelection(n);"pointer"==e?r.setMeta("pointer",!0):"key"==e&&r.scrollIntoView(),t.dispatch(r)}return}let i=t.state.doc.resolve(e),s=i.sharedDepth(n);e=i.before(s+1),n=t.state.doc.resolve(n).after(s+1);let l,a,c=t.state.selection,h=Ki(t,e,n),d=t.state.doc,u=d.slice(h.from,h.to);8===t.input.lastKeyCode&&Date.now()-100Date.now()-225||_n)&&o.some((t=>1==t.nodeType&&!Gi.test(t.nodeName)))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",(e=>e(t,yn(13,"Enter")))))return void(t.input.lastIOSEnter=0);if(!p){if(!(r&&c instanceof Pe&&!c.empty&&c.$head.sameParent(c.$anchor))||t.composing||h.sel&&h.sel.anchor!=h.sel.head){if(h.sel){let e=Yi(t,t.state.doc,h.sel);e&&!e.eq(t.state.selection)&&t.dispatch(t.state.tr.setSelection(e))}return}p={start:c.from,endA:c.to,endB:c.to}}if(An&&t.cursorWrapper&&h.sel&&h.sel.anchor==t.cursorWrapper.deco.from&&h.sel.head==h.sel.anchor){let t=p.endB-p.start;h.sel={anchor:h.sel.anchor+t,head:h.sel.anchor+t}}t.input.domChangeCount++,t.state.selection.fromt.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=h.from?p.start=t.state.selection.from:p.endA=t.state.selection.to-2&&t.state.selection.to<=h.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),Mn&&On<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>h.from&&" "==h.doc.textBetween(p.start-h.from-1,p.start-h.from+1)&&(p.start--,p.endA--,p.endB--);let f,m=h.doc.resolveNoCache(p.start-h.from),g=h.doc.resolveNoCache(p.endB-h.from),y=d.resolve(p.start),w=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA;if((Rn&&t.input.lastIOSEnter>Date.now()-225&&(!w||o.some((t=>"DIV"==t.nodeName||"P"==t.nodeName)))||!w&&m.pose(t,yn(13,"Enter")))))return void(t.input.lastIOSEnter=0);if(t.state.selection.anchor>p.start&&Qi(d,p.start,p.endA,m,g)&&t.someProp("handleKeyDown",(e=>e(t,yn(8,"Backspace")))))return void(_n&&An&&t.domObserver.suppressSelectionUpdates());An&&_n&&p.endB==p.start&&(t.input.lastAndroidDelete=Date.now()),_n&&!w&&m.start()!=g.start()&&0==g.parentOffset&&m.depth==g.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==p.endA&&(p.endB-=2,g=h.doc.resolveNoCache(p.endB-h.from),setTimeout((()=>{t.someProp("handleKeyDown",(function(e){return e(t,yn(13,"Enter"))}))}),20));let v,b,x,k=p.start,S=p.endA;if(w)if(m.pos==g.pos)Mn&&On<=11&&0==m.parentOffset&&(t.domObserver.suppressSelectionUpdates(),setTimeout((()=>qr(t)),20)),v=t.state.tr.delete(k,S),b=d.resolve(p.start).marksAcross(d.resolve(p.endA));else if(p.endA==p.endB&&(x=Zi(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start()))))v=t.state.tr,"add"==x.type?v.addMark(k,S,x.mark):v.removeMark(k,S,x.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let e=m.parent.textBetween(m.parentOffset,g.parentOffset);if(t.someProp("handleTextInput",(n=>n(t,k,S,e))))return;v=t.state.tr.insertText(e,k,S)}if(v||(v=t.state.tr.replace(k,S,h.doc.slice(p.start-h.from,p.endB-h.from))),h.sel){let e=Yi(t,v.doc,h.sel);e&&!(An&&_n&&t.composing&&e.empty&&(p.start!=p.endB||t.input.lastAndroidDeletee.content.size?null:eo(t,e.resolve(n.anchor),e.resolve(n.head))}function Zi(t,e){let n,r,o,i=t.firstChild.marks,s=e.firstChild.marks,l=i,a=s;for(let c=0;ct.mark(r.addToSet(t.marks));else{if(0!=l.length||1!=a.length)return null;r=a[0],n="remove",o=t=>t.mark(r.removeFromSet(t.marks))}let h=[];for(let c=0;cn||ts(s,!0,!1)0&&(e||t.indexAfter(r)==t.node(r).childCount))r--,o++,e=!1;if(n){let e=t.node(r).maybeChild(t.indexAfter(r));while(e&&!e.isLeaf)e=e.firstChild,o++}return o}function es(t,e,n,r,o){let i=t.findDiffStart(e,n);if(null==i)return null;let{a:s,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if("end"==o){let t=Math.max(0,i-Math.min(s,l));r-=s+t-i}if(s=s?i-r:0;i-=t,l=i+(l-s),s=i}else if(l=l?i-r:0;i-=t,s=i+(s-l),l=i}return{start:i,endA:s,endB:l}}class ns{constructor(t,e){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Vo,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=e,this.state=e.state,this.directPlugins=e.plugins||[],this.directPlugins.forEach(hs),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):"function"==typeof t?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=ss(this),is(this),this.nodeViews=as(this),this.docView=Sr(this.state.doc,rs(this),Bi(this),this.dom,this),this.domObserver=new ji(this,((t,e,n,r)=>Xi(this,t,e,n,r))),this.domObserver.start(),Fo(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let e in t)this._props[e]=t[e];this._props.state=this.state}return this._props}update(t){t.handleDOMEvents!=this._props.handleDOMEvents&&Ho(this);let e=this._props;this._props=t,t.plugins&&(t.plugins.forEach(hs),this.directPlugins=t.plugins),this.updateStateInner(t.state,e)}setProps(t){let e={};for(let n in this._props)e[n]=this._props[n];e.state=this.state;for(let n in t)e[n]=t[n];this.update(e)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,e){let n=this.state,r=!1,o=!1;t.storedMarks&&this.composing&&(ci(this),o=!0),this.state=t;let i=n.plugins!=t.plugins||this._props.plugins!=e.plugins;if(i||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let t=as(this);cs(t,this.nodeViews)&&(this.nodeViews=t,r=!0)}(i||e.handleDOMEvents!=this._props.handleDOMEvents)&&Ho(this),this.editable=ss(this),is(this);let s=Bi(this),l=rs(this),a=n.plugins==t.plugins||n.doc.eq(t.doc)?t.scrollToSelection>n.scrollToSelection?"to selection":"preserve":"reset",c=r||!this.docView.matchesNode(t.doc,l,s);!c&&t.selection.eq(n.selection)||(o=!0);let h="preserve"==a&&o&&null==this.dom.style.overflowAnchor&&Ln(this);if(o){this.domObserver.stop();let e=c&&(Mn||An)&&!this.composing&&!n.selection.empty&&!t.selection.empty&&ls(n.selection,t.selection);if(c){let n=An?this.trackWrites=this.domSelectionRange().focusNode:null;!r&&this.docView.update(t.doc,l,s,this)||(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=Sr(t.doc,l,s,this.dom,this)),n&&!this.trackWrites&&(e=!0)}e||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&oo(this))?qr(this,e):(Qr(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),"reset"==a?this.dom.scrollTop=0:"to selection"==a?this.scrollToSelection():h&&Hn(h)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(this.someProp("handleScrollToSelection",(t=>t(this))));else if(this.state.selection instanceof Ve){let e=this.docView.domAfterPos(this.state.selection.from);1==e.nodeType&&Fn(this,e.getBoundingClientRect(),t)}else Fn(this,this.coordsAtPos(this.state.selection.head,1),t)}destroyPluginViews(){let t;while(t=this.pluginViews.pop())t.destroy&&t.destroy()}updatePluginViews(t){if(t&&t.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let e=0;ee.ownerDocument.getSelection()),this._root=e;return t||document}posAtCoords(t){return tr(this,t)}coordsAtPos(t,e=1){return rr(this,t,e)}domAtPos(t,e=0){return this.docView.domFromPos(t,e)}nodeDOM(t){let e=this.docView.descAt(t);return e?e.nodeDOM:null}posAtDOM(t,e,n=-1){let r=this.docView.posFromDOM(t,e,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(t,e){return pr(this,e||this.state,t)}pasteHTML(t,e){return gi(this,"",t,!1,e||new ClipboardEvent("paste"))}pasteText(t,e){return gi(this,t,null,!0,e||new ClipboardEvent("paste"))}destroy(){this.docView&&(jo(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Bi(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)}get isDestroyed(){return null==this.docView}dispatchEvent(t){return qo(this,t)}dispatch(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))}domSelectionRange(){return Tn&&11===this.root.nodeType&&wn(this.dom.ownerDocument)==this.dom?qi(this):this.domSelection()}domSelection(){return this.root.getSelection()}}function rs(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),e.translate="no",t.someProp("attributes",(n=>{if("function"==typeof n&&(n=n(t.state)),n)for(let t in n)"class"==t&&(e.class+=" "+n[t]),"style"==t?e.style=(e.style?e.style+";":"")+n[t]:e[t]||"contenteditable"==t||"nodeName"==t||(e[t]=String(n[t]))})),[Si.node(0,t.state.doc.content.size,e)]}function is(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Si.widget(t.state.selection.head,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function ss(t){return!t.someProp("editable",(e=>!1===e(t.state)))}function ls(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function as(t){let e=Object.create(null);function n(t){for(let n in t)Object.prototype.hasOwnProperty.call(e,n)||(e[n]=t[n])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function cs(t,e){let n=0,r=0;for(let o in t){if(t[o]!=e[o])return!0;n++}for(let o in e)r++;return n!=r}function hs(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}function ds(t={}){return new en({view(e){return new us(e,t)}})}class us{constructor(t,e){this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=e.width||1,this.color=e.color||"black",this.class=e.class,this.handlers=["dragover","dragend","drop","dragleave"].map((e=>{let n=t=>{this[e](t)};return t.dom.addEventListener(e,n),{name:e,handler:n}}))}destroy(){this.handlers.forEach((({name:t,handler:e})=>this.editorView.dom.removeEventListener(t,e)))}update(t,e){null!=this.cursorPos&&e.doc!=t.state.doc&&(this.cursorPos>t.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(t){t!=this.cursorPos&&(this.cursorPos=t,null==t?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let t,e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent;if(n){let n=e.nodeBefore,r=e.nodeAfter;if(n||r){let e=this.editorView.nodeDOM(this.cursorPos-(n?n.nodeSize:0));if(e){let o=e.getBoundingClientRect(),i=n?o.bottom:o.top;n&&r&&(i=(i+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),t={left:o.left,right:o.right,top:i-this.width/2,bottom:i+this.width/2}}}}if(!t){let e=this.editorView.coordsAtPos(this.cursorPos);t={left:e.left-this.width/2,right:e.left+this.width/2,top:e.top,bottom:e.bottom}}let r,o,i=this.editorView.dom.offsetParent;if(this.element||(this.element=i.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none; background-color: "+this.color),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n),!i||i==document.body&&"static"==getComputedStyle(i).position)r=-pageXOffset,o=-pageYOffset;else{let t=i.getBoundingClientRect();r=t.left-i.scrollLeft,o=t.top-i.scrollTop}this.element.style.left=t.left-r+"px",this.element.style.top=t.top-o+"px",this.element.style.width=t.right-t.left+"px",this.element.style.height=t.bottom-t.top+"px"}scheduleRemoval(t){clearTimeout(this.timeout),this.timeout=setTimeout((()=>this.setCursor(null)),t)}dragover(t){if(!this.editorView.editable)return;let e=this.editorView.posAtCoords({left:t.clientX,top:t.clientY}),n=e&&e.inside>=0&&this.editorView.state.doc.nodeAt(e.inside),r=n&&n.type.spec.disableDropCursor,o="function"==typeof r?r(this.editorView,e,t):r;if(e&&!o){let t=e.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=pe(this.editorView.state.doc,t,this.editorView.dragging.slice);null!=e&&(t=e)}this.setCursor(t),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){t.target!=this.editorView.dom&&this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)}}for(var ps={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:"'"},fs={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ms="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent),gs=("undefined"!=typeof navigator&&/Gecko\/\d+/.test(navigator.userAgent),"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)),ys="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),ws=gs||ms&&+ms[1]<57,vs=0;vs<10;vs++)ps[48+vs]=ps[96+vs]=String(vs);for(vs=1;vs<=24;vs++)ps[vs+111]="F"+vs;for(vs=65;vs<=90;vs++)ps[vs]=String.fromCharCode(vs+32),fs[vs]=String.fromCharCode(vs);for(var bs in ps)fs.hasOwnProperty(bs)||(fs[bs]=ps[bs]);function xs(t){var e=ws&&(t.ctrlKey||t.altKey||t.metaKey)||ys&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key,n=!e&&t.key||(t.shiftKey?fs:ps)[t.keyCode]||t.key||"Unidentified";return"Esc"==n&&(n="Escape"),"Del"==n&&(n="Delete"),"Left"==n&&(n="ArrowLeft"),"Up"==n&&(n="ArrowUp"),"Right"==n&&(n="ArrowRight"),"Down"==n&&(n="ArrowDown"),n}const ks="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function Ss(t){let e,n,r,o,i=t.split(/-(?!$)/),s=i[i.length-1];"Space"==s&&(s=" ");for(let l=0;l127)&&(r=ps[n.keyCode])&&r!=o){let o=e[Ms(r,n)];if(o&&o(t.state,t.dispatch,t))return!0}}return!1}}class Es extends ze{constructor(t){super(t,t)}map(t,e){let n=t.resolve(e.map(this.head));return Es.valid(n)?new Es(n):ze.near(n)}content(){return m.empty}eq(t){return t instanceof Es&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new Es(t.resolve(e.pos))}getBookmark(){return new As(this.anchor)}static valid(t){let e=t.parent;if(e.isTextblock||!Ds(t)||!Ts(t))return!1;let n=e.type.spec.allowGapCursor;if(null!=n)return n;let r=e.contentMatchAt(t.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,e,n=!1){t:for(;;){if(!n&&Es.valid(t))return t;let r=t.pos,o=null;for(let n=t.depth;;n--){let i=t.node(n);if(e>0?t.indexAfter(n)0){o=i.child(e>0?t.indexAfter(n):t.index(n)-1);break}if(0==n)return null;r+=e;let s=t.doc.resolve(r);if(Es.valid(s))return s}for(;;){let i=e>0?o.firstChild:o.lastChild;if(!i){if(o.isAtom&&!o.isText&&!Ve.isSelectable(o)){t=t.doc.resolve(r+o.nodeSize*e),n=!1;continue t}break}o=i,r+=e;let s=t.doc.resolve(r);if(Es.valid(s))return s}return null}}}Es.prototype.visible=!1,Es.findFrom=Es.findGapCursorFrom,ze.jsonID("gapcursor",Es);class As{constructor(t){this.pos=t}map(t){return new As(t.map(this.pos))}resolve(t){let e=t.resolve(this.pos);return Es.valid(e)?new Es(e):ze.near(e)}}function Ds(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(0!=n)for(let t=r.child(n-1);;t=t.lastChild){if(0==t.childCount&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return!0;if(t.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}function Ts(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n!=r.childCount)for(let t=r.child(n);;t=t.firstChild){if(0==t.childCount&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return!0;if(t.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}function Rs(){return new en({props:{decorations:Ps,createSelectionBetween(t,e,n){return e.pos==n.pos&&Es.valid(n)?new Es(n):null},handleClick:Is,handleKeyDown:zs,handleDOMEvents:{beforeinput:$s}}})}const zs=Ns({ArrowLeft:_s("horiz",-1),ArrowRight:_s("horiz",1),ArrowUp:_s("vert",-1),ArrowDown:_s("vert",1)});function _s(t,e){const n="vert"==t?e>0?"down":"up":e>0?"right":"left";return function(t,r,o){let i=t.selection,s=e>0?i.$to:i.$from,l=i.empty;if(i instanceof Pe){if(!o.endOfTextblock(n)||0==s.depth)return!1;l=!1,s=t.doc.resolve(e>0?s.after():s.before())}let a=Es.findGapCursorFrom(s,e,l);return!!a&&(r&&r(t.tr.setSelection(new Es(a))),!0)}}function Is(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Es.valid(r))return!1;let o=t.posAtCoords({left:n.clientX,top:n.clientY});return!(o&&o.inside>-1&&Ve.isSelectable(t.state.doc.nodeAt(o.inside)))&&(t.dispatch(t.state.tr.setSelection(new Es(r))),!0)}function $s(t,e){if("insertCompositionText"!=e.inputType||!(t.state.selection instanceof Es))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let o=c.empty;for(let s=r.length-1;s>=0;s--)o=c.from(r[s].createAndFill(null,o));let i=t.state.tr.replace(n.pos,n.pos,new m(o,0,0));return i.setSelection(Pe.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function Ps(t){if(!(t.selection instanceof Es))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Oi.create(t.doc,[Si.widget(t.selection.head,e,{key:"gapcursor"})])}const Bs=(t,e)=>!t.selection.empty&&(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Vs(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Fs=(t,e,n)=>{let r=Vs(t,n);if(!r)return!1;let o=Hs(r);if(!o){let n=r.blockRange(),o=n&&Yt(n);return null!=o&&(e&&e(t.tr.lift(n,o).scrollIntoView()),!0)}let i=o.nodeBefore;if(!i.type.spec.isolating&&ol(t,o,e))return!0;if(0==r.parent.content.size&&(Ls(i,"end")||Ve.isSelectable(i))){let n=fe(t.doc,r.before(),r.after(),m.empty);if(n&&n.slice.size{let{$head:r,empty:o}=t.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=Hs(r)}let s=i&&i.nodeBefore;return!(!s||!Ve.isSelectable(s))&&(e&&e(t.tr.setSelection(Ve.create(t.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function Hs(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function Js(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset{let r=Js(t,n);if(!r)return!1;let o=Ks(r);if(!o)return!1;let i=o.nodeAfter;if(ol(t,o,e))return!0;if(0==r.parent.content.size&&(Ls(i,"start")||Ve.isSelectable(i))){let n=fe(t.doc,r.before(),r.after(),m.empty);if(n&&n.slice.size{let{$head:r,empty:o}=t.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset=0;e--){let n=t.node(e);if(t.index(e)+1{let{$from:n,$to:r}=t.selection,o=n.blockRange(r),i=o&&Yt(o);return null!=i&&(e&&e(t.tr.lift(o,i).scrollIntoView()),!0)},Gs=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!(!n.parent.type.spec.code||!n.sameParent(r))&&(e&&e(t.tr.insertText("\n").scrollIntoView()),!0)};function Xs(t){for(let e=0;e{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let o=n.node(-1),i=n.indexAfter(-1),s=Xs(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(e){let r=n.after(),o=t.tr.replaceWith(r,r,s.createAndFill());o.setSelection(ze.near(o.doc.resolve(r),1)),e(o.scrollIntoView())}return!0},Zs=(t,e)=>{let n=t.selection,{$from:r,$to:o}=n;if(n instanceof Le||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=Xs(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let n=(!r.parentOffset&&o.index(){let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(le(t.doc,r))return e&&e(t.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),o=r&&Yt(r);return null!=o&&(e&&e(t.tr.lift(r,o).scrollIntoView()),!0)};function tl(t){return(e,n)=>{let{$from:r,$to:o}=e.selection;if(e.selection instanceof Ve&&e.selection.node.isBlock)return!(!r.parentOffset||!le(e.doc,r.pos))&&(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.parent.isBlock)return!1;if(n){let i=o.parentOffset==o.parent.content.size,s=e.tr;(e.selection instanceof Pe||e.selection instanceof Le)&&s.deleteSelection();let l=0==r.depth?null:Xs(r.node(-1).contentMatchAt(r.indexAfter(-1))),a=t&&t(o.parent,i),c=a?[a]:i&&l?[{type:l}]:void 0,h=le(s.doc,s.mapping.map(r.pos),1,c);if(c||h||!le(s.doc,s.mapping.map(r.pos),1,l?[{type:l}]:void 0)||(l&&(c=[{type:l}]),h=!0),h&&(s.split(s.mapping.map(r.pos),1,c),!i&&!r.parentOffset&&r.parent.type!=l)){let t=s.mapping.map(r.before()),e=s.doc.resolve(t);l&&r.node(-1).canReplaceWith(e.index(),e.index()+1,l)&&s.setNodeMarkup(s.mapping.map(r.before()),l)}n(s.scrollIntoView())}return!0}}const el=tl(),nl=(t,e)=>(e&&e(t.tr.setSelection(new Le(t.doc))),!0);function rl(t,e,n){let r=e.nodeBefore,o=e.nodeAfter,i=e.index();return!!(r&&o&&r.type.compatibleContent(o.type))&&(!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!(!e.parent.canReplace(i,i+1)||!o.isTextblock&&!ce(t.doc,e.pos))&&(n&&n(t.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),!0))}function ol(t,e,n){let r,o,i=e.nodeBefore,s=e.nodeAfter;if(i.type.spec.isolating||s.type.spec.isolating)return!1;if(rl(t,e,n))return!0;let l=e.parent.canReplace(e.index(),e.index()+1);if(l&&(r=(o=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&o.matchType(r[0]||s.type).validEnd){if(n){let o=e.pos+s.nodeSize,l=c.empty;for(let t=r.length-1;t>=0;t--)l=c.from(r[t].create(null,l));l=c.from(i.copy(l));let a=t.tr.step(new Wt(e.pos-1,o,e.pos,o,new m(l,1,0),r.length,!0)),h=o+2*r.length;ce(a.doc,h)&&a.join(h),n(a.scrollIntoView())}return!0}let a=ze.findFrom(e,1),h=a&&a.$from.blockRange(a.$to),d=h&&Yt(h);if(null!=d&&d>=e.depth)return n&&n(t.tr.lift(h,d).scrollIntoView()),!0;if(l&&Ls(s,"start",!0)&&Ls(i,"end")){let r=i,o=[];for(;;){if(o.push(r),r.isTextblock)break;r=r.lastChild}let l=s,a=1;for(;!l.isTextblock;l=l.firstChild)a++;if(r.canReplace(r.childCount,r.childCount,l.content)){if(n){let r=c.empty;for(let t=o.length-1;t>=0;t--)r=c.from(o[t].copy(r));let i=t.tr.step(new Wt(e.pos-o.length,e.pos+s.nodeSize,e.pos+a,e.pos+s.nodeSize-a,new m(r,o.length,0),0,!0));n(i.scrollIntoView())}return!0}}return!1}function il(t){return function(e,n){let r=e.selection,o=t<0?r.$from:r.$to,i=o.depth;while(o.node(i).isInline){if(!i)return!1;i--}return!!o.node(i).isTextblock&&(n&&n(e.tr.setSelection(Pe.create(e.doc,t<0?o.start(i):o.end(i)))),!0)}}const sl=il(-1),ll=il(1);function al(t,e=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),l=s&&Qt(s,t,e);return!!l&&(r&&r(n.tr.wrap(s,l).scrollIntoView()),!0)}}function cl(t,e=null){return function(n,r){let o=!1;for(let i=0;i{if(o)return!1;if(r.isTextblock&&!r.hasMarkup(t,e))if(r.type==t)o=!0;else{let e=n.doc.resolve(i),r=e.index();o=e.parent.canReplaceWith(r,r+1,t)}}))}if(!o)return!1;if(r){let o=n.tr;for(let r=0;r{if(s)return!1;s=t.inlineContent&&t.type.allowsMarkType(n)})),s)return!0}return!1}function dl(t,e=null){return function(n,r){let{empty:o,$cursor:i,ranges:s}=n.selection;if(o&&!i||!hl(n.doc,s,t))return!1;if(r)if(i)t.isInSet(n.storedMarks||i.marks())?r(n.tr.removeStoredMark(t)):r(n.tr.addStoredMark(t.create(e)));else{let o=!1,i=n.tr;for(let e=0;!o&&e0&&(i=n[0].slice(t-e,t)+i,r=o)}return e.tr.insertText(i,r,o)}}const xl=500;function kl({rules:t}){let e=new en({state:{init(){return null},apply(t,e){let n=t.getMeta(this);return n||(t.selectionSet||t.docChanged?null:e)}},props:{handleTextInput(n,r,o,i){return Sl(n,r,o,i,t,e)},handleDOMEvents:{compositionend:n=>{setTimeout((()=>{let{$cursor:r}=n.state.selection;r&&Sl(n,r.pos,r.pos,"",t,e)}))}}},isInputRules:!0});return e}function Sl(t,e,n,r,o,i){if(t.composing)return!1;let s=t.state,l=s.doc.resolve(e);if(l.parent.type.spec.code)return!1;let a=l.parent.textBetween(Math.max(0,l.parentOffset-xl),l.parentOffset,null,"")+r;for(let c=0;c{let n=t.plugins;for(let r=0;r=0;t--)n.step(r.steps[t].invert(r.docs[t]));if(o.text){let e=n.doc.resolve(o.from).marks();n.replaceWith(o.from,o.to,t.schema.text(o.text,e))}else n.delete(o.from,o.to);e(n)}return!0}}return!1};new vl(/--$/,"—"),new vl(/\.\.\.$/,"…"),new vl(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),new vl(/"$/,"”"),new vl(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),new vl(/'$/,"’");function Ml(t,e,n=null,r){return new vl(t,((t,o,i,s)=>{let l=n instanceof Function?n(o):n,a=t.tr.delete(i,s),c=a.doc.resolve(i),h=c.blockRange(),d=h&&Qt(h,e,l);if(!d)return null;a.wrap(h,d);let u=a.doc.resolve(i-1).nodeBefore;return u&&u.type==e&&ce(a.doc,i-1)&&(!r||r(o,u))&&a.join(i-1),a}))}function Ol(t,e,n=null){return new vl(t,((t,r,o,i)=>{let s=t.doc.resolve(o),l=n instanceof Function?n(r):n;return s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),e)?t.tr.delete(o,i).setBlockType(o,o,e,l):null}))}
/*!
* tiptap-utils v1.13.0
* (c) 2021 überdosis GbR (limited liability)
* @license MIT
*/
function Nl(t,e){return e?t.createChecked(null,e):t.createAndFill()}function El(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach((n=>{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)})),t.cached.tableNodeTypes=e,e}function Al(t,e,n,r,o){const i=El(t),s=[],l=[];for(let c=0;c-1||e.type===t}function Tl(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function Rl(t){return e=>Tl(e.$from,t)}function zl(t){return t instanceof Ve}function _l(t){return function(e){if(zl(e)){const{node:n}=e,{$from:r}=e;if(Dl(t,n))return{node:n,pos:r.pos,depth:r.depth}}}}function Il(t,e){const{from:n,to:r}=t.selection;let o=[];t.doc.nodesBetween(n,r,(t=>{o=[...o,...t.marks]}));const i=o.find((t=>t.type.name===e.name));return i?i.attrs:{}}function $l(t=null,e=null){if(!t||!e)return!1;const n=t.parent.childAfter(t.parentOffset);if(!n.node)return!1;const r=n.node.marks.find((t=>t.type===e));if(!r)return!1;let o=t.index(),i=t.start()+n.offset,s=o+1,l=i+n.node.nodeSize;while(o>0&&r.isInSet(t.parent.child(o-1).marks))o-=1,i-=t.parent.child(o).nodeSize;while(s{o=[...o,t]}));const i=o.reverse().find((t=>t.type.name===e.name));return i?i.attrs:{}}function Bl(t,e){const{from:n,$from:r,to:o,empty:i}=t.selection;return i?!!e.isInSet(t.storedMarks||r.marks()):!!t.doc.rangeHasMark(n,o,e)}function Vl(t,e,n={}){const r=t=>t.type===e,o=_l(e)(t.selection)||Rl(r)(t.selection);return Object.keys(n).length&&o?o.node.hasMarkup(e,{...o.node.attrs,...n}):!!o}var Fl=r(2740),Ll=r.n(Fl);function jl(t,e=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),l=!1,a=s;if(!s)return!1;if(s.depth>=2&&o.node(s.depth-1).type.compatibleContent(t)&&0==s.startIndex){if(0==o.index(s.depth-1))return!1;let t=n.doc.resolve(s.start-2);a=new R(t,t,s.depth),s.endIndex=0;d--)i=c.from(n[d].type.create(n[d].attrs,i));t.step(new Wt(e.start-(r?2:0),e.end,e.start,e.end,new m(i,0,0),n.length,!0));let s=0;for(let c=0;c=r.depth-3;t--)o=c.from(r.node(t).copy(o));let s=r.indexAfter(-1){if(h>-1)return!1;t.isTextblock&&0==t.content.size&&(h=e+1)})),h>-1&&a.setSelection(ze.near(a.doc.resolve(h))),n(a.scrollIntoView())}return!0}let l=o.pos==r.end()?s.contentMatchAt(0).defaultType:null,a=e.tr.delete(r.pos,o.pos),h=l?[null,{type:l}]:void 0;return!!le(a.doc,r.pos,2,h)&&(n&&n(a.split(r.pos,2,h).scrollIntoView()),!0)}}function Wl(t){return function(e,n){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,(e=>e.childCount>0&&e.firstChild.type==t));return!!i&&(!n||(r.node(i.depth-1).type==t?ql(e,n,t,i):Kl(e,n,i)))}}function ql(t,e,n,r){let o=t.tr,i=r.end,s=r.$to.end(r.depth);im;f--)c-=o.child(f).nodeSize,r.delete(c-1,c+1);let i=r.doc.resolve(n.start),s=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let l=0==n.startIndex,a=n.endIndex==o.childCount,h=i.node(-1),d=i.index(-1);if(!h.canReplace(d+(l?0:1),d+1,s.content.append(a?c.empty:c.from(o))))return!1;let u=i.pos,p=u+s.nodeSize;return r.step(new Wt(u-(l?1:0),p+(a?1:0),u+1,p-1,new m((l?c.empty:c.from(o.copy(c.empty))).append(a?c.empty:c.from(o.copy(c.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function Ul(t){return function(e,n){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,(e=>e.childCount>0&&e.firstChild.type==t));if(!i)return!1;let s=i.startIndex;if(0==s)return!1;let l=i.parent,a=l.child(s-1);if(a.type!=t)return!1;if(n){let r=a.lastChild&&a.lastChild.type==l.type,o=c.from(r?t.create():null),s=new m(c.from(t.create(null,c.from(l.type.create(null,o)))),r?3:1,0),h=i.start,d=i.end;n(e.tr.step(new Wt(h-(r?3:1),d,h,d,s,1,!0)).scrollIntoView())}return!0}}function Gl(t,e,n){let r=[];return n.doc.nodesBetween(t,e,((t,e)=>{r=[...r,...t.marks.map((n=>({start:e,end:e+t.nodeSize,mark:n})))]})),r}function Xl(t,e,n){return new vl(t,((t,r,o,i)=>{const s=n instanceof Function?n(r):n,{tr:l}=t,a=r.length-1;let c=i,h=o;if(r[a]){const n=o+r[0].indexOf(r[a-1]),s=n+r[a-1].length-1,d=n+r[a-1].lastIndexOf(r[a]),u=d+r[a].length,p=Gl(o,i,t).filter((t=>{const{excluded:n}=t.mark.type;return n.find((t=>t.name===e.name))})).filter((t=>t.end>n));if(p.length)return!1;un&&l.delete(n,d),h=n,c=h+r[a].length}return l.addMark(h,c,e.create(s)),l.removeStoredMark(e),l}))}function Yl(t,e,n){const r=o=>{const i=[];return o.forEach((o=>{if(o.isText){const{text:r}=o;let s,l=0;do{if(s=t.exec(r),s){const t=s.index,r=t+s[0].length,a=n instanceof Function?n(s[0]):n;t>0&&i.push(o.cut(l,t)),i.push(o.cut(t,r).mark(e.create(a).addToSet(o.marks))),l=r}}while(s);lnew m(r(t.content),t.openStart,t.openEnd)}})}function Zl(t,e,n){const r=(o,i)=>{const s=[];return o.forEach((o=>{if(o.isText){const{text:r,marks:l}=o;let a,c=0;const h=!!l.filter((t=>"link"===t.type.name))[0];while(!h&&null!==(a=t.exec(r)))if(i&&i.type.allowsMarkType(e)&&a[1]){const t=a.index,r=t+a[0].length,i=t+a[0].indexOf(a[1]),l=i+a[1].length,h=n instanceof Function?n(a):n;t>0&&s.push(o.cut(c,t)),s.push(o.cut(i,l).mark(e.create(h).addToSet(o.marks))),c=r}cnew m(r(t.content),t.openStart,t.openEnd)}})}function Ql(t){return(e,n)=>{const{tr:r,selection:o}=e;let{from:i,to:s}=o;const{$from:l,empty:a}=o;if(a){const e=$l(l,t);i=e.from,s=e.to}return r.removeMark(i,s,t),n(r)}}function ta(t,e,n=1,r){const o=t.resolve(e),i=o.depth-n,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,h=n-2;c>i;c--,h--){const t=o.node(c),e=o.index(c);if(t.type.spec.isolating)return!1;let n=t.content.cutByIndex(e,t.childCount);const i=r&&r[h]||t;if(i!=t&&(n=n.replaceChild(0,i.type.create(i.attrs))),!t.canReplace(e+1,t.childCount))return!1}const l=o.indexAfter(i),a=r&&r[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function ea(t){return function(e,n){const{$from:r,$to:o,node:i}=e.selection;if(i&&i.isBlock||r.depth<2||!r.sameParent(o))return!1;const s=r.node(-1);if(s.type!=t)return!1;if(0==r.parent.content.size){if(2==r.depth||r.node(-3).type!=t||r.index(-2)!=r.node(-2).childCount-1)return!1;if(n){let o=c.empty;const i=r.index(-1)>0;for(let t=r.depth-(i?1:2);t>=r.depth-3;t--)o=c.from(r.node(t).copy(o));o=o.append(c.from(t.createAndFill()));const s=e.tr.replace(r.before(i?null:-1),r.after(-3),new m(o,i?3:2,2));s.setSelection(e.selection.constructor.near(s.doc.resolve(r.pos+(i?3:2)))),n(s.scrollIntoView())}return!0}const l=o.pos==r.end()?s.contentMatchAt(r.indexAfter(-1)).defaultType:null,a=e.tr.delete(r.pos,o.pos);let h=l&&[{type:t},{type:l}];return h||(h=[{type:t},null]),!!ta(a.doc,r.pos,2,h)&&(n&&n(a.split(r.pos,2,h).scrollIntoView()),!0)}}function na(t,e,n={}){return(r,o,i)=>{const s=Vl(r,t,n);return s?cl(e)(r,o,i):cl(t,n)(r,o,i)}}function ra(t,e){return t.type===e.nodes.bullet_list||t.type===e.nodes.ordered_list||t.type===e.nodes.todo_list}function oa(t,e){return(n,r,o)=>{const{schema:i,selection:s}=n,{$from:l,$to:a}=s,c=l.blockRange(a);if(!c)return!1;const h=Rl((t=>ra(t,i)))(s);if(c.depth>=1&&h&&c.depth-h.depth<=1){if(h.node.type===t)return Wl(e)(n,r,o);if(ra(h.node,i)&&t.validContent(h.node.content)){const{tr:e}=n;return e.setNodeMarkup(h.pos,t),r&&r(e),!1}}return jl(t)(n,r,o)}}function ia(t,e={}){return(n,r,o)=>{const i=Vl(n,t,e);return i?Us(n,r):al(t,e)(n,r,o)}}function sa(t,e){return(n,r)=>{const{tr:o,selection:i,doc:s}=n,{ranges:l,empty:a}=i;if(a){const{from:n,to:r}=$l(i.$from,t);s.rangeHasMark(n,r,t)&&o.removeMark(n,r,t),o.addMark(n,r,t.create(e))}else l.forEach((n=>{const{$to:r,$from:i}=n;s.rangeHasMark(i.pos,r.pos,t)&&o.removeMark(i.pos,r.pos,t),o.addMark(i.pos,r.pos,t.create(e))}));return r(o)}}
/*!
* tiptap v1.32.1
* (c) 2021 überdosis GbR (limited liability)
* @license MIT
*/
function la(t){return t.replace(/(?:^\w|[A-Z]|\b\w)/g,((t,e)=>0===e?t.toLowerCase():t.toUpperCase())).replace(/\s+/g,"")}class aa{constructor(t,{editor:e,extension:n,parent:r,node:o,view:i,decorations:s,getPos:l}){this.component=t,this.editor=e,this.extension=n,this.parent=r,this.node=o,this.view=i,this.decorations=s,this.isNode=!!this.node.marks,this.isMark=!this.isNode,this.getPos=this.isMark?this.getMarkPos:l,this.captureEvents=!0,this.dom=this.createDOM(),this.contentDOM=this.vm.$refs.content}createDOM(){const t=Ll().extend(this.component),e={editor:this.editor,node:this.node,view:this.view,getPos:()=>this.getPos(),decorations:this.decorations,selected:!1,options:this.extension.options,updateAttrs:t=>this.updateAttrs(t)};return"function"===typeof this.extension.setSelection&&(this.setSelection=this.extension.setSelection),"function"===typeof this.extension.update&&(this.update=this.extension.update),this.vm=new t({parent:this.parent,propsData:e}).$mount(),this.vm.$el}update(t,e){return t.type===this.node.type&&(t===this.node&&this.decorations===e||(this.node=t,this.decorations=e,this.updateComponentProps({node:t,decorations:e})),!0)}updateComponentProps(t){if(!this.vm._props)return;const e=Ll().config.silent;Ll().config.silent=!0,Object.entries(t).forEach((([t,e])=>{this.vm._props[t]=e})),Ll().config.silent=e}updateAttrs(t){if(!this.view.editable)return;const{state:e}=this.view,{type:n}=this.node,r=this.getPos(),o={...this.node.attrs,...t},i=this.isMark?e.tr.removeMark(r.from,r.to,n).addMark(r.from,r.to,n.create(o)):e.tr.setNodeMarkup(r,null,o);this.view.dispatch(i)}ignoreMutation(t){return"selection"!==t.type&&(!this.contentDOM||!this.contentDOM.contains(t.target))}stopEvent(t){if("function"===typeof this.extension.stopEvent)return this.extension.stopEvent(t);const e=!!this.extension.schema.draggable;if(e&&"mousedown"===t.type){const e=t.target.closest&&t.target.closest("[data-drag-handle]"),n=e&&(this.dom===e||this.dom.contains(e));n&&(this.captureEvents=!1,document.addEventListener("dragend",(()=>{this.captureEvents=!0}),{once:!0}))}const n="copy"===t.type,r="paste"===t.type,o="cut"===t.type,i=t.type.startsWith("drag")||"drop"===t.type;return!(e&&i||n||r||o)&&this.captureEvents}selectNode(){this.updateComponentProps({selected:!0})}deselectNode(){this.updateComponentProps({selected:!1})}getMarkPos(){const t=this.view.posAtDOM(this.dom),e=this.view.state.doc.resolve(t),n=$l(e,this.node.type);return n}destroy(){this.vm.$destroy()}}class ca{on(t,e){return this._callbacks=this._callbacks||{},this._callbacks[t]||(this._callbacks[t]=[]),this._callbacks[t].push(e),this}emit(t,...e){this._callbacks=this._callbacks||{};const n=this._callbacks[t];return n&&n.forEach((t=>t.apply(this,e))),this}off(t,e){if(arguments.length){const n=this._callbacks?this._callbacks[t]:null;n&&(e?this._callbacks[t]=n.filter((t=>t!==e)):delete this._callbacks[t])}else this._callbacks={};return this}}class ha{constructor(t={}){this.options={...this.defaultOptions,...t}}init(){return null}bindEditor(t=null){this.editor=t}get name(){return null}get type(){return"extension"}get defaultOptions(){return{}}get plugins(){return[]}inputRules(){return[]}pasteRules(){return[]}keys(){return{}}}class da{constructor(t=[],e){t.forEach((t=>{t.bindEditor(e),t.init()})),this.extensions=t}get nodes(){return this.extensions.filter((t=>"node"===t.type)).reduce(((t,{name:e,schema:n})=>({...t,[e]:n})),{})}get options(){const{view:t}=this;return this.extensions.reduce(((e,n)=>({...e,[n.name]:new Proxy(n.options,{set(e,n,r){const o=e[n]!==r;return Object.assign(e,{[n]:r}),o&&t.updateState(t.state),!0}})})),{})}get marks(){return this.extensions.filter((t=>"mark"===t.type)).reduce(((t,{name:e,schema:n})=>({...t,[e]:n})),{})}get plugins(){return this.extensions.filter((t=>t.plugins)).reduce(((t,{plugins:e})=>[...t,...e]),[])}keymaps({schema:t}){const e=this.extensions.filter((t=>["extension"].includes(t.type))).filter((t=>t.keys)).map((e=>e.keys({schema:t}))),n=this.extensions.filter((t=>["node","mark"].includes(t.type))).filter((t=>t.keys)).map((e=>e.keys({type:t[`${e.type}s`][e.name],schema:t})));return[...e,...n].map((t=>Os(t)))}inputRules({schema:t,excludedExtensions:e}){if(!(e instanceof Array)&&e)return[];const n=e instanceof Array?this.extensions.filter((t=>!e.includes(t.name))):this.extensions,r=n.filter((t=>["extension"].includes(t.type))).filter((t=>t.inputRules)).map((e=>e.inputRules({schema:t}))),o=n.filter((t=>["node","mark"].includes(t.type))).filter((t=>t.inputRules)).map((e=>e.inputRules({type:t[`${e.type}s`][e.name],schema:t})));return[...r,...o].reduce(((t,e)=>[...t,...e]),[])}pasteRules({schema:t,excludedExtensions:e}){if(!(e instanceof Array)&&e)return[];const n=e instanceof Array?this.extensions.filter((t=>!e.includes(t.name))):this.extensions,r=n.filter((t=>["extension"].includes(t.type))).filter((t=>t.pasteRules)).map((e=>e.pasteRules({schema:t}))),o=n.filter((t=>["node","mark"].includes(t.type))).filter((t=>t.pasteRules)).map((e=>e.pasteRules({type:t[`${e.type}s`][e.name],schema:t})));return[...r,...o].reduce(((t,e)=>[...t,...e]),[])}commands({schema:t,view:e}){return this.extensions.filter((t=>t.commands)).reduce(((n,r)=>{const{name:o,type:i}=r,s={},l=r.commands({schema:t,...["node","mark"].includes(i)?{type:t[`${i}s`][o]}:{}}),a=(t,n)=>!!e.editable&&(e.focus(),t(n)(e.state,e.dispatch,e)),c=(t,e)=>{Array.isArray(e)?s[t]=t=>e.forEach((e=>a(e,t))):"function"===typeof e&&(s[t]=t=>a(e,t))};return"object"===typeof l?Object.entries(l).forEach((([t,e])=>{c(t,e)})):c(o,l),{...n,...s}}),{})}}function ua(t){{const e=document.createElement("style");e.type="text/css",e.textContent=t;const{head:n}=document,{firstChild:r}=n;r?n.insertBefore(e,r):n.appendChild(e)}}class pa extends ha{constructor(t={}){super(t)}get type(){return"mark"}get view(){return null}get schema(){return null}command(){return()=>{}}}function fa(t=0,e=0,n=0){return Math.min(Math.max(parseInt(t,10),e),n)}class ma extends ha{constructor(t={}){super(t)}get type(){return"node"}get view(){return null}get schema(){return null}command(){return()=>{}}}class ga extends ma{get name(){return"doc"}get schema(){return{content:"block+"}}}class ya extends ma{get name(){return"paragraph"}get schema(){return{content:"inline*",group:"block",draggable:!1,parseDOM:[{tag:"p"}],toDOM:()=>["p",0]}}commands({type:t}){return()=>cl(t)}}class wa extends ma{get name(){return"text"}get schema(){return{group:"inline"}}}var va='.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n}\n\n.ProseMirror-gapcursor:after {\n content: "";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}\n';class ba extends ca{constructor(t={}){super(),this.defaultOptions={editorProps:{},editable:!0,autoFocus:null,extensions:[],content:"",topNode:"doc",emptyDocument:{type:"doc",content:[{type:"paragraph"}]},useBuiltInExtensions:!0,disableInputRules:!1,disablePasteRules:!1,dropCursor:{},enableDropCursor:!0,enableGapCursor:!0,parseOptions:{},injectCSS:!0,onInit:()=>{},onTransaction:()=>{},onUpdate:()=>{},onFocus:()=>{},onBlur:()=>{},onPaste:()=>{},onDrop:()=>{}},this.events=["init","transaction","update","focus","blur","paste","drop"],this.init(t)}init(t={}){this.setOptions({...this.defaultOptions,...t}),this.focused=!1,this.selection={from:0,to:0},this.element=document.createElement("div"),this.extensions=this.createExtensions(),this.nodes=this.createNodes(),this.marks=this.createMarks(),this.schema=this.createSchema(),this.plugins=this.createPlugins(),this.keymaps=this.createKeymaps(),this.inputRules=this.createInputRules(),this.pasteRules=this.createPasteRules(),this.view=this.createView(),this.commands=this.createCommands(),this.setActiveNodesAndMarks(),this.options.injectCSS&&ua(va),null!==this.options.autoFocus&&this.focus(this.options.autoFocus),this.events.forEach((t=>{this.on(t,this.options[la(`on ${t}`)]||(()=>{}))})),this.emit("init",{view:this.view,state:this.state}),this.extensions.view=this.view}setOptions(t){this.options={...this.options,...t},this.view&&this.state&&this.view.updateState(this.state)}get builtInExtensions(){return this.options.useBuiltInExtensions?[new ga,new wa,new ya]:[]}get state(){return this.view?this.view.state:null}createExtensions(){return new da([...this.builtInExtensions,...this.options.extensions],this)}createPlugins(){return this.extensions.plugins}createKeymaps(){return this.extensions.keymaps({schema:this.schema})}createInputRules(){return this.extensions.inputRules({schema:this.schema,excludedExtensions:this.options.disableInputRules})}createPasteRules(){return this.extensions.pasteRules({schema:this.schema,excludedExtensions:this.options.disablePasteRules})}createCommands(){return this.extensions.commands({schema:this.schema,view:this.view})}createNodes(){return this.extensions.nodes}createMarks(){return this.extensions.marks}createSchema(){return new rt({topNode:this.options.topNode,nodes:this.nodes,marks:this.marks})}createState(){return Qe.create({schema:this.schema,doc:this.createDocument(this.options.content),plugins:[...this.plugins,kl({rules:this.inputRules}),...this.pasteRules,...this.keymaps,Os({Backspace:Cl}),Os(wl),...this.options.enableDropCursor?[ds(this.options.dropCursor)]:[],...this.options.enableGapCursor?[Rs()]:[],new en({key:new on("editable"),props:{editable:()=>this.options.editable}}),new en({props:{attributes:{tabindex:0},handleDOMEvents:{focus:(t,e)=>{this.focused=!0,this.emit("focus",{event:e,state:t.state,view:t});const n=this.state.tr.setMeta("focused",!0);this.view.dispatch(n)},blur:(t,e)=>{this.focused=!1,this.emit("blur",{event:e,state:t.state,view:t});const n=this.state.tr.setMeta("focused",!1);this.view.dispatch(n)}}}}),new en({props:this.options.editorProps})]})}createDocument(t,e=this.options.parseOptions){if(null===t)return this.schema.nodeFromJSON(this.options.emptyDocument);if("object"===typeof t)try{return this.schema.nodeFromJSON(t)}catch(n){return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",n),this.schema.nodeFromJSON(this.options.emptyDocument)}if("string"===typeof t){const n=`${t}
`,r=new window.DOMParser,o=r.parseFromString(n,"text/html").body.firstElementChild;return it.fromSchema(this.schema).parse(o,e)}return!1}createView(){return new ns(this.element,{state:this.createState(),handlePaste:(...t)=>{this.emit("paste",...t)},handleDrop:(...t)=>{this.emit("drop",...t)},dispatchTransaction:this.dispatchTransaction.bind(this)})}setParentComponent(t=null){t&&this.view.setProps({nodeViews:this.initNodeViews({parent:t,extensions:[...this.builtInExtensions,...this.options.extensions]})})}initNodeViews({parent:t,extensions:e}){return e.filter((t=>["node","mark"].includes(t.type))).filter((t=>t.view)).reduce(((e,n)=>{const r=(e,r,o,i)=>{const s=n.view;return new aa(s,{editor:this,extension:n,parent:t,node:e,view:r,getPos:o,decorations:i})};return{...e,[n.name]:r}}),{})}dispatchTransaction(t){const e=this.state.apply(t);this.view.updateState(e),this.selection={from:this.state.selection.from,to:this.state.selection.to},this.setActiveNodesAndMarks(),this.emit("transaction",{getHTML:this.getHTML.bind(this),getJSON:this.getJSON.bind(this),state:this.state,transaction:t}),t.docChanged&&!t.getMeta("preventUpdate")&&this.emitUpdate(t)}emitUpdate(t){this.emit("update",{getHTML:this.getHTML.bind(this),getJSON:this.getJSON.bind(this),state:this.state,transaction:t})}resolveSelection(t=null){if(this.selection&&null===t)return this.selection;if("start"===t||!0===t)return{from:0,to:0};if("end"===t){const{doc:t}=this.state;return{from:t.content.size,to:t.content.size}}return{from:t,to:t}}focus(t=null){if(this.view.focused&&null===t||!1===t)return;const{from:e,to:n}=this.resolveSelection(t);this.setSelection(e,n),setTimeout((()=>this.view.focus()),10)}setSelection(t=0,e=0){const{doc:n,tr:r}=this.state,o=fa(t,0,n.content.size),i=fa(e,0,n.content.size),s=Pe.create(n,o,i),l=r.setSelection(s);this.view.dispatch(l)}blur(){this.view.dom.blur()}getSchemaJSON(){return JSON.parse(JSON.stringify({nodes:this.extensions.nodes,marks:this.extensions.marks}))}getHTML(){const t=document.createElement("div"),e=xt.fromSchema(this.schema).serializeFragment(this.state.doc.content);return t.appendChild(e),t.innerHTML}getJSON(){return this.state.doc.toJSON()}setContent(t={},e=!1,n){const{doc:r,tr:o}=this.state,i=this.createDocument(t,n),s=Pe.create(r,0,r.content.size),l=o.setSelection(s).replaceSelectionWith(i,!1).setMeta("preventUpdate",!e);this.view.dispatch(l)}clearContent(t=!1){this.setContent(this.options.emptyDocument,t)}setActiveNodesAndMarks(){this.activeMarks=Object.entries(this.schema.marks).reduce(((t,[e,n])=>({...t,[e]:(t={})=>Bl(this.state,n,t)})),{}),this.activeMarkAttrs=Object.entries(this.schema.marks).reduce(((t,[e,n])=>({...t,[e]:Il(this.state,n)})),{}),this.activeNodes=Object.entries(this.schema.nodes).reduce(((t,[e,n])=>({...t,[e]:(t={})=>Vl(this.state,n,t)})),{})}getMarkAttrs(t=null){return this.activeMarkAttrs[t]}getNodeAttrs(t=null){return{...Pl(this.state,this.schema.nodes[t])}}get isActive(){return Object.entries({...this.activeMarks,...this.activeNodes}).reduce(((t,[e,n])=>({...t,[e]:(t={})=>n(t)})),{})}registerPlugin(t=null,e){const n="function"===typeof e?e(t,this.state.plugins):[t,...this.state.plugins],r=this.state.reconfigure({plugins:n});this.view.updateState(r)}unregisterPlugin(t=null){if(!t||!this.view.docView)return;const e=this.state.reconfigure({plugins:this.state.plugins.filter((e=>!e.key.startsWith(`${t}$`)))});this.view.updateState(e)}destroy(){this.view&&this.view.destroy()}}var xa={props:{editor:{default:null,type:Object}},watch:{editor:{immediate:!0,handler(t){t&&t.element&&this.$nextTick((()=>{this.$el.appendChild(t.element.firstChild),t.setParentComponent(this)}))}}},render(t){return t("div")},beforeDestroy(){this.editor.element=this.$el}};class ka{constructor({options:t}){this.options=t,this.preventHide=!1,this.mousedownHandler=this.handleClick.bind(this),this.options.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.blurHandler=()=>{this.preventHide?this.preventHide=!1:this.options.editor.emit("menubar:focusUpdate",!1)},this.options.editor.on("blur",this.blurHandler)}handleClick(){this.preventHide=!0}destroy(){this.options.element.removeEventListener("mousedown",this.mousedownHandler),this.options.editor.off("blur",this.blurHandler)}}function Sa(t){return new en({key:new on("menu_bar"),view(e){return new ka({editorView:e,options:t})}})}var Ca={props:{editor:{default:null,type:Object}},data(){return{focused:!1}},watch:{editor:{immediate:!0,handler(t){t&&this.$nextTick((()=>{t.registerPlugin(Sa({editor:t,element:this.$el})),this.focused=t.focused,t.on("focus",(()=>{this.focused=!0})),t.on("menubar:focusUpdate",(t=>{this.focused=t}))}))}}},render(){return this.editor?this.$scopedSlots.default({focused:this.focused,focus:this.editor.focus,commands:this.editor.commands,isActive:this.editor.isActive,getMarkAttrs:this.editor.getMarkAttrs.bind(this.editor),getNodeAttrs:this.editor.getNodeAttrs.bind(this.editor)}):null}};function Ma(t,e,n){const r=document.createRange();return r.setEnd(t,null==n?t.nodeValue.length:n),r.setStart(t,Math.max(e,0)),r}function Oa(t,e){const n=t.getClientRects();return n.length?n[e<0?0:n.length-1]:t.getBoundingClientRect()}function Na(t,e,n=!1){const{node:r,offset:o}=t.docView.domFromPos(e);let i,s;if(3===r.nodeType)n&&o!1,...t},this.editorView=e,this.isActive=!1,this.left=0,this.bottom=0,this.top=0,this.preventHide=!1,this.mousedownHandler=this.handleClick.bind(this),this.options.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.focusHandler=({view:t})=>{this.update(t)},this.options.editor.on("focus",this.focusHandler),this.blurHandler=({event:t})=>{this.preventHide?this.preventHide=!1:this.hide(t)},this.options.editor.on("blur",this.blurHandler)}handleClick(){this.preventHide=!0}update(t,e){const{state:n}=t;if(t.composing)return;if(e&&e.doc.eq(n.doc)&&e.selection.eq(n.selection))return;if(n.selection.empty)return void this.hide();const{from:r,to:o}=n.selection,i=Na(t,r),s=Na(t,o,!0),l=this.options.element.offsetParent;if(!l)return void this.hide();const a=l.getBoundingClientRect(),c=this.options.element.getBoundingClientRect(),h=(i.left+s.left)/2-a.left;this.left=Math.round(this.options.keepInBounds?Math.min(a.width-c.width/2,Math.max(h,c.width/2)):h),this.bottom=Math.round(a.bottom-i.top),this.top=Math.round(s.bottom-a.top),this.isActive=!0,this.sendUpdate()}sendUpdate(){this.options.onUpdate({isActive:this.isActive,left:this.left,bottom:this.bottom,top:this.top})}hide(t){t&&t.relatedTarget&&this.options.element.parentNode&&this.options.element.parentNode.contains(t.relatedTarget)||(this.isActive=!1,this.sendUpdate())}destroy(){this.options.element.removeEventListener("mousedown",this.mousedownHandler),this.options.editor.off("focus",this.focusHandler),this.options.editor.off("blur",this.blurHandler)}}function Aa(t){return new en({key:new on("menu_bubble"),view(e){return new Ea({editorView:e,options:t})}})}Boolean;var Da=function(){var t=this,e=t._self._c;return e("div",{staticClass:"icon",class:[`icon--${t.name}`,`icon--${t.size}`]},[e(t.icon,{tag:"component"})],1)},Ta=[],Ra=r(39),za=r.n(Ra),_a=r(5379),Ia=r.n(_a),$a=r(5726),Pa=r.n($a),Ba=r(7228),Va=r.n(Ba),Fa=r(3642),La=r.n(Fa),ja=r(3282),Ha=r.n(ja),Ja=r(8593),Wa=r.n(Ja),qa=r(2015),Ka=r.n(qa),Ua=r(1071),Ga=r.n(Ua),Xa=r(3649),Ya=r.n(Xa),Za=r(5517),Qa=r.n(Za),tc=r(4077),ec=r.n(tc),nc=r(4478),rc=r.n(nc),oc=r(8242),ic=r.n(oc),sc=r(3998),lc=r.n(sc),ac=r(3028),cc=r.n(ac),hc=r(6803),dc=r.n(hc),uc=r(7674),pc=r.n(uc),fc=r(3524),mc=r.n(fc),gc=r(7260),yc=r.n(gc),wc=r(8710),vc=r.n(wc),bc=r(3899),xc=r.n(bc),kc=r(6499),Sc=r.n(kc),Cc=r(3145),Mc=r.n(Cc),Oc=r(7059),Nc=r.n(Oc),Ec=r(8559),Ac=r.n(Ec),Dc=r(1358),Tc=r.n(Dc),Rc=r(2585),zc=r.n(Rc);const _c={add_col_after:za(),add_col_before:Ia(),add_row_after:Pa(),add_row_before:Va(),bold:La(),checklist:Ha(),code:Wa(),code_block:Ka(),combine_cells:Ga(),delete_col:Ya(),delete_row:Qa(),delete_table:ec(),github:rc(),hr:ic(),image:lc(),italic:cc(),link:dc(),mention:pc(),ol:mc(),paragraph:yc(),quote:vc(),redo:xc(),remove:Sc(),strike:Mc(),table:Nc(),ul:Ac(),underline:Tc(),undo:zc()};var Ic={};for(let[r,os]of Object.entries(_c))Ic["icon_"+r]=os;var $c={components:Ic,props:{name:{},size:{default:"normal"},modifier:{default:null},fixAlign:{default:!0}},computed:{icon:function(){return"icon_"+this.name}}},Pc=$c;function Bc(t,e,n,r,o,i,s,l){var a,c="function"===typeof t?t.options:t;if(e&&(c.render=e,c.staticRenderFns=n,c._compiled=!0),r&&(c.functional=!0),i&&(c._scopeId="data-v-"+i),s?(a=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,t||"undefined"===typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),o&&o.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(s)},c._ssrRegister=a):o&&(a=l?function(){o.call(this,(c.functional?this.parent:this).$root.$options.shadowRoot)}:o),a)if(c.functional){c._injectStyles=a;var h=c.render;c.render=function(t,e){return a.call(e),h(t,e)}}else{var d=c.beforeCreate;c.beforeCreate=d?[].concat(d,a):[a]}return{exports:t,options:c}}var Vc,Fc,Lc=Bc(Pc,Da,Ta,!1,null,"e59f7832",null),jc=Lc.exports;r(4304);if("undefined"!=typeof WeakMap){let t=new WeakMap;Vc=e=>t.get(e),Fc=(e,n)=>(t.set(e,n),n)}else{const t=[],e=10;let n=0;Vc=e=>{for(let n=0;n(n==e&&(n=0),t[n++]=r,t[n++]=o)}var Hc=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e=n){(i||(i=[])).push({type:"overlong_rowspan",pos:h,n:u-t});break}const l=o+t*e;for(let t=0;tr&&(i+=o.attrs.colspan)}}for(let t=0;t1&&(n=!0)}-1==e?e=i:e!=i&&(e=Math.max(e,i))}return e}function qc(t,e,n){t.problems||(t.problems=[]);const r={};for(let o=0;oNumber(t))):null,o=Number(t.getAttribute("colspan")||1),i={colspan:o,rowspan:Number(t.getAttribute("rowspan")||1),colwidth:r&&r.length==o?r:null};for(const s in e){const n=e[s].getFromDOM,r=n&&n(t);null!=r&&(i[s]=r)}return i}function Gc(t,e){const n={};1!=t.attrs.colspan&&(n.colspan=t.attrs.colspan),1!=t.attrs.rowspan&&(n.rowspan=t.attrs.rowspan),t.attrs.colwidth&&(n["data-colwidth"]=t.attrs.colwidth.join(","));for(const r in e){const o=e[r].setDOMAttr;o&&o(t.attrs[r],n)}return n}function Xc(t){const e=t.cellAttributes||{},n={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(const r in e)n[r]={default:e[r].default};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:t.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:t.cellContent,attrs:n,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:t=>Uc(t,e)}],toDOM(t){return["td",Gc(t,e),0]}},table_header:{content:t.cellContent,attrs:n,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:t=>Uc(t,e)}],toDOM(t){return["th",Gc(t,e),0]}}}}function Yc(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],o=r.spec.tableRole;o&&(e[o]=r)}}return e}var Zc=new on("selectingCells");function Qc(t){for(let e=t.depth-1;e>0;e--)if("row"==t.node(e).type.spec.tableRole)return t.node(0).resolve(t.before(e+1));return null}function th(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if("cell"===n||"header_cell"===n)return t.node(e)}return null}function eh(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if("row"==e.node(n).type.spec.tableRole)return!0;return!1}function nh(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&"cell"==e.node.type.spec.tableRole)return e.$anchor;const n=Qc(e.$head)||rh(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function rh(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if("cell"==r||"header_cell"==r)return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if("cell"==r||"header_cell"==r)return t.doc.resolve(n-e.nodeSize)}}function oh(t){return"row"==t.parent.type.spec.tableRole&&!!t.nodeAfter}function ih(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function sh(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function lh(t,e,n){const r=t.node(-1),o=Hc.get(r),i=t.start(-1),s=o.nextCell(t.pos-i,e,n);return null==s?null:t.node(0).resolve(i+s)}function ah(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some((t=>t>0))||(r.colwidth=null)),r}function ch(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let t=0;tt!=e.pos-o));l.unshift(e.pos-o);const a=l.map((t=>{const e=n.nodeAt(t);if(!e)throw RangeError(`No cell with offset ${t} found`);const r=o+t+1;return new _e(s.resolve(r),s.resolve(r+e.content.size))}));super(a[0].$from,a[0].$to,a),this.$anchorCell=t,this.$headCell=e}map(t,e){const n=t.resolve(e.map(this.$anchorCell.pos)),r=t.resolve(e.map(this.$headCell.pos));if(oh(n)&&oh(r)&&sh(n,r)){const t=this.$anchorCell.node(-1)!=n.node(-1);return t&&this.isRowSelection()?dh.rowSelection(n,r):t&&this.isColSelection()?dh.colSelection(n,r):new dh(n,r)}return Pe.between(n,r)}content(){const t=this.$anchorCell.node(-1),e=Hc.get(t),n=this.$anchorCell.start(-1),r=e.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),o={},i=[];for(let l=r.top;l0||h>0){let t=a.attrs;if(c>0&&(t=ah(t,0,c)),h>0&&(t=ah(t,t.colspan-h,h)),l.leftr.bottom){const t={...a.attrs,rowspan:Math.min(l.bottom,r.bottom)-Math.max(l.top,r.top)};a=l.top0)return!1;const n=t+this.$anchorCell.nodeAfter.attrs.rowspan,r=e+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,e=t){const n=t.node(-1),r=Hc.get(n),o=t.start(-1),i=r.findCell(t.pos-o),s=r.findCell(e.pos-o),l=t.node(0);return i.top<=s.top?(i.top>0&&(t=l.resolve(o+r.map[i.left])),s.bottom0&&(e=l.resolve(o+r.map[s.left])),i.bottom0)return!1;const i=r+this.$anchorCell.nodeAfter.attrs.colspan,s=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,s)==e.width}eq(t){return t instanceof dh&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,e=t){const n=t.node(-1),r=Hc.get(n),o=t.start(-1),i=r.findCell(t.pos-o),s=r.findCell(e.pos-o),l=t.node(0);return i.left<=s.left?(i.left>0&&(t=l.resolve(o+r.map[i.top*r.width])),s.right0&&(e=l.resolve(o+r.map[s.top*r.width])),i.right{e.push(Si.node(n,n+t.nodeSize,{class:"selectedCell"}))})),Oi.create(t.doc,e)}function fh({$from:t,$to:e}){if(t.pos==e.pos||t.pos=0;o--,n++)if(t.after(o+1)=0;i--,r--)if(e.before(i+1)>e.start(i))break;return n==r&&/row|table/.test(t.node(o).type.spec.tableRole)}function mh({$from:t,$to:e}){let n,r;for(let o=t.depth;o>0;o--){const e=t.node(o);if("cell"===e.type.spec.tableRole||"header_cell"===e.type.spec.tableRole){n=e;break}}for(let o=e.depth;o>0;o--){const t=e.node(o);if("cell"===t.type.spec.tableRole||"header_cell"===t.type.spec.tableRole){r=t;break}}return n!==r&&0===e.parentOffset}function gh(t,e,n){const r=(e||t).selection,o=(e||t).doc;let i,s;if(r instanceof Ve&&(s=r.node.type.spec.tableRole)){if("cell"==s||"header_cell"==s)i=dh.create(o,r.from);else if("row"==s){const t=o.resolve(r.from+1);i=dh.rowSelection(t,t)}else if(!n){const t=Hc.get(r.node),e=r.from+1,n=e+t.map[t.width*t.height-1];i=dh.create(o,e+1,n)}}else r instanceof Pe&&fh(r)?i=Pe.create(o,r.from):r instanceof Pe&&mh(r)&&(i=Pe.create(o,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}var yh=new on("fix-tables");function wh(t,e,n,r){const o=t.childCount,i=e.childCount;t:for(let s=0,l=0;s{"table"==e.type.spec.tableRole&&(n=bh(t,e,r,n))};return e?e.doc!=t.doc&&wh(e.doc,t.doc,0,r):t.doc.descendants(r),n}function bh(t,e,n,r){const o=Hc.get(e);if(!o.problems)return r;r||(r=t.tr);const i=[];for(let a=0;a0){let e="cell";n.firstChild&&(e=n.firstChild.type.spec.tableRole);const i=[];for(let n=0;n0&&r>0||"table"==e.child(0).type.spec.tableRole))n--,r--,e=e.child(0).content;const o=e.child(0),i=o.type.spec.tableRole,s=o.type.schema,l=[];if("row"==i)for(let a=0;a=0;e--){const{rowspan:r,colspan:i}=t.child(e).attrs;for(let t=o;t=e.length&&e.push(c.empty),n[o]r&&(l=l.type.createChecked(ah(l.attrs,l.attrs.colspan,n+l.attrs.colspan-r),l.content)),s.push(l),n+=l.attrs.colspan;for(let n=1;no&&(e=e.type.create({...e.attrs,rowspan:Math.max(1,o-e.attrs.rowspan)},e.content)),s.push(e)}t.push(c.from(s))}n=t,e=o}return{width:t,height:e,rows:n}}function Mh(t,e,n,r,o,i,s){const l=t.doc.type.schema,a=Yc(l);let h,d;if(o>e.width)for(let c=0,u=0;ce.height){const l=[];for(let t=0,r=(e.height-1)*e.width;t=e.width)&&n.nodeAt(e.map[r+t]).type==a.header_cell;l.push(o?d||(d=a.header_cell.createAndFill()):h||(h=a.cell.createAndFill()))}const u=a.row.create(null,c.from(l)),p=[];for(let t=e.height;t{if(!o)return!1;const i=n.selection;if(i instanceof dh)return Dh(n,r,ze.near(i.$headCell,e));if("horiz"!=t&&!i.empty)return!1;const s=Ph(o,t,e);if(null==s)return!1;if("horiz"==t)return Dh(n,r,ze.near(n.doc.resolve(i.head+e),e));{const o=n.doc.resolve(s),i=lh(o,t,e);let l;return l=i?ze.near(i,1):e<0?ze.near(n.doc.resolve(o.before(-1)),-1):ze.near(n.doc.resolve(o.after(-1)),1),Dh(n,r,l)}}}function Rh(t,e){return(n,r,o)=>{if(!o)return!1;const i=n.selection;let s;if(i instanceof dh)s=i;else{const r=Ph(o,t,e);if(null==r)return!1;s=new dh(n.doc.resolve(r))}const l=lh(s.$headCell,t,e);return!!l&&Dh(n,r,new dh(s.$anchorCell,l))}}function zh(t,e){const n=t.selection;if(!(n instanceof dh))return!1;if(e){const r=t.tr,o=Yc(t.schema).cell.createAndFill().content;n.forEachCell(((t,e)=>{t.content.eq(o)||r.replace(r.mapping.map(e+1),r.mapping.map(e+t.nodeSize-1),new m(o,0,0))})),r.docChanged&&e(r)}return!0}function _h(t,e){const n=t.state.doc,r=Qc(n.resolve(e));return!!r&&(t.dispatch(t.state.tr.setSelection(new dh(r))),!0)}function Ih(t,e,n){if(!eh(t.state))return!1;let r=xh(n);const o=t.state.selection;if(o instanceof dh){r||(r={width:1,height:1,rows:[c.from(Sh(Yc(t.state.schema).cell,n))]});const e=o.$anchorCell.node(-1),i=o.$anchorCell.start(-1),s=Hc.get(e).rectBetween(o.$anchorCell.pos-i,o.$headCell.pos-i);return r=Ch(r,s.right-s.left,s.bottom-s.top),Eh(t.state,t.dispatch,i,s,r),!0}if(r){const e=nh(t.state),n=e.start(-1);return Eh(t.state,t.dispatch,n,Hc.get(e.node(-1)).findCell(e.pos-n),r),!0}return!1}function $h(t,e){var n;if(e.ctrlKey||e.metaKey)return;const r=Bh(t,e.target);let o;if(e.shiftKey&&t.state.selection instanceof dh)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&null!=(o=Qc(t.state.selection.$anchor))&&(null==(n=Vh(t,e))?void 0:n.pos)!=o.pos)i(o,e),e.preventDefault();else if(!r)return;function i(e,n){let r=Vh(t,n);const o=null==Zc.getState(t.state);if(!r||!sh(e,r)){if(!o)return;r=e}const i=new dh(e,r);if(o||!t.state.selection.eq(i)){const n=t.state.tr.setSelection(i);o&&n.setMeta(Zc,e.pos),t.dispatch(n)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",l),null!=Zc.getState(t.state)&&t.dispatch(t.state.tr.setMeta(Zc,-1))}function l(n){const o=n,l=Zc.getState(t.state);let a;if(null!=l)a=t.state.doc.resolve(l);else if(Bh(t,o.target)!=r&&(a=Vh(t,e),!a))return s();a&&i(a,o)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",l)}function Ph(t,e,n){if(!(t.state.selection instanceof Pe))return null;const{$head:r}=t.state.selection;for(let o=r.depth-1;o>=0;o--){const i=r.node(o),s=n<0?r.index(o):r.indexAfter(o);if(s!=(n<0?0:i.childCount))return null;if("cell"==i.type.spec.tableRole||"header_cell"==i.type.spec.tableRole){const i=r.before(o),s="vert"==e?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(s)?i:null}}return null}function Bh(t,e){for(;e&&e!=t.dom;e=e.parentNode)if("TD"==e.nodeName||"TH"==e.nodeName)return e;return null}function Vh(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});return n&&n?Qc(t.state.doc.resolve(n.pos)):null}var Fh=class{constructor(t,e){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Lh(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type==this.node.type&&(this.node=t,Lh(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){return"attributes"==t.type&&(t.target==this.table||this.colgroup.contains(t.target))}};function Lh(t,e,n,r,o,i){var s;let l=0,a=!0,c=e.firstChild;const h=t.firstChild;if(h){for(let t=0,n=0;tnew n(t,e,r),new Jh(-1,!1)},apply(t,e){return e.apply(t)}},props:{attributes:t=>{const e=jh.getState(t);return e&&e.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(n,o)=>{Wh(n,o,t,e,r)},mouseleave:t=>{qh(t)},mousedown:(t,n)=>{Kh(t,n,e)}},decorations:t=>{const e=jh.getState(t);if(e&&e.activeHandle>-1)return nd(t,e.activeHandle)},nodeViews:{}}});return o}var Jh=class{constructor(t,e){this.activeHandle=t,this.dragging=e}apply(t){const e=this,n=t.getMeta(jh);if(n&&null!=n.setHandle)return new Jh(n.setHandle,!1);if(n&&void 0!==n.setDragging)return new Jh(e.activeHandle,n.setDragging);if(e.activeHandle>-1&&t.docChanged){let n=t.mapping.map(e.activeHandle,-1);return oh(t.doc.resolve(n))||(n=-1),new Jh(n,e.dragging)}return e}};function Wh(t,e,n,r,o){const i=jh.getState(t.state);if(i&&!i.dragging){const r=Gh(e.target);let s=-1;if(r){const{left:o,right:i}=r.getBoundingClientRect();e.clientX-o<=n?s=Xh(t,e,"left"):i-e.clientX<=n&&(s=Xh(t,e,"right"))}if(s!=i.activeHandle){if(!o&&-1!==s){const e=t.state.doc.resolve(s),n=e.node(-1),r=Hc.get(n),o=e.start(-1),i=r.colCount(e.pos-o)+e.nodeAfter.attrs.colspan-1;if(i==r.width-1)return}Zh(t,s)}}}function qh(t){const e=jh.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Zh(t,-1)}function Kh(t,e,n){const r=jh.getState(t.state);if(!r||-1==r.activeHandle||r.dragging)return!1;const o=t.state.doc.nodeAt(r.activeHandle),i=Uh(t,r.activeHandle,o.attrs);function s(e){window.removeEventListener("mouseup",s),window.removeEventListener("mousemove",l);const r=jh.getState(t.state);(null==r?void 0:r.dragging)&&(Qh(t,r.activeHandle,Yh(r.dragging,e,n)),t.dispatch(t.state.tr.setMeta(jh,{setDragging:null})))}function l(e){if(!e.which)return s(e);const r=jh.getState(t.state);if(r&&r.dragging){const o=Yh(r.dragging,e,n);td(t,r.activeHandle,o,n)}}return t.dispatch(t.state.tr.setMeta(jh,{setDragging:{startX:e.clientX,startWidth:i}})),window.addEventListener("mouseup",s),window.addEventListener("mousemove",l),e.preventDefault(),!0}function Uh(t,e,{colspan:n,colwidth:r}){const o=r&&r[r.length-1];if(o)return o;const i=t.domAtPos(e),s=i.node.childNodes[i.offset];let l=s.offsetWidth,a=n;if(r)for(let c=0;c0?-1:0;hh(e,r,o+i)&&(i=0==o||o==e.width?null:0);for(let s=0;s0&&o0&&e.map[l-1]==a||o0?-1:0;cd(e,r,o+a)&&(a=0==o||o==e.height?null:0);for(let c=0,h=e.width*o;c0&&o0&&i==e.map[c-e.width]){const e=n.nodeAt(i).attrs;t.setNodeMarkup(t.mapping.slice(l).map(i+r),null,{...e,rowspan:e.rowspan-1}),a+=e.colspan-1}else if(o0&&n[i]==n[i-1]||r.right0&&n[o]==n[o-t]||r.bottomn[t.type.spec.tableRole]))(t,e)}function vd(t){return(e,n)=>{var r;const o=e.selection;let i,s;if(o instanceof dh){if(o.$anchorCell.pos!=o.$headCell.pos)return!1;i=o.$anchorCell.nodeAfter,s=o.$anchorCell.pos}else{if(i=th(o.$from),!i)return!1;s=null==(r=Qc(o.$from))?void 0:r.pos}if(null==i||null==s)return!1;if(1==i.attrs.colspan&&1==i.attrs.rowspan)return!1;if(n){let r=i.attrs;const l=[],a=r.colwidth;r.rowspan>1&&(r={...r,rowspan:1}),r.colspan>1&&(r={...r,colspan:1});const c=rd(e),h=e.tr;for(let t=0;t{n.attrs[t]!==e&&i.setNodeMarkup(r,null,{...n.attrs,[t]:e})})):i.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function xd(t){return function(e,n){if(!eh(e))return!1;if(n){const r=Yc(e.schema),o=rd(e),i=e.tr,s=o.map.cellsInRect("column"==t?{left:o.left,top:0,right:o.right,bottom:o.map.height}:"row"==t?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=s.map((t=>o.table.nodeAt(t)));for(let t=0;t{const e=t+o.tableStart,n=i.doc.nodeAt(e);n&&i.setNodeMarkup(e,d,n.attrs)})),n(i)}return!0}}var Cd=Sd("row",{useDeprecatedLogic:!0}),Md=Sd("column",{useDeprecatedLogic:!0}),Od=Sd("cell",{useDeprecatedLogic:!0});function Nd(t,e){if(e<0){const e=t.nodeBefore;if(e)return t.pos-e.nodeSize;for(let n=t.index(-1)-1,r=t.before();n>=0;n--){const e=t.node(-1).child(n),o=e.lastChild;if(o)return r-1-o.nodeSize;r-=e.nodeSize}}else{if(t.index()0;r--){const o=n.node(r);if("table"==o.type.spec.tableRole)return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0}return!1}function Dd({allowTableNodeSelection:t=!1}={}){return new en({key:Zc,state:{init(){return null},apply(t,e){const n=t.getMeta(Zc);if(null!=n)return-1==n?null:n;if(null==e||!t.docChanged)return e;const{deleted:r,pos:o}=t.mapping.mapResult(e);return r?null:o}},props:{decorations:ph,handleDOMEvents:{mousedown:$h},createSelectionBetween(t){return null!=Zc.getState(t.state)?t.state.selection:null},handleTripleClick:_h,handleKeyDown:Ah,handlePaste:Ih},appendTransaction(e,n,r){return gh(r,vh(r,n),t)}})}var Td=200,Rd=function(){};Rd.prototype.append=function(t){return t.length?(t=Rd.from(t),!this.length&&t||t.length=e?Rd.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,e))},Rd.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)},Rd.prototype.forEach=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=this.length),e<=n?this.forEachInner(t,e,n,0):this.forEachInvertedInner(t,e,n,0)},Rd.prototype.map=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=this.length);var r=[];return this.forEach((function(e,n){return r.push(t(e,n))}),e,n),r},Rd.from=function(t){return t instanceof Rd?t:t&&t.length?new zd(t):Rd.empty};var zd=function(t){function e(e){t.call(this),this.values=e}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(t,n){return 0==t&&n==this.length?this:new e(this.values.slice(t,n))},e.prototype.getInner=function(t){return this.values[t]},e.prototype.forEachInner=function(t,e,n,r){for(var o=e;o=n;o--)if(!1===t(this.values[o],r+o))return!1},e.prototype.leafAppend=function(t){if(this.length+t.length<=Td)return new e(this.values.concat(t.flatten()))},e.prototype.leafPrepend=function(t){if(this.length+t.length<=Td)return new e(t.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}(Rd);Rd.empty=new zd([]);var _d=function(t){function e(e,n){t.call(this),this.left=e,this.right=n,this.length=e.length+n.length,this.depth=Math.max(e.depth,n.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(t){return to&&!1===this.right.forEachInner(t,Math.max(e-o,0),Math.min(this.length,n)-o,r+o))&&void 0)},e.prototype.forEachInvertedInner=function(t,e,n,r){var o=this.left.length;return!(e>o&&!1===this.right.forEachInvertedInner(t,e-o,Math.max(n,o)-o,r+o))&&(!(n=n?this.right.slice(t-n,e-n):this.left.slice(t,n).append(this.right.slice(0,e-n))},e.prototype.leafAppend=function(t){var n=this.right.leafAppend(t);if(n)return new e(this.left,n)},e.prototype.leafPrepend=function(t){var n=this.left.leafPrepend(t);if(n)return new e(n,this.right)},e.prototype.appendInner=function(t){return this.left.depth>=Math.max(this.right.depth,t.depth)+1?new e(this.left,new e(this.right,t)):new e(this,t)},e}(Rd),Id=Rd,$d=Id;const Pd=500;class Bd{constructor(t,e){this.items=t,this.eventCount=e}popEvent(t,e){if(0==this.eventCount)return null;let n,r,o=this.items.length;for(;;o--){let t=this.items.get(o-1);if(t.selection){--o;break}}e&&(n=this.remapping(o,this.items.length),r=n.maps.length);let i,s,l=t.tr,a=[],c=[];return this.items.forEach(((t,e)=>{if(!t.step)return n||(n=this.remapping(o,e+1),r=n.maps.length),r--,void c.push(t);if(n){c.push(new Fd(t.map));let e,o=t.step.map(n.slice(r));o&&l.maybeStep(o).doc&&(e=l.mapping.maps[l.mapping.maps.length-1],a.push(new Fd(e,void 0,void 0,a.length+c.length))),r--,e&&n.appendMap(e,r)}else l.maybeStep(t.step);return t.selection?(i=n?t.selection.map(n.slice(r)):t.selection,s=new Bd(this.items.slice(0,o).append(c.reverse().concat(a)),this.eventCount-1),!1):void 0}),this.items.length,0),{remaining:s,transform:l,selection:i}}addTransform(t,e,n,r){let o=[],i=this.eventCount,s=this.items,l=!r&&s.length?s.get(s.length-1):null;for(let c=0;cjd&&(s=Vd(s,a),i-=a),new Bd(s.append(o),i)}remapping(t,e){let n=new It;return this.items.forEach(((e,r)=>{let o=null!=e.mirrorOffset&&r-e.mirrorOffset>=t?n.maps.length-e.mirrorOffset:void 0;n.appendMap(e.map,o)}),t,e),n}addMaps(t){return 0==this.eventCount?this:new Bd(this.items.append(t.map((t=>new Fd(t)))),this.eventCount)}rebased(t,e){if(!this.eventCount)return this;let n=[],r=Math.max(0,this.items.length-e),o=t.mapping,i=t.steps.length,s=this.eventCount;this.items.forEach((t=>{t.selection&&s--}),r);let l=e;this.items.forEach((e=>{let r=o.getMirror(--l);if(null==r)return;i=Math.min(i,r);let a=o.maps[r];if(e.step){let i=t.steps[r].invert(t.docs[r]),c=e.selection&&e.selection.map(o.slice(l+1,r));c&&s++,n.push(new Fd(a,i,c))}else n.push(new Fd(a))}),r);let a=[];for(let d=e;dPd&&(h=h.compress(this.items.length-n.length)),h}emptyItemCount(){let t=0;return this.items.forEach((e=>{e.step||t++})),t}compress(t=this.items.length){let e=this.remapping(0,t),n=e.maps.length,r=[],o=0;return this.items.forEach(((i,s)=>{if(s>=t)r.push(i),i.selection&&o++;else if(i.step){let t=i.step.map(e.slice(n)),s=t&&t.getMap();if(n--,s&&e.appendMap(s,n),t){let l=i.selection&&i.selection.map(e.slice(n));l&&o++;let a,c=new Fd(s.invert(),t,l),h=r.length-1;(a=r.length&&r[h].merge(c))?r[h]=a:r.push(c)}}else i.map&&n--}),this.items.length,0),new Bd($d.from(r.reverse()),o)}}function Vd(t,e){let n;return t.forEach(((t,r)=>{if(t.selection&&0==e--)return n=r,!1})),t.slice(n)}Bd.empty=new Bd($d.empty,0);class Fd{constructor(t,e,n,r){this.map=t,this.step=e,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let e=t.step.merge(this.step);if(e)return new Fd(e.getMap().invert(),e,this.selection)}}}class Ld{constructor(t,e,n,r){this.done=t,this.undone=e,this.prevRanges=n,this.prevTime=r}}const jd=20;function Hd(t,e,n,r){let o,i=n.getMeta(Yd);if(i)return i.historyState;n.getMeta(Zd)&&(t=new Ld(t.done,t.undone,null,0));let s=n.getMeta("appendedTransaction");if(0==n.steps.length)return t;if(s&&s.getMeta(Yd))return s.getMeta(Yd).redo?new Ld(t.done.addTransform(n,void 0,r,Xd(e)),t.undone,Wd(n.mapping.maps[n.steps.length-1]),t.prevTime):new Ld(t.done,t.undone.addTransform(n,void 0,r,Xd(e)),null,t.prevTime);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return(o=n.getMeta("rebased"))?new Ld(t.done.rebased(n,o),t.undone.rebased(n,o),qd(t.prevRanges,n.mapping),t.prevTime):new Ld(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),qd(t.prevRanges,n.mapping),t.prevTime);{let o=0==t.prevTime||!s&&(t.prevTime<(n.time||0)-r.newGroupDelay||!Jd(n,t.prevRanges)),i=s?qd(t.prevRanges,n.mapping):Wd(n.mapping.maps[n.steps.length-1]);return new Ld(t.done.addTransform(n,o?e.selection.getBookmark():void 0,r,Xd(e)),Bd.empty,i,n.time)}}function Jd(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach(((t,r)=>{for(let o=0;o=e[o]&&(n=!0)})),n}function Wd(t){let e=[];return t.forEach(((t,n,r,o)=>e.push(r,o))),e}function qd(t,e){if(!t)return null;let n=[];for(let r=0;r{let n=Yd.getState(t);return!(!n||0==n.done.eventCount)&&(e&&Kd(n,t,e,!1),!0)},eu=(t,e)=>{let n=Yd.getState(t);return!(!n||0==n.undone.eventCount)&&(e&&Kd(n,t,e,!0),!0)};function nu(t){let e=Yd.getState(t);return e?e.done.eventCount:0}function ru(t){let e=Yd.getState(t);return e?e.undone.eventCount:0}
/*!
* tiptap-extensions v1.35.1
* (c) 2021 überdosis GbR (limited liability)
* @license MIT
*/
class ou extends ma{get name(){return"blockquote"}get schema(){return{content:"block*",group:"block",defining:!0,draggable:!1,parseDOM:[{tag:"blockquote"}],toDOM:()=>["blockquote",0]}}commands({type:t}){return()=>ia(t)}keys({type:t}){return{"Ctrl->":ia(t)}}inputRules({type:t}){return[Ml(/^\s*>\s$/,t)]}}class iu extends ma{get name(){return"bullet_list"}get schema(){return{content:"list_item+",group:"block",parseDOM:[{tag:"ul"}],toDOM:()=>["ul",0]}}commands({type:t,schema:e}){return()=>oa(t,e.nodes.list_item)}keys({type:t,schema:e}){return{"Shift-Ctrl-8":oa(t,e.nodes.list_item)}}inputRules({type:t}){return[Ml(/^\s*([-+*])\s$/,t)]}}class su extends ma{get name(){return"code_block"}get schema(){return{content:"text*",marks:"",group:"block",code:!0,defining:!0,draggable:!1,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM:()=>["pre",["code",0]]}}commands({type:t,schema:e}){return()=>na(t,e.nodes.paragraph)}keys({type:t}){return{"Shift-Ctrl-\\":cl(t)}}inputRules({type:t}){return[Ol(/^```$/,t)]}}class lu extends ma{get name(){return"hard_break"}get schema(){return{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM:()=>["br"]}}commands({type:t}){return()=>ul(Ys,((e,n)=>(n(e.tr.replaceSelectionWith(t.create()).scrollIntoView()),!0)))}keys({type:t}){const e=ul(Ys,((e,n)=>(n(e.tr.replaceSelectionWith(t.create()).scrollIntoView()),!0)));return{"Mod-Enter":e,"Shift-Enter":e}}}class au extends ma{get name(){return"heading"}get defaultOptions(){return{levels:[1,2,3,4,5,6]}}get schema(){return{attrs:{level:{default:1}},content:"inline*",group:"block",defining:!0,draggable:!1,parseDOM:this.options.levels.map((t=>({tag:`h${t}`,attrs:{level:t}}))),toDOM:t=>[`h${t.attrs.level}`,0]}}commands({type:t,schema:e}){return n=>na(t,e.nodes.paragraph,n)}keys({type:t}){return this.options.levels.reduce(((e,n)=>({...e,[`Shift-Ctrl-${n}`]:cl(t,{level:n})})),{})}inputRules({type:t}){return this.options.levels.map((e=>Ol(new RegExp(`^(#{1,${e}})\\s$`),t,(()=>({level:e})))))}}class cu extends ma{get name(){return"list_item"}get schema(){return{content:"paragraph block*",defining:!0,draggable:!1,parseDOM:[{tag:"li"}],toDOM:()=>["li",0]}}keys({type:t}){return{Enter:Jl(t),Tab:Ul(t),"Shift-Tab":Wl(t)}}}class hu extends ma{get name(){return"ordered_list"}get schema(){return{attrs:{order:{default:1}},content:"list_item+",group:"block",parseDOM:[{tag:"ol",getAttrs:t=>({order:t.hasAttribute("start")?+t.getAttribute("start"):1})}],toDOM:t=>1===t.attrs.order?["ol",0]:["ol",{start:t.attrs.order},0]}}commands({type:t,schema:e}){return()=>oa(t,e.nodes.list_item)}keys({type:t,schema:e}){return{"Shift-Ctrl-9":oa(t,e.nodes.list_item)}}inputRules({type:t}){return[Ml(/^(\d+)\.\s$/,t,(t=>({order:+t[1]})),((t,e)=>e.childCount+e.attrs.order===+t[1]))]}}var du=Xc({tableGroup:"block",cellContent:"block+",cellAttributes:{background:{default:null,getFromDOM(t){return t.style.backgroundColor||null},setDOMAttr(t,e){if(t){const n={style:`${e.style||""}background-color: ${t};`};Object.assign(e,n)}}}}});class uu extends ma{get name(){return"table"}get defaultOptions(){return{resizable:!1}}get schema(){return du.table}commands({schema:t}){return{createTable:({rowsCount:e,colsCount:n,withHeaderRow:r})=>(o,i)=>{const s=o.tr.selection.anchor+1,l=Al(t,e,n,r),a=o.tr.replaceSelectionWith(l).scrollIntoView(),c=a.doc.resolve(s);a.setSelection(Pe.near(c)),i(a)},addColumnBefore:()=>id,addColumnAfter:()=>sd,deleteColumn:()=>ad,addRowBefore:()=>dd,addRowAfter:()=>ud,deleteRow:()=>fd,deleteTable:()=>Ad,toggleCellMerge:()=>(t,e)=>{yd(t,e)||wd(t,e)},mergeCells:()=>yd,splitCell:()=>wd,toggleHeaderColumn:()=>Md,toggleHeaderRow:()=>Cd,toggleHeaderCell:()=>Od,setCellAttr:({name:t,value:e})=>bd(t,e),fixTables:()=>vh}}keys(){return{Tab:Ed(1),"Shift-Tab":Ed(-1)}}get plugins(){return[...this.options.resizable?[Hh()]:[],Dd()]}}class pu extends ma{get name(){return"table_header"}get schema(){return du.table_header}}class fu extends ma{get name(){return"table_cell"}get schema(){return du.table_cell}}class mu extends ma{get name(){return"table_row"}get schema(){return du.table_row}}class gu extends ma{get name(){return"todo_item"}get defaultOptions(){return{nested:!1}}get view(){return{props:["node","updateAttrs","view"],methods:{onChange(){this.updateAttrs({done:!this.node.attrs.done})}},template:'\n \n \n \n \n '}}get schema(){return{attrs:{done:{default:!1}},draggable:!0,content:this.options.nested?"(paragraph|todo_list)+":"paragraph+",toDOM:t=>{const{done:e}=t.attrs;return["li",{"data-type":this.name,"data-done":e.toString()},["span",{class:"todo-checkbox",contenteditable:"false"}],["div",{class:"todo-content"},0]]},parseDOM:[{priority:51,tag:`[data-type="${this.name}"]`,getAttrs:t=>({done:"true"===t.getAttribute("data-done")})}]}}keys({type:t}){return{Enter:ea(t),Tab:this.options.nested?Ul(t):()=>{},"Shift-Tab":Wl(t)}}}class yu extends ma{get name(){return"todo_list"}get schema(){return{group:"block",content:"todo_item+",toDOM:()=>["ul",{"data-type":this.name},0],parseDOM:[{priority:51,tag:`[data-type="${this.name}"]`}]}}commands({type:t,schema:e}){return()=>oa(t,e.nodes.todo_item)}inputRules({type:t}){return[Ml(/^\s*(\[ \])\s$/,t)]}}class wu extends pa{get name(){return"bold"}get schema(){return{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:t=>"normal"!==t.style.fontWeight&&null},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}],toDOM:()=>["strong",0]}}keys({type:t}){return{"Mod-b":dl(t)}}commands({type:t}){return()=>dl(t)}inputRules({type:t}){return[Xl(/(?:\*\*|__)([^*_]+)(?:\*\*|__)$/,t)]}pasteRules({type:t}){return[Zl(/(?:\*\*|__)([^*_]+)(?:\*\*|__)/g,t)]}}class vu extends pa{get name(){return"code"}get schema(){return{excludes:"_",parseDOM:[{tag:"code"}],toDOM:()=>["code",0]}}keys({type:t}){return{"Mod-`":dl(t)}}commands({type:t}){return()=>dl(t)}inputRules({type:t}){return[Xl(/(?:`)([^`]+)(?:`)$/,t)]}pasteRules({type:t}){return[Zl(/(?:`)([^`]+)(?:`)/g,t)]}}class bu extends pa{get name(){return"italic"}get schema(){return{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"}],toDOM:()=>["em",0]}}keys({type:t}){return{"Mod-i":dl(t)}}commands({type:t}){return()=>dl(t)}inputRules({type:t}){return[Xl(/(?:^|[^_])(_([^_]+)_)$/,t),Xl(/(?:^|[^*])(\*([^*]+)\*)$/,t)]}pasteRules({type:t}){return[Zl(/_([^_]+)_/g,t),Zl(/\*([^*]+)\*/g,t)]}}class xu extends pa{get name(){return"link"}get defaultOptions(){return{openOnClick:!0,target:null}}get schema(){return{attrs:{href:{default:null},target:{default:null}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs:t=>({href:t.getAttribute("href"),target:t.getAttribute("target")})}],toDOM:t=>["a",{...t.attrs,rel:"noopener noreferrer nofollow",target:t.attrs.target||this.options.target},0]}}commands({type:t}){return e=>e.href?sa(t,e):Ql(t)}pasteRules({type:t}){return[Yl(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z]{2,}\b([-a-zA-Z0-9@:%_+.~#?&//=,()!]*)/gi,t,(t=>({href:t})))]}get plugins(){return this.options.openOnClick?[new en({props:{handleClick:(t,e,n)=>{const{schema:r}=t.state,o=Il(t.state,r.marks.link);o.href&&n.target instanceof HTMLAnchorElement&&(n.stopPropagation(),window.open(o.href,o.target))}}})]:[]}}class ku extends pa{get name(){return"strike"}get schema(){return{parseDOM:[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",getAttrs:t=>"line-through"===t}],toDOM:()=>["s",0]}}keys({type:t}){return{"Mod-d":dl(t)}}commands({type:t}){return()=>dl(t)}inputRules({type:t}){return[Xl(/~([^~]+)~$/,t)]}pasteRules({type:t}){return[Zl(/~([^~]+)~/g,t)]}}class Su extends pa{get name(){return"underline"}get schema(){return{parseDOM:[{tag:"u"},{style:"text-decoration",getAttrs:t=>"underline"===t}],toDOM:()=>["u",0]}}keys({type:t}){return{"Mod-u":dl(t)}}commands({type:t}){return()=>dl(t)}}class Cu extends ha{get name(){return"history"}get defaultOptions(){return{depth:"",newGroupDelay:""}}keys(){const t={"Mod-z":tu,"Mod-y":eu,"Shift-Mod-z":eu,"Mod-я":tu,"Shift-Mod-я":eu};return t}get plugins(){return[Qd({depth:this.options.depth,newGroupDelay:this.options.newGroupDelay})]}commands(){return{undo:()=>tu,redo:()=>eu,undoDepth:()=>nu,redoDepth:()=>ru}}}function Mu(){return[new ou,new iu,new su,new lu,new au,new cu,new hu,new gu,new yu,new xu,new uu({resizable:!0}),new pu,new fu,new mu,new wu,new vu,new bu,new ku,new Su,new Cu]}var Ou={components:{EditorContent:xa,EditorMenuBar:Ca,Icon:jc},props:{value:String},data(){return{editor:new ba({content:this.$props.value,extensions:Mu(),onUpdate:({getHTML:t})=>{const e=t();this.$emit("input",e)}})}},beforeDestroy(){this.editor.destroy()}},Nu=Ou,Eu=Bc(Nu,n,o,!1,null,null,null),Au=Eu.exports;(window.__goplaidVueComponentRegisters=window.__goplaidVueComponentRegisters||[]).push((t=>{t.component("tiptap-editor",Au)}))}(),o=o["default"],o}()})); |