@ibiz-template-plugin/ai-chat 0.0.39 → 0.0.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- !function(){function e(e,n,r,i){var a=t(o(1&i?e.prototype:e),n,r);return 2&i&&"function"==typeof a?function(e){return a.apply(r,e)}:a}function t(){return t="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=o(e)););return e}(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},t.apply(null,arguments)}function n(e){var t="function"==typeof Map?new Map:void 0;return n=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(i())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var o=new(e.bind.apply(e,r));return n&&s(o,n.prototype),o}(e,arguments,o(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),s(n,e)},n(e)}function r(e,t,n){return t=o(t),function(e,t){if(t&&("object"==T(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,i()?Reflect.construct(t,n||[],o(e).constructor):t.apply(e,n))}function i(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(i=function(){return!!e})()}function o(e){return o=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},o(e)}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&s(e,t)}function s(e,t){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},s(e,t)}function c(e){return function(e){if(Array.isArray(e))return p(e)}(e)||u(e)||f(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function l(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=f(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function d(e,t){return v(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],c=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){u=!0,i=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(e,t)||f(e,t)||h()}function h(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function f(e,t){if(e){if("string"==typeof e)return p(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?p(e,t):void 0}}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function v(e){if(Array.isArray(e))return e}function m(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function g(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?m(Object(n),!0).forEach(function(t){_(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):m(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function y(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var c=r&&r.prototype instanceof s?r:s,u=Object.create(c.prototype);return k(u,"_invoke",function(n,r,i){var o,s,c,u=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,c=e,h.n=n,a}};function f(n,r){for(s=n,c=r,t=0;!d&&u&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(c=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(u>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,c=p;(t=s<2?e:c)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,c)):h.n=c:h.v=c);try{if(u=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(c=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?c:n.call(r,h))!==a)break}catch(t){o=e,s=1,c=t}finally{u=1}}return{value:t,done:d}}}(n,i,o),!0),u}var a={};function s(){}function c(){}function u(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(k(t={},r,function(){return this}),t),d=u.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,k(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return c.prototype=u,k(d,"constructor",u),k(u,"constructor",c),c.displayName="GeneratorFunction",k(u,i,"GeneratorFunction"),k(d),k(d,i,"Generator"),k(d,r,function(){return this}),k(d,"toString",function(){return"[object Generator]"}),(y=function(){return{w:o,m:h}})()}function k(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}k=function(e,t,n,r){function o(t,n){k(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},k(e,t,n,r)}function w(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function b(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var o=e.apply(t,n);function a(e){w(o,r,i,a,s,"next",e)}function s(e){w(o,r,i,a,s,"throw",e)}a(void 0)})}}function x(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function C(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,M(r.key),r)}}function S(e,t,n){return t&&C(e.prototype,t),n&&C(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function _(e,t,n){return(t=M(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function M(e){var t=function(e,t){if("object"!=T(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=T(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==T(t)?t:t+""}function T(e){return T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},T(e)}System.register(["interactjs","cherry-markdown","qx-util"],function(t,i){"use strict";var o,s,p;return{setters:[function(e){o=e.default},function(e){s=e.default},function(e){p=e.QXEvent}],execute:function(){var i,m,k,w,C,M,O,N,E,A,D,I,z,R={},P=[],L=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,B=Array.isArray;function V(e,t){for(var n in t)e[n]=t[n];return e}function F(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function $(e,t,n){var r,o,a,s={};for(a in t)"key"==a?r=t[a]:"ref"==a?o=t[a]:s[a]=t[a];if(arguments.length>2&&(s.children=arguments.length>3?i.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(a in e.defaultProps)void 0===s[a]&&(s[a]=e.defaultProps[a]);return j(e,s,r,o,null)}function j(e,t,n,r,i){var o={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:null==i?++k:i,__i:-1,__u:0};return null==i&&null!=m.vnode&&m.vnode(o),o}function H(e){return e.children}function W(e,t){this.props=e,this.context=t}function q(e,t){if(null==t)return e.__?q(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e)return n.__e;return"function"==typeof e.type?q(e):null}function U(e){var t,n;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e){e.__e=e.__c.base=n.__e;break}return U(e)}}function J(e){(!e.__d&&(e.__d=!0)&&C.push(e)&&!K.__r++||M!=m.debounceRendering)&&((M=m.debounceRendering)||O)(K)}function K(){for(var e,t,n,r,i,o,a,s=1;C.length;)C.length>s&&C.sort(N),e=C.shift(),s=C.length,e.__d&&(n=void 0,r=void 0,i=(r=(t=e).__v).__e,o=[],a=[],t.__P&&((n=V({},r)).__v=r.__v+1,m.vnode&&m.vnode(n),ne(t.__P,n,r,t.__n,t.__P.namespaceURI,32&r.__u?[i]:null,o,null==i?q(r):i,!!(32&r.__u),a),n.__v=r.__v,n.__.__k[n.__i]=n,ie(o,n,a),r.__e=r.__=null,n.__e!=i&&U(n)));K.__r=0}function Y(e,t,n,r,i,o,a,s,c,u,l){var d,h,f,p,v,m,g,y=r&&r.__k||P,k=t.length;for(c=function(e,t,n,r,i){var o,a,s,c,u,l=n.length,d=l,h=0;for(e.__k=new Array(i),o=0;o<i;o++)null!=(a=t[o])&&"boolean"!=typeof a&&"function"!=typeof a?(c=o+h,(a=e.__k[o]="string"==typeof a||"number"==typeof a||"bigint"==typeof a||a.constructor==String?j(null,a,null,null,null):B(a)?j(H,{children:a},null,null,null):null==a.constructor&&a.__b>0?j(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):a).__=e,a.__b=e.__b+1,s=null,-1!=(u=a.__i=Z(a,n,c,d))&&(d--,(s=n[u])&&(s.__u|=2)),null==s||null==s.__v?(-1==u&&(i>l?h--:i<l&&h++),"function"!=typeof a.type&&(a.__u|=4)):u!=c&&(u==c-1?h--:u==c+1?h++:(u>c?h--:h++,a.__u|=4))):e.__k[o]=null;if(d)for(o=0;o<l;o++)null!=(s=n[o])&&!(2&s.__u)&&(s.__e==r&&(r=q(s)),ce(s,s));return r}(n,t,y,c,k),d=0;d<k;d++)null!=(f=n.__k[d])&&(h=-1==f.__i?R:y[f.__i]||R,f.__i=d,m=ne(e,f,h,i,o,a,s,c,u,l),p=f.__e,f.ref&&h.ref!=f.ref&&(h.ref&&se(h.ref,null,f),l.push(f.ref,f.__c||p,f)),null==v&&null!=p&&(v=p),(g=!!(4&f.__u))||h.__k===f.__k?c=G(f,c,e,g):"function"==typeof f.type&&void 0!==m?c=m:p&&(c=p.nextSibling),f.__u&=-7);return n.__e=v,c}function G(e,t,n,r){var i,o;if("function"==typeof e.type){for(i=e.__k,o=0;i&&o<i.length;o++)i[o]&&(i[o].__=e,t=G(i[o],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=q(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do{t=t&&t.nextSibling}while(null!=t&&8==t.nodeType);return t}function X(e,t){return t=t||[],null==e||"boolean"==typeof e||(B(e)?e.some(function(e){X(e,t)}):t.push(e)),t}function Z(e,t,n,r){var i,o,a,s=e.key,c=e.type,u=t[n],l=null!=u&&!(2&u.__u);if(null===u&&null==e.key||l&&s==u.key&&c==u.type)return n;if(r>(l?1:0))for(i=n-1,o=n+1;i>=0||o<t.length;)if(null!=(u=t[a=i>=0?i--:o++])&&!(2&u.__u)&&s==u.key&&c==u.type)return a;return-1}function Q(e,t,n){"-"==t[0]?e.setProperty(t,null==n?"":n):e[t]=null==n?"":"number"!=typeof n||L.test(t)?n:n+"px"}function ee(e,t,n,r,i){var o,a;e:if("style"==t)if("string"==typeof n)e.style.cssText=n;else{if("string"==typeof r&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||Q(e.style,t,"");if(n)for(t in n)r&&n[t]==r[t]||Q(e.style,t,n[t])}else if("o"==t[0]&&"n"==t[1])o=t!=(t=t.replace(E,"$1")),a=t.toLowerCase(),t=a in e||"onFocusOut"==t||"onFocusIn"==t?a.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+o]=n,n?r?n.u=r.u:(n.u=A,e.addEventListener(t,o?I:D,o)):e.removeEventListener(t,o?I:D,o);else{if("http://www.w3.org/2000/svg"==i)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=t&&"height"!=t&&"href"!=t&&"list"!=t&&"form"!=t&&"tabIndex"!=t&&"download"!=t&&"rowSpan"!=t&&"colSpan"!=t&&"role"!=t&&"popover"!=t&&t in e)try{e[t]=null==n?"":n;break e}catch(e){}"function"==typeof n||(null==n||!1===n&&"-"!=t[4]?e.removeAttribute(t):e.setAttribute(t,"popover"==t&&1==n?"":n))}}function te(e){return function(t){if(this.l){var n=this.l[t.type+e];if(null==t.t)t.t=A++;else if(t.t<n.u)return;return n(m.event?m.event(t):t)}}}function ne(e,t,n,r,i,o,a,s,c,u){var l,d,h,f,p,v,g,y,k,w,b,x,C,S,_,M,T,O=t.type;if(null!=t.constructor)return null;128&n.__u&&(c=!!(32&n.__u),o=[s=t.__e=n.__e]),(l=m.__b)&&l(t);e:if("function"==typeof O)try{if(y=t.props,k="prototype"in O&&O.prototype.render,w=(l=O.contextType)&&r[l.__c],b=l?w?w.props.value:l.__:r,n.__c?g=(d=t.__c=n.__c).__=d.__E:(k?t.__c=d=new O(y,b):(t.__c=d=new W(y,b),d.constructor=O,d.render=ue),w&&w.sub(d),d.props=y,d.state||(d.state={}),d.context=b,d.__n=r,h=d.__d=!0,d.__h=[],d._sb=[]),k&&null==d.__s&&(d.__s=d.state),k&&null!=O.getDerivedStateFromProps&&(d.__s==d.state&&(d.__s=V({},d.__s)),V(d.__s,O.getDerivedStateFromProps(y,d.__s))),f=d.props,p=d.state,d.__v=t,h)k&&null==O.getDerivedStateFromProps&&null!=d.componentWillMount&&d.componentWillMount(),k&&null!=d.componentDidMount&&d.__h.push(d.componentDidMount);else{if(k&&null==O.getDerivedStateFromProps&&y!==f&&null!=d.componentWillReceiveProps&&d.componentWillReceiveProps(y,b),!d.__e&&null!=d.shouldComponentUpdate&&!1===d.shouldComponentUpdate(y,d.__s,b)||t.__v==n.__v){for(t.__v!=n.__v&&(d.props=y,d.state=d.__s,d.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),x=0;x<d._sb.length;x++)d.__h.push(d._sb[x]);d._sb=[],d.__h.length&&a.push(d);break e}null!=d.componentWillUpdate&&d.componentWillUpdate(y,d.__s,b),k&&null!=d.componentDidUpdate&&d.__h.push(function(){d.componentDidUpdate(f,p,v)})}if(d.context=b,d.props=y,d.__P=e,d.__e=!1,C=m.__r,S=0,k){for(d.state=d.__s,d.__d=!1,C&&C(t),l=d.render(d.props,d.state,d.context),_=0;_<d._sb.length;_++)d.__h.push(d._sb[_]);d._sb=[]}else do{d.__d=!1,C&&C(t),l=d.render(d.props,d.state,d.context),d.state=d.__s}while(d.__d&&++S<25);d.state=d.__s,null!=d.getChildContext&&(r=V(V({},r),d.getChildContext())),k&&!h&&null!=d.getSnapshotBeforeUpdate&&(v=d.getSnapshotBeforeUpdate(f,p)),M=l,null!=l&&l.type===H&&null==l.key&&(M=oe(l.props.children)),s=Y(e,B(M)?M:[M],t,n,r,i,o,a,s,c,u),d.base=t.__e,t.__u&=-161,d.__h.length&&a.push(d),g&&(d.__E=d.__=null)}catch(e){if(t.__v=null,c||null!=o)if(e.then){for(t.__u|=c?160:128;s&&8==s.nodeType&&s.nextSibling;)s=s.nextSibling;o[o.indexOf(s)]=null,t.__e=s}else{for(T=o.length;T--;)F(o[T]);re(t)}else t.__e=n.__e,t.__k=n.__k,e.then||re(t);m.__e(e,t,n)}else null==o&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=ae(n.__e,t,n,r,i,o,a,c,u);return(l=m.diffed)&&l(t),128&t.__u?void 0:s}function re(e){e&&e.__c&&(e.__c.__e=!0),e&&e.__k&&e.__k.forEach(re)}function ie(e,t,n){for(var r=0;r<n.length;r++)se(n[r],n[++r],n[++r]);m.__c&&m.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){m.__e(e,t.__v)}})}function oe(e){return"object"!=T(e)||null==e||e.__b&&e.__b>0?e:B(e)?e.map(oe):V({},e)}function ae(e,t,n,r,o,a,s,c,u){var l,d,h,f,p,v,g,y=n.props,k=t.props,w=t.type;if("svg"==w?o="http://www.w3.org/2000/svg":"math"==w?o="http://www.w3.org/1998/Math/MathML":o||(o="http://www.w3.org/1999/xhtml"),null!=a)for(l=0;l<a.length;l++)if((p=a[l])&&"setAttribute"in p==!!w&&(w?p.localName==w:3==p.nodeType)){e=p,a[l]=null;break}if(null==e){if(null==w)return document.createTextNode(k);e=document.createElementNS(o,w,k.is&&k),c&&(m.__m&&m.__m(t,a),c=!1),a=null}if(null==w)y===k||c&&e.data==k||(e.data=k);else{if(a=a&&i.call(e.childNodes),y=n.props||R,!c&&null!=a)for(y={},l=0;l<e.attributes.length;l++)y[(p=e.attributes[l]).name]=p.value;for(l in y)if(p=y[l],"children"==l);else if("dangerouslySetInnerHTML"==l)h=p;else if(!(l in k)){if("value"==l&&"defaultValue"in k||"checked"==l&&"defaultChecked"in k)continue;ee(e,l,null,p,o)}for(l in k)p=k[l],"children"==l?f=p:"dangerouslySetInnerHTML"==l?d=p:"value"==l?v=p:"checked"==l?g=p:c&&"function"!=typeof p||y[l]===p||ee(e,l,p,y[l],o);if(d)c||h&&(d.__html==h.__html||d.__html==e.innerHTML)||(e.innerHTML=d.__html),t.__k=[];else if(h&&(e.innerHTML=""),Y("template"==t.type?e.content:e,B(f)?f:[f],t,n,r,"foreignObject"==w?"http://www.w3.org/1999/xhtml":o,a,s,a?a[0]:n.__k&&q(n,0),c,u),null!=a)for(l=a.length;l--;)F(a[l]);c||(l="value","progress"==w&&null==v?e.removeAttribute("value"):null!=v&&(v!==e[l]||"progress"==w&&!v||"option"==w&&v!=y[l])&&ee(e,l,v,y[l],o),l="checked",null!=g&&g!=e[l]&&ee(e,l,g,y[l],o))}return e}function se(e,t,n){try{if("function"==typeof e){var r="function"==typeof e.__u;r&&e.__u(),r&&null==t||(e.__u=e(t))}else e.current=t}catch(e){m.__e(e,n)}}function ce(e,t,n){var r,i;if(m.unmount&&m.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||se(r,null,t)),null!=(r=e.__c)){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){m.__e(e,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&ce(r[i],t,n||"function"!=typeof e.type);n||F(e.__e),e.__c=e.__=e.__e=void 0}function ue(e,t,n){return this.constructor(e,n)}function le(e,t,n){var r,o,a,s;t==document&&(t=document.documentElement),m.__&&m.__(e,t),o=(r="function"==typeof n)?null:n&&n.__k||t.__k,a=[],s=[],ne(t,e=(!r&&n||t).__k=$(H,null,[e]),o||R,R,t.namespaceURI,!r&&n?[n]:o?null:t.firstChild?i.call(t.childNodes):null,a,!r&&n?n:o?o.__e:t.firstChild,r,s),ie(a,e,s)}i=P.slice,m={__e:function(e,t,n,r){for(var i,o,a;t=t.__;)if((i=t.__c)&&!i.__)try{if((o=i.constructor)&&null!=o.getDerivedStateFromError&&(i.setState(o.getDerivedStateFromError(e)),a=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(e,r||{}),a=i.__d),a)return i.__E=i}catch(t){e=t}throw e}},k=0,w=function(e){return null!=e&&null==e.constructor},W.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!=this.state?this.__s:this.__s=V({},this.state),"function"==typeof e&&(e=e(V({},n),this.props)),e&&V(n,e),null!=e&&this.__v&&(t&&this._sb.push(t),J(this))},W.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),J(this))},W.prototype.render=H,C=[],O="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,N=function(e,t){return e.__v.__b-t.__v.__b},K.__r=0,E=/(PointerCapture)$|Capture$/i,A=0,D=te(!1),I=te(!0),z=0;var de=0;function he(e,t,n,r,i,o){t||(t={});var a,s,c=t;if("ref"in c)for(s in c={},t)"ref"==s?a=t[s]:c[s]=t[s];var u={type:e,props:c,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--de,__i:-1,__u:0,__source:i,__self:o};if("function"==typeof e&&(a=e.defaultProps))for(s in a)void 0===c[s]&&(c[s]=a[s]);return m.vnode&&m.vnode(u),u}function fe(e,t,n,r,i){var o="".concat(e,"-").concat(t);return n&&(o+="-".concat(n)),r&&(o+="__".concat(r)),i&&(o+="--".concat(i)),o}var pe=function(){return S(function e(t,n){x(this,e),_(this,"namespace",void 0),this.block=t,this.namespace=n||"ibiz"},[{key:"b",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return fe(this.namespace,this.block,e,"","")}},{key:"e",value:function(e){return e?fe(this.namespace,this.block,"",e,""):""}},{key:"m",value:function(e){return e?fe(this.namespace,this.block,"","",e):""}},{key:"be",value:function(e,t){return e&&t?fe(this.namespace,this.block,e,t,""):""}},{key:"em",value:function(e,t){return e&&t?fe(this.namespace,this.block,"",e,t):""}},{key:"bm",value:function(e,t){return e&&t?fe(this.namespace,this.block,e,"",t):""}},{key:"bem",value:function(e,t,n){return e&&t&&n?fe(this.namespace,this.block,e,t,n):""}},{key:"is",value:function(e,t){return e&&t?"".concat("is-").concat(e):""}},{key:"cssVar",value:function(e){var t={};for(var n in e)e[n]&&(t[this.cssVarName(n)]=e[n]);return t}},{key:"cssVarBlock",value:function(e){var t={};for(var n in e)e[n]&&(t[this.cssVarBlockName(n)]=e[n]);return t}},{key:"cssVarName",value:function(e){return"--".concat(this.namespace,"-").concat(e)}},{key:"cssVarBlockName",value:function(e){return"--".concat(this.namespace,"-").concat(this.block,"-").concat(e)}}])}();function ve(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function me(e,t){for(var n,r="",i=0,o=-1,a=0,s=0;s<=e.length;++s){if(s<e.length)n=e.charCodeAt(s);else{if(47===n)break;n=47}if(47===n){if(o===s-1||1===a);else if(o!==s-1&&2===a){if(r.length<2||2!==i||46!==r.charCodeAt(r.length-1)||46!==r.charCodeAt(r.length-2))if(r.length>2){var c=r.lastIndexOf("/");if(c!==r.length-1){-1===c?(r="",i=0):i=(r=r.slice(0,c)).length-1-r.lastIndexOf("/"),o=s,a=0;continue}}else if(2===r.length||1===r.length){r="",i=0,o=s,a=0;continue}t&&(r.length>0?r+="/..":r="..",i=2)}else r.length>0?r+="/"+e.slice(o+1,s):r=e.slice(o+1,s),i=s-o-1;o=s,a=0}else 46===n&&-1!==a?++a:a=-1}return r}var ge={resolve:function(){for(var e,t="",n=!1,r=arguments.length-1;r>=-1&&!n;r--){var i;r>=0?i=arguments[r]:(void 0===e&&(e=process.cwd()),i=e),ve(i),0!==i.length&&(t=i+"/"+t,n=47===i.charCodeAt(0))}return t=me(t,!n),n?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(e){if(ve(e),0===e.length)return".";var t=47===e.charCodeAt(0),n=47===e.charCodeAt(e.length-1);return 0!==(e=me(e,!t)).length||t||(e="."),e.length>0&&n&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return ve(e),e.length>0&&47===e.charCodeAt(0)},join:function(){if(0===arguments.length)return".";for(var e,t=0;t<arguments.length;++t){var n=arguments[t];ve(n),n.length>0&&(void 0===e?e=n:e+="/"+n)}return void 0===e?".":ge.normalize(e)},relative:function(e,t){if(ve(e),ve(t),e===t)return"";if((e=ge.resolve(e))===(t=ge.resolve(t)))return"";for(var n=1;n<e.length&&47===e.charCodeAt(n);++n);for(var r=e.length,i=r-n,o=1;o<t.length&&47===t.charCodeAt(o);++o);for(var a=t.length-o,s=i<a?i:a,c=-1,u=0;u<=s;++u){if(u===s){if(a>s){if(47===t.charCodeAt(o+u))return t.slice(o+u+1);if(0===u)return t.slice(o+u)}else i>s&&(47===e.charCodeAt(n+u)?c=u:0===u&&(c=0));break}var l=e.charCodeAt(n+u);if(l!==t.charCodeAt(o+u))break;47===l&&(c=u)}var d="";for(u=n+c+1;u<=r;++u)u!==r&&47!==e.charCodeAt(u)||(0===d.length?d+="..":d+="/..");return d.length>0?d+t.slice(o+c):(o+=c,47===t.charCodeAt(o)&&++o,t.slice(o))},_makeLong:function(e){return e},dirname:function(e){if(ve(e),0===e.length)return".";for(var t=e.charCodeAt(0),n=47===t,r=-1,i=!0,o=e.length-1;o>=1;--o)if(47===(t=e.charCodeAt(o))){if(!i){r=o;break}}else i=!1;return-1===r?n?"/":".":n&&1===r?"//":e.slice(0,r)},basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');ve(e);var n,r=0,i=-1,o=!0;if(void 0!==t&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var a=t.length-1,s=-1;for(n=e.length-1;n>=0;--n){var c=e.charCodeAt(n);if(47===c){if(!o){r=n+1;break}}else-1===s&&(o=!1,s=n+1),a>=0&&(c===t.charCodeAt(a)?-1===--a&&(i=n):(a=-1,i=s))}return r===i?i=s:-1===i&&(i=e.length),e.slice(r,i)}for(n=e.length-1;n>=0;--n)if(47===e.charCodeAt(n)){if(!o){r=n+1;break}}else-1===i&&(o=!1,i=n+1);return-1===i?"":e.slice(r,i)},extname:function(e){ve(e);for(var t=-1,n=0,r=-1,i=!0,o=0,a=e.length-1;a>=0;--a){var s=e.charCodeAt(a);if(47!==s)-1===r&&(i=!1,r=a+1),46===s?-1===t?t=a:1!==o&&(o=1):-1!==t&&(o=-1);else if(!i){n=a+1;break}}return-1===t||-1===r||0===o||1===o&&t===r-1&&t===n+1?"":e.slice(t,r)},format:function(e){if(null===e||"object"!==T(e))throw new TypeError('The "pathObject" argument must be of type Object. Received type '+T(e));return function(e,t){var n=t.dir||t.root,r=t.base||(t.name||"")+(t.ext||"");return n?n===t.root?n+r:n+e+r:r}("/",e)},parse:function(e){ve(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return t;var n,r=e.charCodeAt(0),i=47===r;i?(t.root="/",n=1):n=0;for(var o=-1,a=0,s=-1,c=!0,u=e.length-1,l=0;u>=n;--u)if(47!==(r=e.charCodeAt(u)))-1===s&&(c=!1,s=u+1),46===r?-1===o?o=u:1!==l&&(l=1):-1!==o&&(l=-1);else if(!c){a=u+1;break}return-1===o||-1===s||0===l||1===l&&o===s-1&&o===a+1?-1!==s&&(t.base=t.name=0===a&&i?e.slice(1,s):e.slice(a,s)):(0===a&&i?(t.name=e.slice(1,o),t.base=e.slice(1,s)):(t.name=e.slice(a,o),t.base=e.slice(a,s)),t.ext=e.slice(o,s)),a>0?t.dir=e.slice(0,a-1):i&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};function ye(){return(65536*(1+Math.random())|0).toString(16).substring(1)}function ke(){return"".concat(ye()+ye(),"-").concat(ye(),"-").concat(ye(),"-").concat(ye(),"-").concat(ye()).concat(ye()).concat(ye())}function we(e){var t=e.lastIndexOf("@");return-1===t?e:e.substring(0,t)}ge.posix=ge;var be=/<svg\b[^>]*>[\s\S]*?<\/svg>/;function xe(e){return be.test(e)}var Ce=function(){return S(function e(){x(this,e)},null,[{key:"copy",value:function(e){return this.inputElement||(this.inputElement=document.createElement("input"),this.inputElement.style.position="absolute",this.inputElement.style.left="-9999px",document.body.appendChild(this.inputElement)),this.inputElement.value=e,this.inputElement.select(),document.execCommand("copy")}}])}();_(Ce,"inputElement",null);var Se=function(){function e(){x(this,e)}return S(e,null,[{key:"checkDataBaseExists",value:(l=b(y().m(function e(t){var n,r;return y().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,indexedDB.databases();case 1:return n=e.v,e.a(2,n.some(function(e){return e.name===t}));case 2:return e.p=2,r=e.v,console.error("检查数据库是否存在时出错:",r),e.a(2,!1)}},e,null,[[0,2]])})),function(e){return l.apply(this,arguments)})},{key:"deleteDatabase",value:(u=b(y().m(function t(n){var r,i;return y().w(function(t){for(;;)if(0===t.n)return e.lastLink&&(null===(r=(i=e.lastLink).close)||void 0===r||r.call(i)),t.a(2,new Promise(function(e,t){var r=indexedDB.deleteDatabase(n);r.onsuccess=function(){e(!0)},r.onerror=function(){e(!1)},r.onblocked=function(){console.warn("删除数据库 ".concat(n," 被阻塞,可能有其他连接正在使用该数据库。")),t(new Error("删除数据库 ".concat(n," 被阻塞")))}}))},t)})),function(e){return u.apply(this,arguments)})},{key:"checkTableExists",value:(c=b(y().m(function t(n,r){return y().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,e.checkDataBaseExists(n);case 1:if(t.v){t.n=2;break}return t.a(2,!1);case 2:return t.a(2,new Promise(function(t,i){var o=indexedDB.open(n);o.onupgradeneeded=function(t){e.db=t.target.result,e.version=e.db.version},o.onsuccess=function(n){e.db=n.target.result,e.lastLink=o.result;var i=e.db.objectStoreNames.contains(r);o.result.close(),t(i)},o.onerror=function(e){i(e.target.error)}}))}},t)})),function(e,t){return c.apply(this,arguments)})},{key:"createTable",value:(s=b(y().m(function t(n,r,i){var o,a=arguments;return y().w(function(t){for(;;)if(0===t.n)return o=a.length>3&&void 0!==a[3]&&a[3],t.a(2,new Promise(function(t){var a,s;e.version+=1,e.lastLink&&(null===(a=(s=e.lastLink).close)||void 0===a||a.call(s));var c=indexedDB.open(n,e.version);c.onupgradeneeded=function(t){if(e.db=t.target.result,!e.db.objectStoreNames.contains(r)){var n={};i?n.keyPath=i:o&&(n.autoIncrement=!0),e.db.createObjectStore(r,n)}},c.onsuccess=function(){e.lastLink=c.result,c.result.close(),t(!0)},c.onerror=function(){t(!1)}}))},t)})),function(e,t,n){return s.apply(this,arguments)})},{key:"deleteTable",value:(a=b(y().m(function t(n,r){return y().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t){var i,o;e.version+=1,e.lastLink&&(null===(i=(o=e.lastLink).close)||void 0===i||i.call(o));var a=indexedDB.open(n,e.version);a.onupgradeneeded=function(t){e.db=t.target.result,e.lastLink=a.result,e.db.objectStoreNames.contains(r)&&e.db.deleteObjectStore(r)},a.onsuccess=function(n){e.db=n.target.result,e.lastLink=a.result,a.result.close(),t(!0)},a.onerror=function(){a.result.close(),t(!1)}}))},t)})),function(e,t){return a.apply(this,arguments)})},{key:"addData",value:(o=b(y().m(function t(n,r,i){return y().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t,o){var a=indexedDB.open(n);a.onsuccess=function(n){if(e.db=n.target.result,e.lastLink=a.result,e.db.objectStoreNames.contains(r)){var o=e.db.transaction([r],"readwrite").objectStore(r).add(i);o.onsuccess=function(e){t(i)},o.onerror=function(){t(null)}}a.result.close()},a.onerror=function(){a.result.close(),o()}}))},t)})),function(e,t,n){return o.apply(this,arguments)})},{key:"deleteData",value:(i=b(y().m(function t(n,r,i){return y().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t,o){var a=indexedDB.open(n);a.onsuccess=function(n){if(e.db=n.target.result,e.lastLink=a.result,e.db.objectStoreNames.contains(r)){var o=e.db.transaction([r],"readwrite").objectStore(r).delete(i);o.onsuccess=function(e){t(!0)},o.onerror=function(){t(!1)}}a.result.close()},a.onerror=function(){a.result.close(),o()}}))},t)})),function(e,t,n){return i.apply(this,arguments)})},{key:"updateData",value:(r=b(y().m(function t(n,r,i){return y().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t,o){var a=indexedDB.open(n);a.onsuccess=function(n){if(e.db=n.target.result,e.lastLink=a.result,e.db.objectStoreNames.contains(r)){var o=e.db.transaction([r],"readwrite").objectStore(r).put(i);o.onsuccess=function(e){t(i)},o.onerror=function(){t(i)}}a.result.close()},a.onerror=function(){a.result.close(),o()}}))},t)})),function(e,t,n){return r.apply(this,arguments)})},{key:"getData",value:(n=b(y().m(function t(n,r,i){return y().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t,o){var a=indexedDB.open(n);a.onsuccess=function(n){if(e.db=n.target.result,e.lastLink=a.result,e.db.objectStoreNames.contains(r)){var s=e.db.transaction([r],"readonly").objectStore(r).get(i);s.onsuccess=function(e){t(s.result)},s.onerror=function(){o(new Error("未找到数据".concat(i)))}}a.result.close()},a.onerror=function(){a.result.close(),o()}}))},t)})),function(e,t,r){return n.apply(this,arguments)})},{key:"getAllData",value:(t=b(y().m(function t(n,r){return y().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t,i){var o=indexedDB.open(n);o.onsuccess=function(n){if(e.db=n.target.result,e.lastLink=o.result,e.db.objectStoreNames.contains(r)){var i=e.db.transaction([r],"readonly").objectStore(r).getAll();i.onsuccess=function(e){t(i.result)},i.onerror=function(){t([])}}o.result.close()},o.onerror=function(){o.result.close(),i()}}))},t)})),function(e,n){return t.apply(this,arguments)})}]);var t,n,r,i,o,a,s,c,u,l}();_(Se,"version",1),_(Se,"db",null),_(Se,"lastLink",void 0);var _e=function(){return S(function e(t){x(this,e),_(this,"options",void 0),this.options=g({multiple:!0,accept:"*/*",maxSize:5242880},t)},[{key:"openFilePicker",value:function(){var e=this,t=document.createElement("input");t.type="file",t.multiple=this.options.multiple,t.accept=this.options.accept||"",t.onchange=function(t){var n=Array.from(t.target.files||[]);e.handleFiles(n)},t.click()}},{key:"handleFiles",value:(t=b(y().m(function e(t){var n,r,i,o=this;return y().w(function(e){for(;;)switch(e.n){case 0:if(0!==t.length){e.n=1;break}return e.a(2);case 1:return i=t.filter(function(e){var t,n;return!(o.options.maxSize&&e.size>o.options.maxSize&&(null===(t=(n=o.options).onError)||void 0===t||t.call(n,new Error("文件大小超过限制 (".concat(o.formatSize(e.size)," > ").concat(o.formatSize(o.options.maxSize),")")),e),1))}),null===(n=(r=this.options).onSelect)||void 0===n||n.call(r,i),e.n=2,Promise.all(i.map(function(e){return o.processFile(e)}));case 2:return e.a(2)}},e,this)})),function(e){return t.apply(this,arguments)})},{key:"processFile",value:(e=b(y().m(function e(t){var n,r,i,o,a,s,c,u,l,d=this;return y().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,a=function(e){var n,r;null===(n=(r=d.options).onProgress)||void 0===n||n.call(r,t,e)},e.n=1,this.options.onUpload(t,a);case 1:s=e.v,null===(n=(r=this.options).onProgress)||void 0===n||n.call(r,t,100),null===(i=(o=this.options).onSuccess)||void 0===i||i.call(o,s,t),e.n=3;break;case 2:e.p=2,l=e.v,null===(c=(u=this.options).onError)||void 0===c||c.call(u,l instanceof Error?l:new Error("上传失败"),t);case 3:return e.a(2)}},e,this,[[0,2]])})),function(t){return e.apply(this,arguments)})},{key:"formatSize",value:function(e){if(0===e)return"0 B";var t=Math.floor(Math.log(e)/Math.log(1024));return"".concat((e/Math.pow(1024,t)).toFixed(2)," ").concat(["B","KB","MB","GB"][t])}}]);var e,t}(),Me=function(){return S(function e(){x(this,e)},null,[{key:"getCdataContent",value:function(e){if(!e)return null;var t=Array.from(e.childNodes).find(function(e){return e.nodeType===e.CDATA_SECTION_NODE});return(null==t?void 0:t.nodeValue)||e.textContent}},{key:"parse",value:function(e){var t=this,n=(new DOMParser).parseFromString(e,"text/xml");return Array.from(n.querySelectorAll("resource")).map(function(e){var n=e.getAttribute("type")||"",r=e.querySelector("data"),i=e.querySelector("metadata");try{var o=t.getCdataContent(r),a=t.getCdataContent(i),s=o?JSON.parse(o):{},c=a?JSON.parse(a):{};return{id:s.id,type:n,data:s,metadata:c}}catch(pt){throw new Error("XML 解析错误: ".concat(pt.message))}})}},{key:"parseMixedContent",value:function(e){var t=/<resources\b[^>]*>[\s\S]*?<\/resources>/i.exec(e);if(!t)return{resources:[],remainingText:e,hasResources:!1};var n=d(t,1)[0],r=t.index,i=r+n.length,o=(e.slice(0,r)+e.slice(i)).replace(/\n/g,"").replace(/(!\[[^\]]*\]\([^)]+\))/g,"\n$1\n").replace(/\n+/g,"\n").replace(/^\n|\n$/g,"");try{return{resources:this.parse(n),remainingText:o,hasResources:!0}}catch(a){return{resources:[],remainingText:o,hasResources:!0,error:"资源解析失败: ".concat(a.message)}}}},{key:"stringify",value:function(e){var t=document.implementation.createDocument(null,null,null),n=t.createElement("resources");n.setAttribute("version","1.0");var r=function(e){return"\n".concat(" ".repeat(e))};return e.forEach(function(e){n.appendChild(t.createTextNode(r(1)));var i=t.createElement("resource");i.setAttribute("type",e.type),i.setAttribute("version","1.0");var o=function(e,n){var i=t.createElement(e);i.appendChild(t.createTextNode(r(2)));var o=t.createCDATASection(JSON.stringify(n));return i.appendChild(o),i.appendChild(t.createTextNode(r(1))),i};i.appendChild(t.createTextNode(r(2))),i.appendChild(o("data",e.data)),i.appendChild(t.createTextNode(r(2))),i.appendChild(o("metadata",e.metadata)),i.appendChild(t.createTextNode(r(1))),n.appendChild(i)}),n.appendChild(t.createTextNode("\n")),t.appendChild(n),(new XMLSerializer).serializeToString(t).replace(/></g,">\n<")}}])}(),Te=function(){return S(function e(){x(this,e)},null,[{key:"getCdataContent",value:function(e){if(!e)return null;var t=Array.from(e.childNodes).find(function(e){return e.nodeType===e.CDATA_SECTION_NODE});return(null==t?void 0:t.nodeValue)||e.textContent}},{key:"parse",value:function(e){var t=this,n=(new DOMParser).parseFromString(e,"text/xml");return Array.from(n.querySelectorAll("suggestion")).map(function(e){var n=e.getAttribute("type")||"",r=e.querySelector("data"),i=e.querySelector("metadata");try{var o=t.getCdataContent(r),a=t.getCdataContent(i);return{type:n,data:o?JSON.parse(o):{},metadata:a?JSON.parse(a):{}}}catch(pt){throw new Error("XML 解析错误: ".concat(pt.message))}})}},{key:"parseMixedContent",value:function(e){var t=/<suggestions\b[^>]*>[\s\S]*?<\/suggestions>/i.exec(e);if(!t)return{suggestions:[],remainingText:e,hasSuggestions:!1};var n=d(t,1)[0],r=t.index,i=r+n.length,o=(e.slice(0,r)+e.slice(i)).replace(/\n/g,"");try{return{suggestions:this.parse(n),remainingText:o,hasSuggestions:!0}}catch(a){return{suggestions:[],remainingText:o,hasSuggestions:!0,error:"资源解析失败: ".concat(a.message)}}}},{key:"stringify",value:function(e){var t=document.implementation.createDocument(null,null,null),n=t.createElement("suggestions");n.setAttribute("version","1.0");var r=function(e){return"\n".concat(" ".repeat(e))};return e.forEach(function(e){n.appendChild(t.createTextNode(r(1)));var i=t.createElement("suggestion");i.setAttribute("type",e.type),i.setAttribute("version","1.0");var o=function(e,n){var i=t.createElement(e);i.appendChild(t.createTextNode(r(2)));var o=t.createCDATASection(JSON.stringify(n));return i.appendChild(o),i.appendChild(t.createTextNode(r(1))),i};i.appendChild(t.createTextNode(r(2))),i.appendChild(o("data",e.data)),i.appendChild(t.createTextNode(r(2))),i.appendChild(o("metadata",e.metadata)),i.appendChild(t.createTextNode(r(1))),n.appendChild(i)}),n.appendChild(t.createTextNode("\n")),t.appendChild(n),(new XMLSerializer).serializeToString(t).replace(/></g,">\n<")}}])}();function Oe(e){return e.x>=0&&e.x<=1&&e.y>=0&&e.y<=1}function Ne(e,t,n,r){var i=e/window.innerWidth,o=t/window.innerHeight;return{x:Math.max(0,Math.min(i,1-n)),y:Math.max(0,Math.min(o,1-r))}}var Ee,Ae,De,Ie,ze=function(){return S(function e(){x(this,e)},null,[{key:"parse",value:function(e){var t,n=new RegExp("<tool_call>\\s*({[\\s\\S]*?})\\s*</tool_call>","g"),r=[],i=l(e.matchAll(n));try{for(i.s();!(t=i.n()).done;){var o=t.value;try{var a=JSON.parse(o[1]),s={name:a.name,parameters:a.parameters,error:a.error||!1};a.result&&Object.assign(s,{result:a.result}),r.push(s)}catch(pt){console.error("解析工具调用失败:",pt)}}}catch(c){i.e(c)}finally{i.f()}return r}}])}(),Re=0,Pe=[],Le=m,Be=Le.__b,Ve=Le.__r,Fe=Le.diffed,$e=Le.__c,je=Le.unmount,He=Le.__;function We(e,t){Le.__h&&Le.__h(Ae,e,Re||t),Re=0;var n=Ae.__H||(Ae.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function qe(e){return Re=1,function(e,t,n){var r=We(Ee++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):rt(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=Ae,!Ae.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=r.__c.__H.__.filter(function(e){return!!e.__c});if(i.every(function(e){return!e.__N}))return!o||o.call(this,e,t,n);var a=r.__c.props!==e;return i.forEach(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(a=!0)}}),o&&o.call(this,e,t,n)||a};Ae.__f=!0;var o=Ae.shouldComponentUpdate,a=Ae.componentWillUpdate;Ae.componentWillUpdate=function(e,t,n){if(this.__e){var r=o;o=void 0,i(e,t,n),o=r}a&&a.call(this,e,t,n)},Ae.shouldComponentUpdate=i}return r.__N||r.__}(rt,e)}function Ue(e,t){var n=We(Ee++,3);!Le.__s&&nt(n.__H,t)&&(n.__=e,n.u=t,Ae.__H.__h.push(n))}function Je(e){return Re=5,Ke(function(){return{current:e}},[])}function Ke(e,t){var n=We(Ee++,7);return nt(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Ye(e,t){return Re=8,Ke(function(){return e},t)}function Ge(e){var t=Ae.context[e.__c],n=We(Ee++,9);return n.c=e,t?(null==n.__&&(n.__=!0,t.sub(Ae)),t.props.value):e.__}function Xe(){for(var e;e=Pe.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(et),e.__H.__h.forEach(tt),e.__H.__h=[]}catch(ot){e.__H.__h=[],Le.__e(ot,e.__v)}}Le.__b=function(e){Ae=null,Be&&Be(e)},Le.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),He&&He(e,t)},Le.__r=function(e){Ve&&Ve(e),Ee=0;var t=(Ae=e.__c).__H;t&&(De===Ae?(t.__h=[],Ae.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.forEach(et),t.__h.forEach(tt),t.__h=[],Ee=0)),De=Ae},Le.diffed=function(e){Fe&&Fe(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(1!==Pe.push(t)&&Ie===Le.requestAnimationFrame||((Ie=Le.requestAnimationFrame)||Qe)(Xe)),t.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),De=Ae=null},Le.__c=function(e,t){t.some(function(e){try{e.__h.forEach(et),e.__h=e.__h.filter(function(e){return!e.__||tt(e)})}catch(Ae){t.some(function(e){e.__h&&(e.__h=[])}),t=[],Le.__e(Ae,e.__v)}}),$e&&$e(e,t)},Le.unmount=function(e){je&&je(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(e){try{et(e)}catch(e){t=e}}),n.__H=void 0,t&&Le.__e(t,n.__v))};var Ze="function"==typeof requestAnimationFrame;function Qe(e){var t,n=function(){clearTimeout(r),Ze&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Ze&&(t=requestAnimationFrame(n))}function et(e){var t=Ae,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),Ae=t}function tt(e){var t=Ae;e.__c=e.__(),Ae=t}function nt(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function rt(e,t){return"function"==typeof t?t(e):t}var it=Symbol.for("preact-signals");function ot(){if(dt>1)dt--;else{for(var e,t=!1;void 0!==lt;){var n=lt;for(lt=void 0,ht++;void 0!==n;){var r=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&gt(n))try{n.c()}catch(n){t||(e=n,t=!0)}n=r}}if(ht=0,dt--,t)throw e}}var at=void 0;function st(e){var t=at;at=void 0;try{return e()}finally{at=t}}var ct,ut,lt=void 0,dt=0,ht=0,ft=0;function pt(e){if(void 0!==at){var t=e.n;if(void 0===t||t.t!==at)return t={i:0,S:e,p:at.s,n:void 0,t:at,e:void 0,x:void 0,r:t},void 0!==at.s&&(at.s.n=t),at.s=t,e.n=t,32&at.f&&e.S(t),t;if(-1===t.i)return t.i=0,void 0!==t.n&&(t.n.p=t.p,void 0!==t.p&&(t.p.n=t.n),t.p=at.s,t.n=void 0,at.s.n=t,at.s=t),t}}function vt(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.W=null==t?void 0:t.watched,this.Z=null==t?void 0:t.unwatched,this.name=null==t?void 0:t.name}function mt(e,t){return new vt(e,t)}function gt(e){for(var t=e.s;void 0!==t;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function yt(e){for(var t=e.s;void 0!==t;t=t.n){var n=t.S.n;if(void 0!==n&&(t.r=n),t.S.n=t,t.i=-1,void 0===t.n){e.s=t;break}}}function kt(e){for(var t=e.s,n=void 0;void 0!==t;){var r=t.p;-1===t.i?(t.S.U(t),void 0!==r&&(r.n=t.n),void 0!==t.n&&(t.n.p=r)):n=t,t.S.n=t.r,void 0!==t.r&&(t.r=void 0),t=r}e.s=n}function wt(e,t){vt.call(this,void 0),this.x=e,this.s=void 0,this.g=ft-1,this.f=4,this.W=null==t?void 0:t.watched,this.Z=null==t?void 0:t.unwatched,this.name=null==t?void 0:t.name}function bt(e,t){return new wt(e,t)}function xt(e){var t=e.u;if(e.u=void 0,"function"==typeof t){dt++;var n=at;at=void 0;try{t()}catch(ot){throw e.f&=-2,e.f|=8,Ct(e),ot}finally{at=n,ot()}}}function Ct(e){for(var t=e.s;void 0!==t;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,xt(e)}function St(e){if(at!==this)throw new Error("Out-of-order effect");kt(this),at=e,this.f&=-2,8&this.f&&Ct(this),ot()}function _t(e,t){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==t?void 0:t.name}function Mt(e,t){var n=new _t(e,t);try{n.c()}catch(e){throw n.d(),e}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}function Tt(e,t){m[e]=t.bind(null,m[e]||function(){})}function Ot(e){ut&&ut(),ut=e&&e.S()}function Nt(e){var t=this,n=e.data,r=At(n);r.value=n;var i=Ke(function(){for(var e=t.__v;e=e.__;)if(e.__c){e.__c.__$f|=4;break}return t.__$u.c=function(){var e,n=t.__$u.S(),r=i.value;n(),w(r)||3!==(null==(e=t.base)?void 0:e.nodeType)?(t.__$f|=1,t.setState({})):t.base.data=r},bt(function(){var e=r.value.value;return 0===e?0:!0===e?"":e||""})},[]);return i.value}function Et(e,t,n,r){var i=t in e&&void 0===e.ownerSVGElement,o=mt(n);return{o:function(e,t){o.value=e,r=t},d:Mt(function(){var n=o.value.value;r[t]!==n&&(r[t]=n,i?e[t]=n:n?e.setAttribute(t,n):e.removeAttribute(t))})}}function At(e){return Ke(function(){return mt(e)},[])}function Dt(e){var t=Je(e);return t.current=e,ct.__$f|=4,Ke(function(){return bt(function(){return t.current()})},[])}vt.prototype.brand=it,vt.prototype.h=function(){return!0},vt.prototype.S=function(e){var t=this,n=this.t;n!==e&&void 0===e.e&&(e.x=n,this.t=e,void 0!==n?n.e=e:st(function(){var e;null==(e=t.W)||e.call(t)}))},vt.prototype.U=function(e){var t=this;if(void 0!==this.t){var n=e.e,r=e.x;void 0!==n&&(n.x=r,e.e=void 0),void 0!==r&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,void 0===r&&st(function(){var e;null==(e=t.Z)||e.call(t)}))}},vt.prototype.subscribe=function(e){var t=this;return Mt(function(){var n=t.value,r=at;at=void 0;try{e(n)}finally{at=r}},{name:"sub"})},vt.prototype.valueOf=function(){return this.value},vt.prototype.toString=function(){return this.value+""},vt.prototype.toJSON=function(){return this.value},vt.prototype.peek=function(){var e=at;at=void 0;try{return this.value}finally{at=e}},Object.defineProperty(vt.prototype,"value",{get:function(){var e=pt(this);return void 0!==e&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(ht>100)throw new Error("Cycle detected");this.v=e,this.i++,ft++,dt++;try{for(var t=this.t;void 0!==t;t=t.x)t.t.N()}finally{ot()}}}}),wt.prototype=new vt,wt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===ft)return!0;if(this.g=ft,this.f|=1,this.i>0&&!gt(this))return this.f&=-2,!0;var e=at;try{yt(this),at=this;var t=this.x();(16&this.f||this.v!==t||0===this.i)&&(this.v=t,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return at=e,kt(this),this.f&=-2,!0},wt.prototype.S=function(e){if(void 0===this.t){this.f|=36;for(var t=this.s;void 0!==t;t=t.n)t.S.S(t)}vt.prototype.S.call(this,e)},wt.prototype.U=function(e){if(void 0!==this.t&&(vt.prototype.U.call(this,e),void 0===this.t)){this.f&=-33;for(var t=this.s;void 0!==t;t=t.n)t.S.U(t)}},wt.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;void 0!==e;e=e.x)e.t.N()}},Object.defineProperty(wt.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=pt(this);if(this.h(),void 0!==e&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),_t.prototype.c=function(){var e=this.S();try{if(8&this.f)return;if(void 0===this.x)return;var t=this.x();"function"==typeof t&&(this.u=t)}finally{e()}},_t.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,xt(this),yt(this),dt++;var e=at;return at=this,St.bind(this,e)},_t.prototype.N=function(){2&this.f||(this.f|=2,this.o=lt,lt=this)},_t.prototype.d=function(){this.f|=8,1&this.f||Ct(this)},_t.prototype.dispose=function(){this.d()},Nt.displayName="_st",Object.defineProperties(vt.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:Nt},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}}),Tt("__b",function(e,t){if("string"==typeof t.type){var n,r=t.props;for(var i in r)if("children"!==i){var o=r[i];o instanceof vt&&(n||(t.__np=n={}),n[i]=o,r[i]=o.peek())}}e(t)}),Tt("__r",function(e,t){Ot();var n,r=t.__c;r&&(r.__$f&=-2,void 0===(n=r.__$u)&&(r.__$u=n=function(){var e;return Mt(function(){e=this}),e.c=function(){r.__$f|=1,r.setState({})},e}())),ct=r,Ot(n),e(t)}),Tt("__e",function(e,t,n,r){Ot(),ct=void 0,e(t,n,r)}),Tt("diffed",function(e,t){var n;if(Ot(),ct=void 0,"string"==typeof t.type&&(n=t.__e)){var r=t.__np,i=t.props;if(r){var o=n.U;if(o)for(var a in o){var s=o[a];void 0===s||a in r||(s.d(),o[a]=void 0)}else n.U=o={};for(var c in r){var u=o[c],l=r[c];void 0===u?(u=Et(n,c,l,i),o[c]=u):u.o(l,i)}}}e(t)}),Tt("unmount",function(e,t){if("string"==typeof t.type){var n=t.__e;if(n){var r=n.U;if(r)for(var i in n.U=void 0,r){var o=r[i];o&&o.d()}}}else{var a=t.__c;if(a){var s=a.__$u;s&&(a.__$u=void 0,s.d())}}e(t)}),Tt("__h",function(e,t,n,r){(r<3||9===r)&&(t.__$f|=2),e(t,n,r)}),W.prototype.shouldComponentUpdate=function(e,t){var n=this.__$u,r=n&&void 0!==n.s;for(var i in t)return!0;if(this.__f||"boolean"==typeof this.u&&!0===this.u){if(!(r||2&this.__$f||4&this.__$f))return!0;if(1&this.__$f)return!0}else{if(!(r||4&this.__$f))return!0;if(3&this.__$f)return!0}for(var o in e)if("__source"!==o&&e[o]!==this.props[o])return!0;for(var a in this.props)if(!(a in e))return!0;return!1};var It=function(){return he("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M843.904 783.573333 783.573333 843.904 512.042667 572.373333 240.512 843.904 180.181333 783.573333 451.712 512.042667 180.181333 240.512 240.512 180.181333 512.042667 451.712 783.573333 180.181333 843.904 240.512 572.373333 512.042667 843.904 783.573333Z"})})},zt=function(){return he("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M900.64 379.808l-263.072-256.032c-36.448-35.328-105.76-35.392-142.304 0.096l-327.04 319.904c-56.416 54.72-70.72 76.704-70.72 150.976l0 143.936c0 132.768 26.976 192 186.912 192l131.872 0c81.12 0 128.448-46.656 193.952-111.264l290.016-297.696c18.592-17.984 29.248-43.968 29.248-71.264C929.504 423.36 918.976 397.6 900.64 379.808zM323.008 786.752c-52.928 0-96-43.072-96-96s43.072-96 96-96 96 43.072 96 96S375.936 786.752 323.008 786.752z"})})},Rt=function(e){return he("svg",{viewBox:"0 0 1024 1024",id:"send",className:e.className,version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M931.4 498.9L94.9 79.5c-3.4-1.7-7.3-2.1-11-1.2-8.5 2.1-13.8 10.7-11.7 19.3l86.2 352.2c1.3 5.3 5.2 9.6 10.4 11.3l147.7 50.7-147.6 50.7c-5.2 1.8-9.1 6-10.3 11.3L72.2 926.5c-0.9 3.7-0.5 7.6 1.2 10.9 3.9 7.9 13.5 11.1 21.5 7.2l836.5-417c3.1-1.5 5.6-4.1 7.2-7.1 3.9-8 0.7-17.6-7.2-21.6zM170.8 826.3l50.3-205.6 295.2-101.3c2.3-0.8 4.2-2.6 5-5 1.4-4.2-0.8-8.7-5-10.2L221.1 403 171 198.2l628 314.9-628.2 313.2z"})})},Pt=function(){return he("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M962 197.61H747v-60c0-55.14-44.86-100-100-100H377c-55.14 0-100 44.86-100 100v60H62c-11.05 0-20 8.95-20 20s8.95 20 20 20h60v630.57c0 66.17 53.83 120 120 120h540c66.17 0 120-53.83 120-120V237.61h60c11.05 0 20-8.95 20-20s-8.95-20-20-20zM637.34 457.66v260c0 12.01-10.72 21.63-23.06 19.77-9.84-1.48-16.94-10.25-16.94-20.2V458.09c0-9.95 7.1-18.72 16.94-20.2 12.34-1.86 23.06 7.76 23.06 19.77z m-210.68 0v260c0 11-9 20-20 20s-20-9-20-20v-260c0-11 9-20 20-20s20 9 20 20zM317 137.61c0-33.08 26.92-60 60-60h270c33.08 0 60 26.92 60 60v60H317v-60z"})})},Lt=function(){return he("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M511.582491 63.413262C265.134543 63.413262 64.62588 263.921925 64.62588 510.369873s200.508663 446.957635 446.957635 446.957635 446.957635-200.508663 446.957635-446.957635S758.031463 63.413262 511.582491 63.413262zM509.001713 751.859903c-98.517781 0-182.467775-62.623269-214.771505-150.056598l0.327458-0.134053c-2.007727-4.036943-3.38305-8.422833-3.38305-13.237489 0-16.647145 13.494339-30.142507 30.142507-30.142507 13.389962 0 24.358781 8.877181 28.2893 20.955264l0.422625-0.172939c23.269983 65.442478 85.645612 112.503307 158.972665 112.503307 93.106538 0 168.845523-75.738985 168.845523-168.845523s-75.738985-168.845523-168.845523-168.845523c-20.432355 0-39.874149 3.980661-58.013275 10.66899l21.248953 40.742936c2.486634 2.677992 4.0175 6.2831 4.0175 10.243295 0 8.417717-8.404414 14.921851-15.365966 15.07023-0.102331 0-0.206708 0-0.309038 0-0.220011 0-0.427742 0-0.647753-0.013303l-150.579507-6.463202c-5.372358-0.234337-10.229992-3.310396-12.716626-8.093329-2.486634-4.76963-2.236947-10.509355 0.647753-15.055904l80.890308-127.179564c2.8847-4.533246 8.006348-7.151887 13.365402-6.960529 5.372358 0.234337 10.227945 3.312442 12.71458 8.095375l18.580171 35.625382c26.629497-10.855232 55.683207-16.963347 86.168522-16.963347 126.338407 0 229.130537 102.791108 229.130537 229.130537S635.340119 751.859903 509.001713 751.859903z"})})},Bt=function(){return he("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M891.072 822.144V167.36a34.432 34.432 0 0 0-34.432-34.432H201.856C201.856 94.848 232.704 64 270.784 64h620.288C929.152 64 960 94.848 960 132.928v620.288c0 38.08-30.848 68.928-68.928 68.928z m-68.928-551.36v620.288c0 38.08-30.848 68.928-68.928 68.928H132.928A68.928 68.928 0 0 1 64 891.072V270.784c0-38.08 30.848-68.928 68.928-68.928h620.288c38.08 0 68.928 30.848 68.928 68.928z m-137.856 137.856H201.856a34.432 34.432 0 0 0 0 68.864h482.432a34.432 34.432 0 0 0 0-68.864z m0 206.72H201.856a34.432 34.432 0 0 0 0 68.864h482.432a34.432 34.432 0 0 0 0-68.864z"})})},Vt=function(){return he("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M547.4 197.4v46l200.3 0.1L546.1 444l32.4 32.6 201.9-200.7v200.9h46V197.5zM471.4 584.4l-32.6-32.6L243.6 747V547.9h-46v278.7h279v-46H275z"})})},Ft=function(){return he("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M544 480V282.944h52.224l0.064 107.968L763.072 224l36.928 36.928-166.976 166.976 108.032-0.128V480H544zM260.928 800l-36.928-36.928 166.912-166.784-107.968-0.064V544H480v197.056h-52.224l0.064-107.968L260.928 800z"})})},$t=function(){return he("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M960 544H64a32 32 0 1 1 0-64h896a32 32 0 1 1 0 64"})})},jt=function(){return he("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:[he("path",{d:"M481.0752 263.3728l50.9952 1.024 1.8432-105.8816-50.9952-0.8192z"}),he("path",{d:"M486.441426 180.895362a66.56 66.56 0 1 0 42.091944-126.290153 66.56 66.56 0 1 0-42.091944 126.290153Z"}),he("path",{d:"M138.8544 664.3712c-52.8384 0-95.8464-43.008-95.8464-95.8464s43.008-95.8464 95.8464-95.8464M880.0256 472.6784c52.8384 0 95.8464 43.008 95.8464 95.8464s-43.008 95.8464-95.8464 95.8464"}),he("path",{d:"M507.4944 220.5696c-220.16 0-398.7456 162.816-398.7456 363.7248s178.5856 363.7248 398.7456 363.7248 398.7456-162.816 398.7456-363.7248-178.5856-363.7248-398.7456-363.7248z m0 559.9232c-166.2976 0-301.2608-100.5568-301.2608-224.4608s134.9632-224.4608 301.2608-224.4608S808.7552 432.128 808.7552 556.032 673.792 780.4928 507.4944 780.4928z"}),he("path",{d:"M319.6928 556.032a47.9232 38.912 90 1 0 77.824 0 47.9232 38.912 90 1 0-77.824 0Z"}),he("path",{d:"M617.472 556.032a47.9232 38.912 90 1 0 77.824 0 47.9232 38.912 90 1 0-77.824 0Z"})]})},Ht=function(){return he("svg",{viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[he("path",{d:"M5.856 17.121a.979.979 0 0 1-.327-.06.839.839 0 0 1-.283-.177.739.739 0 0 1-.187-.255.724.724 0 0 1-.07-.303l-.02-1.609a4.663 4.663 0 0 1-1.446-.455 4.252 4.252 0 0 1-.637-.401c-.199-.146-.385-.31-.553-.492a4.442 4.442 0 0 1-.45-.577 4.303 4.303 0 0 1-.327-.637 3.823 3.823 0 0 1-.206-.686 3.729 3.729 0 0 1-.064-.704V6.478c0-.261.025-.516.077-.771a4.43 4.43 0 0 1 .244-.747 4.062 4.062 0 0 1 .932-1.28c.2-.183.418-.347.65-.493.23-.145.482-.267.739-.364a4.21 4.21 0 0 1 .81-.225c.27-.054.553-.078.835-.078H8.55c.103 0 .2.018.29.054a.7.7 0 0 1 .411.376.667.667 0 0 1-.161.766.736.736 0 0 1-.25.151.764.764 0 0 1-.29.055H5.573c-.186 0-.366.012-.54.049-.18.03-.353.079-.52.145-.167.061-.328.14-.482.237-.148.091-.29.2-.418.316a2.897 2.897 0 0 0-.347.388c-.097.14-.187.286-.257.444a2.473 2.473 0 0 0-.206.977v4.287c0 .17.013.333.051.503a2.549 2.549 0 0 0 .772 1.33 2.721 2.721 0 0 0 .913.559c.167.066.347.115.527.152.18.03.36.048.546.048a.904.904 0 0 1 .61.23.848.848 0 0 1 .194.262.84.84 0 0 1 .07.303l.007.99 1.915-1.293a2.877 2.877 0 0 1 1.64-.492h2.372c.186 0 .366-.018.54-.048.18-.03.353-.08.52-.146.168-.067.329-.146.483-.237.148-.091.29-.2.418-.316.128-.121.244-.249.347-.388a2.8 2.8 0 0 0 .257-.444 2.47 2.47 0 0 0 .206-.977V8.585a.646.646 0 0 1 .225-.492.679.679 0 0 1 .244-.152.814.814 0 0 1 .585 0c.09.03.174.085.244.152a.657.657 0 0 1 .225.492V10.8c0 .261-.032.516-.083.771a4.192 4.192 0 0 1-.245.74c-.109.244-.244.468-.398.687a3.735 3.735 0 0 1-.534.6c-.2.183-.418.347-.65.493a4.134 4.134 0 0 1-.738.364 4.7 4.7 0 0 1-.81.225c-.27.054-.553.079-.836.079h-1.877c-.604 0-1.144.164-1.633.491l-2.54 1.713a.913.913 0 0 1-.514.157z",fill:"currentColor"}),he("path",{d:"M15.866 4.125h-4.174c-.41 0-.741.313-.741.7 0 .387.332.7.741.7h4.174c.41 0 .742-.313.742-.7 0-.387-.332-.7-.742-.7z",fill:"currentColor"}),he("path",{d:"M14.537 2.932c0-.396-.34-.717-.759-.717s-.758.32-.758.717v3.786c0 .396.34.717.758.717.42 0 .76-.321.76-.717V2.932z",fill:"currentColor"})]})},Wt=function(){return he("svg",{viewBox:"64 64 896 896",focusable:"false",width:"1em",height:"1em",fill:"currentColor","aria-hidden":"true",children:he("path",{d:"M842 454c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8 0 140.3-113.7 254-254 254S258 594.3 258 454c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8 0 168.7 126.6 307.9 290 327.6V884H326.7c-13.7 0-24.7 14.3-24.7 32v36c0 4.4 2.8 8 6.2 8h407.6c3.4 0 6.2-3.6 6.2-8v-36c0-17.7-11-32-24.7-32H548V782.1c165.3-18 294-158 294-328.1zM512 624c93.9 0 170-75.2 170-168V232c0-92.8-76.1-168-170-168s-170 75.2-170 168v224c0 92.8 76.1 168 170 168zm-94-392c0-50.6 41.9-92 94-92s94 41.4 94 92v224c0 50.6-41.9 92-94 92s-94-41.4-94-92V232z"})})},qt=function(){var e=1e3,t=140,n=250,r=.8;return he("svg",{fill:"currentColor",viewBox:"0 0 ".concat(e," ").concat(e),xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",children:Array.from({length:4}).map(function(e,i){return he("rect",{fill:"currentColor",rx:70,ry:70,height:n,width:t,x:i*(440/3+t),y:375,children:[he("animate",{attributeName:"height",values:"".concat(n,"; ").concat(500,"; ").concat(n),keyTimes:"0; 0.5; 1",dur:"".concat(r,"s"),begin:"".concat(.2*i,"s"),repeatCount:"indefinite"}),he("animate",{attributeName:"y",values:"".concat(375,"; ").concat(250,"; ").concat(375),keyTimes:"0; 0.5; 1",dur:"".concat(r,"s"),begin:"".concat(.2*i,"s"),repeatCount:"indefinite"})]},i)})})},Ut=function(e){return he("svg",{className:e.className,onClick:e.onClick,viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M128 384a128 128 0 1 1 0 256 128 128 0 0 1 0-256z m768 0a128 128 0 1 1 0 256 128 128 0 0 1 0-256z m-372.4288 0a128 128 0 1 1 0 256 128 128 0 0 1 0-256z"})})},Jt=function(e){return he("svg",{className:e.className,viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M498.33984 607.8464c-10.99776-32.9728-50.09408-73.5232-82.6368-85.74976L150.9376 422.8096c-38.54336-14.4384-36.98688-69.46816 2.27328-81.73568L844.92288 124.90752c33.30048-10.40384 64.57344 20.8896 54.1696 54.1696L682.92608 870.78912a43.2128 43.2128 0 0 1-81.36704 3.25632 121682.5344 121682.5344 0 0 1-103.2192-266.19904z"})})},Kt=function(){return he("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M972.657609 209.348408C987.158609 209.36839 998.930114 197.571202 998.949999 182.99865 998.969882 168.426097 987.230618 156.59651 972.729617 156.576528L32.457975 155.280806C17.956974 155.260823 6.18547 167.058012 6.165585 181.630564 6.1457 196.203116 17.884965 208.032703 32.385966 208.052686L972.657609 209.348408ZM180.466902 992.356169 180.466902 1019.014859 206.993296 1018.74074 833.361858 1012.267947 859.348284 1011.999407 859.348284 985.883377 859.348284 289.397297C859.348284 274.824732 847.59289 263.011332 833.091874 263.011332 818.590859 263.011332 806.835465 274.824732 806.835465 289.397297L806.835465 985.883377 832.82189 959.498805 206.453329 965.971599 232.979723 992.356169 232.979723 282.67005C232.979723 268.097483 221.224329 256.284085 206.723313 256.284085 192.222298 256.284085 180.466902 268.097483 180.466902 282.67005L180.466902 992.356169ZM656.410257 847.079027C656.410257 861.651593 668.165651 873.464992 682.666667 873.464992 697.167682 873.464992 708.923076 861.651593 708.923076 847.079027L708.923076 372.131659C708.923076 357.559091 697.167682 345.745694 682.666667 345.745694 668.165651 345.745694 656.410257 357.559091 656.410257 372.131659L656.410257 847.079027ZM341.333333 847.079027C341.333333 861.651593 353.08873 873.464992 367.589743 873.464992 382.090758 873.464992 393.846155 861.651593 393.846155 847.079027L393.846155 372.131659C393.846155 357.559091 382.090758 345.745694 367.589743 345.745694 353.08873 345.745694 341.333333 357.559091 341.333333 372.131659L341.333333 847.079027ZM498.871795 847.079027C498.871795 861.651593 510.627189 873.464992 525.128205 873.464992 539.62922 873.464992 551.384614 861.651593 551.384614 847.079027L551.384614 372.131659C551.384614 357.559091 539.62922 345.745694 525.128205 345.745694 510.627189 345.745694 498.871795 357.559091 498.871795 372.131659L498.871795 847.079027ZM392.147755 116.721777C392.147755 102.063669 403.758665 90.363507 418.40134 90.363507L622.925796 90.363507C637.408947 90.363507 649.179381 102.1619 649.179381 116.549585L649.179381 171.644875 701.692203 171.644875 701.692203 116.549585C701.692203 72.986607 666.38105 37.591577 622.925796 37.591577L418.40134 37.591577C374.724427 37.591577 339.634933 72.950804 339.634933 116.721777L339.634933 165.310801 392.147755 165.310801 392.147755 116.721777Z"})})},Yt=function(e){return he("svg",{xmlns:"http://www.w3.org/2000/svg",className:e.className,viewBox:"0 0 512 512",children:he("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"48",d:"M112 184l144 144 144-144"})})},Gt=function(e){return he("svg",{xmlns:"http://www.w3.org/2000/svg",className:"".concat(e.className," icon"),viewBox:"0 0 512 512",children:he("path",{d:"M256 48C141.31 48 48 141.31 48 256s93.31 208 208 208 208-93.31 208-208S370.69 48 256 48zm108.25 138.29l-134.4 160a16 16 0 01-12 5.71h-.27a16 16 0 01-11.89-5.3l-57.6-64a16 16 0 1123.78-21.4l45.29 50.32 122.59-145.91a16 16 0 0124.5 20.58z"})})},Xt=function(e){return he("svg",{className:e.className,width:"16",height:"16",viewBox:"0 0 50 50",xmlns:"http://www.w3.org/2000/svg",children:he("circle",{cx:"25",cy:"25",r:"20",stroke:"currentColor",strokeWidth:"5",fill:"none",strokeDasharray:"31.415, 31.415",strokeLinecap:"round",children:he("animateTransform",{attributeName:"transform",type:"rotate",from:"0 25 25",to:"360 25 25",dur:"1s",repeatCount:"indefinite"})})})},Zt=function(){return he("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:he("path",{d:"M704 256v490.666667a170.666667 170.666667 0 0 1-170.666667 170.666666 170.666667 170.666667 0 0 1-170.666666-170.666666V213.333333A106.666667 106.666667 0 0 1 469.333333 106.666667 106.666667 106.666667 0 0 1 576 213.333333v448a42.666667 42.666667 0 0 1-42.666667 42.666667 42.666667 42.666667 0 0 1-42.666666-42.666667V256H426.666667v405.333333a106.666667 106.666667 0 0 0 106.666666 106.666667 106.666667 106.666667 0 0 0 106.666667-106.666667V213.333333a170.666667 170.666667 0 0 0-170.666667-170.666666 170.666667 170.666667 0 0 0-170.666666 170.666666v533.333334a234.666667 234.666667 0 0 0 234.666666 234.666666 234.666667 234.666667 0 0 0 234.666667-234.666666V256h-64z"})})},Qt=function(){return he("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:[he("path",{d:"M842.666667 285.866667l-187.733334-187.733334c-14.933333-14.933333-32-21.333333-53.333333-21.333333H234.666667C194.133333 74.666667 160 108.8 160 149.333333v725.333334c0 40.533333 34.133333 74.666667 74.666667 74.666666h554.666666c40.533333 0 74.666667-34.133333 74.666667-74.666666V337.066667c0-19.2-8.533333-38.4-21.333333-51.2z m-44.8 44.8c-2.133333 2.133333-4.266667 0-8.533334 0h-170.666666c-6.4 0-10.666667-4.266667-10.666667-10.666667V149.333333c0-2.133333 0-6.4-2.133333-8.533333 0 0 2.133333 0 2.133333 2.133333l189.866667 187.733334z m-8.533334 554.666666H234.666667c-6.4 0-10.666667-4.266667-10.666667-10.666666V149.333333c0-6.4 4.266667-10.666667 10.666667-10.666666h311.466666c-2.133333 4.266667-2.133333 6.4-2.133333 10.666666v170.666667c0 40.533333 34.133333 74.666667 74.666667 74.666667h170.666666c4.266667 0 6.4 0 10.666667-2.133334V874.666667c0 6.4-4.266667 10.666667-10.666667 10.666666z",fill:"currentColor"}),he("path",{d:"M640 693.333333H341.333333c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h298.666667c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM640 522.666667H341.333333c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h298.666667c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM341.333333 416h85.333334c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32h-85.333334c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32z",fill:"currentColor"})]})},en=function(){return he("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:he("path",{d:"M557.248 511.68l135.776-135.744-45.248-45.28L512 466.432l-135.776-135.776-45.248 45.28 135.776 135.744-135.776 135.776 45.248 45.248L512 556.928l135.776 135.776 45.248-45.248-135.776-135.776zM512 64c247.136 0 448 200.864 448 448s-200.864 448-448 448S64 759.136 64 512 264.864 64 512 64z",fill:"currentColor"})})},tn=function(){return he("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:he("path",{d:"M512.43945313 904.51953125c-6.06445313 0-12.12890625-1.58203125-17.57812501-4.74609375L136.70703125 689.71484375c-10.63476563-6.24023438-17.13867188-17.66601563-17.13867188-29.97070313s6.50390625-23.73046875 17.13867188-29.97070312l76.37695313-44.91210938L136.97070312 540.125c-10.63476563-6.24023438-17.13867188-17.66601563-17.13867187-29.97070313s6.50390625-23.73046875 17.13867188-29.97070312l73.38867187-43.15429688-73.125-42.890625C126.51171875 387.81054687 120.0078125 376.38476562 120.0078125 364.08007812c0-12.3046875 6.50390625-23.73046875 17.13867188-29.97070312L495.828125 122.99609375c10.8984375-6.41601563 24.34570313-6.41601563 35.24414063 0l358.15429687 210.05859375c10.63476563 6.24023438 17.13867188 17.66601563 17.13867188 29.97070313s-6.50390625 23.73046875-17.13867188 29.97070312l-73.38867188 43.15429688 73.12500001 42.890625c10.63476563 6.24023438 17.13867188 17.66601563 17.13867187 29.97070312s-6.50390625 23.73046875-17.13867187 29.97070313L812.5859375 583.89453125l76.11328125 44.6484375c10.63476563 6.24023438 17.13867188 17.66601563 17.13867188 29.97070313s-6.50390625 23.73046875-17.13867188 29.97070312l-358.59375 211.2890625c-5.44921875 3.1640625-11.6015625 4.74609375-17.66601563 4.74609375zM223.015625 659.65625l289.42382813 169.8046875 290.12695312-170.77148438-58.44726563-34.27734374L530.28125 750.18359375a34.67285156 34.67285156 0 0 1-35.24414063 0L281.7265625 625.02734375 223.015625 659.65625z m76.90429688-104.58984375l212.69531249 124.8046875 290.12695313-170.77148438-55.546875-32.60742187-216.65039063 127.6171875a34.67285156 34.67285156 0 0 1-35.24414062 0L279.00195312 477.28320312l-55.81054687 32.78320313 75.49804688 44.296875c0.43945313 0.26367188 0.79101563 0.52734375 1.23046874 0.703125z m-2.81250001-147.83203125l215.68359376 126.5625 216.12304687-127.17773438c0.3515625-0.26367188 0.703125-0.43945313 1.0546875-0.61523437l72.86132813-42.890625-289.33593751-169.8046875-290.12695312 170.68359375 72.59765625 42.62695313c0.43945313 0.17578125 0.79101563 0.43945313 1.14257813 0.61523437z"})})},nn=function(e){return he("svg",{className:e.className,id:"stop",viewBox:"0 0 1025 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:[he("path",{d:"M512.268258 1022.835842c-68.658678 0-135.399619-13.564433-198.369591-40.316509-60.752236-25.809077-115.373446-62.712976-162.346233-109.685763-46.971763-46.971763-83.875662-101.592974-109.685763-162.346233C15.115619 647.517366 1.551186 580.777449 1.551186 512.118771S15.115619 376.719151 41.866671 313.74918c25.810101-60.752236 62.714-115.373446 109.685763-162.346233 46.972787-46.971763 101.593997-83.875662 162.346233-109.685763 62.969971-26.751052 129.710912-40.315485 198.369591-40.315485s135.398595 13.564433 198.368567 40.315485c60.752236 25.810101 115.373446 62.714 162.346233 109.685763 46.971763 46.972787 83.875662 101.593997 109.685763 162.346233 26.752076 62.969971 40.316509 129.710912 40.316509 198.369591s-13.564433 135.398595-40.316509 198.368567c-25.809077 60.75326-62.712976 115.37447-109.685763 162.346233-46.971763 46.972787-101.592974 83.876686-162.346233 109.685763C647.666853 1009.27141 580.925912 1022.835842 512.268258 1022.835842zM512.268258 50.548195c-62.018782 0-122.293887 12.247716-179.152287 36.403219-54.923257 23.333323-104.317532 56.709936-146.810821 99.204249s-75.870926 91.888588-99.204249 146.810821c-24.155503 56.8584-36.403219 117.133505-36.403219 179.152287 0 62.017758 12.247716 122.292863 36.403219 179.152287 23.333323 54.923257 56.709936 104.317532 99.204249 146.811845 42.493289 42.493289 91.888588 75.870926 146.810821 99.204249 56.8584 24.155503 117.133505 36.403219 179.152287 36.403219 62.017758 0 122.292863-12.247716 179.152287-36.403219 54.923257-23.333323 104.317532-56.71096 146.811845-99.204249 42.493289-42.494313 75.870926-91.888588 99.204249-146.811845 24.155503-56.8584 36.403219-117.133505 36.403219-179.152287s-12.247716-122.293887-36.403219-179.152287c-23.334347-54.923257-56.71096-104.317532-99.205273-146.810821-42.493289-42.493289-91.887565-75.870926-146.810821-99.204249C634.561121 62.795911 574.286016 50.548195 512.268258 50.548195z",fill:"currentColor"}),he("path",{d:"M655.434047 694.244421 367.12637 694.244421c-21.046987 0-38.170445-17.123458-38.170445-38.170445L328.955925 367.766298c0-21.046987 17.123458-38.170445 38.170445-38.170445l288.307678 0c21.048011 0 38.170445 17.123458 38.170445 38.170445l0 288.307678C693.604492 677.120962 676.482058 694.244421 655.434047 694.244421zM380.150191 643.050154l262.260035 0L642.410226 380.79012 380.150191 380.79012 380.150191 643.050154z",fill:"currentColor"})]})},rn=function(e){return he("svg",{xmlns:"http://www.w3.org/2000/svg",className:e.className,viewBox:"0 0 512 512",children:he("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"48",d:"M112 268l144 144 144-144M256 392V100"})})},on=function(){return he("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:[he("path",{d:"M394.688 126.208a32 32 0 0 1 32-32h170.688a32 32 0 0 1 32 32v138.624h288a32 32 0 0 1 32 32v170.688a32 32 0 0 1-32 32H106.688a32 32 0 0 1-32-32V296.832a32 32 0 0 1 32-32h288V126.208z m64 32v138.624a32 32 0 0 1-32 32h-288v106.688h746.688V328.832h-288a32 32 0 0 1-32-32V158.208H458.688z"}),he("path",{d:"M138.688 469.376a32 32 0 0 1 32-32h682.688a32 32 0 0 1 32 32v384a32 32 0 0 1-32 32H170.688a32 32 0 0 1-32-32v-384z m64 32v320h618.688v-320H202.688z"}),he("path",{d:"M341.376 691.52a32 32 0 0 1 32 32V851.2a32 32 0 1 1-64 0v-127.68a32 32 0 0 1 32-32zM512 691.2a32 32 0 0 1 32 32v128a32 32 0 0 1-64 0v-128a32 32 0 0 1 32-32zM682.688 691.52a32 32 0 0 1 32 32V851.2a32 32 0 1 1-64 0v-127.68a32 32 0 0 1 32-32z"})]})},an=function(){return he("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:he("path",{d:"M843.251 424.407l43.828-74.898c10.194-17.946 32.596-22.158 48.956-11.598 16.298 10.499 23.44 32.658 14.223 49.566l-113.11 195.212-61.164-40.044-126.418-82.285c-16.115-11.598-20.632-34.428-10.194-51.702 9.705-17.397 31.009-23.501 47.857-13.734l89.67 59.028C748.576 295.547 615.81 180.667 461.008 180.667c-177.387 0-320.042 148.758-320.042 331.335 0 183.613 143.692 331.334 319.981 331.334 107.861 0.184 208.58-56.158 268.034-149.858 1.099-1.038 1.099-2.075 2.075-2.075 6.348-9.949 17.092-15.871 28.568-15.81 19.35 0 35.648 16.848 35.648 36.93 0 7.508-2.137 14.833-6.104 21.059-72.823 114.698-196.066 183.675-328.099 183.614-216.088 0-391.4-181.478-391.4-405.195 0-223.718 175.312-405.195 391.339-405.195 183.125-0.427 342.016 131.606 382.243 317.601z"})})},sn=function(){return he("svg",{version:"1.1",className:"icon",viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M627.498667 55.168l170.666666 170.666667a42.624 42.624 0 0 1 0 60.330666l-469.333333 469.333334A42.538667 42.538667 0 0 1 298.666667 768H128a42.666667 42.666667 0 0 1-42.666667-42.666667v-170.666666c0-11.306667 4.48-22.186667 12.501334-30.165334l469.333333-469.333333a42.624 42.624 0 0 1 60.330667 0zM896 896a42.666667 42.666667 0 0 1 0 85.333333H128a42.666667 42.666667 0 0 1 0-85.333333h768zM597.333333 145.664l-426.666666 426.666667V682.666667h110.336l426.666666-426.666667L597.333333 145.664z"})})},cn=function(e){return he("svg",{xmlns:"http://www.w3.org/2000/svg",className:e.className,viewBox:"0 0 512 512",children:he("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"48",d:"M184 112l144 144-144 144"})})},un=function(){return he("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M896 870.4l-128-128c55.467-68.267 89.6-149.333 89.6-238.933 0-98.134-38.4-192-110.933-264.534-149.334-149.333-384-149.333-533.334-4.266-145.066 145.066-145.066 384 0 529.066 72.534 72.534 166.4 110.934 264.534 110.934 89.6 0 174.933-29.867 238.933-89.6l128 128c4.267 4.266 12.8 8.533 21.333 8.533s17.067-4.267 21.334-8.533c17.066-8.534 17.066-29.867 8.533-42.667zM260.267 721.067c-119.467-123.734-119.467-320 0-439.467 59.733-59.733 140.8-89.6 217.6-89.6 81.066 0 157.866 29.867 217.6 89.6 59.733 59.733 89.6 136.533 89.6 217.6 0 81.067-34.134 162.133-89.6 217.6-55.467 59.733-132.267 93.867-217.6 93.867-81.067 0-157.867-34.134-217.6-89.6z"})})},ln=function(){return he("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:[he("path",{d:"M190.193225 471.411583c14.446014 0 26.139334-11.718903 26.139334-26.13831 0-14.44499-11.69332-26.164916-26.139334-26.164916-0.271176 0-0.490164 0.149403-0.73678 0.149403l-62.496379 0.146333c-1.425466-0.195451-2.90005-0.295735-4.373611-0.295735-19.677155 0-35.621289 16.141632-35.621289 36.114522L86.622358 888.550075c0 19.949354 15.96767 35.597753 35.670407 35.597753 1.916653 0 3.808746 0.292666 5.649674 0l61.022819 0.022513c0.099261 0 0.148379 0.048095 0.24764 0.048095 0.097214 0 0.146333-0.048095 0.24457-0.048095l0.73678 0 0-0.148379c13.413498-0.540306 24.174586-11.422144 24.174586-24.960485 0-13.55983-10.760065-24.441669-24.174586-24.981974l0-0.393973-50.949392 0 1.450025-402.275993L190.193225 471.409536z"}),he("path",{d:"M926.52241 433.948343c-19.283182-31.445176-47.339168-44.172035-81.289398-45.546336-1.77032-0.246617-3.536546-0.39295-5.380544-0.39295l-205.447139-0.688685c13.462616-39.059598 22.698978-85.58933 22.698978-129.317251 0-28.349675-3.193739-55.962569-9.041934-82.542948l-0.490164 0.049119c-10.638291-46.578852-51.736315-81.31498-100.966553-81.31498-57.264215 0-95.466282 48.15065-95.466282 106.126063 0 3.241834-0.294712 6.387477 0 9.532097-2.996241 108.386546-91.240027 195.548698-196.23636 207.513194l0 54.881958-0.785899 222.227314 0 229.744521 10.709923 0 500.025271 0.222057 8.746198-0.243547c19.35686 0.049119 30.239721-4.817726 47.803749-16.116049 16.682961-10.761088 29.236881-25.50079 37.490869-42.156122 2.260483-3.341095 4.028757-7.075139 5.106298-11.20111l77.018118-344.324116c1.056052-4.053316 1.348718-8.181333 1.056052-12.160971C943.643346 476.446249 938.781618 453.944769 926.52241 433.948343zM893.82573 486.837924l-82.983993 367.783411-0.099261-0.049119c-2.555196 6.141884-6.879688 11.596106-12.872169 15.427364-4.177136 2.727111-8.773827 4.351098-13.414521 4.964058-1.49812-0.195451-3.046383 0-4.620227 0l-477.028511-0.540306-0.171915-407.408897c89.323375-40.266076 154.841577-79.670527 188.596356-173.661202 0.072655 0.024559 0.124843 0.049119 0.195451 0.072655 2.99931-9.137101 6.313799-20.73423 8.697079-33.164331 5.551436-29.185716 5.258771-58.123792 5.258771-58.123792-4.937452-37.98001 25.940812-52.965306 44.364417-52.965306 25.304316 0.860601 50.263777 33.656541 50.263777 52.326762 0 0 5.600555 27.563776 5.649674 57.190537 0.048095 37.366026-4.6673 56.847729-4.6673 56.847729l-0.466628 0c-5.872754 30.879288-16.214287 60.138682-30.464849 86.964654l0.36839 0.342808c-2.358721 4.815679-3.709485 10.220782-3.709485 15.943111 0 19.922748 19.088754 21.742187 38.765909 21.742187l238.761895 0.270153c0 0 14.666024 0.465604 14.690584 0.465604l0 0.100284c12.132318-0.638543 24.221658 5.207605 31.100322 16.409738 5.504364 9.016351 6.437619 19.6045 3.486404 28.988218L893.82573 486.837924z"}),he("path",{d:"M264.827039 924.31872c0.319272 0.024559 0.441045 0.024559 0.295735-0.024559 0.243547-0.048095 0.367367-0.074701-0.295735-0.074701s-0.539282 0.026606-0.271176 0.074701C264.43409 924.343279 264.532327 924.343279 264.827039 924.31872z"})]})},dn=function(){return he("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:he("path",{d:"M190.208 552.576a26.176 26.176 0 0 1 0 52.288L189.44 604.8l-62.464-0.128a35.84 35.84 0 0 1-40-35.84l-0.384-433.28c0-19.968 16-35.648 35.712-35.648 1.92 0 3.84-0.256 5.632 0h62.272v0.128c13.44 0.576 24.192 11.456 24.192 24.96a25.024 25.024 0 0 1-24.192 24.96v0.448h-50.944l1.408 402.24h49.536z m736.32 37.504c-19.264 31.36-47.36 44.16-81.28 45.504a38.656 38.656 0 0 1-5.376 0.384l-205.44 0.704c13.44 39.04 22.656 85.568 22.656 129.28 0 28.416-3.2 56-9.024 82.56h-0.512a103.936 103.936 0 0 1-100.928 81.28c-57.28 0-95.488-48.128-95.488-106.112 0-3.2-0.32-6.4 0-9.536-3.008-108.352-91.264-195.52-196.224-207.488V551.68L254.08 329.6v-229.76h10.688l500.032-0.192 8.704 0.192c19.392 0 30.272 4.864 47.808 16.128 16.704 10.752 29.248 25.536 37.504 42.176 2.304 3.328 4.032 7.04 5.12 11.2l76.992 344.32a37.568 37.568 0 0 1 1.088 12.16c1.536 21.76-3.328 44.288-15.552 64.32z m-32.704-52.928l-83.008-367.744h-0.064a33.408 33.408 0 0 0-26.24-20.352c-1.536 0.192-3.072 0-4.672 0l-477.056 0.512-0.128 407.424c89.28 40.32 154.88 79.68 188.544 173.632h0.256c2.944 9.088 6.272 20.672 8.64 33.088 5.568 29.184 5.312 58.176 5.312 58.176-4.992 37.952 25.92 52.928 44.352 52.928 25.28-0.832 50.24-33.664 50.24-52.288 0 0 5.632-27.584 5.632-57.216 0.064-37.376-4.608-56.832-4.608-56.832h-0.512a307.84 307.84 0 0 0-30.464-87.04l0.384-0.256a36.16 36.16 0 0 1-3.712-16c0-19.84 19.072-21.76 38.784-21.76l238.72-0.192 14.72-0.512v-0.064c12.16 0.64 24.192-5.248 31.104-16.448a35.2 35.2 0 0 0 3.456-28.992h0.32zM267.52 96.768c2.048-0.192 2.816-0.192 1.92 0.128 1.536 0.32 2.304 0.512-1.92 0.512s-3.456-0.192-1.728-0.512c-0.768-0.32-0.192-0.32 1.728-0.128z"})})},hn=function(){return he("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M413.610667 336.192l226.346666-125.461333-11.114666-76.586667c-5.909333-40.64 43.349333-65.344 72.384-36.309333l241.365333 241.344c29.013333 29.013333 4.373333 78.250667-36.245333 72.405333l-76.458667-10.965333-126.165333 227.029333 2.176 5.12c34.56 84.330667 27.413333 153.962667-30.208 214.549333l-4.416 4.544a42.666667 42.666667 0 0 1-60.330667 0l-139.968-139.968L153.365333 946.730667c-38.528 28.48-86.677333-18.133333-61.44-57.109334l1.706667-2.474666 234.154667-318.442667-136.810667-136.832-4.906667-5.12a42.666667 42.666667 0 0 1 2.496-57.6c62.272-62.293333 139.157333-71.445333 222.122667-34.304l2.922667 1.344zM795.733333 313.024l-68.138666-68.117333-0.96 3.136a42.666667 42.666667 0 0 1-19.52 23.04L435.306667 421.76a42.666667 42.666667 0 0 1-41.216 0.085333c-42.197333-23.146667-76.565333-29.290667-106.581334-18.218666l-2.944 1.173333 129.493334 129.493333a42.666667 42.666667 0 0 1 4.202666 55.466667l-88.661333 120.533333 120.213333-88.853333a42.666667 42.666667 0 0 1 52.821334 1.642667l2.709333 2.496 130.282667 130.282666 1.685333-4.522666c8.917333-27.008 3.242667-58.24-16.704-100.608l-2.944-6.144A42.666667 42.666667 0 0 1 618.666667 605.077333l150.912-271.573333a42.666667 42.666667 0 0 1 23.018666-19.498667l3.157334-0.981333z"})})},fn=function(){return he("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M342.464 368.576l73.344 42.368-8.512 7.936a32 32 0 0 1-14.272 7.68l-5.44 0.832-2.88 0.192-19.456 2.24a442.88 442.88 0 0 0-53.504 10.688 245.12 245.12 0 0 0-64.32 25.984l-7.488 4.928 150.144 86.784a32 32 0 0 1 15.808 31.168l-1.024 5.312-61.568 215.168 155.584-160.896a32 32 0 0 1 34.112-7.744l4.928 2.304 152.32 87.872 1.472-8.192c4.992-38.272-7.68-83.456-31.552-128.832l-6.784-12.416a32 32 0 0 1-3.456-23.04l2.56-11.328 78.016 44.992c27.328 61.44 36.672 122.816 15.168 177.856l-5.12 11.84-6.208 11.648a32 32 0 0 1-43.712 11.712l-163.072-94.272-227.2 235.072c-21.632 22.336-57.728 3.84-55.04-24.768l1.28-6.272L336.448 600.96l-163.072-94.08a32 32 0 0 1-14.144-38.464l2.432-5.248c23.936-41.6 71.36-67.84 133.504-84.48 20.48-5.568 41.28-9.6 61.312-12.288l-14.016 2.112zM267.968 218.688l609.664 352a32 32 0 1 1-32 55.424l-609.664-352a32 32 0 1 1 32-55.424z m258.816-106.24a32 32 0 0 1 40.384-42.752l5.056 2.432 295.552 170.624a32 32 0 0 1-12.16 59.52l-83.584 9.984-31.68 138.24-57.984-33.408 32.32-140.992a32 32 0 0 1 21.76-23.424l5.632-1.216 10.56-1.344-129.28-74.624 4.16 9.856a32 32 0 0 1-3.84 31.808l-3.84 4.224L513.92 319.808l-57.984-33.472 104-96.64z"})})},pn=function(e){var t=e.items,n=At([]),r=new pe("chat-thought-chain"),i=At([]);Ue(function(){i.value=t.filter(function(e){return e.description}),i.value.length>0&&i.value.forEach(function(e,t){e.done&&(n.value=[].concat(c(n.value),[t]))})},[t]);return 0===i.value.length?null:he("div",{className:"".concat(r.b()," ").concat(r.is("single",1===i.value.length)),children:i.value.map(function(e,t){if(e.description){var i=n.value.includes(t);return he("div",{className:"".concat(r.e("item")," ").concat(r.is("collapsed",i)),children:[he("div",{className:r.e("item-icon"),children:e.icon||he("span",{children:t})}),he("div",{className:r.e("item-content"),children:[he("div",{className:r.e("item-title"),onClick:function(){return function(e){n.value.includes(e)?n.value=n.value.filter(function(t){return t!==e}):n.value=[].concat(c(n.value),[e])}(t)},children:[e.title,he(Yt,{className:r.e("icon")})]}),he("div",{className:r.e("item-description"),children:e.description})]})]},t)}})})},vn=function(e){var t=e.items,n=e.onItemClick,r=new pe("chat-suggestions");return he("div",{className:"".concat(r.b()),children:t.map(function(e,t){return he("div",{className:"".concat(r.e("item")," ").concat(r.is("action","action"===e.type)),onClick:function(t){return function(e,t){null==n||n(e,t)}(e,t)},title:e.metadata.content_name,children:[e.metadata.content_name,he(cn,{className:"".concat(r.e("item-icon"))})]},t)})})},mn=function(e){var t,n,r=new pe("chat-tool-call-item"),i=At(!1),o=At(!1),a=ke();Ue(function(){return function(){n&&clearTimeout(n)}},[]);var s=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=document.getElementById(e);r&&(r.innerHTML="",i.value&&u(t,n).forEach(function(e,t){var n=document.createElement("div");n.className="code-line";var i=document.createElement("span");i&&(i.className="line-number",i.textContent=(t+1).toString(),n.appendChild(i),n.innerHTML+=e,r.appendChild(n))}))},u=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=" ".repeat(t),r=[];if(Array.isArray(e)){if(0===e.length)return["".concat(n,'<span class="array">[]</span>')];r.push("".concat(n,'<span class="array">[</span>')),e.forEach(function(n,i){var o=u(n,t+1),a=i<e.length-1?",":"";"object"===T(n)&&null!==n?(r.push.apply(r,c(o.slice(0,-1))),r.push("".concat(o[o.length-1]).concat(a))):r.push("".concat(o[0]).concat(a))}),r.push("".concat(n,'<span class="array">]</span>'))}else if("object"===T(e)&&null!==e){var i=Object.keys(e);if(0===i.length)return["".concat(n,'<span class="property">{}</span>')];r.push("".concat(n,'<span class="property">{</span>')),i.forEach(function(o,a){var s=e[o],d=a<i.length-1?",":"",h='<span class="json-key">"'.concat(o,'":</span>');if("object"===T(s)&&null!==s){var f=u(s,t+1);r.push("".concat(n," ").concat(h," ").concat(f[0].trim())),f.length>1&&(r.push.apply(r,c(f.slice(1,-1))),r.push("".concat(f[f.length-1]).concat(d)))}else{var p=l(s);r.push("".concat(n," ").concat(h," ").concat(p).concat(d))}}),r.push("".concat(n,'<span class="property">}</span>'))}else r.push("".concat(n).concat(l(e)));return r},l=function(e){return"string"==typeof e?e.includes("Failed")||e.includes("Error")||e.includes("ERR_")?'<span class="error">"'.concat(e,'"</span>'):'<span class="string">"'.concat(e,'"</span>'):"number"==typeof e?'<span class="number">'.concat(e,"</span>"):"boolean"==typeof e?'<span class="boolean">'.concat(e,"</span>"):null===e?'<span class="null">null</span>':""};return he("div",{className:"".concat(r.b()),children:[he("div",{className:r.e("header"),onClick:function(){return i.value=!i.value,void s("code-block-".concat(a),e.item)},children:[he("div",{className:r.e("header-left"),children:[he("div",{className:r.em("header-left","caption"),children:e.item.name}),he("div",{className:r.em("header-left","desc"),children:(null===(t=e.item.parameters)||void 0===t?void 0:t.desc)||""})]}),he("div",{className:r.e("header-right"),children:[e.item.error&&he("span",{style:"color: red;",children:"发生错误"}),e.item.error&&he("svg",{xmlns:"http://www.w3.org/2000/svg",width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"red",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:"margin-left: 6px;",children:[he("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}),he("path",{d:"M12 9v4"}),he("path",{d:"M12 17h.01"})]}),he("span",{className:r.e("copy"),title:"复制",children:o.value?he("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"rgb(0, 185, 107)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-check","aria-hidden":"true",style:"margin-left: 6px;",onClick:function(e){return e.stopPropagation()},children:he("path",{d:"M20 6 9 17l-5-5"})}):he("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:"margin-left: 6px;",onClick:function(t){return function(t){t.stopPropagation(),n&&clearTimeout(n),o.value=!0,navigator.clipboard.writeText(JSON.stringify(e.item,void 0,2)),window.ibiz.message.success("已复制"),n=setTimeout(function(){o.value=!1},2e3)}(t)},children:[he("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),he("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})}),he("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{"margin-left":" 6px",transform:i.value?"rotate(90deg)":"rotate(0deg)"},children:he("path",{d:"m9 18 6-6-6-6"})})]})]}),he("div",{className:r.e("content"),id:"code-block-".concat(a)})]})},gn=function(e){var t=e.items,n=new pe("chat-tool-call"),r=At([]),i=At(!1),o=At(!1);Ue(function(){r.value=t.filter(function(e){return e}),o.value=t.length>4},[t]);var a=Dt(function(){return o.value&&!i.value?r.value.slice(0,4):r.value});return he("div",{className:"".concat(n.b()),children:[a.value.map(function(e,t){return he(mn,{item:e},t)}),o.value&&he("div",{className:n.e("toggle"),onClick:function(){i.value=!i.value},children:i.value?"收起工具调用":"展开全部 ".concat(r.value.length," 个工具调用")})]})},yn=new pe("chat-select"),kn=function(e){var t,n=e.options,r=e.value,i=e.defaultValue,o=e.className,a=e.placeholder,s=void 0===a?"请选择":a,c=e.onChange,u=e.disabled,l=void 0!==u&&u,h=Je(null),f=Je(null),p=d(qe(r||i||""),2),v=p[0],m=p[1],g=d(qe(!1),2),y=g[0],k=g[1];Ue(function(){void 0!==r&&m(r)},[r]);Ue(function(){var e=function(e){var t,n;l||null!==(t=f.current)&&void 0!==t&&t.contains(e.target)||(null!==(n=h.current)&&void 0!==n&&n.contains(e.target)?k(function(e){return!e}):k(!1))};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}},[]);var w=(null==n||null===(t=n.find(function(e){return e.value===v}))||void 0===t?void 0:t.label)||s;return he("div",{className:"".concat(yn.b()," ").concat(o||""," ").concat(yn.is("visble",y)," ").concat(yn.is("disabled",l)),children:[he("div",{className:yn.e("header"),ref:h,children:[he("span",{className:yn.em("header","prefix"),title:"智能体",children:he("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",width:"1em",height:"1em",children:he("path",{d:"M497.0496 55.7056a38.4 38.4 0 0 1 38.912 0l362.7008 213.2992c11.776 6.912 18.944 19.456 18.944 33.1264v426.6496a38.4 38.4 0 0 1-18.944 33.0752l-362.6496 213.3504a38.4 38.4 0 0 1-38.912 0L134.3488 761.856a38.4 38.4 0 0 1-18.944-33.0752V302.1312a38.4 38.4 0 0 1 18.944-33.1264z m19.456 77.6192L192.3072 324.096v382.72l324.3008 190.7712 324.2496-190.7712V324.096l-324.2496-190.7712zM345.9584 370.3296c7.68 0 14.848 2.2528 20.8384 6.144l149.6576 93.696 149.8624-93.696a38.4512 38.4512 0 0 1 49.1008 58.2656l-1.792 1.792a38.6048 38.6048 0 0 1-6.656 5.12l-152.0128 94.976v170.4448a38.4 38.4 0 0 1-0.1536 3.7376l-0.512 3.7376a38.0928 38.0928 0 0 1-23.04 27.9552 38.0928 38.0928 0 0 1-35.9936-3.5328 38.1952 38.1952 0 0 1-17.0496-31.8976v-170.2912l-152.064-95.1296a38.4 38.4 0 0 1 19.7632-71.3216z"})})}),he("span",{className:yn.em("header","display-value"),title:w,children:w}),he("span",{className:"".concat(yn.em("header","suffix")," ").concat(yn.is("disabled",l)),children:he("svg",{className:"icon",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",width:"1em",height:"1em",children:he("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M19 9l-7 7-7-7"})})})]}),he("div",{className:yn.e("dropdown"),ref:f,children:he("ul",{className:yn.em("dropdown","list"),children:null==n?void 0:n.map(function(e){return he("li",{className:"".concat(yn.em("dropdown","item")," ").concat(yn.is("active",e.value===v)),title:e.label,onClick:function(){return function(e){m(e.value),null==c||c(e.value),k(!1)}(e)},children:e.label},e.value)})})})]})},wn=new pe("messsage-toolbar"),bn=function(e){var t=e.controller,n=e.message,r=[{id:"islike",label:"点赞",title:"点赞",icon:function(){return he(ln,{})},onClick:function(){t.messageLike(n._origin)}},{id:"isdislike",label:"点踩",title:"点踩",icon:function(){return he(dn,{})},onClick:function(){t.messageDisLike(n._origin)}}],i=function(e){var t,n,r,i;return"function"==typeof e.icon?e.icon():null!==(t=e.icon)&&void 0!==t&&t.showIcon&&null!==(n=e.icon)&&void 0!==n&&n.cssClass?he("i",{className:e.icon.cssClass}):null!==(r=e.icon)&&void 0!==r&&r.showIcon&&null!==(i=e.icon)&&void 0!==i&&i.imagePath?xe(e.icon.imagePath)?he("div",{dangerouslySetInnerHTML:{__html:e.icon.imagePath}}):he("img",{src:e.icon.imagePath}):void 0};return Ke(function(){return 20===n.state&&!0!==n.completed||"REMOTE"!==t.resourceMode||!n.realmessageid||t.currentTopicDisableStorage},[n.state,n.completed])?he(H,{}):he("div",{className:"".concat(wn.b()),children:r.map(function(e,r){var o="islike"===e.id&&"1"===n.islike||"isdislike"===e.id&&"1"===n.isdislike;return he("div",{title:e.title,onClick:function(r){return function(e,r){var i;null===(i=r.onClick)||void 0===i||i.call(r,e,r,t.context,t.params,n)}(r,e)},className:"".concat(wn.e("item")," ").concat(wn.is("actived",o)),children:i(e)},r)})})},xn=new pe("markdown-message"),Cn=function(e){var t=e.message,n=e.size,r=At(ke()),i=At(null),o=Ke(function(){return 20===t.state&&!0!==t.completed},[t.state,t.completed]),a=Ke(function(){return 20===t.state&&!0===t.completed},[t.state,t.completed]),c=At({title:"",description:"",icon:he(Xt,{})}),u=At({hasSuggestions:!1,suggestions:[]}),l=function(e){e&&e.length>0?u.value={hasSuggestions:!0,suggestions:e}:u.value={hasSuggestions:!1,suggestions:[]}},d=function(e){var t=e.indexOf("<think>"),n=e.indexOf("</think>"),r="",i="",o=!1;return-1===n?(o=!1,r=e.slice(t+7),i=""):(o=!0,r=e.slice(t+7,n),i=e.slice(n+8)),{isThoughtCompleted:o,thoughtContent:r,answerContent:i}};return Ue(function(){if(n>=0&&i.value){if(-1!==t.content.indexOf("<think>")){var e=d(t.content),r=e.isThoughtCompleted,o=e.thoughtContent,a=e.answerContent;r?(c.value.icon=he(Gt,{}),c.value.title="思考完成"):!0===t.completed?(c.value.icon=he(Gt,{}),c.value.title="思考已停止"):(c.value.icon=he(Xt,{}),c.value.title="思考中..."),c.value.description=o||"",i.value.setMarkdown(a||"")}else if(-1!==t.content.indexOf("<tool_call>")){var s=t.content.replace(/<tool_call>[^]*?<\/tool_call>/g,"").trim();i.value.setMarkdown(s||"")}else i.value.setMarkdown(t.content||"");l(t.suggestions)}},[t,n]),Ue(function(){var e="";if(-1!==t.content.indexOf("<think>")){var n=d(t.content),o=n.isThoughtCompleted,a=n.thoughtContent,u=n.answerContent;c.value={title:o?"思考完成":!0===t.completed?"思考已停止":"思考中...",description:a||"",icon:o||!0===t.completed?he(Gt,{}):he(Xt,{})},u&&(e=u)}else e=-1!==t.content.indexOf("<tool_call>")?t.content.replace(/<tool_call>[^]*?<\/tool_call>/g,"").trim():t.content;l(t.suggestions),i.value=new s({id:r,value:e||"",editor:{defaultModel:"previewOnly"},themeSettings:{mainTheme:"dark",codeBlockTheme:"dark"},previewer:{enablePreviewerBubble:!1},engine:{syntax:{table:{enableChart:!1,externals:["echarts"]}}}})},[]),he("div",{className:"".concat(xn.b()," ").concat(xn.is("loading",o)),children:[he("div",{className:xn.b("header"),children:[he("div",{className:xn.be("header","caption"),children:"AI "}),e.children,a?he("div",{className:xn.be("header","timeout"),children:"请求超时"}):null]}),he("div",{className:"".concat(xn.b("content")," pre-wrap-container"),children:[he(pn,{items:[c.value]}),t.toolcalls&&t.toolcalls.length>0?he(gn,{items:t.toolcalls||[]}):null,he("div",{id:r})]}),he("div",{className:xn.b("footer"),children:[he(bn,{message:t,controller:e.controller},"".concat(t.messageid,"_").concat(t.islike,"_").concat(t.isdislike)),u.value.hasSuggestions?he(vn,{items:u.value.suggestions,onItemClick:function(t,n){!function(t,n){e.controller.handleSuggestionClick(e.message,t,n)}(t,n)}}):null]})]})},Sn=new pe("ossfile-material"),_n=function(e){var t=Dt(function(){return e.material.data.name}),n=Dt(function(){return e.material.metadata.size}),r=Dt(function(){var t=e.material.metadata.state;return"successed"===t?"上传成功":"uploading"===t?"上传中":"failed"===t?"上传失败":"未知状态"}),i=Dt(function(){switch(e.material.metadata.state){case"successed":return"#1890ff";case"uploading":return"#52c41a";default:return"#ff4d4f"}});return he("div",{className:Sn.b(),children:[he("div",{className:Sn.b("left"),children:he(Qt,{})}),he("div",{className:Sn.b("right"),children:[he("div",{className:Sn.e("name"),title:t,children:t}),he("div",{className:Sn.e("metadata"),children:[he("div",{children:[n,"B"]}),he("div",{style:{color:i.value},children:r})]})]})]})},Mn=new pe("common-material"),Tn=function(e){var t,n,r,i,o=null===(t=e.controller.opts.questionToolbarItems)||void 0===t?void 0:t.find(function(t){return t.id===e.material.metadata.actionId}),a=Dt(function(){return e.material.metadata.name});return he("div",{className:Mn.b(),children:[he("div",{className:Mn.b("left"),children:o&&o.icon?"function"==typeof o.icon?o.icon():(null===(n=o.icon)||void 0===n?void 0:n.showIcon)&&he(H,{children:null!==(r=o.icon)&&void 0!==r&&r.cssClass?he("i",{className:o.icon.cssClass}):null!==(i=o.icon)&&void 0!==i&&i.imagePath?xe(o.icon.imagePath)?he("div",{dangerouslySetInnerHTML:{__html:o.icon.imagePath}}):he("img",{src:o.icon.imagePath}):null}):he(tn,{})}),he("div",{className:Mn.b("right"),children:[he("div",{className:Mn.e("name"),title:a,children:a}),he("div",{className:Mn.e("metadata"),children:he("div",{children:(null==o?void 0:o.label)||"素材资源"})})]})]})},On=new pe("chat-input-material-item"),Nn=function(e){var t=e.material,n=null;if("ossfile"===t.type)n=_n;else n=Tn;return he("div",{className:"".concat(On.b()," ").concat(On.is("disabled",e.disabled)),children:[he("div",{className:On.e("icon"),onClick:function(){e.controller.deleteMaterial(t)},children:he(en,{})}),$(n,{material:t,controller:e.controller})]})},En=new pe("user-message-question"),An=function(e){var t=At(ke()),n=At(null),r=At(135),i=At(!0),o=At(!1),a=Je(null),c=Dt(function(){return e.message.content}),u=Dt(function(){return Me.parseMixedContent(c.value)});return Ue(function(){n.value=new s({id:t,value:u.value.remainingText||"",editor:{defaultModel:"previewOnly"},themeSettings:{mainTheme:"dark",codeBlockTheme:"dark"},previewer:{enablePreviewerBubble:!1},engine:{syntax:{table:{enableChart:!1,externals:["echarts"]}}}})},[u.value.remainingText]),Ue(function(){if(a.current&&window.ResizeObserver){var e=new ResizeObserver(function(){var e,t=null===(e=n.value)||void 0===e?void 0:e.previewer.options.previewerDom;t&&(o.value=t.scrollHeight>r.value)});return e.observe(a.current),function(){e.disconnect()}}},[a.current]),he("div",{className:En.b(),children:[he("div",{className:En.e("user-header"),children:[e.children,he("div",{className:En.e("user"),children:"我"})]}),he("div",{className:En.e("content"),children:he("div",{className:En.em("content","body"),children:[u.value.hasResources&&he("div",{className:En.em("content","material"),children:u.value.resources.map(function(t){return he(Nn,{material:t,disabled:!0,controller:e.controller},t.id)})}),he("div",{className:"pre-wrap-container",children:[he("div",{className:"".concat(En.e("text-content")," ").concat(En.is("collapse",i.value)),id:t,ref:a,style:{maxHeight:i.value?"".concat(r.value,"px"):""}}),he("div",{className:"".concat(En.e("collapse-btn")," ").concat(En.is("visible",o.value)),title:i.value?"展开":"收起",onClick:function(){i.value=!i.value},children:i.value?he("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",children:he("path",{fill:"currentColor",d:"M104.704 338.752a64 64 0 0 1 90.496 0l316.8 316.8 316.8-316.8a64 64 0 0 1 90.496 90.496L557.248 791.296a64 64 0 0 1-90.496 0L104.704 429.248a64 64 0 0 1 0-90.496"})}):he("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",children:he("path",{fill:"currentColor",d:"M104.704 685.248a64 64 0 0 0 90.496 0l316.8-316.8 316.8 316.8a64 64 0 0 0 90.496-90.496L557.248 232.704a64 64 0 0 0-90.496 0L104.704 594.752a64 64 0 0 0 0 90.496"})})})]})]})})]})},Dn=new pe("error-message"),In=function(e){var t=Dt(function(){return e.message.content});return he("div",{className:Dn.b(),children:[he("div",{className:Dn.b("header"),children:[he("div",{className:Dn.be("header","caption"),children:"AI "}),e.children]}),he("div",{className:"".concat(Dn.e("content")," pre-wrap-container"),children:he("span",{children:t})})]})},zn=new pe("unknown-message"),Rn=function(e){return he("div",{className:zn.b(),children:he("div",{className:"".concat(zn.e("content")," pre-wrap-container"),children:["暂未支持的消息类型: ",e.message.type]})})},Pn=new pe("chat-message-item"),Ln=function(e){var t=e.message,n=e.size,r=null;switch(t.type){case"DEFAULT":r="ASSISTANT"===t.role?Cn:An;break;case"ERROR":r=In;break;default:r=Rn}return he("div",{className:Pn.b(),children:$(r,{size:n,message:t,controller:e.controller,children:e.children})})},Bn=function(){return S(function e(t){x(this,e),_(this,"toolcalls",[]),_(this,"allcontent",""),this.msg=t,this.toolcalls=t.toolcalls||[],this.allcontent=t.content},[{key:"messageid",get:function(){return this.msg.messageid}},{key:"state",get:function(){return this.msg.state}},{key:"role",get:function(){return this.msg.role}},{key:"type",get:function(){return this.msg.type}},{key:"realcontent",get:function(){var e=this.msg.content;if(-1!==e.indexOf("<think>")&&-1===e.indexOf("</think>"))return"";if(-1!==(e=e.replace(/<think>[^]*?<\/think>/g,"").trim()).indexOf("<tool_call>")&&-1===e.indexOf("</tool_call>"))return"";if(-1!==(e=e.replace(/<tool_call>[^]*?<\/tool_call>/g,"").trim()).indexOf("<resources>")&&-1===e.indexOf("</resources>"))return"";var t=(e=e.replace(/<resources>[^]*?<\/resources>/g,"").trim()).indexOf("<suggestions>");return-1!==t&&(e=e.substring(0,t).trim()),e}},{key:"content",get:function(){return this.msg.content}},{key:"completed",get:function(){return this.msg.completed}},{key:"suggestions",get:function(){return this.msg.suggestions}},{key:"_origin",get:function(){return this.msg}},{key:"islike",get:function(){return this.msg.islike}},{key:"isdislike",get:function(){return this.msg.isdislike}},{key:"feedbackcontent",get:function(){return this.msg.feedbackcontent}},{key:"realmessageid",get:function(){return this.msg.realmessageid}},{key:"update",value:function(e){e.content||(e.content=""),this.allcontent+=e.content,-1!==e.content.indexOf("<think>")&&this.msg.content&&(this.msg.content=""),this.msg.content+=e.content,this.computeToolCalls()}},{key:"replace",value:function(e){this.msg=e}},{key:"updateCompleted",value:function(e){this.msg.completed=e}},{key:"computeToolCalls",value:function(){this.toolcalls=ze.parse(this.allcontent)}}])}(),Vn=function(){return S(function e(t){x(this,e),this.data=t},[{key:"appid",get:function(){return this.data.appid}},{key:"id",get:function(){return this.data.id}},{key:"type",get:function(){return this.data.type}},{key:"caption",get:function(){return this.data.caption}},{key:"sourceCaption",get:function(){return this.data.sourceCaption}},{key:"url",get:function(){return this.data.url}},{key:"aiChat",get:function(){return this.data.aiChat}},{key:"captionMode",get:function(){return this.data.captionMode}},{key:"captionFilled",get:function(){return this.data.captionFilled}},{key:"realid",get:function(){return this.data.realid}},{key:"sequence",get:function(){return this.data.sequence}},{key:"isTop",get:function(){return this.data.isTop}},{key:"disableStorage",get:function(){return this.data.disableStorage||!1}}])}(),Fn=function(){return S(function e(t){x(this,e),this.material=t},[{key:"id",get:function(){return this.material.id}},{key:"type",get:function(){return this.material.type}},{key:"metadata",get:function(){return this.material.metadata}},{key:"data",get:function(){return this.material.data}}])}(),$n=function(){return S(function e(t){x(this,e),this.agent=t},[{key:"id",get:function(){return this.agent.id}},{key:"caption",get:function(){return this.agent.caption}},{key:"default",get:function(){return this.agent.default}},{key:"order",get:function(){return this.agent.order}},{key:"value",get:function(){return this.agent.id}},{key:"label",get:function(){return this.agent.caption}}])}(),jn=new pe("chat-toolbar-item"),Hn=function(e){var t,n,r,i=e.model,o=e.data,a=e.className,s=e.disabled,c=void 0!==s&&s,u=e.buttonType,l=void 0===u?"default":u,h=e.onClick,f=d(qe(!1),2),p=f[0],v=f[1],m=Je(null),g=function(e){return"function"==typeof e.hidden?e.hidden(o):!0===e.hidden};if(g(i))return he(H,{});var y=function(e){return!!c||("function"==typeof e.disabled?e.disabled(o):!0===e.disabled)},k=function(e){var t,n,r,i;return"function"==typeof e.icon?e.icon():null!==(t=e.icon)&&void 0!==t&&t.showIcon&&null!==(n=e.icon)&&void 0!==n&&n.cssClass?he("i",{className:e.icon.cssClass}):null!==(r=e.icon)&&void 0!==r&&r.showIcon&&null!==(i=e.icon)&&void 0!==i&&i.imagePath?xe(e.icon.imagePath)?he("div",{dangerouslySetInnerHTML:{__html:e.icon.imagePath}}):he("img",{src:e.icon.imagePath}):void 0},w=function(e,t){y(t)||(v(!1),h(e,t))};return Ue(function(){var e=function(e){m.current&&m.current.contains(e.target)||v(!1)};return p&&document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}},[p]),he("div",{className:"".concat(jn.b()," ").concat(jn.b(l)," ").concat(i.customClass||""," ").concat(a||""," ").concat(jn.is("disabled",y(i))," ").concat(jn.is("more",!(null===(t=i.children)||void 0===t||!t.length))),children:[he("div",{title:i.title,className:jn.e("content"),onClick:function(e){return w(e,i)},children:[he("div",{className:jn.em("content","icon"),children:k(i)}),he("div",{className:jn.em("content","label"),children:i.label})]}),(null===(n=i.children)||void 0===n?void 0:n.length)&&he("div",{title:"更多",className:jn.e("more"),onClick:function(e){y(i)||v(!0)},children:he("i",{"aria-hidden":"true",className:"fa fa-angle-down ".concat(jn.em("more","icon"))})}),p&&he("div",{ref:m,className:jn.b("dropdown"),children:null===(r=i.children)||void 0===r?void 0:r.map(function(e,t){if(!g(e))return he("div",{title:e.title,onClick:function(t){return w(t,e)},className:"".concat(jn.be("dropdown","item")," ").concat(e.customClass||""," ").concat(jn.is("disabled",y(e))),children:[he("div",{className:jn.bem("dropdown","item","icon"),children:k(e)}),he("div",{className:jn.bem("dropdown","item","label"),children:e.label})]},t)})})]})},Wn=new pe("chat-toolbar"),qn=function(e){var t=e.controller,n=e.items,r=void 0===n?[]:n,i=e.data,o=e.type,a=e.className,s=e.mode,u=e.hideTopicSidebar,l=[],d=[{label:"重置对话",title:"重置对话",icon:function(){return he(an,{})},onClick:function(){t.resetTopic()},children:[{label:"清空对话",title:"清空对话",icon:function(){return he(on,{})},onClick:function(){t.clearTopic()}},{label:"新建对话",title:"新建对话",hidden:"TOPIC"!==s||u,icon:function(){return he(Ht,{})},onClick:function(){t.newTopic()}}]}],h=[{label:"刷新",title:"刷新",icon:function(){return he(Lt,{})},onClick:function(){t.refreshMessage(i)}},{label:"删除",title:"删除",hidden:function(){return!i.realmessageid},icon:function(){return he(Pt,{})},onClick:function(){t.deleteMessage(i)}},{label:"复制",title:"复制",icon:function(){return he(Bt,{})},onClick:function(){t.copyMessage(i)}}];Ge($f).enableBackFill&&h.unshift.apply(h,[{label:"回填",title:"回填",icon:function(){return he(zt,{})},onClick:function(){t.backfill(i)}}]);var f=[{label:"刷新",title:"刷新",icon:function(){return he(Lt,{})},onClick:function(){t.refreshMessage(i,!0)}}];if("content"===o)switch(i.type){case"DEFAULT":l="ASSISTANT"===i.role?[].concat(h,c(r)):[].concat(f);break;case"ERROR":l=[].concat(h,c(r))}else l=[].concat(d,c(r));var p=function(n,r){var o=g({},i);if(i instanceof Bn?(Object.assign(o,{topic:t.topic}),o.msg.realcontent=i.realcontent):(o.data||(o.data={}),Object.assign(o.data,{messages:t.messages.value})),r.onClick&&"function"==typeof r.onClick)r.onClick(n,r,t.context,t.params,o);else{var a=e.controller.opts.extendToolbarClick;a&&"function"==typeof a&&a(n,r,t.context,t.params,o)}},v=Ke(function(){return"content"===o&&20===(null==i?void 0:i.state)&&!0!==(null==i?void 0:i.completed)},[null==i?void 0:i.state,null==i?void 0:i.completed]);return he("div",{className:"".concat(Wn.b()," ").concat(a||""),children:l.map(function(e,t){return he(Hn,{data:i,model:e,disabled:v,buttonType:"content"===o?"circle":"default",onClick:p.bind(void 0)},t)})})};var Un=function(e){var t=At(!1),n=At({}),r=new pe("chat-back-bottom"),i=At(null),o=function(){if(i.value){var n=e.visibilityHeight||200,r=i.value.scrollHeight-i.value.scrollTop-i.value.offsetHeight;t.value=r>=n}},a=function(e,t){var n=null;return function(){for(var r=this,i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];n||(n=setTimeout(function(){e.apply(r,o),n=null},t))}}(o,300);return Ke(function(){n.value={right:"".concat(e.right,"px"),bottom:"".concat(e.bottom,"px")}},[e.right,e.bottom]),Ue(function(){if(e.target){var t,n=null!==(t=document.querySelector(e.target))&&void 0!==t?t:void 0;n&&(i.value=n,n.addEventListener("scroll",a),o())}},[]),he("div",{className:"".concat(r.b()," ").concat(r.is("visible",t.value)),style:n.value,onClick:function(){var t;i.value&&(i.value.scrollTo({top:i.value.scrollHeight,behavior:"smooth"}),null===(t=e.onClick)||void 0===t||t.call(e))},children:he(rn,{className:r.e("icon")})})},Jn=new pe("chat-messages"),Kn=function(e){var t=Je(null),n=d(qe(5),2),r=n[0],i=n[1],o=d(qe(!1),2),a=o[0],s=o[1],c=d(qe(!0),2),u=c[0],l=c[1],h=Je(!1),f=e.controller.messages,p=Ke(function(){var e=Math.max(0,f.value.length-r);return f.value.slice(e)},[f.value,r]),v=Ke(function(){return r<f.value.length},[f.value,r]);Ue(function(){var e;u&&((e=t.current)&&(h.current=!0,e.scrollTo({top:e.scrollHeight,behavior:"auto"}),setTimeout(function(){h.current=!1},500)))},[f.value]);return he("div",{ref:t,className:Jn.b(),onScroll:function(){if(!h.current){var e=t.current;if(e){var n=e.scrollTop,o=e.scrollHeight,c=e.clientHeight;n<100&&!a&&v&&(s(!0),setTimeout(function(){var t=Math.min(r+5,f.value.length);i(t);var n=e.scrollHeight;setTimeout(function(){var t=e.scrollHeight;e.scrollTop=t-n+e.scrollTop,s(!1)},0)},300)),l(o-(n+c)<50)}}},children:[p.map(function(t){var n,r=(null===(n=t.content)||void 0===n?void 0:n.length)||0;return"SYSTEM"!==t.role?he(Ln,{size:r,message:t,controller:e.controller,children:he(qn,{type:"content",mode:"DEFAULT",hideTopicSidebar:!1,data:t,items:e.toolbarItems,controller:e.controller})},t.messageid):null}),he(Un,{right:20,bottom:14,target:".".concat(Jn.b()),onClick:function(){h.current=!0,l(!0)}})]})};function Yn(e,t){for(var n in e)if("__source"!==n&&!(n in t))return!0;for(var r in t)if("__source"!==r&&e[r]!==t[r])return!0;return!1}function Gn(e,t){this.props=e,this.context=t}(Gn.prototype=new W).isPureReactComponent=!0,Gn.prototype.shouldComponentUpdate=function(e,t){return Yn(this.props,e)||Yn(this.state,t)};var Xn=m.__b;m.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Xn&&Xn(e)};var Zn=m.__e;m.__e=function(e,t,n,r){if(e.then)for(var i,o=t;o=o.__;)if((i=o.__c)&&i.__c)return null==t.__e&&(t.__e=n.__e,t.__k=n.__k),i.__c(e,t);Zn(e,t,n,r)};var Qn=m.unmount;function er(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(e){"function"==typeof e.__c&&e.__c()}),e.__c.__H=null),null!=(e=function(e,t){for(var n in t)e[n]=t[n];return e}({},e)).__c&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(e){return er(e,t,n)})),e}function tr(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(e){return tr(e,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function nr(){this.__u=0,this.o=null,this.__b=null}function rr(e){var t=e.__.__c;return t&&t.__a&&t.__a(e)}function ir(){this.i=null,this.l=null}m.unmount=function(e){var t=e.__c;t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Qn&&Qn(e)},(nr.prototype=new W).__c=function(e,t){var n=t.__c,r=this;null==r.o&&(r.o=[]),r.o.push(n);var i=rr(r.__v),o=!1,a=function(){o||(o=!0,n.__R=null,i?i(s):s())};n.__R=a;var s=function(){if(! --r.__u){if(r.state.__a){var e=r.state.__a;r.__v.__k[0]=tr(e,e.__c.__P,e.__c.__O)}var t;for(r.setState({__a:r.__b=null});t=r.o.pop();)t.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(a,a)},nr.prototype.componentWillUnmount=function(){this.o=[]},nr.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),r=this.__v.__k[0].__c;this.__v.__k[0]=er(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&$(H,null,e.fallback);return i&&(i.__u&=-33),[$(H,null,t.__a?null:e.children),i]};var or=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&("t"!==e.props.revealOrder[0]||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}};function ar(e){return this.getChildContext=function(){return e.context},e.children}function sr(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){le(null,t.v),t.v=null,t.h=null},t.h&&t.h!==n&&t.componentWillUnmount(),!t.v){for(var r=t.__v;null!==r&&!r.__m&&null!==r.__;)r=r.__;t.h=n,t.v={nodeType:1,parentNode:n,childNodes:[],__k:{__m:r.__m},contains:function(){return!0},insertBefore:function(e,n){this.childNodes.push(e),t.h.insertBefore(e,n)},removeChild:function(e){this.childNodes.splice(this.childNodes.indexOf(e)>>>1,1),t.h.removeChild(e)}}}le($(ar,{context:t.context},e.__v),t.v)}function cr(e,t){var n=$(sr,{__v:e,h:t});return n.containerInfo=t,n}(ir.prototype=new W).__a=function(e){var t=this,n=rr(t.__v),r=t.l.get(e);return r[0]++,function(i){var o=function(){t.props.revealOrder?(r.push(i),or(t,e,r)):i()};n?n(o):o()}},ir.prototype.render=function(e){this.i=null,this.l=new Map;var t=X(e.children);e.revealOrder&&"b"===e.revealOrder[0]&&t.reverse();for(var n=t.length;n--;)this.l.set(t[n],this.i=[1,0,this.i]);return e.children},ir.prototype.componentDidUpdate=ir.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){or(e,n,t)})};var ur="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,lr=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,dr=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,hr=/[A-Z0-9]/g,fr="undefined"!=typeof document,pr=function(e){return("undefined"!=typeof Symbol&&"symbol"==T(Symbol())?/fil|che|rad/:/fil|che|ra/).test(e)};W.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(W.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var vr=m.event;function mr(){}function gr(){return this.cancelBubble}function yr(){return this.defaultPrevented}m.event=function(e){return vr&&(e=vr(e)),e.persist=mr,e.isPropagationStopped=gr,e.isDefaultPrevented=yr,e.nativeEvent=e};var kr={enumerable:!1,configurable:!0,get:function(){return this.class}},wr=m.vnode;m.vnode=function(e){"string"==typeof e.type&&function(e){var t=e.props,n=e.type,r={},i=-1===n.indexOf("-");for(var o in t){var a=t[o];if(!("value"===o&&"defaultValue"in t&&null==a||fr&&"children"===o&&"noscript"===n||"class"===o||"className"===o)){var s=o.toLowerCase();"defaultValue"===o&&"value"in t&&null==t.value?o="value":"download"===o&&!0===a?a="":"translate"===s&&"no"===a?a=!1:"o"===s[0]&&"n"===s[1]?"ondoubleclick"===s?o="ondblclick":"onchange"!==s||"input"!==n&&"textarea"!==n||pr(t.type)?"onfocus"===s?o="onfocusin":"onblur"===s?o="onfocusout":dr.test(o)&&(o=s):s=o="oninput":i&&lr.test(o)?o=o.replace(hr,"-$&").toLowerCase():null===a&&(a=void 0),"oninput"===s&&r[o=s]&&(o="oninputCapture"),r[o]=a}}"select"==n&&r.multiple&&Array.isArray(r.value)&&(r.value=X(t.children).forEach(function(e){e.props.selected=-1!=r.value.indexOf(e.props.value)})),"select"==n&&null!=r.defaultValue&&(r.value=X(t.children).forEach(function(e){e.props.selected=r.multiple?-1!=r.defaultValue.indexOf(e.props.value):r.defaultValue==e.props.value})),t.class&&!t.className?(r.class=t.class,Object.defineProperty(r,"className",kr)):(t.className&&!t.class||t.class&&t.className)&&(r.class=r.className=t.className),e.props=r}(e),e.$$typeof=ur,wr&&wr(e)};var br=m.__r;m.__r=function(e){br&&br(e),e.__c};var xr=m.diffed;m.diffed=function(e){xr&&xr(e);var t=e.props,n=e.__e;null!=n&&"textarea"===e.type&&"value"in t&&t.value!==n.value&&(n.value=null==t.value?"":t.value)};var Cr=function(e){return e.STYLE_CACHE="ai-chat-style-cache",e.MINIMIZE_STYLY_CHCHE="ai-chat-minimize-style-cache",e.DATA_BASE_NAME="ibiz-chat",e.DATA_TABLE_NAME="history-message",e.DATA_TABLE_KEY_NAME="id",e}(Cr||{});function Sr(e){switch(e){case"user":default:return"USER";case"agent":return"ASSISTANT";case"system":return"SYSTEM"}}function _r(e){switch(e){case"pending":return 20;case"sent":case"cancelled":default:return 30;case"failed":return 40}}function Mr(e){switch(e){case"pending":case"sent":case"cancelled":default:return"DEFAULT";case"failed":return"ERROR"}}var Tr=function(){return S(function e(t,n){x(this,e),_(this,"evt",new p),_(this,"messages",mt([])),_(this,"materials",mt([])),_(this,"input",mt("")),_(this,"isLoading",mt(!1)),_(this,"enableAIAgentChange",!0),_(this,"activeAIAgentID",void 0),_(this,"agentList",mt([])),_(this,"context",void 0),_(this,"params",void 0),_(this,"appDataEntityId",void 0),_(this,"topicId",void 0),_(this,"topic",void 0),_(this,"aiTopic",void 0),_(this,"chatSessionid",""),_(this,"chatMode",void 0),this.opts=t,this.resourceOptions=n,this.context=t.context,this.params=t.params,this.appDataEntityId=t.appDataEntityId,this.aiTopic=t.aiTopic,this.topicId=t.topicId,this.topic=t.topic,this.activeAIAgentID=t.activeAIAgentID,this.enableAIAgentChange=!!t.enableAIAgentChange,this.chatMode=t.srfMode,this.chatSessionid=t.sessionid,this.initAIChat()},[{key:"resourceMode",get:function(){var e;return(null===(e=this.resourceOptions)||void 0===e?void 0:e.resourceMode)||"LOCAL"}},{key:"currentTopicDisableStorage",get:function(){if(this.topicId&&this.aiTopic){var e=this.aiTopic.getCurrentTopicByID(this.topicId);if(e&&e.disableStorage)return!0}return!1}},{key:"initAIChat",value:(T=b(y().m(function e(){return y().w(function(e){for(;;)switch(e.n){case 0:return this.messages.value=[],e.n=1,this.initAIChatAgent();case 1:return e.n=2,this.fecthHistory();case 2:return e.a(2)}},e,this)})),function(){return T.apply(this,arguments)})},{key:"initAIChatAgent",value:(M=b(y().m(function e(){var t=this;return y().w(function(e){for(;;)switch(e.n){case 0:this.opts.aiAgentlist&&this.opts.aiAgentlist.length>0&&this.opts.aiAgentlist.forEach(function(e){t.agentList.value=[].concat(c(t.agentList.value),[new $n(e)])});case 1:return e.a(2)}},e,this)})),function(){return M.apply(this,arguments)})},{key:"getHistoryStoreKey",value:function(e){return"".concat(e)}},{key:"fecthHistory",value:(C=b(y().m(function e(){var t,n,r,i=this;return y().w(function(e){for(;;)switch(e.n){case 0:if(!this.topicId){e.n=7;break}if(t={},!this.currentTopicDisableStorage){e.n=1;break}t.data=[],e.n=5;break;case 1:if("LOCAL"!==this.resourceMode){e.n=3;break}return e.n=2,Se.getData(Cr.DATA_BASE_NAME,Cr.DATA_TABLE_NAME,this.getHistoryStoreKey(this.topicId));case 2:t=e.v,e.n=5;break;case 3:if("REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=5;break}return e.n=4,this.resourceOptions.getMessages({n_session_id_eq:this.chatSessionid});case 4:(n=e.v)&&n.length>0&&(r=[],n.forEach(function(e){var t;r.push({messageid:(t=e).id,state:_r(t.status),type:Mr(t.status),role:Sr(t.sender_type),content:t.content,completed:!0,islike:t.is_like,isdislike:t.is_dislike,feedbackcontent:t.feedback_content,realmessageid:t.id})}),t.data=r);case 5:if(!(t&&t.data&&t.data.length>0)){e.n=7;break}return t.data.forEach(function(e){var t={messageid:e.messageid,state:e.state,type:e.type,role:e.role,islike:e.islike,isdislike:e.isdislike,feedbackcontent:e.feedbackcontent,content:e.content,suggestions:e.suggestions,completed:!0,toolcalls:e.toolcalls,realmessageid:e.realmessageid};i.addMessage(t)}),e.n=6,this.afterFecthHistory();case 6:return e.a(2,!0);case 7:return e.n=8,this.opts.history(this.context,this.params,{appDataEntityId:this.appDataEntityId,appendCurData:this.opts.appendCurData,sessionid:this.chatSessionid,srfaiagent:this.activeAIAgentID,srfmode:this.chatMode});case 8:if(!e.v){e.n=9;break}return e.n=9,this.afterFecthHistory();case 9:return e.a(2,!0)}},e,this)})),function(){return C.apply(this,arguments)})},{key:"afterFecthHistory",value:(w=b(y().m(function e(){var t,n,r,i,o,a,s,u,l=this;return y().w(function(e){for(;;)switch(e.p=e.n){case 0:if(this.opts.appendCurContent&&this.addMessage({state:30,messageid:ke(),role:"USER",type:"DEFAULT",content:this.opts.appendCurContent,completed:!0}),this.opts.appendCurResource&&(t=Me.parseMixedContent(this.opts.appendCurResource),n=t.hasResources,r=t.resources,n&&r&&r.length>0&&r.forEach(function(e){l.replaceMaterial(e.id,e)})),!1===this.opts.autoQuestion){e.n=4;break}if(i=this.messages.value.length-1,!(o=this.messages.value[i])||"USER"!==o.role){e.n=4;break}return(a=this.stringlyMaterialResource(!1))&&(s=a+o.content,u=g(g({},o._origin),{},{messageid:ke(),content:s}),this.messages.value[i]=new Bn(u),this.messages.value=c(this.messages.value)),e.p=1,this.isLoading.value=!0,e.n=2,this.opts.question(this,this.context,this.params,{appDataEntityId:this.appDataEntityId},this.getMessages(),this.chatSessionid,this.activeAIAgentID,this.chatMode);case 2:if(!this.opts.action){e.n=3;break}return e.n=3,this.opts.action("question",o.content);case 3:return e.p=3,this.isLoading.value=!1,e.f(3);case 4:return e.n=5,this.updateTopicCaption();case 5:return e.a(2)}},e,this,[[1,,3,4]])})),function(){return w.apply(this,arguments)})},{key:"asyncToIndexDB",value:(k=b(y().m(function e(){var t;return y().w(function(e){for(;;)switch(e.n){case 0:if(this.topicId&&"LOCAL"===this.resourceMode){e.n=1;break}return e.a(2);case 1:if(!this.currentTopicDisableStorage){e.n=2;break}return e.a(2);case 2:return t={id:this.getHistoryStoreKey(this.topicId),data:this.messages.value.map(function(e){return g(g({},e._origin),{},{toolcalls:e.toolcalls})}),timestamp:(new Date).getTime()},e.n=3,Se.updateData(Cr.DATA_BASE_NAME,Cr.DATA_TABLE_NAME,t);case 3:return e.a(2)}},e,this)})),function(){return k.apply(this,arguments)})},{key:"setInput",value:function(e){this.input.value=e||""}},{key:"addMessage",value:function(e){var t=this.messages.value.find(function(t){return t.messageid===e.messageid});t?(t.update(e),this.messages.value=c(this.messages.value)):this.messages.value=[].concat(c(this.messages.value),[new Bn(e)]),this.asyncToIndexDB()}},{key:"completeMessage",value:(m=b(y().m(function e(t,n){var r,i;return y().w(function(e){for(;;)switch(e.n){case 0:if(!(r=this.messages.value.find(function(e){return e.messageid===t}))){e.n=1;break}return r.updateCompleted(n),this.messages.value=c(this.messages.value),e.n=1,this.asyncToIndexDB();case 1:!0===this.opts.autoFill&&"ASSISTANT"===(i=r||this.messages.value[this.messages.value.length-1]).role&&30===i.state&&this.backfill(i),this.evt.emit("onCompleteMessage",{messageid:t,completed:n});case 2:return e.a(2)}},e,this)})),function(e,t){return m.apply(this,arguments)})},{key:"replaceMessage",value:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=this.messages.value.findIndex(function(t){return t.messageid===e.messageid});-1!==r?(this.messages.value[r].replace(e),this.messages.value=c(this.messages.value)):this.messages.value=[].concat(c(this.messages.value),[new Bn(e)]),this.asyncToIndexDB(),"DEFAULT"===e.type&&this.opts.recommendPrompt&&n&&this.opts.recommendPrompt(this.context,this.params,{appDataEntityId:this.appDataEntityId,message:{messages:[e],sessionid:this.chatSessionid,srfaiagent:this.activeAIAgentID}}).then(function(n){n&&n.content&&t.updateRecommendPrompt(e,n.content)})}},{key:"stopMessage",value:(v=b(y().m(function e(t){var n,r;return y().w(function(e){for(;;)switch(e.n){case 0:return-1!==(n=this.messages.value.findIndex(function(e){return e.messageid===t.messageid}))?(r=this.messages.value[n],t.content=r.content,this.messages.value[n].replace(t),this.messages.value=c(this.messages.value)):this.messages.value=[].concat(c(this.messages.value),[new Bn(t)]),e.n=1,this.asyncToIndexDB();case 1:return e.a(2)}},e,this)})),function(e){return v.apply(this,arguments)})},{key:"stringlyMaterialResource",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t="",n=[];return this.materials.value&&this.materials.value.length>0&&(this.materials.value.forEach(function(e){if("ossfile"===e.type){var t=e.metadata;t.state&&"successed"===t.state&&n.push(e)}else n.push(e)}),e&&(this.materials.value=[])),n&&n.length>0&&(t=Me.stringify(n)),t}},{key:"getMessages",value:function(){var e=this.messages.value.filter(function(e){return"ERROR"!==e.type}).map(function(e){return e._origin});return e.forEach(function(e){e.content=e.content.replace(/<tool_call>[^]*?<\/tool_call>/g,"").trim()}),e}},{key:"getAllMessages",value:function(){return this.messages.value.map(function(e){return e._origin})}},{key:"question",value:(f=b(y().m(function e(t){var n,r=this;return y().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,this.isLoading.value=!0,this.messages.value.forEach(function(e,t){var n=e._origin;n.suggestions&&(n.suggestions=void 0,r.messages.value[t].replace(n))}),this.messages.value=c(this.messages.value),this.asyncToIndexDB(),(n=this.stringlyMaterialResource(!1))?n+="\n".concat(t):n=t,this.addMessage({state:30,messageid:ke(),role:"USER",type:"DEFAULT",content:n}),e.n=1,this.opts.question(this,this.context,this.params,{appDataEntityId:this.appDataEntityId},this.getMessages(),this.chatSessionid,this.activeAIAgentID,this.chatMode);case 1:return e.n=2,this.updateTopicCaption();case 2:this.opts.action&&this.opts.action("question",t),this.isLoading.value=!1;case 3:return e.p=3,this.isLoading.value=!1,e.f(3);case 4:return e.a(2)}},e,this,[[0,,3,4]])})),function(e){return f.apply(this,arguments)})},{key:"abortQuestion",value:(h=b(y().m(function e(){return y().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,this.opts.abortQuestion(this,this.context,this.params,{appDataEntityId:this.appDataEntityId,sessionid:this.chatSessionid,srfaiagent:this.activeAIAgentID,srfmode:this.chatMode});case 1:return e.p=1,this.isLoading.value=!1,e.f(1);case 2:return e.a(2)}},e,this,[[0,,1,2]])})),function(){return h.apply(this,arguments)})},{key:"backfill",value:function(e){this.opts.action&&this.opts.action("backfill",e)}},{key:"deleteMessage",value:(d=b(y().m(function e(t){var n;return y().w(function(e){for(;;)switch(e.n){case 0:if(-1!==(n=this.messages.value.findIndex(function(e){return e.messageid===t.messageid}))&&(this.messages.value.splice(n,1),this.messages.value=c(this.messages.value)),this.asyncToIndexDB(),"REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=1;break}if(!t.realmessageid){e.n=1;break}return e.n=1,this.resourceOptions.deleteMessage(t.realmessageid);case 1:this.opts.action&&this.opts.action("deletemsg",t);case 2:return e.a(2)}},e,this)})),function(e){return d.apply(this,arguments)})},{key:"refreshMessage",value:(l=b(y().m(function e(t){var n,r,i,o=arguments;return y().w(function(e){for(;;)switch(e.p=e.n){case 0:if(n=o.length>1&&void 0!==o[1]&&o[1],this.isLoading.value=!0,e.p=1,r=this.messages.value.findIndex(function(e){return e.messageid===t.messageid}),!n){e.n=3;break}return this.messages.value.splice(r+1,this.messages.value.length-r-1),this.messages.value=c(this.messages.value),e.n=2,this.opts.question(this,this.context,this.params,{appDataEntityId:this.appDataEntityId},this.getMessages(),this.chatSessionid,this.activeAIAgentID,this.chatMode);case 2:e.n=6;break;case 3:if(r!==this.messages.value.length-1){e.n=5;break}return this.messages.value.pop(),this.messages.value=c(this.messages.value),e.n=4,this.opts.question(this,this.context,this.params,{appDataEntityId:this.appDataEntityId},this.getMessages(),this.chatSessionid,this.activeAIAgentID,this.chatMode);case 4:e.n=6;break;case 5:i=this.messages.value[r-1].content,this.messages.value.splice(r-1,2),this.question(i);case 6:this.asyncToIndexDB(),this.opts.action&&this.opts.action("refreshmsg",t);case 7:return e.p=7,this.isLoading.value=!1,e.f(7);case 8:return e.a(2)}},e,this,[[1,,7,8]])})),function(e){return l.apply(this,arguments)})},{key:"copyMessage",value:function(e){var t=e.realcontent;Ce.copy(t),this.opts.action&&this.opts.action("copymsg",e)}},{key:"resetTopic",value:(u=b(y().m(function e(){var t;return y().w(function(e){for(;;)switch(e.n){case 0:return t=!0,e.n=1,this.clearTopic();case 1:if(t=e.v){e.n=2;break}return e.a(2,t);case 2:return e.n=3,this.fecthHistory();case 3:return e.a(2,t)}},e,this)})),function(){return u.apply(this,arguments)})},{key:"clearTopic",value:(s=b(y().m(function e(){var t,n;return y().w(function(e){for(;;)switch(e.n){case 0:return t=!0,e.n=1,this.abortQuestion();case 1:if(!this.topicId){e.n=7;break}if(!this.topicId||!this.aiTopic){e.n=6;break}if(!this.currentTopicDisableStorage){e.n=2;break}t=!0,e.n=6;break;case 2:if("LOCAL"!==this.resourceMode){e.n=4;break}return e.n=3,Se.deleteData(Cr.DATA_BASE_NAME,Cr.DATA_TABLE_NAME,this.getHistoryStoreKey(this.topicId));case 3:t=e.v,e.n=6;break;case 4:if("REMOTE"!==this.resourceMode){e.n=6;break}return e.n=5,this.aiTopic.clearMessagesByTopicId(this.topicId);case 5:t=e.v;case 6:e.n=10;break;case 7:if("REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=10;break}return e.n=8,this.resourceOptions.getSessionList({n_session_id_eq:this.chatSessionid});case 8:if(!((n=e.v)&&n.length>0)){e.n=10;break}return e.n=9,this.resourceOptions.clearAllMessageBySessionId(n[0].realid);case 9:t=e.v;case 10:if(t){e.n=11;break}return e.a(2,t);case 11:return this.messages.value=[],e.a(2,t)}},e,this)})),function(){return s.apply(this,arguments)})},{key:"newTopic",value:(a=b(y().m(function e(){return y().w(function(e){for(;;)switch(e.n){case 0:this.topicId&&this.aiTopic&&this.aiTopic.newTopic(this.topicId,{activeAIAgentID:this.activeAIAgentID,sessionid:"".concat(we(this.chatSessionid),"@").concat((new Date).getTime())});case 1:return e.a(2)}},e,this)})),function(){return a.apply(this,arguments)})},{key:"addMaterial",value:function(e){var t=this.materials.value.find(function(t){return t.id===e.id});this.materials.value=t?c(this.materials.value):[].concat(c(this.materials.value),[new Fn(e)])}},{key:"replaceMaterial",value:function(e,t){var n=this.materials.value.findIndex(function(t){return t.id===e});-1!==n?(this.materials.value[n]=new Fn(t),this.materials.value=c(this.materials.value)):this.materials.value=[].concat(c(this.materials.value),[new Fn(t)])}},{key:"deleteMaterial",value:function(e){var t=this.materials.value.findIndex(function(t){return t.id===e.id});-1!==t&&(this.materials.value.splice(t,1),this.materials.value=c(this.materials.value))}},{key:"updateRecommendPrompt",value:function(e,t){if(t){var n=this.messages.value.findIndex(function(t){return t.messageid===e.messageid}),r=Te.parseMixedContent(t).suggestions;r&&r.length>0&&(e.suggestions=r,-1!==n?(this.messages.value[n]=new Bn(e),this.messages.value=c(this.messages.value)):this.messages.value=[].concat(c(this.messages.value),[new Bn(e)]),this.asyncToIndexDB())}}},{key:"handleSuggestionClick",value:(o=b(y().m(function e(t,n,r){var i,o,a,s,u,l,d,h,f;return y().w(function(e){for(;;)switch(e.n){case 0:-1!==(i=this.messages.value.findIndex(function(e){return e.messageid===t.messageid}))&&((o=this.messages.value[i]._origin).suggestions=void 0,this.messages.value[i].replace(o),this.messages.value=c(this.messages.value)),this.asyncToIndexDB(),a=n.type,s=n.metadata,f=a,e.n="action"===f?1:"raw"===f?5:7;break;case 1:if(!this.opts.extendToolbarClick){e.n=4;break}if(u=n.data.actionid){e.n=2;break}throw new Error("actionid不能为空");case 2:return this.addMessage({messageid:ke(),state:30,type:"DEFAULT",role:"USER",content:s.content_name}),l=g({},t),Object.assign(l,{topic:this.topic}),l.msg.realcontent=t.realcontent,e.n=3,this.opts.extendToolbarClick(r,{id:u,appId:this.context.srfappid},this.context,this.params,l);case 3:(d=e.v)&&d.data&&(h=d.data[0],this.addMessage(g({messageid:ke(),state:30,type:"DEFAULT",role:"ASSISTANT"},h)));case 4:return e.a(3,8);case 5:return e.n=6,this.question(n.data.content);case 6:return e.a(3,8);case 7:throw new Error("不支持".concat(a,"推荐类型"));case 8:return e.a(2)}},e,this)})),function(e,t,n){return o.apply(this,arguments)})},{key:"setActiveAIAgentID",value:(i=b(y().m(function e(t){return y().w(function(e){for(;;)switch(e.n){case 0:this.activeAIAgentID=t,this.topicId&&this.aiTopic&&this.aiTopic.updateTopicChatByID(this.topicId,{activeAIAgentID:t});case 1:return e.a(2)}},e,this)})),function(e){return i.apply(this,arguments)})},{key:"updateTopicCaption",value:(r=b(y().m(function e(){var t,n,r;return y().w(function(e){for(;;)switch(e.n){case 0:if(!(t=this.messages.value.find(function(e){return"USER"===e.role}))){e.n=4;break}if(!this.topicId||!this.aiTopic){e.n=1;break}this.aiTopic.updateTopicCaption(this.topicId,t.content),e.n=4;break;case 1:if("REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=4;break}return e.n=2,this.resourceOptions.getSessionList({n_session_id_eq:this.chatSessionid});case 2:if(!((n=e.v)&&n.length>0)){e.n=4;break}if(r=t.content.substring(0,15)||this.opts.caption,n[0].caption!==r){e.n=3;break}return e.a(2);case 3:return e.n=4,this.resourceOptions.updateSession(n[0].realid,{caption:r});case 4:return e.a(2)}},e,this)})),function(){return r.apply(this,arguments)})},{key:"messageLike",value:(n=b(y().m(function e(t){var n,r,i;return y().w(function(e){for(;;)switch(e.n){case 0:if(n="1"===t.islike,(r=t.realmessageid)&&this.resourceOptions){e.n=1;break}return e.a(2);case 1:if(!n){e.n=3;break}return e.n=2,this.resourceOptions.cancelFeedback(r);case 2:i=e.v,e.n=5;break;case 3:return e.n=4,this.resourceOptions.likeMessage(r);case 4:i=e.v;case 5:i&&(t.islike=n?"0":"1",n||"1"!==t.isdislike||(t.isdislike="0"),this.replaceMessage(t,!1));case 6:return e.a(2)}},e,this)})),function(e){return n.apply(this,arguments)})},{key:"messageDisLike",value:(t=b(y().m(function e(t){var n,r,i,o;return y().w(function(e){for(;;)switch(e.n){case 0:if(n="1"===t.isdislike,r=t.realmessageid,i=t.feedbackcontent,r&&this.resourceOptions){e.n=1;break}return e.a(2);case 1:if(!n){e.n=3;break}return e.n=2,this.resourceOptions.cancelFeedback(r);case 2:o=e.v,e.n=5;break;case 3:return e.n=4,this.resourceOptions.dislikeMessage(r,i);case 4:o=e.v;case 5:o&&(t.isdislike=n?"0":"1",n||"1"!==t.islike||(t.islike="0"),this.replaceMessage(t,!1));case 6:return e.a(2)}},e,this)})),function(e){return t.apply(this,arguments)})},{key:"destroyed",value:(e=b(y().m(function e(){return y().w(function(e){for(;;)switch(e.n){case 0:this.evt.reset();case 1:return e.a(2)}},e,this)})),function(){return e.apply(this,arguments)})}]);var e,t,n,r,i,o,a,s,u,l,d,h,f,v,m,k,w,C,M,T}(),Or=function(){return S(function e(t){x(this,e),_(this,"topics",mt([])),_(this,"activedTopic",mt(void 0)),_(this,"backupOptions",void 0),_(this,"remoteSessionList",[]),_(this,"resourceMode","LOCAL"),_(this,"resourceOptions",void 0),this.chat=t},[{key:"injectResourceOptions",value:function(e){this.resourceMode=(null==e?void 0:e.resourceMode)||"LOCAL",this.resourceOptions=e}},{key:"fetchHistory",value:(d=b(y().m(function e(t){var n,r,i=this;return y().w(function(e){for(;;)switch(e.n){case 0:return this.topics.value=[],n=t.configService(t.appid,"aitopics",t.type),e.n=1,n.load();case 1:if(!((r=e.v)&&r.length>0)){e.n=5;break}if("REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=4;break}return e.n=2,this.resourceOptions.getSessionList();case 2:return this.remoteSessionList=e.v,e.n=3,this.asyncRemoteSession(r);case 3:e.n=5;break;case 4:r.forEach(function(e,t){Object.prototype.hasOwnProperty.call(e,"sequence")||(e.sequence=t),Object.prototype.hasOwnProperty.call(e,"isTop")||(e.isTop=0),i.topics.value=[].concat(c(i.topics.value),[new Vn(e)])});case 5:return e.a(2)}},e,this)})),function(e){return d.apply(this,arguments)})},{key:"asyncRemoteSession",value:(l=b(y().m(function e(t){var n=this;return y().w(function(e){for(;;)switch(e.n){case 0:if(this.remoteSessionList&&0!==this.remoteSessionList.length&&t&&0!==t.length){e.n=1;break}return e.a(2);case 1:this.remoteSessionList.forEach(function(e){var r=t.find(function(t){var n;return(null===(n=t.aiChat)||void 0===n?void 0:n.sessionid)===e.session_id});r&&(r.realid=e.realid,r.sequence=e.sequence,r.isTop=e.is_top?e.is_top:0,e.caption&&(r.caption=e.caption),n.topics.value=[].concat(c(n.topics.value),[new Vn(r)]))});case 2:return e.a(2)}},e,this)})),function(e){return l.apply(this,arguments)})},{key:"asyncTopic",value:(u=b(y().m(function e(t){var n,r;return y().w(function(e){for(;;)switch(e.n){case 0:return this.backupOptions=t,n=this.topics.value.findIndex(function(e){return e.id===t.id}),r=new Vn(t),-1!==n?this.topics.value.splice(n,1,r):this.topics.value=[].concat(c(this.topics.value),[r]),e.n=1,this.updateTopic(t);case 1:this.activedTopic.value=r;case 2:return e.a(2)}},e,this)})),function(e){return u.apply(this,arguments)})},{key:"getCurrentTopicByID",value:function(e){var t=this.topics.value.find(function(t){return t.id===e});return t&&t.data?new Vn(g({},t.data)):void 0}},{key:"updateTopicChatByID",value:(s=b(y().m(function e(t,n){var r;return y().w(function(e){for(;;)switch(e.n){case 0:if(t&&n&&this.backupOptions){e.n=1;break}return e.a(2);case 1:if(-1!==(r=this.topics.value.findIndex(function(e){return e.id===t}))&&this.topics.value[r].data.aiChat){e.n=2;break}return e.a(2);case 2:return this.topics.value[r].data.aiChat=g(g({},this.topics.value[r].data.aiChat),n),e.n=3,this.updateTopic(this.backupOptions);case 3:return e.a(2)}},e,this)})),function(e,t){return s.apply(this,arguments)})},{key:"removeTopic",value:(a=b(y().m(function e(t,n,r,i,o){var a,s,u,l,d;return y().w(function(e){for(;;)switch(e.n){case 0:if(s=!0,!t.beforeDelete){e.n=2;break}return e.n=1,t.beforeDelete(n,r,i,o);case 1:s=e.v;case 2:if(s){e.n=3;break}return e.a(2);case 3:if(u=!1,!i||!i.disableStorage){e.n=4;break}u=!0,e.n=12;break;case 4:if("LOCAL"!==this.resourceMode){e.n=6;break}return e.n=5,Se.deleteData(Cr.DATA_BASE_NAME,Cr.DATA_TABLE_NAME,i.id);case 5:u=e.v,e.n=12;break;case 6:if("REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=12;break}if(!i.realid){e.n=8;break}return e.n=7,this.resourceOptions.deleteSession(i.realid);case 7:u=e.v,e.n=12;break;case 8:if(!i.aiChat||!i.aiChat.sessionid){e.n=12;break}return e.n=9,this.resourceOptions.getSessionList({n_session_id_eq:i.aiChat.sessionid});case 9:if(!((l=e.v)&&l.length>0)){e.n=11;break}return e.n=10,this.resourceOptions.deleteSession(l[0].realid);case 10:u=e.v,e.n=12;break;case 11:u=!0;case 12:if(u){e.n=13;break}return e.a(2);case 13:return-1!==(d=this.topics.value.findIndex(function(e){return e.id===i.id}))&&(this.topics.value.splice(d,1),this.topics.value=c(this.topics.value)),e.n=14,this.updateTopic(t);case 14:this.topics.value.length>0&&i.id===(null===(a=this.activedTopic.value)||void 0===a?void 0:a.id)&&this.handleTopicChange(this.topics.value[0]);case 15:return e.a(2)}},e,this)})),function(e,t,n,r,i){return a.apply(this,arguments)})},{key:"handleTopicChange",value:function(e){var t;(null===(t=this.activedTopic.value)||void 0===t?void 0:t.id)!==e.id&&(this.activedTopic.value=e,this.chat.switchAiChatController(e))}},{key:"handleTopicAction",value:(o=b(y().m(function e(t,n,r){var i,o,a,s,u,l,d,h;return y().w(function(e){for(;;)switch(e.n){case 0:if(i=this.topics.value.find(function(e){return e.id===n.id}),!(this.backupOptions&&i&&i.aiChat)){e.n=10;break}s=i.aiChat,u=s.context,l=s.params,h=t,e.n="DELETE"===h?1:"RENAME"===h||"PINNED"===h?3:9;break;case 1:return e.n=2,this.removeTopic(this.backupOptions,u,l,i,r);case 2:return e.a(3,9);case 3:if("PINNED"===t&&(n.data.isTop=0===n.data.isTop?1:0,this.topics.value=c(this.topics.value)),!n||n.disableStorage){e.n=8;break}return e.n=4,this.updateTopic(this.backupOptions);case 4:if(!n||"REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=8;break}if(!n.realid){e.n=6;break}return e.n=5,this.resourceOptions.updateSession(n.realid,{caption:n.caption,is_top:n.isTop});case 5:e.n=8;break;case 6:if(!n.aiChat||!n.aiChat.sessionid){e.n=8;break}return e.n=7,this.resourceOptions.getSessionList({n_session_id_eq:n.aiChat.sessionid});case 7:if(!((d=e.v)&&d.length>0)){e.n=8;break}return e.n=8,this.resourceOptions.updateSession(d[0].realid,{caption:n.caption,is_top:n.isTop});case 8:return e.a(3,9);case 9:null===(o=(a=this.backupOptions).action)||void 0===o||o.call(a,t,u,l,n,r);case 10:return e.a(2)}},e,this)})),function(e,t,n){return o.apply(this,arguments)})},{key:"clearMessagesByTopicId",value:(i=b(y().m(function e(t){var n,r,i,o;return y().w(function(e){for(;;)switch(e.n){case 0:if(n=!0,t&&this.backupOptions){e.n=1;break}return e.a(2,n);case 1:if(-1!==(r=this.topics.value.findIndex(function(e){return e.id===t}))&&this.topics.value[r].data){e.n=2;break}return e.a(2,n);case 2:if(i=this.topics.value[r]){e.n=3;break}return e.a(2,n);case 3:if(!i.disableStorage){e.n=4;break}return e.a(2,n);case 4:if("REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=10;break}if(!i.realid){e.n=6;break}return e.n=5,this.resourceOptions.clearAllMessageBySessionId(i.realid);case 5:n=e.v,e.n=9;break;case 6:if(!i.aiChat||!i.aiChat.sessionid){e.n=9;break}return e.n=7,this.resourceOptions.getSessionList({n_session_id_eq:i.aiChat.sessionid});case 7:if(!((o=e.v)&&o.length>0)){e.n=9;break}return e.n=8,this.resourceOptions.clearAllMessageBySessionId(o[0].realid);case 8:n=e.v;case 9:if(n){e.n=10;break}return e.a(2,n);case 10:return e.a(2,n)}},e,this)})),function(e){return i.apply(this,arguments)})},{key:"newTopic",value:(r=b(y().m(function e(t,n){var r,i,o,a,s,u,l,d;return y().w(function(e){for(;;)switch(e.n){case 0:if(t){e.n=1;break}return e.a(2);case 1:if(r=this.getCurrentTopicByID(t)){e.n=2;break}return e.a(2);case 2:if(i=we(r.id),o=this.topics.value.filter(function(e){return e.id.startsWith(i)}),n&&r.aiChat&&(r.data.aiChat=g(g({},r.aiChat),n)),a="",a="default"===r.captionMode?"".concat(null===(s=r.sourceCaption)||void 0===s?void 0:s.split("_")[0],"_").concat(o.length):"新会话",u=Math.max.apply(Math,c(this.topics.value.map(function(e){return e.sequence}))),l={appid:r.appid,id:"".concat(i,"@").concat(Date.now()),type:r.type,captionMode:r.captionMode,captionFilled:!1,caption:a,sourceCaption:r.sourceCaption,url:r.url,aiChat:r.aiChat,sequence:u+1,isTop:0,disableStorage:r.disableStorage},d=new Vn(l),this.topics.value=[].concat(c(this.topics.value),[d]),!this.backupOptions){e.n=3;break}return e.n=3,this.updateTopic(this.backupOptions);case 3:this.handleTopicChange(d);case 4:return e.a(2)}},e,this)})),function(e,t){return r.apply(this,arguments)})},{key:"clearTopic",value:(n=b(y().m(function e(){var t,n,r,i,o,a=this;return y().w(function(e){for(;;)switch(e.n){case 0:if(t=this.topics.value.find(function(e){var t;return e.id===(null===(t=a.activedTopic.value)||void 0===t?void 0:t.id)}),this.backupOptions&&t){e.n=1;break}return e.a(2);case 1:if(n=!0,!this.backupOptions.beforeDelete){e.n=3;break}return e.n=2,this.backupOptions.beforeDelete(t.aiChat.context,t.aiChat.params,t,void 0,!0);case 2:n=e.v;case 3:if(n){e.n=4;break}return e.a(2);case 4:if(r=!1,"LOCAL"!==this.resourceMode){e.n=6;break}return e.n=5,Promise.all(this.topics.value.map(function(e){if(e.id!==(null==t?void 0:t.id)&&!e.disableStorage)return Se.deleteData(Cr.DATA_BASE_NAME,Cr.DATA_TABLE_NAME,e.id)}));case 5:r=!0,e.n=11;break;case 6:if("REMOTE"!==this.resourceMode){e.n=11;break}if(!t||!this.resourceOptions){e.n=10;break}if(!(o=null===(i=t.aiChat)||void 0===i?void 0:i.sessionid)){e.n=8;break}return e.n=7,this.resourceOptions.clearAllSession(o);case 7:r=e.v,e.n=9;break;case 8:r=!0;case 9:e.n=11;break;case 10:r=!0;case 11:if(r){e.n=12;break}return e.a(2);case 12:return this.topics.value=t?[t]:[],e.n=13,this.updateTopic(this.backupOptions);case 13:return e.a(2)}},e,this)})),function(){return n.apply(this,arguments)})},{key:"updateTopicCaption",value:(t=b(y().m(function e(t,n){var r,i,o;return y().w(function(e){for(;;)switch(e.n){case 0:if(!(r=this.topics.value.find(function(e){return e.id===t}))||r.captionFilled){e.n=10;break}if("default"===r.captionMode){e.n=3;break}o=r.captionMode,e.n="snippet"===o?1:2;break;case 1:return r.data.caption=n.substring(0,15),e.a(3,2);case 2:if(this.topics.value=c(this.topics.value),!this.backupOptions){e.n=3;break}return e.n=3,this.updateTopic(this.backupOptions);case 3:if(!r.disableStorage){e.n=4;break}return e.a(2);case 4:if("REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=9;break}if(!r.realid){e.n=6;break}return e.n=5,this.resourceOptions.updateSession(r.realid,{caption:r.caption});case 5:e.n=9;break;case 6:if(!r.aiChat||!r.aiChat.sessionid){e.n=9;break}return e.n=7,this.resourceOptions.getSessionList({n_session_id_eq:r.aiChat.sessionid});case 7:if(!((i=e.v)&&i.length>0)){e.n=9;break}if(i[0].caption!==r.caption){e.n=8;break}return e.a(2);case 8:return e.n=9,this.resourceOptions.updateSession(i[0].realid,{caption:r.caption});case 9:r.data.captionFilled=!0;case 10:return e.a(2)}},e,this)})),function(e,n){return t.apply(this,arguments)})},{key:"updateTopic",value:(e=b(y().m(function e(t){var n,r;return y().w(function(e){for(;;)switch(e.n){case 0:if(t){e.n=1;break}return e.a(2);case 1:return n=[],this.topics.value.forEach(function(e){e.disableStorage||n.push({appid:e.appid,id:e.id,type:e.type,captionMode:e.captionMode,captionFilled:e.captionFilled,caption:e.caption||e.sourceCaption,sourceCaption:e.sourceCaption,url:e.url,aiChat:e.aiChat,isTop:e.isTop,sequence:e.sequence})}),r=t.configService(t.appid,"aitopics",t.type),e.n=2,null==r?void 0:r.save(n);case 2:return e.a(2)}},e,this)})),function(t){return e.apply(this,arguments)})}]);var e,t,n,r,i,o,a,s,u,l,d}(),Nr=S(function e(t){x(this,e),this.aiChat=t}),Er=function(e){function t(){return x(this,t),r(this,t,arguments)}return a(t,e),S(t,[{key:"excuteAction",value:(n=b(y().m(function e(t,n){var r,i,o,a;return y().w(function(e){for(;;)switch(e.n){case 0:if(!n||!n.onClick||"function"!=typeof n.onClick){e.n=2;break}return e.n=1,n.onClick(t,n,this.aiChat.context,this.aiChat.params);case 1:r=e.v,e.n=5;break;case 2:if(!(i=this.aiChat.opts.extendToolbarClick)){e.n=4;break}return e.n=3,i(t,n,this.aiChat.context,this.aiChat.params,{});case 3:r=e.v,e.n=5;break;case 4:console.error("未找到扩展工具栏点击事件");case 5:r&&r.data&&r.data.length>0&&(o=r.data[0],a={id:o.id,type:o.type,data:o.data||{},metadata:o.metadata||{}},n.id&&Object.assign(a.metadata,{actionId:n.id}),this.aiChat.addMaterial(a));case 6:return e.a(2)}},e,this)})),function(e,t){return n.apply(this,arguments)})}]);var n}(Nr),Ar=function(e){function t(){return x(this,t),r(this,t,arguments)}return a(t,e),S(t,[{key:"excuteAction",value:(n=b(y().m(function e(t,n){var r,i,o,a,s,c,u,l,d,h,f=this;return y().w(function(e){for(;;)switch(e.n){case 0:r=this.aiChat.opts.uploader,i=r.multiple,o=r.accept,a=r.maxSize,s=r.onSelect,c=r.onUpload,u=r.onSuccess,l=r.onError,d=r.onProgress,h={multiple:i||!0,accept:o||"*/*",maxSize:a||5242880,onSelect:function(e){null==s||s(e),e.length>0&&e.forEach(function(e){var t=f.buildMaterialObject(e);Object.assign(t.metadata,{state:"uploading"}),f.aiChat.addMaterial(t)})},onUpload:function(){var e=b(y().m(function e(t,n){return y().w(function(e){for(;;)if(0===e.n)return e.a(2,c(t,n,{context:f.aiChat.context,params:f.aiChat.params}))},e)}));return function(t,n){return e.apply(this,arguments)}}(),onSuccess:function(e,t){var n={id:e.id,type:"ossfile",data:{id:e.id,name:e.name},metadata:{ext:e.ext,fileext:e.fileext,fileid:e.fileid,filename:e.filename,size:e.size,filesize:e.filesize,state:"successed"}};f.aiChat.replaceMaterial(t.name,n),null==u||u(e,t)},onError:function(e,t){var n=f.buildMaterialObject(t);Object.assign(n.metadata,{state:"failed"}),f.aiChat.replaceMaterial(t.name,n),null==l||l(e,t)},onProgress:function(e,t){null==d||d(e,t)}},new _e(h).openFilePicker();case 1:return e.a(2)}},e,this)})),function(e,t){return n.apply(this,arguments)})},{key:"buildMaterialObject",value:function(e){return{id:e.name,type:"ossfile",data:{name:e.name,id:e.name},metadata:{size:e.size,type:e.type,lastModified:e.lastModified}}}}]);var n}(Nr),Dr=function(){return S(function e(){x(this,e)},null,[{key:"getMaterialHelper",value:function(e,t){return"ossfile"===e?new Ar(t):new Er(t)}}])}(),Ir=function(){return S(function e(){x(this,e),_(this,"container",void 0),_(this,"mode","DEFAULT"),_(this,"resourceOptions",void 0),_(this,"backupChatOptions",void 0),_(this,"aiTopic",void 0),_(this,"aiTopicMap",new Map),this.aiTopic=new Or(this)},[{key:"aiChat",get:function(){var e;return this.aiTopicMap.get("".concat(null===(e=this.aiTopic.activedTopic.value)||void 0===e?void 0:e.id))}},{key:"initIndexDB",value:(t=b(y().m(function e(){return y().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,Se.checkTableExists(Cr.DATA_BASE_NAME,Cr.DATA_TABLE_NAME);case 1:if(e.v){e.n=2;break}return e.n=2,Se.createTable(Cr.DATA_BASE_NAME,Cr.DATA_TABLE_NAME,Cr.DATA_TABLE_KEY_NAME,!1);case 2:return e.a(2)}},e)})),function(){return t.apply(this,arguments)})},{key:"create",value:(e=b(y().m(function e(t){var n,r,i,o,a,s,c,u,l,d,h=this;return y().w(function(e){for(;;)switch(e.n){case 0:if(this.resourceOptions=t.resourceOptions,"LOCAL"!==((null===(n=t.resourceOptions)||void 0===n?void 0:n.resourceMode)||"LOCAL")){e.n=1;break}return e.n=1,this.initIndexDB();case 1:if(this.backupChatOptions=t,this.close(),this.container=document.createElement("div"),this.container.classList.add("ibiz-ai-chat"),document.body.appendChild(this.container),u=t.chatOptions,!t.mode||"TOPIC"!==t.mode){e.n=4;break}return this.aiTopic.injectResourceOptions(t.resourceOptions),e.n=2,this.aiTopic.fetchHistory(t.topicOptions);case 2:return l=t.topicOptions,Object.assign(l,{aiChat:{caption:u.caption,context:u.context,params:u.params,appDataEntityId:u.appDataEntityId,sessionid:u.sessionid,contentToolbarItems:u.contentToolbarItems,footerToolbarItems:u.footerToolbarItems,questionToolbarItems:u.questionToolbarItems,otherToolbarItems:u.otherToolbarItems,appendCurData:u.appendCurData,appendCurContent:u.appendCurContent,enableAIAgentChange:u.enableAIAgentChange,activeAIAgentID:u.activeAIAgentID,aiAgentlist:u.aiAgentlist,srfMode:u.srfMode,appendCurResource:u.appendCurResource}}),this.syncHistoryOptions(l,u,t.resourceOptions),e.n=3,this.aiTopic.asyncTopic(l);case 3:e.n=5;break;case 4:this.aiTopic.activedTopic.value=void 0;case 5:return Object.assign(u,{topicId:null===(r=l)||void 0===r?void 0:r.id,topic:l,aiTopic:this.aiTopic}),d=new Tr(u,this.resourceOptions),this.aiTopicMap.set("".concat(null===(i=l)||void 0===i?void 0:i.id),d),le($(jf,{aiChat:d,aiTopic:this.aiTopic,mode:t.mode?t.mode:"DEFAULT",containerOptions:t.containerOptions,caption:t.mode&&"TOPIC"===t.mode?"AI助手":u.caption,enableBackFill:null===(o=t.containerOptions)||void 0===o?void 0:o.enableBackFill,contentToolbarItems:u.contentToolbarItems,footerToolbarItems:u.footerToolbarItems,questionToolbarItems:u.questionToolbarItems,autoClose:null===(a=t.containerOptions)||void 0===a?void 0:a.autoClose,openMode:null===(s=t.containerOptions)||void 0===s?void 0:s.openMode,hideTopicSidebar:(null===(c=t.topicOptions)||void 0===c?void 0:c.hideTopicSidebar)||!1,close:function(){h.close(),u.closed&&u.closed(u.context,u.params,d.getAllMessages())},fullscreen:function(e){u.fullscreen&&u.fullscreen(e,u.context,u.params)},minimize:function(e){u.minimize&&u.minimize(e,u.context,u.params)}}),this.container),e.a(2,d)}},e,this)})),function(t){return e.apply(this,arguments)})},{key:"syncHistoryOptions",value:function(e,t,n){if(e.disableStorage){var r=function(e,t){var n="";switch(e){case"TOPIC":n+="topic";break;case"INLINE":n+="inline";break;case"TEMP":n+="temp";break;default:n+="unknow"}return n+"@".concat(t||ke(),"@").concat((new Date).getTime())}("TEMP");return t.sessionid=r,e.aiChat.sessionid=r,e.caption="临时会话",e.sourceCaption="临时会话",void(e.captionFilled=!0)}var i=this.aiTopic.getCurrentTopicByID(e.id);if(i&&i.aiChat&&i.aiChat.activeAIAgentID)t.activeAIAgentID=i.aiChat.activeAIAgentID,e.aiChat.activeAIAgentID=i.aiChat.activeAIAgentID;else if(t.aiAgentlist&&t.aiAgentlist.length>0&&!t.activeAIAgentID){var o=t.aiAgentlist.find(function(e){return 1===e.default});o?(t.activeAIAgentID=o.id,e.aiChat.activeAIAgentID=o.id):(t.activeAIAgentID=t.aiAgentlist[0].id,e.aiChat.activeAIAgentID=t.aiAgentlist[0].id)}i&&i.aiChat&&i.aiChat.sessionid&&(t.sessionid=i.aiChat.sessionid,e.aiChat.sessionid=i.aiChat.sessionid);var a=n.resourceMode;"LOCAL"===a?"default"!==e.captionMode?(e.sourceCaption="新会话",i&&i.captionFilled&&i.caption?(e.captionFilled=i.captionFilled,e.caption=i.caption):e.caption="新会话"):(e.sourceCaption=e.caption,e.captionFilled=!0):"REMOTE"===a&&(e.sourceCaption=e.caption,i&&i.caption&&(e.caption=i.caption),e.captionFilled=!1),"REMOTE"===a&&i&&i.realid&&(e.realid=i.realid)}},{key:"switchAiChatController",value:function(e){var t,n,r,i,o,a,s,c,u=this,l=g({},this.backupChatOptions.chatOptions);(e.aiChat&&Object.assign(l,{caption:e.aiChat.caption,context:e.aiChat.context,params:e.aiChat.params,sessionid:e.aiChat.sessionid,contentToolbarItems:e.aiChat.contentToolbarItems,footerToolbarItems:e.aiChat.footerToolbarItems,questionToolbarItems:e.aiChat.questionToolbarItems,otherToolbarItems:e.aiChat.otherToolbarItems,appendCurData:e.aiChat.appendCurData,appendCurContent:e.aiChat.appendCurContent,aiAgentlist:e.aiChat.aiAgentlist,activeAIAgentID:e.aiChat.activeAIAgentID,enableAIAgentChange:e.aiChat.enableAIAgentChange,srfMode:e.aiChat.srfMode,appendCurResource:e.aiChat.appendCurResource,appDataEntityId:e.aiChat.appDataEntityId,topicId:e.id,topic:e,aiTopic:this.aiTopic,extendToolbarClick:this.backupChatOptions.chatOptions.extendToolbarClick,recommendPrompt:this.backupChatOptions.chatOptions.recommendPrompt}),this.aiTopicMap.has("".concat(e.id))?t=this.aiTopicMap.get("".concat(e.id)):(t=new Tr(l,this.resourceOptions),this.aiTopicMap.set("".concat(e.id),t)),this.container)&&(le(null,this.container),le($(jf,{aiChat:t,aiTopic:this.aiTopic,mode:null!==(n=this.backupChatOptions)&&void 0!==n&&n.mode?this.backupChatOptions.mode:"DEFAULT",containerOptions:null===(r=this.backupChatOptions)||void 0===r?void 0:r.containerOptions,caption:null!==(i=this.backupChatOptions)&&void 0!==i&&i.mode&&"TOPIC"===this.backupChatOptions.mode?"AI助手":l.caption,enableBackFill:null===(o=this.backupChatOptions)||void 0===o||null===(o=o.containerOptions)||void 0===o?void 0:o.enableBackFill,contentToolbarItems:l.contentToolbarItems,footerToolbarItems:l.footerToolbarItems,questionToolbarItems:l.questionToolbarItems,autoClose:null===(a=this.backupChatOptions)||void 0===a||null===(a=a.containerOptions)||void 0===a?void 0:a.autoClose,openMode:null===(s=this.backupChatOptions)||void 0===s||null===(s=s.containerOptions)||void 0===s?void 0:s.openMode,hideTopicSidebar:(null===(c=this.backupChatOptions)||void 0===c||null===(c=c.topicOptions)||void 0===c?void 0:c.hideTopicSidebar)||!1,close:function(){u.close(),l.closed&&l.closed(l.context,l.params,t.getAllMessages())},fullscreen:function(e){l.fullscreen&&l.fullscreen(e,l.context,l.params)},minimize:function(e){l.minimize&&l.minimize(e,l.context,l.params)}}),this.container))}},{key:"hidden",value:function(){this.container&&(this.container.style.display="none")}},{key:"show",value:function(){this.container&&(this.container.style.display="flex")}},{key:"close",value:function(){this.container&&(le(null,this.container),this.container.remove(),this.container=void 0),this.aiTopicMap.forEach(function(e){e.destroyed()})}}]);var e,t}(),zr=(t("chat",new Ir),new pe("chat-input-material")),Rr=function(e){var t=e.controller.materials;return he("div",{className:zr.b(),children:t.value.map(function(t){return he(Nn,{material:t,disabled:!1,controller:e.controller},t.id)})})},Pr=function(e){var t=e.children,n=e.actions,r=e.content,i=e.position,o=void 0===i?"bottom":i,a=e.isOpen,s=e.onToggleOpen,c=e.onAction,u=new pe("pop"),l=Ge($f),h=d(qe(a||!1),2),f=h[0],p=h[1],v=Je(null),m=Je(null);Ue(function(){void 0!==a&&p(a)},[a]),Ue(function(){return m.current||(m.current=document.createElement("div"),m.current.className=u.b("content-container"),document.body.appendChild(m.current)),function(){m.current&&document.body.removeChild(m.current)}},[]),Ue(function(){var e=function(e){!v.current||v.current.contains(e.target)||e.target.closest(".".concat(u.b()))||e.target.closest(".ibiz-quick-edit")||e.target.closest(".ibiz-picker__transfer")||(p(!1),null==s||s(!1))};return f&&document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}},[f,s]);return he("span",{className:"".concat(u.b("trigger-container")),children:[he("span",{className:"".concat(u.b("trigger-element")),ref:v,onClick:function(e){e.stopPropagation();var t=!f;p(t),null==s||s(t)},children:t}),f&&m.current&&cr(he("div",{className:"".concat(u.b()," pop-").concat(o),style:function(){if(!v.current)return{};var e=v.current.getBoundingClientRect(),t={position:"absolute",zIndex:l.zIndex+1},n={bottom:{top:e.bottom+window.scrollY,left:e.left+window.scrollX},top:{bottom:window.innerHeight-e.top+window.scrollY,left:e.left+window.scrollX},left:{top:e.top+window.scrollY,right:window.innerWidth-e.left+window.scrollX},right:{top:e.top+window.scrollY,left:e.right+window.scrollX},"top-left":{bottom:window.innerHeight-e.top+window.scrollY,right:window.innerWidth-e.left+window.scrollX}};return g(g({},t),n[o])}(),children:r||(null==n?void 0:n.map(function(e){return he("div",{title:e.caption,className:u.e("item"),onMouseDown:function(t){t.stopPropagation(),null==c||c(e.id,t)},children:[e.icon,he("div",{className:u.em("item","caption"),children:e.caption})]},e.id)}))}),m.current)]})};function Lr(e){this.content=e}function Br(e,t,n){for(var r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;var i=e.child(r),o=t.child(r);if(i!=o){if(!i.sameMarkup(o))return n;if(i.isText&&i.text!=o.text){for(var a=0;i.text[a]==o.text[a];a++)n++;return n}if(i.content.size||o.content.size){var s=Br(i.content,o.content,n+1);if(null!=s)return s}n+=i.nodeSize}else n+=i.nodeSize}}function Vr(e,t,n,r){for(var i=e.childCount,o=t.childCount;;){if(0==i||0==o)return i==o?null:{a:n,b:r};var a=e.child(--i),s=t.child(--o),c=a.nodeSize;if(a!=s){if(!a.sameMarkup(s))return{a:n,b:r};if(a.isText&&a.text!=s.text){for(var u=0,l=Math.min(a.text.length,s.text.length);u<l&&a.text[a.text.length-u-1]==s.text[s.text.length-u-1];)u++,n--,r--;return{a:n,b:r}}if(a.content.size||s.content.size){var d=Vr(a.content,s.content,n-1,r-1);if(d)return d}n-=c,r-=c}else n-=c,r-=c}}Lr.prototype={constructor:Lr,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return-1==t?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),o=r.content.slice();return-1==i?o.push(n||e,t):(o[i+1]=t,n&&(o[i]=n)),new Lr(o)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new Lr(n)},addToStart:function(e,t){return new Lr([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new Lr(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),o=r.find(e);return i.splice(-1==o?i.length:o,0,t,n),new Lr(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=Lr.from(e)).size?new Lr(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=Lr.from(e)).size?new Lr(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=Lr.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},Lr.from=function(e){if(e instanceof Lr)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new Lr(t)};var Fr=function(){function e(t,n){if(x(this,e),this.content=t,this.size=n||0,null==n)for(var r=0;r<t.length;r++)this.size+=t[r].nodeSize}return S(e,[{key:"nodesBetween",value:function(e,t,n){for(var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4?arguments[4]:void 0,o=0,a=0;a<t;o++){var s=this.content[o],c=a+s.nodeSize;if(c>e&&!1!==n(s,r+a,i||null,o)&&s.content.size){var u=a+1;s.nodesBetween(Math.max(0,e-u),Math.min(s.content.size,t-u),n,r+u)}a=c}}},{key:"descendants",value:function(e){this.nodesBetween(0,this.size,e)}},{key:"textBetween",value:function(e,t,n,r){var i="",o=!0;return this.nodesBetween(e,t,function(a,s){var c=a.isText?a.text.slice(Math.max(e,s)-s,t-s):a.isLeaf?r?"function"==typeof r?r(a):r:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&c||a.isTextblock)&&n&&(o?o=!1:i+=n),i+=c},0),i}},{key:"append",value:function(t){if(!t.size)return this;if(!this.size)return t;var n=this.lastChild,r=t.firstChild,i=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),o=1);o<t.content.length;o++)i.push(t.content[o]);return new e(i,this.size+t.size)}},{key:"cut",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.size;if(0==t&&n==this.size)return this;var r=[],i=0;if(n>t)for(var o=0,a=0;a<n;o++){var s=this.content[o],c=a+s.nodeSize;c>t&&((a<t||c>n)&&(s=s.isText?s.cut(Math.max(0,t-a),Math.min(s.text.length,n-a)):s.cut(Math.max(0,t-a-1),Math.min(s.content.size,n-a-1))),r.push(s),i+=s.nodeSize),a=c}return new e(r,i)}},{key:"cutByIndex",value:function(t,n){return t==n?e.empty:0==t&&n==this.content.length?this:new e(this.content.slice(t,n))}},{key:"replaceChild",value:function(t,n){var r=this.content[t];if(r==n)return this;var i=this.content.slice(),o=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,o)}},{key:"addToStart",value:function(t){return new e([t].concat(this.content),this.size+t.nodeSize)}},{key:"addToEnd",value:function(t){return new e(this.content.concat(t),this.size+t.nodeSize)}},{key:"eq",value:function(e){if(this.content.length!=e.content.length)return!1;for(var t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}},{key:"firstChild",get:function(){return this.content.length?this.content[0]:null}},{key:"lastChild",get:function(){return this.content.length?this.content[this.content.length-1]:null}},{key:"childCount",get:function(){return this.content.length}},{key:"child",value:function(e){var t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}},{key:"maybeChild",value:function(e){return this.content[e]||null}},{key:"forEach",value:function(e){for(var t=0,n=0;t<this.content.length;t++){var r=this.content[t];e(r,n,t),n+=r.nodeSize}}},{key:"findDiffStart",value:function(e){return Br(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0)}},{key:"findDiffEnd",value:function(e){return Vr(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.size,arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.size)}},{key:"findIndex",value:function(e){if(0==e)return jr(0,e);if(e==this.size)return jr(this.content.length,e);if(e>this.size||e<0)throw new RangeError("Position ".concat(e," outside of fragment (").concat(this,")"));for(var t=0,n=0;;t++){var r=n+this.child(t).nodeSize;if(r>=e)return r==e?jr(t+1,r):jr(t,n);n=r}}},{key:"toString",value:function(){return"<"+this.toStringInner()+">"}},{key:"toStringInner",value:function(){return this.content.join(", ")}},{key:"toJSON",value:function(){return this.content.length?this.content.map(function(e){return e.toJSON()}):null}}],[{key:"fromJSON",value:function(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new e(n.map(t.nodeFromJSON))}},{key:"fromArray",value:function(t){if(!t.length)return e.empty;for(var n,r=0,i=0;i<t.length;i++){var o=t[i];r+=o.nodeSize,i&&o.isText&&t[i-1].sameMarkup(o)?(n||(n=t.slice(0,i)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new e(n||t,r)}},{key:"from",value:function(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}])}();Fr.empty=new Fr([],0);var $r={index:0,offset:0};function jr(e,t){return $r.index=e,$r.offset=t,$r}function Hr(e,t){if(e===t)return!0;if(!e||"object"!=T(e)||!t||"object"!=T(t))return!1;var n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(var r=0;r<e.length;r++)if(!Hr(e[r],t[r]))return!1}else{for(var i in e)if(!(i in t)||!Hr(e[i],t[i]))return!1;for(var o in t)if(!(o in e))return!1}return!0}var Wr=function(){function e(t,n){x(this,e),this.type=t,this.attrs=n}return S(e,[{key:"addToSet",value:function(e){for(var t,n=!1,r=0;r<e.length;r++){var i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,r));else{if(i.type.excludes(this.type))return e;!n&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(i)}}return t||(t=e.slice()),n||t.push(this),t}},{key:"removeFromSet",value:function(e){for(var t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}},{key:"isInSet",value:function(e){for(var t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}},{key:"eq",value:function(e){return this==e||this.type==e.type&&Hr(this.attrs,e.attrs)}},{key:"toJSON",value:function(){var e={type:this.type.name};for(var t in this.attrs){e.attrs=this.attrs;break}return e}}],[{key:"fromJSON",value:function(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");var n=e.marks[t.type];if(!n)throw new RangeError("There is no mark type ".concat(t.type," in this schema"));var r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}},{key:"sameSet",value:function(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}},{key:"setFrom",value:function(t){if(!t||Array.isArray(t)&&0==t.length)return e.none;if(t instanceof e)return[t];var n=t.slice();return n.sort(function(e,t){return e.type.rank-t.type.rank}),n}}])}();Wr.none=[];var qr=function(e){function t(){return x(this,t),r(this,t,arguments)}return a(t,e),S(t)}(n(Error)),Ur=function(){function e(t,n,r){x(this,e),this.content=t,this.openStart=n,this.openEnd=r}return S(e,[{key:"size",get:function(){return this.content.size-this.openStart-this.openEnd}},{key:"insertAt",value:function(t,n){var r=Kr(this.content,t+this.openStart,n);return r&&new e(r,this.openStart,this.openEnd)}},{key:"removeBetween",value:function(t,n){return new e(Jr(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}},{key:"eq",value:function(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}},{key:"toString",value:function(){return this.content+"("+this.openStart+","+this.openEnd+")"}},{key:"toJSON",value:function(){if(!this.content.size)return null;var e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}}],[{key:"fromJSON",value:function(t,n){if(!n)return e.empty;var r=n.openStart||0,i=n.openEnd||0;if("number"!=typeof r||"number"!=typeof i)throw new RangeError("Invalid input for Slice.fromJSON");return new e(Fr.fromJSON(t,n.content),r,i)}},{key:"maxOpen",value:function(t){for(var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=0,i=0,o=t.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)r++;for(var a=t.lastChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.lastChild)i++;return new e(t,r,i)}}])}();function Jr(e,t,n){var r=e.findIndex(t),i=r.index,o=r.offset,a=e.maybeChild(i),s=e.findIndex(n),c=s.index,u=s.offset;if(o==t||a.isText){if(u!=n&&!e.child(c).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(i!=c)throw new RangeError("Removing non-flat range");return e.replaceChild(i,a.copy(Jr(a.content,t-o-1,n-o-1)))}function Kr(e,t,n,r){var i=e.findIndex(t),o=i.index,a=i.offset,s=e.maybeChild(o);if(a==t||s.isText)return r&&!r.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));var c=Kr(s.content,t-a-1,n,s);return c&&e.replaceChild(o,s.copy(c))}function Yr(e,t,n){if(n.openStart>e.depth)throw new qr("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new qr("Inconsistent open depths");return Gr(e,t,n,0)}function Gr(e,t,n,r){var i=e.index(r),o=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){var a=Gr(e,t,n,r+1);return o.copy(o.content.replaceChild(i,a))}if(n.content.size){if(n.openStart||n.openEnd||e.depth!=r||t.depth!=r){var s=function(e,t){for(var n=t.depth-e.openStart,r=t.node(n).copy(e.content),i=n-1;i>=0;i--)r=t.node(i).copy(Fr.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}(n,e);return ti(o,ni(e,s.start,s.end,t,r))}var c=e.parent,u=c.content;return ti(c,u.cut(0,e.parentOffset).append(n.content).append(u.cut(t.parentOffset)))}return ti(o,ri(e,t,r))}function Xr(e,t){if(!t.type.compatibleContent(e.type))throw new qr("Cannot join "+t.type.name+" onto "+e.type.name)}function Zr(e,t,n){var r=e.node(n);return Xr(r,t.node(n)),r}function Qr(e,t){var n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function ei(e,t,n,r){var i=(t||e).node(n),o=0,a=t?t.index(n):i.childCount;e&&(o=e.index(n),e.depth>n?o++:e.textOffset&&(Qr(e.nodeAfter,r),o++));for(var s=o;s<a;s++)Qr(i.child(s),r);t&&t.depth==n&&t.textOffset&&Qr(t.nodeBefore,r)}function ti(e,t){return e.type.checkContent(t),e.copy(t)}function ni(e,t,n,r,i){var o=e.depth>i&&Zr(e,t,i+1),a=r.depth>i&&Zr(n,r,i+1),s=[];return ei(null,e,i,s),o&&a&&t.index(i)==n.index(i)?(Xr(o,a),Qr(ti(o,ni(e,t,n,r,i+1)),s)):(o&&Qr(ti(o,ri(e,t,i+1)),s),ei(t,n,i,s),a&&Qr(ti(a,ri(n,r,i+1)),s)),ei(r,null,i,s),new Fr(s)}function ri(e,t,n){var r=[];(ei(null,e,n,r),e.depth>n)&&Qr(ti(Zr(e,t,n+1),ri(e,t,n+1)),r);return ei(t,null,n,r),new Fr(r)}Ur.empty=new Ur(Fr.empty,0,0);var ii=function(){function e(t,n,r){x(this,e),this.pos=t,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}return S(e,[{key:"resolveDepth",value:function(e){return null==e?this.depth:e<0?this.depth+e:e}},{key:"parent",get:function(){return this.node(this.depth)}},{key:"doc",get:function(){return this.node(0)}},{key:"node",value:function(e){return this.path[3*this.resolveDepth(e)]}},{key:"index",value:function(e){return this.path[3*this.resolveDepth(e)+1]}},{key:"indexAfter",value:function(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}},{key:"start",value:function(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}},{key:"end",value:function(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}},{key:"before",value:function(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}},{key:"after",value:function(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}},{key:"textOffset",get:function(){return this.pos-this.path[this.path.length-1]}},{key:"nodeAfter",get:function(){var e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;var n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}},{key:"nodeBefore",get:function(){var e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}},{key:"posAtIndex",value:function(e,t){t=this.resolveDepth(t);for(var n=this.path[3*t],r=0==t?0:this.path[3*t-1]+1,i=0;i<e;i++)r+=n.child(i).nodeSize;return r}},{key:"marks",value:function(){var e=this.parent,t=this.index();if(0==e.content.size)return Wr.none;if(this.textOffset)return e.child(t).marks;var n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){var i=n;n=r,r=i}for(var o=n.marks,a=0;a<o.length;a++)!1!==o[a].type.spec.inclusive||r&&o[a].isInSet(r.marks)||(o=o[a--].removeFromSet(o));return o}},{key:"marksAcross",value:function(e){var t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;for(var n=t.marks,r=e.parent.maybeChild(e.index()),i=0;i<n.length;i++)!1!==n[i].type.spec.inclusive||r&&n[i].isInSet(r.marks)||(n=n[i--].removeFromSet(n));return n}},{key:"sharedDepth",value:function(e){for(var t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}},{key:"blockRange",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this,t=arguments.length>1?arguments[1]:void 0;if(e.pos<this.pos)return e.blockRange(this);for(var n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new ci(this,e,n);return null}},{key:"sameParent",value:function(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}},{key:"max",value:function(e){return e.pos>this.pos?e:this}},{key:"min",value:function(e){return e.pos<this.pos?e:this}},{key:"toString",value:function(){for(var e="",t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}}],[{key:"resolve",value:function(t,n){if(!(n>=0&&n<=t.content.size))throw new RangeError("Position "+n+" out of range");for(var r=[],i=0,o=n,a=t;;){var s=a.content.findIndex(o),c=s.index,u=s.offset,l=o-u;if(r.push(a,c,i+u),!l)break;if((a=a.child(c)).isText)break;o=l-1,i+=u+1}return new e(n,r,o)}},{key:"resolveCached",value:function(t,n){var r=si.get(t);if(r)for(var i=0;i<r.elts.length;i++){var o=r.elts[i];if(o.pos==n)return o}else si.set(t,r=new oi);var a=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%ai,a}}])}(),oi=S(function e(){x(this,e),this.elts=[],this.i=0}),ai=12,si=new WeakMap,ci=function(){return S(function e(t,n,r){x(this,e),this.$from=t,this.$to=n,this.depth=r},[{key:"start",get:function(){return this.$from.before(this.depth+1)}},{key:"end",get:function(){return this.$to.after(this.depth+1)}},{key:"parent",get:function(){return this.$from.node(this.depth)}},{key:"startIndex",get:function(){return this.$from.index(this.depth)}},{key:"endIndex",get:function(){return this.$to.indexAfter(this.depth)}}])}(),ui=Object.create(null),li=function(){function e(t,n,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Wr.none;x(this,e),this.type=t,this.attrs=n,this.marks=i,this.content=r||Fr.empty}return S(e,[{key:"children",get:function(){return this.content.content}},{key:"nodeSize",get:function(){return this.isLeaf?1:2+this.content.size}},{key:"childCount",get:function(){return this.content.childCount}},{key:"child",value:function(e){return this.content.child(e)}},{key:"maybeChild",value:function(e){return this.content.maybeChild(e)}},{key:"forEach",value:function(e){this.content.forEach(e)}},{key:"nodesBetween",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;this.content.nodesBetween(e,t,n,r,this)}},{key:"descendants",value:function(e){this.nodesBetween(0,this.content.size,e)}},{key:"textContent",get:function(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}},{key:"textBetween",value:function(e,t,n,r){return this.content.textBetween(e,t,n,r)}},{key:"firstChild",get:function(){return this.content.firstChild}},{key:"lastChild",get:function(){return this.content.lastChild}},{key:"eq",value:function(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}},{key:"sameMarkup",value:function(e){return this.hasMarkup(e.type,e.attrs,e.marks)}},{key:"hasMarkup",value:function(e,t,n){return this.type==e&&Hr(this.attrs,t||e.defaultAttrs||ui)&&Wr.sameSet(this.marks,n||Wr.none)}},{key:"copy",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}},{key:"mark",value:function(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}},{key:"cut",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.content.size;return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}},{key:"slice",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.content.size,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e==t)return Ur.empty;var r=this.resolve(e),i=this.resolve(t),o=n?0:r.sharedDepth(t),a=r.start(o),s=r.node(o).content.cut(r.pos-a,i.pos-a);return new Ur(s,r.depth-o,i.depth-o)}},{key:"replace",value:function(e,t,n){return Yr(this.resolve(e),this.resolve(t),n)}},{key:"nodeAt",value:function(e){for(var t=this;;){var n=t.content.findIndex(e),r=n.index,i=n.offset;if(!(t=t.maybeChild(r)))return null;if(i==e||t.isText)return t;e-=i+1}}},{key:"childAfter",value:function(e){var t=this.content.findIndex(e),n=t.index,r=t.offset;return{node:this.content.maybeChild(n),index:n,offset:r}}},{key:"childBefore",value:function(e){if(0==e)return{node:null,index:0,offset:0};var t=this.content.findIndex(e),n=t.index,r=t.offset;if(r<e)return{node:this.content.child(n),index:n,offset:r};var i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}},{key:"resolve",value:function(e){return ii.resolveCached(this,e)}},{key:"resolveNoCache",value:function(e){return ii.resolve(this,e)}},{key:"rangeHasMark",value:function(e,t,n){var r=!1;return t>e&&this.nodesBetween(e,t,function(e){return n.isInSet(e.marks)&&(r=!0),!r}),r}},{key:"isBlock",get:function(){return this.type.isBlock}},{key:"isTextblock",get:function(){return this.type.isTextblock}},{key:"inlineContent",get:function(){return this.type.inlineContent}},{key:"isInline",get:function(){return this.type.isInline}},{key:"isText",get:function(){return this.type.isText}},{key:"isLeaf",get:function(){return this.type.isLeaf}},{key:"isAtom",get:function(){return this.type.isAtom}},{key:"toString",value:function(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);var e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),hi(this.marks,e)}},{key:"contentMatchAt",value:function(e){var t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}},{key:"canReplace",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Fr.empty,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:n.childCount,o=this.contentMatchAt(e).matchFragment(n,r,i),a=o&&o.matchFragment(this.content,t);if(!a||!a.validEnd)return!1;for(var s=r;s<i;s++)if(!this.type.allowsMarks(n.child(s).marks))return!1;return!0}},{key:"canReplaceWith",value:function(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;var i=this.contentMatchAt(e).matchType(n),o=i&&i.matchFragment(this.content,t);return!!o&&o.validEnd}},{key:"canAppend",value:function(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}},{key:"check",value:function(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);for(var e=Wr.none,t=0;t<this.marks.length;t++){var n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!Wr.sameSet(e,this.marks))throw new RangeError("Invalid collection of marks for node ".concat(this.type.name,": ").concat(this.marks.map(function(e){return e.type.name})));this.content.forEach(function(e){return e.check()})}},{key:"toJSON",value:function(){var e={type:this.type.name};for(var t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(function(e){return e.toJSON()})),e}}],[{key:"fromJSON",value:function(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");var n=void 0;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}var r=Fr.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}}])}();li.prototype.text=void 0;var di=function(t){function n(e,t,i,o){var a;if(x(this,n),a=r(this,n,[e,t,null,o]),!i)throw new RangeError("Empty text nodes are not allowed");return a.text=i,a}return a(n,t),S(n,[{key:"toString",value:function(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):hi(this.marks,JSON.stringify(this.text))}},{key:"textContent",get:function(){return this.text}},{key:"textBetween",value:function(e,t){return this.text.slice(e,t)}},{key:"nodeSize",get:function(){return this.text.length}},{key:"mark",value:function(e){return e==this.marks?this:new n(this.type,this.attrs,this.text,e)}},{key:"withText",value:function(e){return e==this.text?this:new n(this.type,this.attrs,e,this.marks)}},{key:"cut",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.text.length;return 0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))}},{key:"eq",value:function(e){return this.sameMarkup(e)&&this.text==e.text}},{key:"toJSON",value:function(){var t=e(n,"toJSON",this,3)([]);return t.text=this.text,t}}])}(li);function hi(e,t){for(var n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}var fi=function(){function e(t){x(this,e),this.validEnd=t,this.next=[],this.wrapCache=[]}return S(e,[{key:"matchType",value:function(e){for(var t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}},{key:"matchFragment",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.childCount,r=this,i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}},{key:"inlineContent",get:function(){return 0!=this.next.length&&this.next[0].type.isInline}},{key:"defaultType",get:function(){for(var e=0;e<this.next.length;e++){var t=this.next[e].type;if(!t.isText&&!t.hasRequiredAttrs())return t}return null}},{key:"compatible",value:function(e){for(var t=0;t<this.next.length;t++)for(var n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}},{key:"fillBefore",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=[this];return function i(o,a){var s=o.matchFragment(e,n);if(s&&(!t||s.validEnd))return Fr.from(a.map(function(e){return e.createAndFill()}));for(var c=0;c<o.next.length;c++){var u=o.next[c],l=u.type,d=u.next;if(!l.isText&&!l.hasRequiredAttrs()&&-1==r.indexOf(d)){r.push(d);var h=i(d,a.concat(l));if(h)return h}}return null}(this,[])}},{key:"findWrapping",value:function(e){for(var t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];var n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}},{key:"computeWrapping",value:function(e){for(var t=Object.create(null),n=[{match:this,type:null,via:null}];n.length;){var r=n.shift(),i=r.match;if(i.matchType(e)){for(var o=[],a=r;a.type;a=a.via)o.push(a.type);return o.reverse()}for(var s=0;s<i.next.length;s++){var c=i.next[s],u=c.type,l=c.next;u.isLeaf||u.hasRequiredAttrs()||u.name in t||r.type&&!l.validEnd||(n.push({match:u.contentMatch,type:u,via:r}),t[u.name]=!0)}}return null}},{key:"edgeCount",get:function(){return this.next.length}},{key:"edge",value:function(e){if(e>=this.next.length)throw new RangeError("There's no ".concat(e,"th edge in this content match"));return this.next[e]}},{key:"toString",value:function(){var e=[];return function t(n){e.push(n);for(var r=0;r<n.next.length;r++)-1==e.indexOf(n.next[r].next)&&t(n.next[r].next)}(this),e.map(function(t,n){for(var r=n+(t.validEnd?"*":" ")+" ",i=0;i<t.next.length;i++)r+=(i?", ":"")+t.next[i].type.name+"->"+e.indexOf(t.next[i].next);return r}).join("\n")}}],[{key:"parse",value:function(t,n){var r=new pi(t,n);if(null==r.next)return e.empty;var i=vi(r);r.next&&r.err("Unexpected trailing text");var o=xi(function(e){var t=[[]];return i(o(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){var i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(function(e){return e.to=t})}function o(e,t){if("choice"==e.type)return e.exprs.reduce(function(e,n){return e.concat(o(n,t))},[]);if("seq"!=e.type){if("star"==e.type){var a=n();return r(t,a),i(o(e.expr,a),a),[r(a)]}if("plus"==e.type){var s=n();return i(o(e.expr,t),s),i(o(e.expr,s),s),[r(s)]}if("opt"==e.type)return[r(t)].concat(o(e.expr,t));if("range"==e.type){for(var c=t,u=0;u<e.min;u++){var l=n();i(o(e.expr,c),l),c=l}if(-1==e.max)i(o(e.expr,c),c);else for(var d=e.min;d<e.max;d++){var h=n();r(c,h),i(o(e.expr,c),h),c=h}return[r(c)]}if("name"==e.type)return[r(t,void 0,e.value)];throw new Error("Unknown expr type")}for(var f=0;;f++){var p=o(e.exprs[f],t);if(f==e.exprs.length-1)return p;i(p,t=n())}}}(i));return function(e,t){for(var n=0,r=[e];n<r.length;n++){for(var i=r[n],o=!i.validEnd,a=[],s=0;s<i.next.length;s++){var c=i.next[s],u=c.type,l=c.next;a.push(u.name),!o||u.isText||u.hasRequiredAttrs()||(o=!1),-1==r.indexOf(l)&&r.push(l)}o&&t.err("Only non-generatable nodes ("+a.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(o,r),o}}])}();fi.empty=new fi(!0);var pi=function(){return S(function e(t,n){x(this,e),this.string=t,this.nodeTypes=n,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()},[{key:"next",get:function(){return this.tokens[this.pos]}},{key:"eat",value:function(e){return this.next==e&&(this.pos++||!0)}},{key:"err",value:function(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}])}();function vi(e){var t=[];do{t.push(mi(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function mi(e){var t=[];do{t.push(gi(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function gi(e){for(var t=function(e){if(e.eat("(")){var t=vi(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){var n=function(e,t){var n=e.nodeTypes,r=n[t];if(r)return[r];var i=[];for(var o in n){var a=n[o];a.isInGroup(t)&&i.push(a)}0==i.length&&e.err("No node type or group '"+t+"' found");return i}(e,e.next).map(function(t){return null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t}});return e.pos++,1==n.length?n[0]:{type:"choice",exprs:n}}e.err("Unexpected token '"+e.next+"'")}(e);;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=ki(e,t)}return t}function yi(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");var t=Number(e.next);return e.pos++,t}function ki(e,t){var n=yi(e),r=n;return e.eat(",")&&(r="}"!=e.next?yi(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}function wi(e,t){return t-e}function bi(e,t){var n=[];return function t(r){var i=e[r];if(1==i.length&&!i[0].term)return t(i[0].to);n.push(r);for(var o=0;o<i.length;o++){var a=i[o],s=a.term,c=a.to;s||-1!=n.indexOf(c)||t(c)}}(t),n.sort(wi)}function xi(e){var t=Object.create(null);return function n(r){var i=[];r.forEach(function(t){e[t].forEach(function(t){var n=t.term,r=t.to;if(n){for(var o,a=0;a<i.length;a++)i[a][0]==n&&(o=i[a][1]);bi(e,r).forEach(function(e){o||i.push([n,o=[]]),-1==o.indexOf(e)&&o.push(e)})}})});for(var o=t[r.join(",")]=new fi(r.indexOf(e.length-1)>-1),a=0;a<i.length;a++){var s=i[a][1].sort(wi);o.next.push({type:i[a][0],next:t[s.join(",")]||n(s)})}return o}(bi(e,0))}function Ci(e){var t=Object.create(null);for(var n in e){var r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function Si(e,t){var n=Object.create(null);for(var r in e){var i=t&&t[r];if(void 0===i){var o=e[r];if(!o.hasDefault)throw new RangeError("No value supplied for attribute "+r);i=o.default}n[r]=i}return n}function _i(e,t,n,r){for(var i in t)if(!(i in e))throw new RangeError("Unsupported attribute ".concat(i," for ").concat(n," of type ").concat(i));for(var o in e){var a=e[o];a.validate&&a.validate(t[o])}}function Mi(e,t){var n=Object.create(null);if(t)for(var r in t)n[r]=new Oi(e,r,t[r]);return n}var Ti=function(){function e(t,n,r){x(this,e),this.name=t,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Mi(t,r.attrs),this.defaultAttrs=Ci(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||"text"==t),this.isText="text"==t}return S(e,[{key:"isInline",get:function(){return!this.isBlock}},{key:"isTextblock",get:function(){return this.isBlock&&this.inlineContent}},{key:"isLeaf",get:function(){return this.contentMatch==fi.empty}},{key:"isAtom",get:function(){return this.isLeaf||!!this.spec.atom}},{key:"isInGroup",value:function(e){return this.groups.indexOf(e)>-1}},{key:"whitespace",get:function(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}},{key:"hasRequiredAttrs",value:function(){for(var e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}},{key:"compatibleContent",value:function(e){return this==e||this.contentMatch.compatible(e.contentMatch)}},{key:"computeAttrs",value:function(e){return!e&&this.defaultAttrs?this.defaultAttrs:Si(this.attrs,e)}},{key:"create",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0;if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new li(this,this.computeAttrs(e),Fr.from(t),Wr.setFrom(n))}},{key:"createChecked",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0;return t=Fr.from(t),this.checkContent(t),new li(this,this.computeAttrs(e),t,Wr.setFrom(n))}},{key:"createAndFill",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0;if(e=this.computeAttrs(e),(t=Fr.from(t)).size){var r=this.contentMatch.fillBefore(t);if(!r)return null;t=r.append(t)}var i=this.contentMatch.matchFragment(t),o=i&&i.fillBefore(Fr.empty,!0);return o?new li(this,e,t.append(o),Wr.setFrom(n)):null}},{key:"validContent",value:function(e){var t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(var n=0;n<e.childCount;n++)if(!this.allowsMarks(e.child(n).marks))return!1;return!0}},{key:"checkContent",value:function(e){if(!this.validContent(e))throw new RangeError("Invalid content for node ".concat(this.name,": ").concat(e.toString().slice(0,50)))}},{key:"checkAttrs",value:function(e){_i(this.attrs,e,"node",this.name)}},{key:"allowsMarkType",value:function(e){return null==this.markSet||this.markSet.indexOf(e)>-1}},{key:"allowsMarks",value:function(e){if(null==this.markSet)return!0;for(var t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}},{key:"allowedMarks",value:function(e){if(null==this.markSet)return e;for(var t,n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:Wr.none:e}}],[{key:"compile",value:function(t,n){var r=Object.create(null);t.forEach(function(t,i){return r[t]=new e(t,n,i)});var i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(var o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}}])}();var Oi=function(){return S(function e(t,n,r){x(this,e),this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate="string"==typeof r.validate?function(e,t,n){var r=n.split("|");return function(n){var i=null===n?"null":T(n);if(r.indexOf(i)<0)throw new RangeError("Expected value of type ".concat(r," for attribute ").concat(t," on type ").concat(e,", got ").concat(i))}}(t,n,r.validate):r.validate},[{key:"isRequired",get:function(){return!this.hasDefault}}])}(),Ni=function(){function e(t,n,r,i){x(this,e),this.name=t,this.rank=n,this.schema=r,this.spec=i,this.attrs=Mi(t,i.attrs),this.excluded=null;var o=Ci(this.attrs);this.instance=o?new Wr(this,o):null}return S(e,[{key:"create",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return!e&&this.instance?this.instance:new Wr(this,Si(this.attrs,e))}},{key:"removeFromSet",value:function(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}},{key:"isInSet",value:function(e){for(var t=0;t<e.length;t++)if(e[t].type==this)return e[t]}},{key:"checkAttrs",value:function(e){_i(this.attrs,e,"mark",this.name)}},{key:"excludes",value:function(e){return this.excluded.indexOf(e)>-1}}],[{key:"compile",value:function(t,n){var r=Object.create(null),i=0;return t.forEach(function(t,o){return r[t]=new e(t,i++,n,o)}),r}}])}(),Ei=function(){return S(function e(t){var n=this;x(this,e),this.linebreakReplacement=null,this.cached=Object.create(null);var r=this.spec={};for(var i in t)r[i]=t[i];r.nodes=Lr.from(t.nodes),r.marks=Lr.from(t.marks||{}),this.nodes=Ti.compile(this.spec.nodes,this),this.marks=Ni.compile(this.spec.marks,this);var o=Object.create(null);for(var a in this.nodes){if(a in this.marks)throw new RangeError(a+" can not be both a node and a mark");var s=this.nodes[a],c=s.spec.content||"",u=s.spec.marks;if(s.contentMatch=o[c]||(o[c]=fi.parse(c,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet="_"==u?null:u?Ai(this,u.split(" ")):""!=u&&s.inlineContent?null:[]}for(var l in this.marks){var d=this.marks[l],h=d.spec.excludes;d.excluded=null==h?[d]:""==h?[]:Ai(this,h.split(" "))}this.nodeFromJSON=function(e){return li.fromJSON(n,e)},this.markFromJSON=function(e){return Wr.fromJSON(n,e)},this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)},[{key:"node",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0;if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof Ti))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,r)}},{key:"text",value:function(e,t){var n=this.nodes.text;return new di(n,n.defaultAttrs,e,Wr.setFrom(t))}},{key:"mark",value:function(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}},{key:"nodeType",value:function(e){var t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}])}();function Ai(e,t){for(var n=[],r=0;r<t.length;r++){var i=t[r],o=e.marks[i],a=o;if(o)n.push(o);else for(var s in e.marks){var c=e.marks[s];("_"==i||c.spec.group&&c.spec.group.split(" ").indexOf(i)>-1)&&n.push(a=c)}if(!a)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}var Di=function(){function e(t,n){var r=this;x(this,e),this.schema=t,this.rules=n,this.tags=[],this.styles=[];var i=this.matchedStyles=[];n.forEach(function(e){if(function(e){return null!=e.tag}(e))r.tags.push(e);else if(function(e){return null!=e.style}(e)){var t=/[^=]*/.exec(e.style)[0];i.indexOf(t)<0&&i.push(t),r.styles.push(e)}}),this.normalizeLists=!this.tags.some(function(e){if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return!1;var n=t.nodes[e.node];return n.contentMatch.matchType(n)})}return S(e,[{key:"parse",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new Bi(this,t,!1);return n.addAll(e,Wr.none,t.from,t.to),n.finish()}},{key:"parseSlice",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new Bi(this,t,!0);return n.addAll(e,Wr.none,t.from,t.to),Ur.maxOpen(n.finish())}},{key:"matchTag",value:function(e,t,n){for(var r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){var i=this.tags[r];if(Vi(e,i.tag)&&(void 0===i.namespace||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs){var o=i.getAttrs(e);if(!1===o)continue;i.attrs=o||void 0}return i}}}},{key:"matchStyle",value:function(e,t,n,r){for(var i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){var o=this.styles[i],a=o.style;if(!(0!=a.indexOf(e)||o.context&&!n.matchesContext(o.context)||a.length>e.length&&(61!=a.charCodeAt(e.length)||a.slice(e.length+1)!=t))){if(o.getAttrs){var s=o.getAttrs(t);if(!1===s)continue;o.attrs=s||void 0}return o}}}}],[{key:"schemaRules",value:function(e){var t=[];function n(e){for(var n=null==e.priority?50:e.priority,r=0;r<t.length;r++){var i=t[r];if((null==i.priority?50:i.priority)<n)break}t.splice(r,0,e)}var r=function(t){var r=e.marks[t].spec.parseDOM;r&&r.forEach(function(e){n(e=Fi(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})};for(var i in e.marks)r(i);var o=function(t){var r=e.nodes[t].spec.parseDOM;r&&r.forEach(function(e){n(e=Fi(e)),e.node||e.ignore||e.mark||(e.node=t)})};for(var a in e.nodes)o(a);return t}},{key:"fromSchema",value:function(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}}])}(),Ii={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},zi={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ri={ol:!0,ul:!0};function Pi(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}var Li=function(){return S(function e(t,n,r,i,o,a){x(this,e),this.type=t,this.attrs=n,this.marks=r,this.solid=i,this.options=a,this.content=[],this.activeMarks=Wr.none,this.match=o||(4&a?null:t.contentMatch)},[{key:"findWrapping",value:function(e){if(!this.match){if(!this.type)return[];var t=this.type.contentMatch.fillBefore(Fr.from(e));if(!t){var n,r=this.type.contentMatch;return(n=r.findWrapping(e.type))?(this.match=r,n):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}},{key:"finish",value:function(e){if(!(1&this.options)){var t,n=this.content[this.content.length-1];if(n&&n.isText&&(t=/[ \t\r\n\u000c]+$/.exec(n.text))){var r=n;n.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=r.withText(r.text.slice(0,r.text.length-t[0].length))}}var i=Fr.from(this.content);return!e&&this.match&&(i=i.append(this.match.fillBefore(Fr.empty,!0))),this.type?this.type.create(this.attrs,i,this.marks):i}},{key:"inlineContext",value:function(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Ii.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}])}(),Bi=function(){return S(function e(t,n,r){x(this,e),this.parser=t,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;var i,o=n.topNode,a=Pi(null,n.preserveWhitespace,0)|(r?4:0);i=o?new Li(o.type,o.attrs,Wr.none,!0,n.topMatch||o.type.contentMatch,a):new Li(r?null:t.schema.topNodeType,null,Wr.none,!0,null,a),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1},[{key:"top",get:function(){return this.nodes[this.open]}},{key:"addDOM",value:function(e,t){3==e.nodeType?this.addTextNode(e,t):1==e.nodeType&&this.addElement(e,t)}},{key:"addTextNode",value:function(e,t){var n=e.nodeValue,r=this.top,i=2&r.options?"full":this.localPreserveWS||(1&r.options)>0,o=this.parser.schema;if("full"===i||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(i)if("full"===i)n=n.replace(/\r\n?/g,"\n");else if(o.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(o.linebreakReplacement.create())){for(var a=n.split(/\r?\n|\r/),s=0;s<a.length;s++)s&&this.insertNode(o.linebreakReplacement.create(),t,!0),a[s]&&this.insertNode(o.text(a[s]),t,!/\S/.test(a[s]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){var c=r.content[r.content.length-1],u=e.previousSibling;(!c||u&&"BR"==u.nodeName||c.isText&&/[ \t\r\n\u000c]$/.test(c.text))&&(n=n.slice(1))}n&&this.insertNode(o.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}},{key:"addElement",value:function(e,t,n){var r=this.localPreserveWS,i=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);var o,a=e.nodeName.toLowerCase();Ri.hasOwnProperty(a)&&this.parser.normalizeLists&&function(e){for(var t=e.firstChild,n=null;t;t=t.nextSibling){var r=1==t.nodeType?t.nodeName.toLowerCase():null;r&&Ri.hasOwnProperty(r)&&n?(n.appendChild(t),t=n):"li"==r?n=t:r&&(n=null)}}(e);var s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));e:if(s?s.ignore:zi.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);var c,u=this.needsBlock;if(Ii.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}var l=s&&s.skip?t:this.readStyles(e,t);l&&this.addAll(e,l),c&&this.sync(i),this.needsBlock=u}else{var d=this.readStyles(e,t);d&&this.addElementByRule(e,s,d,!1===s.consuming?o:void 0)}this.localPreserveWS=r}},{key:"leafFallback",value:function(e,t){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),t)}},{key:"ignoreFallback",value:function(e,t){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),t,!0)}},{key:"readStyles",value:function(e,t){var n=this,r=e.style;if(r&&r.length)for(var i=0;i<this.parser.matchedStyles.length;i++){var o=this.parser.matchedStyles[i],a=r.getPropertyValue(o);if(a)for(var s,c=function(e){var r=n.parser.matchStyle(o,a,n,e);return r?r.ignore?{v:null}:(t=r.clearMark?t.filter(function(e){return!r.clearMark(e)}):t.concat(n.parser.schema.marks[r.mark].create(r.attrs)),!1!==r.consuming?(u=e,0):void(u=e=r)):(u=e,0)},u=void 0;0!==(s=c(u));)if(s)return s.v}return t}},{key:"addElementByRule",value:function(e,t,n,r){var i,o,a=this;if(t.node)if((o=this.parser.schema.nodes[t.node]).isLeaf)this.insertNode(o.create(t.attrs),n,"BR"==e.nodeName)||this.leafFallback(e,n);else{var s=this.enter(o,t.attrs||null,n,t.preserveWhitespace);s&&(i=!0,n=s)}else{var c=this.parser.schema.marks[t.mark];n=n.concat(c.create(t.attrs))}var u=this.top;if(o&&o.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(function(e){return a.insertNode(e,n,!1)});else{var l=e;"string"==typeof t.contentElement?l=e.querySelector(t.contentElement):"function"==typeof t.contentElement?l=t.contentElement(e):t.contentElement&&(l=t.contentElement),this.findAround(e,l,!0),this.addAll(l,n),this.findAround(e,l,!1)}i&&this.sync(u)&&this.open--}},{key:"addAll",value:function(e,t,n,r){for(var i=n||0,o=n?e.childNodes[n]:e.firstChild,a=null==r?null:e.childNodes[r];o!=a;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,t);this.findAtPoint(e,i)}},{key:"findPlace",value:function(e,t,n){for(var r,i,o=this.open,a=0;o>=0;o--){var s=this.nodes[o],c=s.findWrapping(e);if(c&&(!r||r.length>c.length+a)&&(r=c,i=s,!c.length))break;if(s.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(var u=0;u<r.length;u++)t=this.enterInner(r[u],null,t,!1);return t}},{key:"insertNode",value:function(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){var r=this.textblockFromContext();r&&(t=this.enterInner(r,null,t))}var i=this.findPlace(e,t,n);if(i){this.closeExtra();var o=this.top;o.match&&(o.match=o.match.matchType(e.type));var a,s=Wr.none,c=l(i.concat(e.marks));try{for(c.s();!(a=c.n()).done;){var u=a.value;(o.type?o.type.allowsMarkType(u.type):$i(u.type,e.type))&&(s=u.addToSet(s))}}catch(d){c.e(d)}finally{c.f()}return o.content.push(e.mark(s)),!0}return!1}},{key:"enter",value:function(e,t,n,r){var i=this.findPlace(e.create(t),n,!1);return i&&(i=this.enterInner(e,t,n,!0,r)),i}},{key:"enterInner",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4?arguments[4]:void 0;this.closeExtra();var o=this.top;o.match=o.match&&o.match.matchType(e);var a=Pi(e,i,o.options);4&o.options&&0==o.content.length&&(a|=4);var s=Wr.none;return n=n.filter(function(t){return!(o.type?o.type.allowsMarkType(t.type):$i(t.type,e))||(s=t.addToSet(s),!1)}),this.nodes.push(new Li(e,t,s,r,null,a)),this.open++,n}},{key:"closeExtra",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}},{key:"finish",value:function(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!(!this.isOpen&&!this.options.topOpen))}},{key:"sync",value:function(e){for(var t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=1)}return!1}},{key:"currentPos",get:function(){this.closeExtra();for(var e=0,t=this.open;t>=0;t--){for(var n=this.nodes[t].content,r=n.length-1;r>=0;r--)e+=n[r].nodeSize;t&&e++}return e}},{key:"findAtPoint",value:function(e,t){if(this.find)for(var n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}},{key:"findInside",value:function(e){if(this.find)for(var t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}},{key:"findAround",value:function(e,t,n){if(e!=t&&this.find)for(var r=0;r<this.find.length;r++){if(null==this.find[r].pos&&1==e.nodeType&&e.contains(this.find[r].node))t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}}},{key:"findInText",value:function(e){if(this.find)for(var t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}},{key:"matchesContext",value:function(e){var t=this;if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);var n=e.split("/"),r=this.options.context,i=!(this.isOpen||r&&r.parent.type!=this.nodes[0].type),o=-(r?r.depth+1:0)+(i?0:1),a=function(e,s){for(;e>=0;e--){var c=n[e];if(""==c){if(e==n.length-1||0==e)continue;for(;s>=o;s--)if(a(e-1,s))return!0;return!1}var u=s>0||0==s&&i?t.nodes[s].type:r&&s>=o?r.node(s-o).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;s--}return!0};return a(n.length-1,this.open)}},{key:"textblockFromContext",value:function(){var e=this.options.context;if(e)for(var t=e.depth;t>=0;t--){var n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(var r in this.parser.schema.nodes){var i=this.parser.schema.nodes[r];if(i.isTextblock&&i.defaultAttrs)return i}}}])}();function Vi(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Fi(e){var t={};for(var n in e)t[n]=e[n];return t}function $i(e,t){var n,r=t.schema.nodes,i=function(){var n=r[o];if(!n.allowsMarkType(e))return 0;var i=[],a=function(e){i.push(e);for(var n=0;n<e.edgeCount;n++){var r=e.edge(n),o=r.type,s=r.next;if(o==t)return!0;if(i.indexOf(s)<0&&a(s))return!0}};return a(n.contentMatch)?{v:!0}:void 0};for(var o in r)if(0!==(n=i())&&n)return n.v}var ji=function(){function e(t,n){x(this,e),this.nodes=t,this.marks=n}return S(e,[{key:"serializeFragment",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0;r||(r=Wi(n).createDocumentFragment());var i=r,o=[];return e.forEach(function(e){if(o.length||e.marks.length){for(var r=0,a=0;r<o.length&&a<e.marks.length;){var s=e.marks[a];if(t.marks[s.type.name]){if(!s.eq(o[r][0])||!1===s.type.spec.spanning)break;r++,a++}else a++}for(;r<o.length;)i=o.pop()[1];for(;a<e.marks.length;){var c=e.marks[a++],u=t.serializeMark(c,e.isInline,n);u&&(o.push([c,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(t.serializeNodeInner(e,n))}),r}},{key:"serializeNodeInner",value:function(e,t){var n=Ji(Wi(t),this.nodes[e.type.name](e),null,e.attrs),r=n.dom,i=n.contentDOM;if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return r}},{key:"serializeNode",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.serializeNodeInner(e,t),r=e.marks.length-1;r>=0;r--){var i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}},{key:"serializeMark",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=this.marks[e.type.name];return r&&Ji(Wi(n),r(e,t),null,e.attrs)}}],[{key:"renderSpec",value:function(e,t){return Ji(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,arguments.length>3?arguments[3]:void 0)}},{key:"fromSchema",value:function(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}},{key:"nodesFromSchema",value:function(e){var t=Hi(e.nodes);return t.text||(t.text=function(e){return e.text}),t}},{key:"marksFromSchema",value:function(e){return Hi(e.marks)}}])}();function Hi(e){var t={};for(var n in e){var r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function Wi(e){return e.document||window.document}var qi=new WeakMap;function Ui(e){var t=qi.get(e);return void 0===t&&qi.set(e,t=function(e){var t=null;function n(e){if(e&&"object"==T(e))if(Array.isArray(e))if("string"==typeof e[0])t||(t=[]),t.push(e);else for(var r=0;r<e.length;r++)n(e[r]);else for(var i in e)n(e[i])}return n(e),t}(e)),t}function Ji(e,t,n,r){if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;var i,o=t[0];if("string"!=typeof o)throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=Ui(r))&&i.indexOf(t)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");var a,s=o.indexOf(" ");s>0&&(n=o.slice(0,s),o=o.slice(s+1));var c=n?e.createElementNS(n,o):e.createElement(o),u=t[1],l=1;if(u&&"object"==T(u)&&null==u.nodeType&&!Array.isArray(u))for(var d in l=2,u)if(null!=u[d]){var h=d.indexOf(" ");h>0?c.setAttributeNS(d.slice(0,h),d.slice(h+1),u[d]):"style"==d&&c.style?c.style.cssText=u[d]:c.setAttribute(d,u[d])}for(var f=l;f<t.length;f++){var p=t[f];if(0===p){if(f<t.length-1||f>l)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}var v=Ji(e,p,n,r),m=v.dom,g=v.contentDOM;if(c.appendChild(m),g){if(a)throw new RangeError("Multiple content holes");a=g}}return{dom:c,contentDOM:a}}var Ki=Math.pow(2,16);function Yi(e,t){return e+t*Ki}function Gi(e){return 65535&e}var Xi=function(){return S(function e(t,n,r){x(this,e),this.pos=t,this.delInfo=n,this.recover=r},[{key:"deleted",get:function(){return(8&this.delInfo)>0}},{key:"deletedBefore",get:function(){return(5&this.delInfo)>0}},{key:"deletedAfter",get:function(){return(6&this.delInfo)>0}},{key:"deletedAcross",get:function(){return(4&this.delInfo)>0}}])}(),Zi=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(x(this,e),this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}return S(e,[{key:"recover",value:function(e){var t=0,n=Gi(e);if(!this.inverted)for(var r=0;r<n;r++)t+=this.ranges[3*r+2]-this.ranges[3*r+1];return this.ranges[3*n]+t+function(e){return(e-(65535&e))/Ki}(e)}},{key:"mapResult",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this._map(e,t,!1)}},{key:"map",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this._map(e,t,!0)}},{key:"_map",value:function(e,t,n){for(var r=0,i=this.inverted?2:1,o=this.inverted?1:2,a=0;a<this.ranges.length;a+=3){var s=this.ranges[a]-(this.inverted?r:0);if(s>e)break;var c=this.ranges[a+i],u=this.ranges[a+o],l=s+c;if(e<=l){var d=s+r+((c?e==s?-1:e==l?1:t:t)<0?0:u);if(n)return d;var h=e==(t<0?s:l)?null:Yi(a/3,e-s),f=e==s?2:e==l?1:4;return(t<0?e!=s:e!=l)&&(f|=8),new Xi(d,f,h)}r+=u-c}return n?e+r:new Xi(e+r,0,null)}},{key:"touches",value:function(e,t){for(var n=0,r=Gi(t),i=this.inverted?2:1,o=this.inverted?1:2,a=0;a<this.ranges.length;a+=3){var s=this.ranges[a]-(this.inverted?n:0);if(s>e)break;var c=this.ranges[a+i];if(e<=s+c&&a==3*r)return!0;n+=this.ranges[a+o]-c}return!1}},{key:"forEach",value:function(e){for(var t=this.inverted?2:1,n=this.inverted?1:2,r=0,i=0;r<this.ranges.length;r+=3){var o=this.ranges[r],a=o-(this.inverted?i:0),s=o+(this.inverted?0:i),c=this.ranges[r+t],u=this.ranges[r+n];e(a,a+c,s,s+u),i+=u-c}}},{key:"invert",value:function(){return new e(this.ranges,!this.inverted)}},{key:"toString",value:function(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}}],[{key:"offset",value:function(t){return 0==t?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}}])}();Zi.empty=new Zi([]);var Qi=function(){function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t?t.length:0;x(this,e),this.mirror=n,this.from=r,this.to=i,this._maps=t||[],this.ownData=!(t||n)}return S(e,[{key:"maps",get:function(){return this._maps}},{key:"slice",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.maps.length;return new e(this._maps,this.mirror,t,n)}},{key:"appendMap",value:function(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),null!=t&&this.setMirror(this._maps.length-1,t)}},{key:"appendMapping",value:function(e){for(var t=0,n=this._maps.length;t<e._maps.length;t++){var r=e.getMirror(t);this.appendMap(e._maps[t],null!=r&&r<t?n+r:void 0)}}},{key:"getMirror",value:function(e){if(this.mirror)for(var t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}},{key:"setMirror",value:function(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}},{key:"appendMappingInverted",value:function(e){for(var t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){var r=e.getMirror(t);this.appendMap(e._maps[t].invert(),null!=r&&r>t?n-r-1:void 0)}}},{key:"invert",value:function(){var t=new e;return t.appendMappingInverted(this),t}},{key:"map",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(this.mirror)return this._map(e,t,!0);for(var n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}},{key:"mapResult",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this._map(e,t,!1)}},{key:"_map",value:function(e,t,n){for(var r=0,i=this.from;i<this.to;i++){var o=this._maps[i].mapResult(e,t);if(null!=o.recover){var a=this.getMirror(i);if(null!=a&&a>i&&a<this.to){i=a,e=this._maps[a].recover(o.recover);continue}}r|=o.delInfo,e=o.pos}return n?e:new Xi(e,r,null)}}])}(),eo=Object.create(null),to=function(){return S(function e(){x(this,e)},[{key:"getMap",value:function(){return Zi.empty}},{key:"merge",value:function(e){return null}}],[{key:"fromJSON",value:function(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");var n=eo[t.stepType];if(!n)throw new RangeError("No step type ".concat(t.stepType," defined"));return n.fromJSON(e,t)}},{key:"jsonID",value:function(e,t){if(e in eo)throw new RangeError("Duplicate use of step JSON ID "+e);return eo[e]=t,t.prototype.jsonID=e,t}}])}(),no=function(){function e(t,n){x(this,e),this.doc=t,this.failed=n}return S(e,null,[{key:"ok",value:function(t){return new e(t,null)}},{key:"fail",value:function(t){return new e(null,t)}},{key:"fromReplace",value:function(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(pt){if(pt instanceof qr)return e.fail(pt.message);throw pt}}}])}();function ro(e,t,n){for(var r=[],i=0;i<e.childCount;i++){var o=e.child(i);o.content.size&&(o=o.copy(ro(o.content,t,o))),o.isInline&&(o=t(o,n,i)),r.push(o)}return Fr.fromArray(r)}var io=function(e){function t(e,n,i){var o;return x(this,t),(o=r(this,t)).from=e,o.to=n,o.mark=i,o}return a(t,e),S(t,[{key:"apply",value:function(e){var t=this,n=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),o=new Ur(ro(n.content,function(e,n){return e.isAtom&&n.type.allowsMarkType(t.mark.type)?e.mark(t.mark.addToSet(e.marks)):e},i),n.openStart,n.openEnd);return no.fromReplace(e,this.from,this.to,o)}},{key:"invert",value:function(){return new oo(this.from,this.to,this.mark)}},{key:"map",value:function(e){var n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)}},{key:"merge",value:function(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}},{key:"toJSON",value:function(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}}])}(to);to.jsonID("addMark",io);var oo=function(e){function t(e,n,i){var o;return x(this,t),(o=r(this,t)).from=e,o.to=n,o.mark=i,o}return a(t,e),S(t,[{key:"apply",value:function(e){var t=this,n=e.slice(this.from,this.to),r=new Ur(ro(n.content,function(e){return e.mark(t.mark.removeFromSet(e.marks))},e),n.openStart,n.openEnd);return no.fromReplace(e,this.from,this.to,r)}},{key:"invert",value:function(){return new io(this.from,this.to,this.mark)}},{key:"map",value:function(e){var n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)}},{key:"merge",value:function(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}},{key:"toJSON",value:function(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}}])}(to);to.jsonID("removeMark",oo);var ao=function(e){function t(e,n){var i;return x(this,t),(i=r(this,t)).pos=e,i.mark=n,i}return a(t,e),S(t,[{key:"apply",value:function(e){var t=e.nodeAt(this.pos);if(!t)return no.fail("No node at mark step's position");var n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return no.fromReplace(e,this.pos,this.pos+1,new Ur(Fr.from(n),0,t.isLeaf?0:1))}},{key:"invert",value:function(e){var n=e.nodeAt(this.pos);if(n){var r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(var i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new t(this.pos,n.marks[i]);return new t(this.pos,this.mark)}}return new so(this.pos,this.mark)}},{key:"map",value:function(e){var n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.mark)}},{key:"toJSON",value:function(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new t(n.pos,e.markFromJSON(n.mark))}}])}(to);to.jsonID("addNodeMark",ao);var so=function(e){function t(e,n){var i;return x(this,t),(i=r(this,t)).pos=e,i.mark=n,i}return a(t,e),S(t,[{key:"apply",value:function(e){var t=e.nodeAt(this.pos);if(!t)return no.fail("No node at mark step's position");var n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return no.fromReplace(e,this.pos,this.pos+1,new Ur(Fr.from(n),0,t.isLeaf?0:1))}},{key:"invert",value:function(e){var t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new ao(this.pos,this.mark):this}},{key:"map",value:function(e){var n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.mark)}},{key:"toJSON",value:function(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new t(n.pos,e.markFromJSON(n.mark))}}])}(to);to.jsonID("removeNodeMark",so);var co=function(e){function t(e,n,i){var o,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return x(this,t),(o=r(this,t)).from=e,o.to=n,o.slice=i,o.structure=a,o}return a(t,e),S(t,[{key:"apply",value:function(e){return this.structure&&lo(e,this.from,this.to)?no.fail("Structure replace would overwrite content"):no.fromReplace(e,this.from,this.to,this.slice)}},{key:"getMap",value:function(){return new Zi([this.from,this.to-this.from,this.slice.size])}},{key:"invert",value:function(e){return new t(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}},{key:"map",value:function(e){var n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new t(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}},{key:"merge",value:function(e){if(!(e instanceof t)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;var n=this.slice.size+e.slice.size==0?Ur.empty:new Ur(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new t(e.from,this.to,n,this.structure)}var r=this.slice.size+e.slice.size==0?Ur.empty:new Ur(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new t(this.from,this.to+(e.to-e.from),r,this.structure)}},{key:"toJSON",value:function(){var e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new t(n.from,n.to,Ur.fromJSON(e,n.slice),!!n.structure)}}])}(to);to.jsonID("replace",co);var uo=function(e){function t(e,n,i,o,a,s){var c,u=arguments.length>6&&void 0!==arguments[6]&&arguments[6];return x(this,t),(c=r(this,t)).from=e,c.to=n,c.gapFrom=i,c.gapTo=o,c.slice=a,c.insert=s,c.structure=u,c}return a(t,e),S(t,[{key:"apply",value:function(e){if(this.structure&&(lo(e,this.from,this.gapFrom)||lo(e,this.gapTo,this.to)))return no.fail("Structure gap-replace would overwrite content");var t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return no.fail("Gap is not a flat range");var n=this.slice.insertAt(this.insert,t.content);return n?no.fromReplace(e,this.from,this.to,n):no.fail("Content does not fit in gap")}},{key:"getMap",value:function(){return new Zi([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}},{key:"invert",value:function(e){var n=this.gapTo-this.gapFrom;return new t(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}},{key:"map",value:function(e){var n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||o>r.pos?null:new t(n.pos,r.pos,i,o,this.slice,this.insert,this.structure)}},{key:"toJSON",value:function(){var e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.from||"number"!=typeof n.to||"number"!=typeof n.gapFrom||"number"!=typeof n.gapTo||"number"!=typeof n.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new t(n.from,n.to,n.gapFrom,n.gapTo,Ur.fromJSON(e,n.slice),n.insert,!!n.structure)}}])}(to);function lo(e,t,n){for(var r=e.resolve(t),i=n-t,o=r.depth;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0)for(var a=r.node(o).maybeChild(r.indexAfter(o));i>0;){if(!a||a.isLeaf)return!0;a=a.firstChild,i--}return!1}function ho(e,t,n){for(var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:n.contentMatch,i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=e.doc.nodeAt(t),a=[],s=t+1,c=0;c<o.childCount;c++){var u=o.child(c),l=s+u.nodeSize,d=r.matchType(u.type);if(d){r=d;for(var h=0;h<u.marks.length;h++)n.allowsMarkType(u.marks[h].type)||e.step(new oo(s,l,u.marks[h]));if(i&&u.isText&&"pre"!=n.whitespace)for(var f=void 0,p=/\r?\n|\r/g,v=void 0;f=p.exec(u.text);)v||(v=new Ur(Fr.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),a.push(new co(s+f.index,s+f.index+f[0].length,v))}else a.push(new co(s,l,Ur.empty));s=l}if(!r.validEnd){var m=r.fillBefore(Fr.empty,!0);e.replace(s,s,new Ur(m,0,0))}for(var g=a.length-1;g>=0;g--)e.step(a[g])}function fo(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function po(e){for(var t=e.parent.content.cutByIndex(e.startIndex,e.endIndex),n=e.depth,r=0,i=0;;--n){var o=e.$from.node(n),a=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&o.canReplace(a,s,t))return n;if(0==n||o.type.spec.isolating||!fo(o,a,s))break;a&&(r=1),s<o.childCount&&(i=1)}return null}function vo(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e,i=function(e,t){var n=e.parent,r=e.startIndex,i=e.endIndex,o=n.contentMatchAt(r).findWrapping(t);if(!o)return null;var a=o.length?o[0]:t;return n.canReplaceWith(r,i,a)?o:null}(e,t),o=i&&function(e,t){var n=e.parent,r=e.startIndex,i=e.endIndex,o=n.child(r),a=t.contentMatch.findWrapping(o.type);if(!a)return null;for(var s=(a.length?a[a.length-1]:t).contentMatch,c=r;s&&c<i;c++)s=s.matchType(n.child(c).type);return s&&s.validEnd?a:null}(r,t);return o?i.map(mo).concat({type:t,attrs:n}).concat(o.map(mo)):null}function mo(e){return{type:e,attrs:null}}function go(e,t,n,r){t.forEach(function(i,o){if(i.isText)for(var a,s=/\r?\n|\r/g;a=s.exec(i.text);){var c=e.mapping.slice(r).map(n+1+o+a.index);e.replaceWith(c,c+1,t.type.schema.linebreakReplacement.create())}})}function yo(e,t,n,r){t.forEach(function(i,o){if(i.type==i.type.schema.linebreakReplacement){var a=e.mapping.slice(r).map(n+1+o);e.replaceWith(a,a+1,t.type.schema.text("\n"))}})}function ko(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3?arguments[3]:void 0,i=e.resolve(t),o=i.depth-n,a=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!a.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(var s=i.depth-1,c=n-2;s>o;s--,c--){var u=i.node(s),l=i.index(s);if(u.type.spec.isolating)return!1;var d=u.content.cutByIndex(l,u.childCount),h=r&&r[c+1];h&&(d=d.replaceChild(0,h.type.create(h.attrs)));var f=r&&r[c]||u;if(!u.canReplace(l+1,u.childCount)||!f.type.validContent(d))return!1}var p=i.indexAfter(o),v=r&&r[0];return i.node(o).canReplaceWith(p,p,v?v.type:i.node(o+1).type)}function wo(e,t){var n=e.resolve(t),r=n.index();return bo(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function bo(e,t){return!(!e||!t||e.isLeaf||!function(e,t){t.content.size||e.type.compatibleContent(t.type);for(var n=e.contentMatchAt(e.childCount),r=e.type.schema.linebreakReplacement,i=0;i<t.childCount;i++){var o=t.child(i),a=o.type==r?e.type.schema.nodes.text:o.type;if(!(n=n.matchType(a)))return!1;if(!e.type.allowsMarks(o.marks))return!1}return n.validEnd}(e,t))}function xo(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,r=e.resolve(t),i=r.depth;;i--){var o=void 0,a=void 0,s=r.index(i);if(i==r.depth?(o=r.nodeBefore,a=r.nodeAfter):n>0?(o=r.node(i+1),s++,a=r.node(i).maybeChild(s)):(o=r.node(i).maybeChild(s-1),a=r.node(i+1)),o&&!o.isTextblock&&bo(o,a)&&r.node(i).canReplace(s,s+1))return t;if(0==i)break;t=n<0?r.before(i):r.after(i)}}function Co(e,t,n){var r=e.resolve(t);if(!n.content.size)return t;for(var i=n.content,o=0;o<n.openStart;o++)i=i.firstChild.content;for(var a=1;a<=(0==n.openStart&&n.size?2:1);a++)for(var s=r.depth;s>=0;s--){var c=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,u=r.index(s)+(c>0?1:0),l=r.node(s),d=!1;if(1==a)d=l.canReplace(u,u,i);else{var h=l.contentMatchAt(u).findWrapping(i.firstChild.type);d=h&&l.canReplaceWith(u,u,h[0])}if(d)return 0==c?r.pos:c<0?r.before(s+1):r.after(s+1)}return null}function So(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Ur.empty;if(t==n&&!r.size)return null;var i=e.resolve(t),o=e.resolve(n);return _o(i,o,r)?new co(t,n,r):new Mo(i,o,r).fit()}function _o(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}to.jsonID("replaceAround",uo);var Mo=function(){return S(function e(t,n,r){x(this,e),this.$from=t,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=Fr.empty;for(var i=0;i<=t.depth;i++){var o=t.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(t.indexAfter(i))})}for(var a=t.depth;a>0;a--)this.placed=Fr.from(t.node(a).copy(this.placed))},[{key:"depth",get:function(){return this.frontier.length-1}},{key:"fit",value:function(){for(;this.unplaced.size;){var e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}var t=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(t<0?this.$to:r.doc.resolve(t));if(!i)return null;for(var o=this.placed,a=r.depth,s=i.depth;a&&s&&1==o.childCount;)o=o.firstChild.content,a--,s--;var c=new Ur(o,a,s);return t>-1?new uo(r.pos,t,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new co(r.pos,i.pos,c):null}},{key:"findFittable",value:function(){for(var e=this.unplaced.openStart,t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){var i=t.firstChild;if(t.childCount>1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(var o=1;o<=2;o++)for(var a=1==o?e:this.unplaced.openStart;a>=0;a--)for(var s=null,c=(a?(s=No(this.unplaced.content,a-1).firstChild).content:this.unplaced.content).firstChild,u=this.depth;u>=0;u--){var l=this.frontier[u],d=l.type,h=l.match,f=void 0,p=null;if(1==o&&(c?h.matchType(c.type)||(p=h.fillBefore(Fr.from(c),!1)):s&&d.compatibleContent(s.type)))return{sliceDepth:a,frontierDepth:u,parent:s,inject:p};if(2==o&&c&&(f=h.findWrapping(c.type)))return{sliceDepth:a,frontierDepth:u,parent:s,wrap:f};if(s&&h.matchType(s.type))break}}},{key:"openMore",value:function(){var e=this.unplaced,t=e.content,n=e.openStart,r=e.openEnd,i=No(t,n);return!(!i.childCount||i.firstChild.isLeaf)&&(this.unplaced=new Ur(t,n+1,Math.max(r,i.size+n>=t.size-r?n+1:0)),!0)}},{key:"dropNode",value:function(){var e=this.unplaced,t=e.content,n=e.openStart,r=e.openEnd,i=No(t,n);if(i.childCount<=1&&n>0){var o=t.size-n<=n+i.size;this.unplaced=new Ur(To(t,n-1,1),n-1,o?n-1:r)}else this.unplaced=new Ur(To(t,n,1),n,r)}},{key:"placeNodes",value:function(e){for(var t=e.sliceDepth,n=e.frontierDepth,r=e.parent,i=e.inject,o=e.wrap;this.depth>n;)this.closeFrontierNode();if(o)for(var a=0;a<o.length;a++)this.openFrontierNode(o[a]);var s=this.unplaced,c=r?r.content:s.content,u=s.openStart-t,l=0,d=[],h=this.frontier[n],f=h.match,p=h.type;if(i){for(var v=0;v<i.childCount;v++)d.push(i.child(v));f=f.matchFragment(i)}for(var m=c.size+t-(s.content.size-s.openEnd);l<c.childCount;){var g=c.child(l),y=f.matchType(g.type);if(!y)break;(++l>1||0==u||g.content.size)&&(f=y,d.push(Eo(g.mark(p.allowedMarks(g.marks)),1==l?u:0,l==c.childCount?m:-1)))}var k=l==c.childCount;k||(m=-1),this.placed=Oo(this.placed,n,Fr.from(d)),this.frontier[n].match=f,k&&m<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(var w=0,b=c;w<m;w++){var x=b.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),b=x.content}this.unplaced=k?0==t?Ur.empty:new Ur(To(s.content,t-1,1),t-1,m<0?s.openEnd:t-1):new Ur(To(s.content,t,l),s.openStart,s.openEnd)}},{key:"mustMoveInline",value:function(){if(!this.$to.parent.isTextblock)return-1;var e,t=this.frontier[this.depth];if(!t.type.isTextblock||!Ao(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;for(var n=this.$to.depth,r=this.$to.after(n);n>1&&r==this.$to.end(--n);)++r;return r}},{key:"findCloseLevel",value:function(e){e:for(var t=Math.min(this.depth,e.depth);t>=0;t--){var n=this.frontier[t],r=n.match,i=n.type,o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),a=Ao(e,t,i,r,o);if(a){for(var s=t-1;s>=0;s--){var c=this.frontier[s],u=c.match,l=Ao(e,s,c.type,u,!0);if(!l||l.childCount)continue e}return{depth:t,fit:a,move:o?e.doc.resolve(e.after(t+1)):e}}}}},{key:"close",value:function(e){var t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Oo(this.placed,t.depth,t.fit)),e=t.move;for(var n=t.depth+1;n<=e.depth;n++){var r=e.node(n),i=r.type.contentMatch.fillBefore(r.content,!0,e.index(n));this.openFrontierNode(r.type,r.attrs,i)}return e}},{key:"openFrontierNode",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2?arguments[2]:void 0,r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=Oo(this.placed,this.depth,Fr.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}},{key:"closeFrontierNode",value:function(){var e=this.frontier.pop().match.fillBefore(Fr.empty,!0);e.childCount&&(this.placed=Oo(this.placed,this.frontier.length,e))}}])}();function To(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(To(e.firstChild.content,t-1,n)))}function Oo(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Oo(e.lastChild.content,t-1,n)))}function No(e,t){for(var n=0;n<t;n++)e=e.firstChild.content;return e}function Eo(e,t,n){if(t<=0)return e;var r=e.content;return t>1&&(r=r.replaceChild(0,Eo(r.firstChild,t-1,1==r.childCount?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(Fr.empty,!0)))),e.copy(r)}function Ao(e,t,n,r,i){var o=e.node(t),a=i?e.indexAfter(t):e.index(t);if(a==o.childCount&&!n.compatibleContent(o.type))return null;var s=r.fillBefore(o.content,!0,a);return s&&!function(e,t,n){for(var r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}(n,o.content,a)?s:null}function Do(e){return e.spec.defining||e.spec.definingForContent}function Io(e,t,n,r,i){if(t<n){var o=e.firstChild;e=e.replaceChild(0,o.copy(Io(o.content,t+1,n,r,o)))}if(t>r){var a=i.contentMatchAt(0),s=a.fillBefore(e).append(e);e=s.append(a.matchFragment(s).fillBefore(Fr.empty,!0))}return e}function zo(e,t){for(var n=[],r=Math.min(e.depth,t.depth);r>=0;r--){var i=e.start(r);if(i<e.pos-(e.depth-r)||t.end(r)>t.pos+(t.depth-r)||e.node(r).type.spec.isolating||t.node(r).type.spec.isolating)break;(i==t.start(r)||r==e.depth&&r==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&r&&t.start(r-1)==i-1)&&n.push(r)}return n}var Ro=function(e){function t(e,n,i){var o;return x(this,t),(o=r(this,t)).pos=e,o.attr=n,o.value=i,o}return a(t,e),S(t,[{key:"apply",value:function(e){var t=e.nodeAt(this.pos);if(!t)return no.fail("No node at attribute step's position");var n=Object.create(null);for(var r in t.attrs)n[r]=t.attrs[r];n[this.attr]=this.value;var i=t.type.create(n,null,t.marks);return no.fromReplace(e,this.pos,this.pos+1,new Ur(Fr.from(i),0,t.isLeaf?0:1))}},{key:"getMap",value:function(){return Zi.empty}},{key:"invert",value:function(e){return new t(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}},{key:"map",value:function(e){var n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.attr,this.value)}},{key:"toJSON",value:function(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.pos||"string"!=typeof n.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new t(n.pos,n.attr,n.value)}}])}(to);to.jsonID("attr",Ro);var Po=function(e){function t(e,n){var i;return x(this,t),(i=r(this,t)).attr=e,i.value=n,i}return a(t,e),S(t,[{key:"apply",value:function(e){var t=Object.create(null);for(var n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;var r=e.type.create(t,e.content,e.marks);return no.ok(r)}},{key:"getMap",value:function(){return Zi.empty}},{key:"invert",value:function(e){return new t(this.attr,e.attrs[this.attr])}},{key:"map",value:function(e){return this}},{key:"toJSON",value:function(){return{stepType:"docAttr",attr:this.attr,value:this.value}}}],[{key:"fromJSON",value:function(e,n){if("string"!=typeof n.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new t(n.attr,n.value)}}])}(to);to.jsonID("docAttr",Po);var Lo=Error;((Lo=function e(t){var n=Error.call(this,t);return n.__proto__=e.prototype,n}).prototype=Object.create(Error.prototype)).constructor=Lo,Lo.prototype.name="TransformError";var Bo=function(){return S(function e(t){x(this,e),this.doc=t,this.steps=[],this.docs=[],this.mapping=new Qi},[{key:"before",get:function(){return this.docs.length?this.docs[0]:this.doc}},{key:"step",value:function(e){var t=this.maybeStep(e);if(t.failed)throw new Lo(t.failed);return this}},{key:"maybeStep",value:function(e){var t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}},{key:"docChanged",get:function(){return this.steps.length>0}},{key:"addStep",value:function(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}},{key:"replace",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Ur.empty,r=So(this.doc,e,t,n);return r&&this.step(r),this}},{key:"replaceWith",value:function(e,t,n){return this.replace(e,t,new Ur(Fr.from(n),0,0))}},{key:"delete",value:function(e,t){return this.replace(e,t,Ur.empty)}},{key:"insert",value:function(e,t){return this.replaceWith(e,e,t)}},{key:"replaceRange",value:function(e,t,n){return function(e,t,n,r){if(!r.size)return e.deleteRange(t,n);var i=e.doc.resolve(t),o=e.doc.resolve(n);if(_o(i,o,r))return e.step(new co(t,n,r));var a=zo(i,o);0==a[a.length-1]&&a.pop();var s=-(i.depth+1);a.unshift(s);for(var c=i.depth,u=i.pos-1;c>0;c--,u--){var l=i.node(c).type.spec;if(l.defining||l.definingAsContext||l.isolating)break;a.indexOf(c)>-1?s=c:i.before(c)==u&&a.splice(1,0,-c)}for(var d=a.indexOf(s),h=[],f=r.openStart,p=r.content,v=0;;v++){var m=p.firstChild;if(h.push(m),v==r.openStart)break;p=m.content}for(var g=f-1;g>=0;g--){var y=h[g],k=Do(y.type);if(k&&!y.sameMarkup(i.node(Math.abs(s)-1)))f=g;else if(k||!y.type.isTextblock)break}for(var w=r.openStart;w>=0;w--){var b=(w+f+1)%(r.openStart+1),x=h[b];if(x)for(var C=0;C<a.length;C++){var S=a[(C+d)%a.length],_=!0;S<0&&(_=!1,S=-S);var M=i.node(S-1),T=i.index(S-1);if(M.canReplaceWith(T,T,x.type,x.marks))return e.replace(i.before(S),_?o.after(S):n,new Ur(Io(r.content,0,r.openStart,b),b,r.openEnd))}}for(var O=e.steps.length,N=a.length-1;N>=0&&(e.replace(t,n,r),!(e.steps.length>O));N--){var E=a[N];E<0||(t=i.before(E),n=o.after(E))}}(this,e,t,n),this}},{key:"replaceRangeWith",value:function(e,t,n){return function(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){var i=function(e,t,n){var r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(0==r.parentOffset)for(var i=r.depth-1;i>=0;i--){var o=r.index(i);if(r.node(i).canReplaceWith(o,o,n))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(var a=r.depth-1;a>=0;a--){var s=r.indexAfter(a);if(r.node(a).canReplaceWith(s,s,n))return r.after(a+1);if(s<r.node(a).childCount)return null}return null}(e.doc,t,r.type);null!=i&&(t=n=i)}e.replaceRange(t,n,new Ur(Fr.from(r),0,0))}(this,e,t,n),this}},{key:"deleteRange",value:function(e,t){return function(e,t,n){for(var r=e.doc.resolve(t),i=e.doc.resolve(n),o=zo(r,i),a=0;a<o.length;a++){var s=o[a],c=a==o.length-1;if(c&&0==s||r.node(s).type.contentMatch.validEnd)return e.delete(r.start(s),i.end(s));if(s>0&&(c||r.node(s-1).canReplace(r.index(s-1),i.indexAfter(s-1))))return e.delete(r.before(s),i.after(s))}for(var u=1;u<=r.depth&&u<=i.depth;u++)if(t-r.start(u)==r.depth-u&&n>r.end(u)&&i.end(u)-n!=i.depth-u&&r.start(u-1)==i.start(u-1)&&r.node(u-1).canReplace(r.index(u-1),i.index(u-1)))return e.delete(r.before(u),n);e.delete(t,n)}(this,e,t),this}},{key:"lift",value:function(e,t){return function(e,t,n){for(var r=t.$from,i=t.$to,o=t.depth,a=r.before(o+1),s=i.after(o+1),c=a,u=s,l=Fr.empty,d=0,h=o,f=!1;h>n;h--)f||r.index(h)>0?(f=!0,l=Fr.from(r.node(h).copy(l)),d++):c--;for(var p=Fr.empty,v=0,m=o,g=!1;m>n;m--)g||i.after(m+1)<i.end(m)?(g=!0,p=Fr.from(i.node(m).copy(p)),v++):u++;e.step(new uo(c,u,a,s,new Ur(l.append(p),d,v),l.size-d,!0))}(this,e,t),this}},{key:"join",value:function(e){return function(e,t,n){var r=null,i=e.doc.type.schema.linebreakReplacement,o=e.doc.resolve(t-n),a=o.node().type;if(i&&a.inlineContent){var s="pre"==a.whitespace,c=!!a.contentMatch.matchType(i);s&&!c?r=!1:!s&&c&&(r=!0)}var u=e.steps.length;if(!1===r){var l=e.doc.resolve(t+n);yo(e,l.node(),l.before(),u)}a.inlineContent&&ho(e,t+n-1,a,o.node().contentMatchAt(o.index()),null==r);var d=e.mapping.slice(u),h=d.map(t-n);if(e.step(new co(h,d.map(t+n,-1),Ur.empty,!0)),!0===r){var f=e.doc.resolve(h);go(e,f.node(),f.before(),e.steps.length)}}(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:1),this}},{key:"wrap",value:function(e,t){return function(e,t,n){for(var r=Fr.empty,i=n.length-1;i>=0;i--){if(r.size){var o=n[i].type.contentMatch.matchFragment(r);if(!o||!o.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=Fr.from(n[i].type.create(n[i].attrs,r))}var a=t.start,s=t.end;e.step(new uo(a,s,a,s,new Ur(r,0,0),n.length,!0))}(this,e,t),this}},{key:"setBlockType",value:function(e){return function(e,t,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");var o=e.steps.length;e.doc.nodesBetween(t,n,function(t,n){var a="function"==typeof i?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,a)&&function(e,t,n){var r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}(e.doc,e.mapping.slice(o).map(n),r)){var s=null;if(r.schema.linebreakReplacement){var c="pre"==r.whitespace,u=!!r.contentMatch.matchType(r.schema.linebreakReplacement);c&&!u?s=!1:!c&&u&&(s=!0)}!1===s&&yo(e,t,n,o),ho(e,e.mapping.slice(o).map(n,1),r,void 0,null===s);var l=e.mapping.slice(o),d=l.map(n,1),h=l.map(n+t.nodeSize,1);return e.step(new uo(d,h,d+1,h-1,new Ur(Fr.from(r.create(a,null,t.marks)),0,0),1,!0)),!0===s&&go(e,t,n,o),!1}})}(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,arguments.length>2?arguments[2]:void 0,arguments.length>3&&void 0!==arguments[3]?arguments[3]:null),this}},{key:"setNodeMarkup",value:function(e,t){return function(e,t,n,r,i){var o=e.doc.nodeAt(t);if(!o)throw new RangeError("No node at given position");n||(n=o.type);var a=n.create(r,null,i||o.marks);if(o.isLeaf)return e.replaceWith(t,t+o.nodeSize,a);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new uo(t,t+o.nodeSize,t+1,t+o.nodeSize-1,new Ur(Fr.from(a),0,0),1,!0))}(this,e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,arguments.length>3?arguments[3]:void 0),this}},{key:"setNodeAttribute",value:function(e,t,n){return this.step(new Ro(e,t,n)),this}},{key:"setDocAttribute",value:function(e,t){return this.step(new Po(e,t)),this}},{key:"addNodeMark",value:function(e,t){return this.step(new ao(e,t)),this}},{key:"removeNodeMark",value:function(e,t){var n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof Wr)t.isInSet(n.marks)&&this.step(new so(e,t));else{for(var r,i=n.marks,o=[];r=t.isInSet(i);)o.push(new so(e,r)),i=r.removeFromSet(i);for(var a=o.length-1;a>=0;a--)this.step(o[a])}return this}},{key:"split",value:function(e){return function(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3?arguments[3]:void 0,i=e.doc.resolve(t),o=Fr.empty,a=Fr.empty,s=i.depth,c=i.depth-n,u=n-1;s>c;s--,u--){o=Fr.from(i.node(s).copy(o));var l=r&&r[u];a=Fr.from(l?l.type.create(l.attrs,a):i.node(s).copy(a))}e.step(new co(t,t,new Ur(o.append(a),n,n),!0))}(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,arguments.length>2?arguments[2]:void 0),this}},{key:"addMark",value:function(e,t,n){return function(e,t,n,r){var i,o,a=[],s=[];e.doc.nodesBetween(t,n,function(e,c,u){if(e.isInline){var l=e.marks;if(!r.isInSet(l)&&u.type.allowsMarkType(r.type)){for(var d=Math.max(c,t),h=Math.min(c+e.nodeSize,n),f=r.addToSet(l),p=0;p<l.length;p++)l[p].isInSet(f)||(i&&i.to==d&&i.mark.eq(l[p])?i.to=h:a.push(i=new oo(d,h,l[p])));o&&o.to==d?o.to=h:s.push(o=new io(d,h,r))}}}),a.forEach(function(t){return e.step(t)}),s.forEach(function(t){return e.step(t)})}(this,e,t,n),this}},{key:"removeMark",value:function(e,t,n){return function(e,t,n,r){var i=[],o=0;e.doc.nodesBetween(t,n,function(e,a){if(e.isInline){o++;var s=null;if(r instanceof Ni)for(var c,u=e.marks;c=r.isInSet(u);)(s||(s=[])).push(c),u=c.removeFromSet(u);else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length)for(var l=Math.min(a+e.nodeSize,n),d=0;d<s.length;d++){for(var h=s[d],f=void 0,p=0;p<i.length;p++){var v=i[p];v.step==o-1&&h.eq(i[p].style)&&(f=v)}f?(f.to=l,f.step=o):i.push({style:h,from:Math.max(a,t),to:l,step:o})}}}),i.forEach(function(t){return e.step(new oo(t.from,t.to,t.style))})}(this,e,t,n),this}},{key:"clearIncompatible",value:function(e,t,n){return ho(this,e,t,n),this}}])}(),Vo=Object.create(null),Fo=function(){return S(function e(t,n,r){x(this,e),this.$anchor=t,this.$head=n,this.ranges=r||[new $o(t.min(n),t.max(n))]},[{key:"anchor",get:function(){return this.$anchor.pos}},{key:"head",get:function(){return this.$head.pos}},{key:"from",get:function(){return this.$from.pos}},{key:"to",get:function(){return this.$to.pos}},{key:"$from",get:function(){return this.ranges[0].$from}},{key:"$to",get:function(){return this.ranges[0].$to}},{key:"empty",get:function(){for(var e=this.ranges,t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}},{key:"content",value:function(){return this.$from.doc.slice(this.from,this.to,!0)}},{key:"replace",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ur.empty,n=t.content.lastChild,r=null,i=0;i<t.openEnd;i++)r=n,n=n.lastChild;for(var o=e.steps.length,a=this.ranges,s=0;s<a.length;s++){var c=a[s],u=c.$from,l=c.$to,d=e.mapping.slice(o);e.replaceRange(d.map(u.pos),d.map(l.pos),s?Ur.empty:t),0==s&&Xo(e,o,(n?n.isInline:r&&r.isTextblock)?-1:1)}}},{key:"replaceWith",value:function(e,t){for(var n=e.steps.length,r=this.ranges,i=0;i<r.length;i++){var o=r[i],a=o.$from,s=o.$to,c=e.mapping.slice(n),u=c.map(a.pos),l=c.map(s.pos);i?e.deleteRange(u,l):(e.replaceRangeWith(u,l,t),Xo(e,n,t.isInline?-1:1))}}},{key:"getBookmark",value:function(){return Wo.between(this.$anchor,this.$head).getBookmark()}}],[{key:"findFrom",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=e.parent.inlineContent?new Wo(e):Go(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(var i=e.depth-1;i>=0;i--){var o=t<0?Go(e.node(0),e.node(i),e.before(i+1),e.index(i),t,n):Go(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,n);if(o)return o}return null}},{key:"near",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this.findFrom(e,t)||this.findFrom(e,-t)||new Ko(e.node(0))}},{key:"atStart",value:function(e){return Go(e,e,0,0,1)||new Ko(e)}},{key:"atEnd",value:function(e){return Go(e,e,e.content.size,e.childCount,-1)||new Ko(e)}},{key:"fromJSON",value:function(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");var n=Vo[t.type];if(!n)throw new RangeError("No selection type ".concat(t.type," defined"));return n.fromJSON(e,t)}},{key:"jsonID",value:function(e,t){if(e in Vo)throw new RangeError("Duplicate use of selection JSON ID "+e);return Vo[e]=t,t.prototype.jsonID=e,t}}])}();Fo.prototype.visible=!0;var $o=S(function e(t,n){x(this,e),this.$from=t,this.$to=n}),jo=!1;function Ho(e){jo||e.parent.inlineContent||(jo=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}var Wo=function(t){function n(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;return x(this,n),Ho(e),Ho(t),r(this,n,[e,t])}return a(n,t),S(n,[{key:"$cursor",get:function(){return this.$anchor.pos==this.$head.pos?this.$head:null}},{key:"map",value:function(e,t){var r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return Fo.near(r);var i=e.resolve(t.map(this.anchor));return new n(i.parent.inlineContent?i:r,r)}},{key:"replace",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ur.empty;if(e(n,"replace",this,3)([t,r]),r==Ur.empty){var i=this.$from.marksAcross(this.$to);i&&t.ensureMarks(i)}}},{key:"eq",value:function(e){return e instanceof n&&e.anchor==this.anchor&&e.head==this.head}},{key:"getBookmark",value:function(){return new qo(this.anchor,this.head)}},{key:"toJSON",value:function(){return{type:"text",anchor:this.anchor,head:this.head}}}],[{key:"fromJSON",value:function(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new n(e.resolve(t.anchor),e.resolve(t.head))}},{key:"create",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}},{key:"between",value:function(e,t,r){var i=e.pos-t.pos;if(r&&!i||(r=i>=0?1:-1),!t.parent.inlineContent){var o=Fo.findFrom(t,r,!0)||Fo.findFrom(t,-r,!0);if(!o)return Fo.near(t,r);t=o.$head}return e.parent.inlineContent||(0==i||(e=(Fo.findFrom(e,-r,!0)||Fo.findFrom(e,r,!0)).$anchor).pos<t.pos!=i<0)&&(e=t),new n(e,t)}}])}(Fo);Fo.jsonID("text",Wo);var qo=function(){function e(t,n){x(this,e),this.anchor=t,this.head=n}return S(e,[{key:"map",value:function(t){return new e(t.map(this.anchor),t.map(this.head))}},{key:"resolve",value:function(e){return Wo.between(e.resolve(this.anchor),e.resolve(this.head))}}])}(),Uo=function(e){function t(e){var n;x(this,t);var i=e.nodeAfter,o=e.node(0).resolve(e.pos+i.nodeSize);return(n=r(this,t,[e,o])).node=i,n}return a(t,e),S(t,[{key:"map",value:function(e,n){var r=n.mapResult(this.anchor),i=r.deleted,o=r.pos,a=e.resolve(o);return i?Fo.near(a):new t(a)}},{key:"content",value:function(){return new Ur(Fr.from(this.node),0,0)}},{key:"eq",value:function(e){return e instanceof t&&e.anchor==this.anchor}},{key:"toJSON",value:function(){return{type:"node",anchor:this.anchor}}},{key:"getBookmark",value:function(){return new Jo(this.anchor)}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new t(e.resolve(n.anchor))}},{key:"create",value:function(e,n){return new t(e.resolve(n))}},{key:"isSelectable",value:function(e){return!e.isText&&!1!==e.type.spec.selectable}}])}(Fo);Uo.prototype.visible=!1,Fo.jsonID("node",Uo);var Jo=function(){function e(t){x(this,e),this.anchor=t}return S(e,[{key:"map",value:function(t){var n=t.mapResult(this.anchor),r=n.deleted,i=n.pos;return r?new qo(i,i):new e(i)}},{key:"resolve",value:function(e){var t=e.resolve(this.anchor),n=t.nodeAfter;return n&&Uo.isSelectable(n)?new Uo(t):Fo.near(t)}}])}(),Ko=function(t){function n(e){return x(this,n),r(this,n,[e.resolve(0),e.resolve(e.content.size)])}return a(n,t),S(n,[{key:"replace",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ur.empty;if(r==Ur.empty){t.delete(0,t.doc.content.size);var i=Fo.atStart(t.doc);i.eq(t.selection)||t.setSelection(i)}else e(n,"replace",this,3)([t,r])}},{key:"toJSON",value:function(){return{type:"all"}}},{key:"map",value:function(e){return new n(e)}},{key:"eq",value:function(e){return e instanceof n}},{key:"getBookmark",value:function(){return Yo}}],[{key:"fromJSON",value:function(e){return new n(e)}}])}(Fo);Fo.jsonID("all",Ko);var Yo={map:function(){return this},resolve:function(e){return new Ko(e)}};function Go(e,t,n,r,i){var o=arguments.length>5&&void 0!==arguments[5]&&arguments[5];if(t.inlineContent)return Wo.create(e,n);for(var a=r-(i>0?0:1);i>0?a<t.childCount:a>=0;a+=i){var s=t.child(a);if(s.isAtom){if(!o&&Uo.isSelectable(s))return Uo.create(e,n-(i<0?s.nodeSize:0))}else{var c=Go(e,s,n+i,i<0?s.childCount:0,i,o);if(c)return c}n+=s.nodeSize*i}return null}function Xo(e,t,n){var r=e.steps.length-1;if(!(r<t)){var i,o=e.steps[r];if(o instanceof co||o instanceof uo)e.mapping.maps[r].forEach(function(e,t,n,r){null==i&&(i=r)}),e.setSelection(Fo.near(e.doc.resolve(i),n))}}var Zo=function(t){function n(e){var t;return x(this,n),(t=r(this,n,[e.doc])).curSelectionFor=0,t.updated=0,t.meta=Object.create(null),t.time=Date.now(),t.curSelection=e.selection,t.storedMarks=e.storedMarks,t}return a(n,t),S(n,[{key:"selection",get:function(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}},{key:"setSelection",value:function(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=-3&this.updated|1,this.storedMarks=null,this}},{key:"selectionSet",get:function(){return(1&this.updated)>0}},{key:"setStoredMarks",value:function(e){return this.storedMarks=e,this.updated|=2,this}},{key:"ensureMarks",value:function(e){return Wr.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}},{key:"addStoredMark",value:function(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}},{key:"removeStoredMark",value:function(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}},{key:"storedMarksSet",get:function(){return(2&this.updated)>0}},{key:"addStep",value:function(t,r){e(n,"addStep",this,3)([t,r]),this.updated=-3&this.updated,this.storedMarks=null}},{key:"setTime",value:function(e){return this.time=e,this}},{key:"replaceSelection",value:function(e){return this.selection.replace(this,e),this}},{key:"replaceSelectionWith",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||Wr.none))),n.replaceWith(this,e),this}},{key:"deleteSelection",value:function(){return this.selection.replace(this),this}},{key:"insertText",value:function(e,t,n){var r=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();if(null==n&&(n=t),!e)return this.deleteRange(t,n);var i=this.storedMarks;if(!i){var o=this.doc.resolve(t);i=n==t?o.marks():o.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),this.selection.empty||this.selection.to!=t+e.length||this.setSelection(Fo.near(this.selection.$to)),this}},{key:"setMeta",value:function(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}},{key:"getMeta",value:function(e){return this.meta["string"==typeof e?e:e.key]}},{key:"isGeneric",get:function(){for(var e in this.meta)return!1;return!0}},{key:"scrollIntoView",value:function(){return this.updated|=4,this}},{key:"scrolledIntoView",get:function(){return(4&this.updated)>0}}])}(Bo);function Qo(e,t){return t&&e?e.bind(t):e}var ea=S(function e(t,n,r){x(this,e),this.name=t,this.init=Qo(n.init,r),this.apply=Qo(n.apply,r)}),ta=[new ea("doc",{init:function(e){return e.doc||e.schema.topNodeType.createAndFill()},apply:function(e){return e.doc}}),new ea("selection",{init:function(e,t){return e.selection||Fo.atStart(t.doc)},apply:function(e){return e.selection}}),new ea("storedMarks",{init:function(e){return e.storedMarks||null},apply:function(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new ea("scrollToSelection",{init:function(){return 0},apply:function(e,t){return e.scrolledIntoView?t+1:t}})],na=S(function e(t,n){var r=this;x(this,e),this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=ta.slice(),n&&n.forEach(function(e){if(r.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");r.plugins.push(e),r.pluginsByKey[e.key]=e,e.spec.state&&r.fields.push(new ea(e.key,e.spec.state,e))})}),ra=function(){function e(t){x(this,e),this.config=t}return S(e,[{key:"schema",get:function(){return this.config.schema}},{key:"plugins",get:function(){return this.config.plugins}},{key:"apply",value:function(e){return this.applyTransaction(e).state}},{key:"filterTransaction",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1,n=0;n<this.config.plugins.length;n++)if(n!=t){var r=this.config.plugins[n];if(r.spec.filterTransaction&&!r.spec.filterTransaction.call(r,e,this))return!1}return!0}},{key:"applyTransaction",value:function(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};for(var t=[e],n=this.applyInner(e),r=null;;){for(var i=!1,o=0;o<this.config.plugins.length;o++){var a=this.config.plugins[o];if(a.spec.appendTransaction){var s=r?r[o].n:0,c=r?r[o].state:this,u=s<t.length&&a.spec.appendTransaction.call(a,s?t.slice(s):t,c,n);if(u&&n.filterTransaction(u,o)){if(u.setMeta("appendedTransaction",e),!r){r=[];for(var l=0;l<this.config.plugins.length;l++)r.push(l<o?{state:n,n:t.length}:{state:this,n:0})}t.push(u),n=n.applyInner(u),i=!0}r&&(r[o]={state:n,n:t.length})}}if(!i)return{state:n,transactions:t}}}},{key:"applyInner",value:function(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");for(var n=new e(this.config),r=this.config.fields,i=0;i<r.length;i++){var o=r[i];n[o.name]=o.apply(t,this[o.name],this,n)}return n}},{key:"tr",get:function(){return new Zo(this)}},{key:"reconfigure",value:function(t){for(var n=new na(this.schema,t.plugins),r=n.fields,i=new e(n),o=0;o<r.length;o++){var a=r[o].name;i[a]=this.hasOwnProperty(a)?this[a]:r[o].init(t,i)}return i}},{key:"toJSON",value:function(e){var t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(function(e){return e.toJSON()})),e&&"object"==T(e))for(var n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");var r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}}],[{key:"create",value:function(t){for(var n=new na(t.doc?t.doc.type.schema:t.schema,t.plugins),r=new e(n),i=0;i<n.fields.length;i++)r[n.fields[i].name]=n.fields[i].init(t,r);return r}},{key:"fromJSON",value:function(t,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");var i=new na(t.schema,t.plugins),o=new e(i);return i.fields.forEach(function(e){if("doc"==e.name)o.doc=li.fromJSON(t.schema,n.doc);else if("selection"==e.name)o.selection=Fo.fromJSON(o.doc,n.selection);else if("storedMarks"==e.name)n.storedMarks&&(o.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(r)for(var i in r){var a=r[i],s=a.spec.state;if(a.key==e.name&&s&&s.fromJSON&&Object.prototype.hasOwnProperty.call(n,i))return void(o[e.name]=s.fromJSON.call(a,t,n[i],o))}o[e.name]=e.init(t,o)}}),o}}])}();function ia(e,t,n){for(var r in e){var i=e[r];i instanceof Function?i=i.bind(t):"handleDOMEvents"==r&&(i=ia(i,t,{})),n[r]=i}return n}var oa=function(){return S(function e(t){x(this,e),this.spec=t,this.props={},t.props&&ia(t.props,this,this.props),this.key=t.key?t.key.key:sa("plugin")},[{key:"getState",value:function(e){return e[this.key]}}])}(),aa=Object.create(null);function sa(e){return e in aa?e+"$"+ ++aa[e]:(aa[e]=0,e+"$")}var ca=function(){return S(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"key";x(this,e),this.key=sa(t)},[{key:"get",value:function(e){return e.config.pluginsByKey[this.key]}},{key:"getState",value:function(e){return e[this.key]}}])}();function ua(e,t){var n=e.selection.$cursor;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}function la(e,t,n){for(var r=t.nodeBefore,i=t.pos-1;!r.isTextblock;i--){if(r.type.spec.isolating)return!1;var o=r.lastChild;if(!o)return!1;r=o}for(var a=t.nodeAfter,s=t.pos+1;!a.isTextblock;s++){if(a.type.spec.isolating)return!1;var c=a.firstChild;if(!c)return!1;a=c}var u=So(e.doc,i,s,Ur.empty);if(!u||u.from!=i||u instanceof co&&u.slice.size>=s-i)return!1;if(n){var l=e.tr.step(u);l.setSelection(Wo.create(l.doc,i)),n(l.scrollIntoView())}return!0}function da(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=e;r;r="start"==t?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)return!1}return!1}function ha(e){if(!e.parent.type.spec.isolating)for(var t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function fa(e,t){var n=e.selection.$cursor;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}function pa(e){if(!e.parent.type.spec.isolating)for(var t=e.depth-1;t>=0;t--){var n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}function va(e){for(var t=0;t<e.edgeCount;t++){var n=e.edge(t).type;if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function ma(e,t,n,r){var i,o,a=t.nodeBefore,s=t.nodeAfter,c=a.type.spec.isolating||s.type.spec.isolating;if(!c&&function(e,t,n){var r=t.nodeBefore,i=t.nodeAfter,o=t.index();return!(!(r&&i&&r.type.compatibleContent(i.type))||(!r.content.size&&t.parent.canReplace(o-1,o)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(o,o+1)||!i.isTextblock&&!wo(e.doc,t.pos)||(n&&n(e.tr.join(t.pos).scrollIntoView()),0)))}(e,t,n))return!0;var u=!c&&t.parent.canReplace(t.index(),t.index()+1);if(u&&(i=(o=a.contentMatchAt(a.childCount)).findWrapping(s.type))&&o.matchType(i[0]||s.type).validEnd){if(n){for(var l=t.pos+s.nodeSize,d=Fr.empty,h=i.length-1;h>=0;h--)d=Fr.from(i[h].create(null,d));d=Fr.from(a.copy(d));var f=e.tr.step(new uo(t.pos-1,l,t.pos,l,new Ur(d,1,0),i.length,!0)),p=f.doc.resolve(l+2*i.length);p.nodeAfter&&p.nodeAfter.type==a.type&&wo(f.doc,p.pos)&&f.join(p.pos),n(f.scrollIntoView())}return!0}var v=s.type.spec.isolating||r>0&&c?null:Fo.findFrom(t,1),m=v&&v.$from.blockRange(v.$to),g=m&&po(m);if(null!=g&&g>=t.depth)return n&&n(e.tr.lift(m,g).scrollIntoView()),!0;if(u&&da(s,"start",!0)&&da(a,"end")){for(var y=a,k=[];k.push(y),!y.isTextblock;)y=y.lastChild;for(var w=s,b=1;!w.isTextblock;w=w.firstChild)b++;if(y.canReplace(y.childCount,y.childCount,w.content)){if(n){for(var x=Fr.empty,C=k.length-1;C>=0;C--)x=Fr.from(k[C].copy(x));n(e.tr.step(new uo(t.pos-k.length,t.pos+s.nodeSize,t.pos+b,t.pos+s.nodeSize-b,new Ur(x,k.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function ga(e){return function(t,n){for(var r=t.selection,i=e<0?r.$from:r.$to,o=i.depth;i.node(o).isInline;){if(!o)return!1;o--}return!!i.node(o).isTextblock&&(n&&n(t.tr.setSelection(Wo.create(t.doc,e<0?i.start(o):i.end(o)))),!0)}}var ya=ga(-1),ka=ga(1);function wa(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return function(n,r){for(var i=!1,o=0;o<n.selection.ranges.length&&!i;o++){var a=n.selection.ranges[o],s=a.$from.pos,c=a.$to.pos;n.doc.nodesBetween(s,c,function(r,o){if(i)return!1;if(r.isTextblock&&!r.hasMarkup(e,t))if(r.type==e)i=!0;else{var a=n.doc.resolve(o),s=a.index();i=a.parent.canReplaceWith(s,s+1,e)}})}if(!i)return!1;if(r){for(var u=n.tr,l=0;l<n.selection.ranges.length;l++){var d=n.selection.ranges[l],h=d.$from.pos,f=d.$to.pos;u.setBlockType(h,f,e,t)}r(u.scrollIntoView())}return!0}}function ba(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return function(n,r){var i=n.selection,o=i.$from,a=i.$to,s=o.blockRange(a);if(!s)return!1;var c=r?n.tr:null;return!!function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=!1,o=t,a=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&0==t.startIndex){if(0==t.$from.index(t.depth-1))return!1;var s=a.resolve(t.start-2);o=new ci(s,s,t.depth),t.endIndex<t.parent.childCount&&(t=new ci(t.$from,a.resolve(t.$to.end(t.depth)),t.depth)),i=!0}var c=vo(o,n,r,t);if(!c)return!1;e&&function(e,t,n,r,i){for(var o=Fr.empty,a=n.length-1;a>=0;a--)o=Fr.from(n[a].type.create(n[a].attrs,o));e.step(new uo(t.start-(r?2:0),t.end,t.start,t.end,new Ur(o,0,0),n.length,!0));for(var s=0,c=0;c<n.length;c++)n[c].type==i&&(s=c+1);for(var u=n.length-s,l=t.start+n.length-(r?2:0),d=t.parent,h=t.startIndex,f=t.endIndex,p=!0;h<f;h++,p=!1)!p&&ko(e.doc,l,u)&&(e.split(l,u),l+=2*u),l+=d.child(h).nodeSize}(e,t,c,i,n);return!0}(c,s,e,t)&&(r&&r(c.scrollIntoView()),!0)}}function xa(e){return function(t,n){var r=t.selection,i=r.$from,o=r.$to,a=i.blockRange(o,function(t){return t.childCount>0&&t.firstChild.type==e});return!!a&&(!n||(i.node(a.depth-1).type==e?function(e,t,n,r){var i=e.tr,o=r.end,a=r.$to.end(r.depth);o<a&&(i.step(new uo(o-1,a,o,a,new Ur(Fr.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new ci(i.doc.resolve(r.$from.pos),i.doc.resolve(a),r.depth));var s=po(r);if(null==s)return!1;i.lift(r,s);var c=i.doc.resolve(i.mapping.map(o,-1)-1);wo(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos);return t(i.scrollIntoView()),!0}(t,n,e,a):function(e,t,n){for(var r=e.tr,i=n.parent,o=n.end,a=n.endIndex-1,s=n.startIndex;a>s;a--)o-=i.child(a).nodeSize,r.delete(o-1,o+1);var c=r.doc.resolve(n.start),u=c.nodeAfter;if(r.mapping.map(n.end)!=n.start+c.nodeAfter.nodeSize)return!1;var l=0==n.startIndex,d=n.endIndex==i.childCount,h=c.node(-1),f=c.index(-1);if(!h.canReplace(f+(l?0:1),f+1,u.content.append(d?Fr.empty:Fr.from(i))))return!1;var p=c.pos,v=p+u.nodeSize;return r.step(new uo(p-(l?1:0),v+(d?1:0),p+1,v-1,new Ur((l?Fr.empty:Fr.from(i.copy(Fr.empty))).append(d?Fr.empty:Fr.from(i.copy(Fr.empty))),l?0:1,d?0:1),l?0:1)),t(r.scrollIntoView()),!0}(t,n,a)))}}"undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&os.platform();var Ca=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},Sa=function(e){var t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t},_a=null,Ma=function(e,t,n){var r=_a||(_a=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},Ta=function(e,t,n,r){return n&&(Na(e,t,n,r,-1)||Na(e,t,n,r,1))},Oa=/^(img|br|input|textarea|hr)$/i;function Na(e,t,n,r,i){for(var o;;){if(e==n&&t==r)return!0;if(t==(i<0?0:Ea(e))){var a=e.parentNode;if(!a||1!=a.nodeType||Aa(e)||Oa.test(e.nodeName)||"false"==e.contentEditable)return!1;t=Ca(e)+(i<0?0:1),e=a}else{if(1!=e.nodeType)return!1;var s=e.childNodes[t+(i<0?-1:0)];if(1==s.nodeType&&"false"==s.contentEditable){if(!(null===(o=s.pmViewDesc)||void 0===o?void 0:o.ignoreForSelection))return!1;t+=i}else e=s,t=i<0?Ea(e):0}}}function Ea(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Aa(e){for(var t,n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}var Da=function(e){return e.focusNode&&Ta(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function Ia(e,t){var n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}var za="undefined"!=typeof navigator?navigator:null,Ra="undefined"!=typeof document?document:null,Pa=za&&za.userAgent||"",La=/Edge\/(\d+)/.exec(Pa),Ba=/MSIE \d/.exec(Pa),Va=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Pa),Fa=!!(Ba||Va||La),$a=Ba?document.documentMode:Va?+Va[1]:La?+La[1]:0,ja=!Fa&&/gecko\/(\d+)/i.test(Pa);ja&&(/Firefox\/(\d+)/.exec(Pa)||[0,0])[1];var Ha=!Fa&&/Chrome\/(\d+)/.exec(Pa),Wa=!!Ha,qa=Ha?+Ha[1]:0,Ua=!Fa&&!!za&&/Apple Computer/.test(za.vendor),Ja=Ua&&(/Mobile\/\w+/.test(Pa)||!!za&&za.maxTouchPoints>2),Ka=Ja||!!za&&/Mac/.test(za.platform),Ya=!!za&&/Win/.test(za.platform),Ga=/Android \d/.test(Pa),Xa=!!Ra&&"webkitFontSmoothing"in Ra.documentElement.style,Za=Xa?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Qa(e){var t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function es(e,t){return"number"==typeof e?e:e[t]}function ts(e){var t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function ns(e,t,n){for(var r=e.someProp("scrollThreshold")||0,i=e.someProp("scrollMargin")||5,o=e.dom.ownerDocument,a=n||e.dom;a;)if(1==a.nodeType){var s=a,c=s==o.body,u=c?Qa(o):ts(s),l=0,d=0;if(t.top<u.top+es(r,"top")?d=-(u.top-t.top+es(i,"top")):t.bottom>u.bottom-es(r,"bottom")&&(d=t.bottom-t.top>u.bottom-u.top?t.top+es(i,"top")-u.top:t.bottom-u.bottom+es(i,"bottom")),t.left<u.left+es(r,"left")?l=-(u.left-t.left+es(i,"left")):t.right>u.right-es(r,"right")&&(l=t.right-u.right+es(i,"right")),l||d)if(c)o.defaultView.scrollBy(l,d);else{var h=s.scrollLeft,f=s.scrollTop;d&&(s.scrollTop+=d),l&&(s.scrollLeft+=l);var p=s.scrollLeft-h,v=s.scrollTop-f;t={left:t.left-p,top:t.top-v,right:t.right-p,bottom:t.bottom-v}}var m=c?"fixed":getComputedStyle(a).position;if(/^(fixed|sticky)$/.test(m))break;a="absolute"==m?a.offsetParent:Sa(a)}else a=Sa(a)}function rs(e){for(var t=[],n=e.ownerDocument,r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=Sa(r));return t}function is(e,t){for(var n=0;n<e.length;n++){var r=e[n],i=r.dom,o=r.top,a=r.left;i.scrollTop!=o+t&&(i.scrollTop=o+t),i.scrollLeft!=a&&(i.scrollLeft=a)}}var as=null;function ss(e,t){for(var n,r,i,o,a=2e8,s=0,c=t.top,u=t.top,l=e.firstChild,d=0;l;l=l.nextSibling,d++){var h=void 0;if(1==l.nodeType)h=l.getClientRects();else{if(3!=l.nodeType)continue;h=Ma(l).getClientRects()}for(var f=0;f<h.length;f++){var p=h[f];if(p.top<=c&&p.bottom>=u){c=Math.max(p.bottom,c),u=Math.min(p.top,u);var v=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(v<a){n=l,a=v,r=v&&3==n.nodeType?{left:p.right<t.left?p.right:p.left,top:t.top}:t,1==l.nodeType&&v&&(s=d+(t.left>=(p.left+p.right)/2?1:0));continue}}else p.top>t.top&&!i&&p.left<=t.left&&p.right>=t.left&&(i=l,o={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(s=d+1)}}return!n&&i&&(n=i,r=o,a=0),n&&3==n.nodeType?function(e,t){for(var n,r=e.nodeValue.length,i=document.createRange(),o=0;o<r;o++){i.setEnd(e,o+1),i.setStart(e,o);var a=hs(i,1);if(a.top!=a.bottom&&cs(t,a)){n={node:e,offset:o+(t.left>=(a.left+a.right)/2?1:0)};break}}return i.detach(),n||{node:e,offset:0}}(n,r):!n||a&&1==n.nodeType?{node:e,offset:s}:ss(n,r)}function cs(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function us(e,t,n){var r=e.childNodes.length;if(r&&n.top<n.bottom)for(var i=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),o=i;;){var a=e.childNodes[o];if(1==a.nodeType)for(var s=a.getClientRects(),c=0;c<s.length;c++){var u=s[c];if(cs(t,u))return us(a,t,u)}if((o=(o+1)%r)==i)break}return e}function ls(e,t){var n,r=e.dom.ownerDocument,i=0,o=function(e,t,n){if(e.caretPositionFromPoint)try{var r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(Ea(r.offsetNode),r.offset)}}catch(xt){}if(e.caretRangeFromPoint){var i=e.caretRangeFromPoint(t,n);if(i)return{node:i.startContainer,offset:Math.min(Ea(i.startContainer),i.startOffset)}}}(r,t.left,t.top);o&&(n=o.node,i=o.offset);var a,s=(e.root.elementFromPoint?e.root:r).elementFromPoint(t.left,t.top);if(!s||!e.dom.contains(1!=s.nodeType?s.parentNode:s)){var c=e.dom.getBoundingClientRect();if(!cs(t,c))return null;if(!(s=us(e.dom,t,c)))return null}if(Ua)for(var u=s;n&&u;u=Sa(u))u.draggable&&(n=void 0);if(s=function(e,t){var n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(s,t),n){if(ja&&1==n.nodeType&&(i=Math.min(i,n.childNodes.length))<n.childNodes.length){var l,d=n.childNodes[i];"IMG"==d.nodeName&&(l=d.getBoundingClientRect()).right<=t.left&&l.bottom>t.top&&i++}var h;Xa&&i&&1==n.nodeType&&1==(h=n.childNodes[i-1]).nodeType&&"false"==h.contentEditable&&h.getBoundingClientRect().top>=t.top&&i--,n==e.dom&&i==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?a=e.state.doc.content.size:0!=i&&1==n.nodeType&&"BR"==n.childNodes[i-1].nodeName||(a=function(e,t,n,r){for(var i=-1,o=t,a=!1;o!=e.dom;){var s=e.docView.nearestDesc(o,!0),c=void 0;if(!s)return null;if(1==s.dom.nodeType&&(s.node.isBlock&&s.parent||!s.contentDOM)&&((c=s.dom.getBoundingClientRect()).width||c.height)&&(s.node.isBlock&&s.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(s.dom.nodeName)&&(!a&&c.left>r.left||c.top>r.top?i=s.posBefore:(!a&&c.right<r.left||c.bottom<r.top)&&(i=s.posAfter),a=!0),!s.contentDOM&&i<0&&!s.node.isText))return(s.node.isBlock?r.top<(c.top+c.bottom)/2:r.left<(c.left+c.right)/2)?s.posBefore:s.posAfter;o=s.dom.parentNode}return i>-1?i:e.docView.posFromDOM(t,n,-1)}(e,n,i,t))}null==a&&(a=function(e,t,n){var r=ss(t,n),i=r.node,o=r.offset,a=-1;if(1==i.nodeType&&!i.firstChild){var s=i.getBoundingClientRect();a=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return e.docView.posFromDOM(i,o,a)}(e,s,t));var f=e.docView.nearestDesc(s,!0);return{pos:a,inside:f?f.posAtStart-f.border:-1}}function ds(e){return e.top<e.bottom||e.left<e.right}function hs(e,t){var n=e.getClientRects();if(n.length){var r=n[t<0?0:n.length-1];if(ds(r))return r}return Array.prototype.find.call(n,ds)||e.getBoundingClientRect()}var fs=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function ps(e,t,n){var r=e.docView.domFromPos(t,n<0?-1:1),i=r.node,o=r.offset,a=r.atom,s=Xa||ja;if(3==i.nodeType){if(!s||!fs.test(i.nodeValue)&&(n<0?o:o!=i.nodeValue.length)){var c=o,u=o,l=n<0?1:-1;return n<0&&!o?(u++,l=-1):n>=0&&o==i.nodeValue.length?(c--,l=1):n<0?c--:u++,vs(hs(Ma(i,c,u),l),l<0)}var d=hs(Ma(i,o,o),n);if(ja&&o&&/\s/.test(i.nodeValue[o-1])&&o<i.nodeValue.length){var h=hs(Ma(i,o-1,o-1),-1);if(h.top==d.top){var f=hs(Ma(i,o,o+1),-1);if(f.top!=d.top)return vs(f,f.left<h.left)}}return d}if(!e.state.doc.resolve(t-(a||0)).parent.inlineContent){if(null==a&&o&&(n<0||o==Ea(i))){var p=i.childNodes[o-1];if(1==p.nodeType)return ms(p.getBoundingClientRect(),!1)}if(null==a&&o<Ea(i)){var v=i.childNodes[o];if(1==v.nodeType)return ms(v.getBoundingClientRect(),!0)}return ms(i.getBoundingClientRect(),n>=0)}if(null==a&&o&&(n<0||o==Ea(i))){var m=i.childNodes[o-1],g=3==m.nodeType?Ma(m,Ea(m)-(s?0:1)):1!=m.nodeType||"BR"==m.nodeName&&m.nextSibling?null:m;if(g)return vs(hs(g,1),!1)}if(null==a&&o<Ea(i)){for(var y=i.childNodes[o];y.pmViewDesc&&y.pmViewDesc.ignoreForCoords;)y=y.nextSibling;var k=y?3==y.nodeType?Ma(y,0,s?0:1):1==y.nodeType?y:null:null;if(k)return vs(hs(k,-1),!0)}return vs(hs(3==i.nodeType?Ma(i):i,-n),n>=0)}function vs(e,t){if(0==e.width)return e;var n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function ms(e,t){if(0==e.height)return e;var n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function gs(e,t,n){var r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}var ys=/[\u0590-\u08ac]/;var ks=null,ws=null,bs=!1;function xs(e,t,n){return ks==t&&ws==n?bs:(ks=t,ws=n,bs="up"==n||"down"==n?function(e,t,n){var r=t.selection,i="up"==n?r.$from:r.$to;return gs(e,t,function(){for(var t=e.docView.domFromPos(i.pos,"up"==n?-1:1).node;;){var r=e.docView.nearestDesc(t,!0);if(!r)break;if(r.node.isBlock){t=r.contentDOM||r.dom;break}t=r.dom.parentNode}for(var o=ps(e,i.pos,1),a=t.firstChild;a;a=a.nextSibling){var s=void 0;if(1==a.nodeType)s=a.getClientRects();else{if(3!=a.nodeType)continue;s=Ma(a,0,a.nodeValue.length).getClientRects()}for(var c=0;c<s.length;c++){var u=s[c];if(u.bottom>u.top+1&&("up"==n?o.top-u.top>2*(u.bottom-o.top):u.bottom-o.bottom>2*(o.bottom-u.top)))return!1}}return!0})}(e,t,n):function(e,t,n){var r=t.selection.$head;if(!r.parent.isTextblock)return!1;var i=r.parentOffset,o=!i,a=i==r.parent.content.size,s=e.domSelection();return s?ys.test(r.parent.textContent)&&s.modify?gs(e,t,function(){var t=e.domSelectionRange(),i=t.focusNode,o=t.focusOffset,a=t.anchorNode,c=t.anchorOffset,u=s.caretBidiLevel;s.modify("move",n,"character");var l=r.depth?e.docView.domAfterPos(r.before()):e.dom,d=e.domSelectionRange(),h=d.focusNode,f=d.focusOffset,p=h&&!l.contains(1==h.nodeType?h:h.parentNode)||i==h&&o==f;try{s.collapse(a,c),i&&(i!=a||o!=c)&&s.extend&&s.extend(i,o)}catch(xt){}return null!=u&&(s.caretBidiLevel=u),p}):"left"==n||"backward"==n?o:a:r.pos==r.start()||r.pos==r.end()}(e,t,n))}var Cs=function(){return S(function e(t,n,r,i){x(this,e),this.parent=t,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=0,r.pmViewDesc=this},[{key:"matchesWidget",value:function(e){return!1}},{key:"matchesMark",value:function(e){return!1}},{key:"matchesNode",value:function(e,t,n){return!1}},{key:"matchesHack",value:function(e){return!1}},{key:"parseRule",value:function(){return null}},{key:"stopEvent",value:function(e){return!1}},{key:"size",get:function(){for(var e=0,t=0;t<this.children.length;t++)e+=this.children[t].size;return e}},{key:"border",get:function(){return 0}},{key:"destroy",value:function(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(var e=0;e<this.children.length;e++)this.children[e].destroy()}},{key:"posBeforeChild",value:function(e){for(var t=0,n=this.posAtStart;;t++){var r=this.children[t];if(r==e)return n;n+=r.size}}},{key:"posBefore",get:function(){return this.parent.posBeforeChild(this)}},{key:"posAtStart",get:function(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}},{key:"posAfter",get:function(){return this.posBefore+this.size}},{key:"posAtEnd",get:function(){return this.posAtStart+this.size-2*this.border}},{key:"localPosFromDOM",value:function(e,t,n){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(n<0){var r,i;if(e==this.contentDOM)r=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;r=e.previousSibling}for(;r&&(!(i=r.pmViewDesc)||i.parent!=this);)r=r.previousSibling;return r?this.posBeforeChild(i)+i.size:this.posAtStart}var o,a;if(e==this.contentDOM)o=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&(!(a=o.pmViewDesc)||a.parent!=this);)o=o.nextSibling;return o?this.posBeforeChild(a):this.posAtEnd}var s;if(e==this.dom&&this.contentDOM)s=t>Ca(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(var c=e;;c=c.parentNode){if(c==this.dom){s=!1;break}if(c.previousSibling)break}if(null==s&&t==e.childNodes.length)for(var u=e;;u=u.parentNode){if(u==this.dom){s=!0;break}if(u.nextSibling)break}}return(null==s?n>0:s)?this.posAtEnd:this.posAtStart}},{key:"nearestDesc",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=!0,r=e;r;r=r.parentNode){var i=this.getDesc(r),o=void 0;if(i&&(!t||i.node)){if(!n||!(o=i.nodeDOM)||(1==o.nodeType?o.contains(1==e.nodeType?e:e.parentNode):o==e))return i;n=!1}}}},{key:"getDesc",value:function(e){for(var t=e.pmViewDesc,n=t;n;n=n.parent)if(n==this)return t}},{key:"posFromDOM",value:function(e,t,n){for(var r=e;r;r=r.parentNode){var i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return-1}},{key:"descAt",value:function(e){for(var t=0,n=0;t<this.children.length;t++){var r=this.children[t],i=n+r.size;if(n==e&&i!=n){for(;!r.border&&r.children.length;)for(var o=0;o<r.children.length;o++){var a=r.children[o];if(a.size){r=a;break}}return r}if(e<i)return r.descAt(e-n-r.border);n=i}}},{key:"domFromPos",value:function(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};for(var n,r=0,i=0,o=0;r<this.children.length;r++){var a=this.children[r],s=o+a.size;if(s>e||a instanceof Es){i=e-o;break}o=s}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(;r&&!(n=this.children[r-1]).size&&n instanceof Ss&&n.side>=0;r--);if(t<=0){for(var c,u=!0;(c=r?this.children[r-1]:null)&&c.dom.parentNode!=this.contentDOM;r--,u=!1);return c&&t&&u&&!c.border&&!c.domAtom?c.domFromPos(c.size,t):{node:this.contentDOM,offset:c?Ca(c.dom)+1:0}}for(var l,d=!0;(l=r<this.children.length?this.children[r]:null)&&l.dom.parentNode!=this.contentDOM;r++,d=!1);return l&&d&&!l.border&&!l.domAtom?l.domFromPos(0,t):{node:this.contentDOM,offset:l?Ca(l.dom):this.contentDOM.childNodes.length}}},{key:"parseRange",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};for(var r=-1,i=-1,o=n,a=0;;a++){var s=this.children[a],c=o+s.size;if(-1==r&&e<=c){var u=o+s.border;if(e>=u&&t<=c-s.border&&s.node&&s.contentDOM&&this.contentDOM.contains(s.contentDOM))return s.parseRange(e,t,u);e=o;for(var l=a;l>0;l--){var d=this.children[l-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){r=Ca(d.dom)+1;break}e-=d.size}-1==r&&(r=0)}if(r>-1&&(c>t||a==this.children.length-1)){t=c;for(var h=a+1;h<this.children.length;h++){var f=this.children[h];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){i=Ca(f.dom);break}t+=f.size}-1==i&&(i=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:i}}},{key:"emptyChildAt",value:function(e){if(this.border||!this.contentDOM||!this.children.length)return!1;var t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}},{key:"domAfterPos",value:function(e){var t=this.domFromPos(e,0),n=t.node,r=t.offset;if(1!=n.nodeType||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}},{key:"setSelection",value:function(e,t,n){for(var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=Math.min(e,t),o=Math.max(e,t),a=0,s=0;a<this.children.length;a++){var c=this.children[a],u=s+c.size;if(i>s&&o<u)return c.setSelection(e-s-c.border,t-s-c.border,n,r);s=u}var l=this.domFromPos(e,e?-1:1),d=t==e?l:this.domFromPos(t,t?-1:1),h=n.root.getSelection(),f=n.domSelectionRange(),p=!1;if((ja||Ua)&&e==t){var v=l,m=v.node,g=v.offset;if(3==m.nodeType){if((p=!(!g||"\n"!=m.nodeValue[g-1]))&&g==m.nodeValue.length)for(var y,k=m;k;k=k.parentNode){if(y=k.nextSibling){"BR"==y.nodeName&&(l=d={node:y.parentNode,offset:Ca(y)+1});break}var w=k.pmViewDesc;if(w&&w.node&&w.node.isBlock)break}}else{var b=m.childNodes[g-1];p=b&&("BR"==b.nodeName||"false"==b.contentEditable)}}if(ja&&f.focusNode&&f.focusNode!=d.node&&1==f.focusNode.nodeType){var x=f.focusNode.childNodes[f.focusOffset];x&&"false"==x.contentEditable&&(r=!0)}if(r||p&&Ua||!Ta(l.node,l.offset,f.anchorNode,f.anchorOffset)||!Ta(d.node,d.offset,f.focusNode,f.focusOffset)){var C=!1;if((h.extend||e==t)&&(!p||!ja)){h.collapse(l.node,l.offset);try{e!=t&&h.extend(d.node,d.offset),C=!0}catch(xt){}}if(!C){if(e>t){var S=l;l=d,d=S}var _=document.createRange();_.setEnd(d.node,d.offset),_.setStart(l.node,l.offset),h.removeAllRanges(),h.addRange(_)}}}},{key:"ignoreMutation",value:function(e){return!this.contentDOM&&"selection"!=e.type}},{key:"contentLost",get:function(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}},{key:"markDirty",value:function(e,t){for(var n=0,r=0;r<this.children.length;r++){var i=this.children[r],o=n+i.size;if(n==o?e<=o&&t>=n:e<o&&t>n){var a=n+i.border,s=o-i.border;if(e>=a&&t<=s)return this.dirty=e==n||t==o?2:1,void(e!=a||t!=s||!i.contentLost&&i.dom.parentNode==this.contentDOM?i.markDirty(e-a,t-a):i.dirty=3);i.dirty=i.dom!=i.contentDOM||i.dom.parentNode!=this.contentDOM||i.children.length?3:2}n=o}this.dirty=2}},{key:"markParentsDirty",value:function(){for(var e=1,t=this.parent;t;t=t.parent,e++){var n=1==e?2:1;t.dirty<n&&(t.dirty=n)}}},{key:"domAtom",get:function(){return!1}},{key:"ignoreForCoords",get:function(){return!1}},{key:"ignoreForSelection",get:function(){return!1}},{key:"isText",value:function(e){return!1}}])}(),Ss=function(t){function n(e,t,i,o){var a;x(this,n);var s,c=t.type.toDOM;if("function"==typeof c&&(c=c(i,function(){return s?s.parent?s.parent.posBeforeChild(s):void 0:o})),!t.type.spec.raw){if(1!=c.nodeType){var u=document.createElement("span");u.appendChild(c),c=u}c.contentEditable="false",c.classList.add("ProseMirror-widget")}return(a=r(this,n,[e,[],c,null])).widget=t,a.widget=t,s=a,a}return a(n,t),S(n,[{key:"matchesWidget",value:function(e){return 0==this.dirty&&e.type.eq(this.widget.type)}},{key:"parseRule",value:function(){return{ignore:!0}}},{key:"stopEvent",value:function(e){var t=this.widget.spec.stopEvent;return!!t&&t(e)}},{key:"ignoreMutation",value:function(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}},{key:"destroy",value:function(){this.widget.type.destroy(this.dom),e(n,"destroy",this,3)([])}},{key:"domAtom",get:function(){return!0}},{key:"ignoreForSelection",get:function(){return!!this.widget.type.spec.relaxedSide}},{key:"side",get:function(){return this.widget.type.side}}])}(Cs),_s=function(e){function t(e,n,i,o){var a;return x(this,t),(a=r(this,t,[e,[],n,null])).textDOM=i,a.text=o,a}return a(t,e),S(t,[{key:"size",get:function(){return this.text.length}},{key:"localPosFromDOM",value:function(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}},{key:"domFromPos",value:function(e){return{node:this.textDOM,offset:e}}},{key:"ignoreMutation",value:function(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue}}])}(Cs),Ms=function(t){function n(e,t,i,o,a){var s;return x(this,n),(s=r(this,n,[e,[],i,o])).mark=t,s.spec=a,s}return a(n,t),S(n,[{key:"parseRule",value:function(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}},{key:"matchesMark",value:function(e){return 3!=this.dirty&&this.mark.eq(e)}},{key:"markDirty",value:function(t,r){if(e(n,"markDirty",this,3)([t,r]),0!=this.dirty){for(var i=this.parent;!i.node;)i=i.parent;i.dirty<this.dirty&&(i.dirty=this.dirty),this.dirty=0}}},{key:"slice",value:function(e,t,r){var i=n.create(this.parent,this.mark,!0,r),o=this.children,a=this.size;t<a&&(o=Hs(o,t,a,r)),e>0&&(o=Hs(o,0,e,r));for(var s=0;s<o.length;s++)o[s].parent=i;return i.children=o,i}},{key:"ignoreMutation",value:function(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):e(n,"ignoreMutation",this,3)([t])}},{key:"destroy",value:function(){this.spec.destroy&&this.spec.destroy(),e(n,"destroy",this,3)([])}}],[{key:"create",value:function(e,t,r,i){var o=i.nodeViews[t.type.name],a=o&&o(t,i,r);return a&&a.dom||(a=ji.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new n(e,t,a.dom,a.contentDOM||a.dom,a)}}])}(Cs),Ts=function(e){function t(e,n,i,o,a,s,c,u,l){var d;return x(this,t),(d=r(this,t,[e,[],a,s])).node=n,d.outerDeco=i,d.innerDeco=o,d.nodeDOM=c,d}return a(t,e),S(t,[{key:"parseRule",value:function(){var e=this;if(this.node.type.spec.reparseInView)return null;var 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(var n=this.children.length-1;n>=0;n--){var r=this.children[n];if(this.dom.contains(r.dom.parentNode)){t.contentElement=r.dom.parentNode;break}}t.contentElement||(t.getContent=function(){return Fr.empty})}else t.contentElement=this.contentDOM;else t.getContent=function(){return e.node.content};return t}},{key:"matchesNode",value:function(e,t,n){return 0==this.dirty&&e.eq(this.node)&&Vs(t,this.outerDeco)&&n.eq(this.innerDeco)}},{key:"size",get:function(){return this.node.nodeSize}},{key:"border",get:function(){return this.node.isLeaf?0:1}},{key:"updateChildren",value:function(e,t){var n=this,r=this.node.inlineContent,i=t,o=e.composing?this.localCompositionInfo(e,t):null,a=o&&o.pos>-1?o:null,s=o&&o.pos<0,c=new $s(this,a&&a.node,e);!function(e,t,n,r){var i=t.locals(e),o=0;if(0==i.length){for(var a=0;a<e.childCount;a++){var s=e.child(a);r(s,i,t.forChild(o,s),a),o+=s.nodeSize}return}for(var c=0,u=[],l=null,d=0;;){for(var h=void 0,f=void 0;c<i.length&&i[c].to==o;){var p=i[c++];p.widget&&(h?(f||(f=[h])).push(p):h=p)}if(h)if(f){f.sort(js);for(var v=0;v<f.length;v++)n(f[v],d,!!l)}else n(h,d,!!l);var m=void 0,g=void 0;if(l)g=-1,m=l,l=null;else{if(!(d<e.childCount))break;g=d,m=e.child(d++)}for(var y=0;y<u.length;y++)u[y].to<=o&&u.splice(y--,1);for(;c<i.length&&i[c].from<=o&&i[c].to>o;)u.push(i[c++]);var k=o+m.nodeSize;if(m.isText){var w=k;c<i.length&&i[c].from<w&&(w=i[c].from);for(var b=0;b<u.length;b++)u[b].to<w&&(w=u[b].to);w<k&&(l=m.cut(w-o),m=m.cut(0,w-o),k=w,g=-1)}else for(;c<i.length&&i[c].to<k;)c++;var x=m.isInline&&!m.isLeaf?u.filter(function(e){return!e.inline}):u.slice();r(m,x,t.forChild(o,m),g),o=k}}(this.node,this.innerDeco,function(t,o,a){t.spec.marks?c.syncToMarks(t.spec.marks,r,e):t.type.side>=0&&!a&&c.syncToMarks(o==n.node.childCount?Wr.none:n.node.child(o).marks,r,e),c.placeWidget(t,e,i)},function(t,n,a,u){var l;c.syncToMarks(t.marks,r,e),c.findNodeMatch(t,n,a,u)||s&&e.state.selection.from>i&&e.state.selection.to<i+t.nodeSize&&(l=c.findIndexWithChild(o.node))>-1&&c.updateNodeAt(t,n,a,l,e)||c.updateNextNode(t,n,a,e,u,i)||c.addNode(t,n,a,e,i),i+=t.nodeSize}),c.syncToMarks([],r,e),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||2==this.dirty)&&(a&&this.protectLocalComposition(e,a),Ds(this.contentDOM,this.children,e),Ja&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){var t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}},{key:"localCompositionInfo",value:function(e,t){var n=e.state.selection,r=n.from,i=n.to;if(!(e.state.selection instanceof Wo)||r<t||i>t+this.node.content.size)return null;var o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){var a=o.nodeValue,s=function(e,t,n,r){for(var i=0,o=0;i<e.childCount&&o<=r;){var a=e.child(i++),s=o;if(o+=a.nodeSize,a.isText){for(var c=a.text;i<e.childCount;){var u=e.child(i++);if(o+=u.nodeSize,!u.isText)break;c+=u.text}if(o>=n){if(o>=r&&c.slice(r-t.length-s,r-s)==t)return r-t.length;var l=s<r?c.lastIndexOf(t,r-s-1):-1;if(l>=0&&l+t.length+s>=n)return s+l;if(n==r&&c.length>=r+t.length-s&&c.slice(r-s,r-s+t.length)==t)return r}}}return-1}(this.node.content,a,r-t,i-t);return s<0?null:{node:o,pos:s,text:a}}return{node:o,pos:-1,text:""}}},{key:"protectLocalComposition",value:function(e,t){var n=t.node,r=t.pos,i=t.text;if(!this.getDesc(n)){for(var o=n;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}var a=new _s(this,o,n,i);e.input.compositionNodes.push(a),this.children=Hs(this.children,r,r+i.length,e,a)}}},{key:"update",value:function(e,t,n,r){return!(3==this.dirty||!e.sameMarkup(this.node))&&(this.updateInner(e,t,n,r),!0)}},{key:"updateInner",value:function(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}},{key:"updateOuterDeco",value:function(e){if(!Vs(e,this.outerDeco)){var t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=Ps(this.dom,this.nodeDOM,Rs(this.outerDeco,this.node,t),Rs(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}}},{key:"selectNode",value:function(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.nodeDOM.draggable=!0))}},{key:"deselectNode",value:function(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.nodeDOM.removeAttribute("draggable"))}},{key:"domAtom",get:function(){return this.node.isAtom}}],[{key:"create",value:function(e,n,r,i,o,a){var s,c=o.nodeViews[n.type.name],u=c&&c(n,o,function(){return s?s.parent?s.parent.posBeforeChild(s):void 0:a},r,i),l=u&&u.dom,d=u&&u.contentDOM;if(n.isText)if(l){if(3!=l.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else l=document.createTextNode(n.text);else if(!l){var h=ji.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);l=h.dom,d=h.contentDOM}d||n.isText||"BR"==l.nodeName||(l.hasAttribute("contenteditable")||(l.contentEditable="false"),n.type.spec.draggable&&(l.draggable=!0));var f=l;return l=Bs(l,r,n),u?s=new As(e,n,r,i,l,d||null,f,u,o,a+1):n.isText?new Ns(e,n,r,i,l,f,o):new t(e,n,r,i,l,d||null,f,o,a+1)}}])}(Cs);function Os(e,t,n,r,i){Bs(r,t,e);var o=new Ts(void 0,e,t,n,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}var Ns=function(t){function n(e,t,i,o,a,s,c){return x(this,n),r(this,n,[e,t,i,o,a,null,s,c,0])}return a(n,t),S(n,[{key:"parseRule",value:function(){for(var e=this.nodeDOM.parentNode;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}},{key:"update",value:function(e,t,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!e.sameMarkup(this.node))&&(this.updateOuterDeco(t),0==this.dirty&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=0,!0)}},{key:"inParent",value:function(){for(var e=this.parent.contentDOM,t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}},{key:"domFromPos",value:function(e){return{node:this.nodeDOM,offset:e}}},{key:"localPosFromDOM",value:function(t,r,i){return t==this.nodeDOM?this.posAtStart+Math.min(r,this.node.text.length):e(n,"localPosFromDOM",this,3)([t,r,i])}},{key:"ignoreMutation",value:function(e){return"characterData"!=e.type&&"selection"!=e.type}},{key:"slice",value:function(e,t,r){var i=this.node.cut(e,t),o=document.createTextNode(i.text);return new n(this.parent,i,this.outerDeco,this.innerDeco,o,o,r)}},{key:"markDirty",value:function(t,r){e(n,"markDirty",this,3)([t,r]),this.dom==this.nodeDOM||0!=t&&r!=this.nodeDOM.nodeValue.length||(this.dirty=3)}},{key:"domAtom",get:function(){return!1}},{key:"isText",value:function(e){return this.node.text==e}}])}(Ts),Es=function(e){function t(){return x(this,t),r(this,t,arguments)}return a(t,e),S(t,[{key:"parseRule",value:function(){return{ignore:!0}}},{key:"matchesHack",value:function(e){return 0==this.dirty&&this.dom.nodeName==e}},{key:"domAtom",get:function(){return!0}},{key:"ignoreForCoords",get:function(){return"IMG"==this.dom.nodeName}}])}(Cs),As=function(t){function n(e,t,i,o,a,s,c,u,l,d){var h;return x(this,n),(h=r(this,n,[e,t,i,o,a,s,c,l,d])).spec=u,h}return a(n,t),S(n,[{key:"update",value:function(t,r,i,o){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){var a=this.spec.update(t,r,i);return a&&this.updateInner(t,r,i,o),a}return!(!this.contentDOM&&!t.isLeaf)&&e(n,"update",this,3)([t,r,i,o])}},{key:"selectNode",value:function(){this.spec.selectNode?this.spec.selectNode():e(n,"selectNode",this,3)([])}},{key:"deselectNode",value:function(){this.spec.deselectNode?this.spec.deselectNode():e(n,"deselectNode",this,3)([])}},{key:"setSelection",value:function(t,r,i,o){this.spec.setSelection?this.spec.setSelection(t,r,i.root):e(n,"setSelection",this,3)([t,r,i,o])}},{key:"destroy",value:function(){this.spec.destroy&&this.spec.destroy(),e(n,"destroy",this,3)([])}},{key:"stopEvent",value:function(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}},{key:"ignoreMutation",value:function(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):e(n,"ignoreMutation",this,3)([t])}}])}(Ts);function Ds(e,t,n){for(var r=e.firstChild,i=!1,o=0;o<t.length;o++){var a=t[o],s=a.dom;if(s.parentNode==e){for(;s!=r;)r=Fs(r),i=!0;r=r.nextSibling}else i=!0,e.insertBefore(s,r);if(a instanceof Ms){var c=r?r.previousSibling:e.lastChild;Ds(a.contentDOM,a.children,n),r=c?c.nextSibling:e.firstChild}}for(;r;)r=Fs(r),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}var Is=function(e){e&&(this.nodeName=e)};Is.prototype=Object.create(null);var zs=[new Is];function Rs(e,t,n){if(0==e.length)return zs;for(var r=n?zs[0]:new Is,i=[r],o=0;o<e.length;o++){var a=e[o].type.attrs;if(a)for(var s in a.nodeName&&i.push(r=new Is(a.nodeName)),a){var c=a[s];null!=c&&(n&&1==i.length&&i.push(r=new Is(t.isInline?"span":"div")),"class"==s?r.class=(r.class?r.class+" ":"")+c:"style"==s?r.style=(r.style?r.style+";":"")+c:"nodeName"!=s&&(r[s]=c))}}return i}function Ps(e,t,n,r){if(n==zs&&r==zs)return t;for(var i=t,o=0;o<r.length;o++){var a=r[o],s=n[o];if(o){var c=void 0;s&&s.nodeName==a.nodeName&&i!=e&&(c=i.parentNode)&&c.nodeName.toLowerCase()==a.nodeName||((c=document.createElement(a.nodeName)).pmIsDeco=!0,c.appendChild(i),s=zs[0]),i=c}Ls(i,s||zs[0],a)}return i}function Ls(e,t,n){for(var r in t)"class"==r||"style"==r||"nodeName"==r||r in n||e.removeAttribute(r);for(var i in n)"class"!=i&&"style"!=i&&"nodeName"!=i&&n[i]!=t[i]&&e.setAttribute(i,n[i]);if(t.class!=n.class){for(var o=t.class?t.class.split(" ").filter(Boolean):[],a=n.class?n.class.split(" ").filter(Boolean):[],s=0;s<o.length;s++)-1==a.indexOf(o[s])&&e.classList.remove(o[s]);for(var c=0;c<a.length;c++)-1==o.indexOf(a[c])&&e.classList.add(a[c]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style)for(var u,l=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;u=l.exec(t.style);)e.style.removeProperty(u[1]);n.style&&(e.style.cssText+=n.style)}}function Bs(e,t,n){return Ps(e,e,zs,Rs(t,n,1!=e.nodeType))}function Vs(e,t){if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function Fs(e){var t=e.nextSibling;return e.parentNode.removeChild(e),t}var $s=function(){return S(function e(t,n,r){x(this,e),this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=function(e,t){var n=t,r=n.children.length,i=e.childCount,o=new Map,a=[];e:for(;i>0;){for(var s=void 0;;)if(r){var c=n.children[r-1];if(!(c instanceof Ms)){s=c,r--;break}n=c,r=c.children.length}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}var u=s.node;if(u){if(u!=e.child(i-1))break;--i,o.set(s,i),a.push(s)}}return{index:i,matched:o,matches:a.reverse()}}(t.node.content,t)},[{key:"destroyBetween",value:function(e,t){if(e!=t){for(var n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}},{key:"destroyRest",value:function(){this.destroyBetween(this.index,this.top.children.length)}},{key:"syncToMarks",value:function(e,t,n){for(var r=0,i=this.stack.length>>1,o=Math.min(i,e.length);r<o&&(r==i-1?this.top:this.stack[r+1<<1]).matchesMark(e[r])&&!1!==e[r].type.spec.spanning;)r++;for(;r<i;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);for(var a=-1,s=this.index;s<Math.min(this.index+3,this.top.children.length);s++){var c=this.top.children[s];if(c.matchesMark(e[i])&&!this.isLocked(c.dom)){a=s;break}}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{var u=Ms.create(this.top,e[i],t,n);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,i++}}},{key:"findNodeMatch",value:function(e,t,n,r){var i,o=-1;if(r>=this.preMatch.index&&(i=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,n))o=this.top.children.indexOf(i,this.index);else for(var a=this.index,s=Math.min(this.top.children.length,a+5);a<s;a++){var c=this.top.children[a];if(c.matchesNode(e,t,n)&&!this.preMatch.matched.has(c)){o=a;break}}return!(o<0)&&(this.destroyBetween(this.index,o),this.index++,!0)}},{key:"updateNodeAt",value:function(e,t,n,r,i){var o=this.top.children[r];return 3==o.dirty&&o.dom==o.contentDOM&&(o.dirty=2),!!o.update(e,t,n,i)&&(this.destroyBetween(this.index,r),this.index++,!0)}},{key:"findIndexWithChild",value:function(e){for(;;){var t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){var n=e.pmViewDesc;if(n)for(var r=this.index;r<this.top.children.length;r++)if(this.top.children[r]==n)return r;return-1}e=t}}},{key:"updateNextNode",value:function(e,t,n,r,i,o){for(var a=this.index;a<this.top.children.length;a++){var s=this.top.children[a];if(s instanceof Ts){var c=this.preMatch.matched.get(s);if(null!=c&&c!=i)return!1;var u=s.dom,l=void 0,d=this.isLocked(u)&&!(e.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==e.text&&3!=s.dirty&&Vs(t,s.outerDeco));if(!d&&s.update(e,t,n,r))return this.destroyBetween(this.index,a),s.dom!=u&&(this.changed=!0),this.index++,!0;if(!d&&(l=this.recreateWrapper(s,e,t,n,r,o)))return this.destroyBetween(this.index,a),this.top.children[this.index]=l,l.contentDOM&&(l.dirty=2,l.updateChildren(r,o+1),l.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}},{key:"recreateWrapper",value:function(e,t,n,r,i,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Vs(n,e.outerDeco)||!r.eq(e.innerDeco))return null;var a=Ts.create(this.top,t,n,r,i,o);if(a.contentDOM){a.children=e.children,e.children=[];var s,c=l(a.children);try{for(c.s();!(s=c.n()).done;){s.value.parent=a}}catch(u){c.e(u)}finally{c.f()}}return e.destroy(),a}},{key:"addNode",value:function(e,t,n,r,i){var o=Ts.create(this.top,e,t,n,r,i);o.contentDOM&&o.updateChildren(r,i+1),this.top.children.splice(this.index++,0,o),this.changed=!0}},{key:"placeWidget",value:function(e,t,n){var r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(e)||e!=r.widget&&r.widget.type.toDOM.parentNode){var i=new Ss(this.top,e,t,n);this.top.children.splice(this.index++,0,i),this.changed=!0}else this.index++}},{key:"addTextblockHacks",value:function(){for(var e=this.top.children[this.index-1],t=this.top;e instanceof Ms;)e=(t=e).children[t.children.length-1];(!e||!(e instanceof Ns)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ua||Wa)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}},{key:"addHackNode",value:function(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{var n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");var r=new Es(this.top,[],n,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}},{key:"isLocked",value:function(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}}])}();function js(e,t){return e.type.side-t.type.side}function Hs(e,t,n,r,i){for(var o=[],a=0,s=0;a<e.length;a++){var c=e[a],u=s,l=s+=c.size;u>=n||l<=t?o.push(c):(u<t&&o.push(c.slice(0,t-u,r)),i&&(o.push(i),i=void 0),l>n&&o.push(c.slice(n-u,c.size,r)))}return o}function Ws(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;var i=e.docView.nearestDesc(n.focusNode),o=i&&0==i.size,a=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(a<0)return null;var s,c,u=r.resolve(a);if(Da(n)){for(s=a;i&&!i.node;)i=i.parent;var l=i.node;if(i&&l.isAtom&&Uo.isSelectable(l)&&i.parent&&(!l.isInline||!function(e,t,n){for(var r=0==t,i=t==Ea(e);r||i;){if(e==n)return!0;var o=Ca(e);if(!(e=e.parentNode))return!1;r=r&&0==o,i=i&&o==Ea(e)}}(n.focusNode,n.focusOffset,i.dom))){var h=i.posBefore;c=new Uo(a==h?u:r.resolve(h))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){for(var f=a,p=a,v=0;v<n.rangeCount;v++){var m=n.getRangeAt(v);f=Math.min(f,e.docView.posFromDOM(m.startContainer,m.startOffset,1)),p=Math.max(p,e.docView.posFromDOM(m.endContainer,m.endOffset,-1))}if(f<0)return null;var g=d(p==e.state.selection.anchor?[p,f]:[f,p],2);s=g[0],a=g[1],u=r.resolve(a)}else s=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(s<0)return null}var y=r.resolve(s);c||(c=Qs(e,y,u,"pointer"==t||e.state.selection.head<u.pos&&!o?1:-1));return c}function qs(e){return e.editable?e.hasFocus():tc(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function Us(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=e.state.selection;if(Xs(e,n),qs(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&Wa){var r=e.domSelectionRange(),i=e.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Ta(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset))return e.input.mouseDown.delayedSelectionSync=!0,void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){var t=e.domSelection();if(!t)return;var n=e.cursorWrapper.dom,r="IMG"==n.nodeName;r?t.collapse(n.parentNode,Ca(n)+1):t.collapse(n,0);!r&&!e.state.selection.visible&&Fa&&$a<=11&&(n.disabled=!0,n.disabled=!1)}(e);else{var o,a,s=n.anchor,c=n.head;!Js||n instanceof Wo||(n.$from.parent.inlineContent||(o=Ks(e,n.from)),n.empty||n.$from.parent.inlineContent||(a=Ks(e,n.to))),e.docView.setSelection(s,c,e,t),Js&&(o&&Gs(o),a&&Gs(a)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){var t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);var n=e.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=function(){n.anchorNode==r&&n.anchorOffset==i||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(function(){qs(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")},20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}var Js=Ua||Wa&&qa<63;function Ks(e,t){var n=e.docView.domFromPos(t,0),r=n.node,i=n.offset,o=i<r.childNodes.length?r.childNodes[i]:null,a=i?r.childNodes[i-1]:null;if(Ua&&o&&"false"==o.contentEditable)return Ys(o);if(!(o&&"false"!=o.contentEditable||a&&"false"!=a.contentEditable)){if(o)return Ys(o);if(a)return Ys(a)}}function Ys(e){return e.contentEditable="true",Ua&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function Gs(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function Xs(e,t){if(t instanceof Uo){var n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(Zs(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else Zs(e)}function Zs(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Qs(e,t,n,r){return e.someProp("createSelectionBetween",function(r){return r(e,t,n)})||Wo.between(t,n,r)}function ec(e){return!(e.editable&&!e.hasFocus())&&tc(e)}function tc(e){var t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(xt){return!1}}function nc(e,t){var n=e.selection,r=n.$anchor,i=n.$head,o=t>0?r.max(i):r.min(i),a=o.parent.inlineContent?o.depth?e.doc.resolve(t>0?o.after():o.before()):null:o;return a&&Fo.findFrom(a,t)}function rc(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function ic(e,t,n){var r=e.state.selection;if(!(r instanceof Wo)){if(r instanceof Uo&&r.node.isInline)return rc(e,new Wo(t>0?r.$to:r.$from));var i=nc(e.state,t);return!!i&&rc(e,i)}if(n.indexOf("s")>-1){var o=r.$head,a=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter;if(!a||a.isText||!a.isLeaf)return!1;var s=e.state.doc.resolve(o.pos+a.nodeSize*(t<0?-1:1));return rc(e,new Wo(r.$anchor,s))}if(!r.empty)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){var c=nc(e.state,t);return!!(c&&c instanceof Uo)&&rc(e,c)}if(!(Ka&&n.indexOf("m")>-1)){var u,l=r.$head,d=l.textOffset?null:t<0?l.nodeBefore:l.nodeAfter;if(!d||d.isText)return!1;var h=t<0?l.pos-d.nodeSize:l.pos;return!!(d.isAtom||(u=e.docView.descAt(h))&&!u.contentDOM)&&(Uo.isSelectable(d)?rc(e,new Uo(t<0?e.state.doc.resolve(l.pos-d.nodeSize):l)):!!Xa&&rc(e,new Wo(e.state.doc.resolve(t<0?h:h+d.nodeSize))))}}function oc(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function ac(e,t){var n=e.pmViewDesc;return n&&0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function sc(e,t){return t<0?function(e){var t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;var i,o,a=!1;ja&&1==n.nodeType&&r<oc(n)&&ac(n.childNodes[r],-1)&&(a=!0);for(;;)if(r>0){if(1!=n.nodeType)break;var s=n.childNodes[r-1];if(ac(s,-1))i=n,o=--r;else{if(3!=s.nodeType)break;r=(n=s).nodeValue.length}}else{if(cc(n))break;for(var c=n.previousSibling;c&&ac(c,-1);)i=n.parentNode,o=Ca(c),c=c.previousSibling;if(c)r=oc(n=c);else{if((n=n.parentNode)==e.dom)break;r=0}}a?uc(e,n,r):i&&uc(e,i,o)}(e):function(e){var t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;for(var i,o,a=oc(n);;)if(r<a){if(1!=n.nodeType)break;if(!ac(n.childNodes[r],1))break;i=n,o=++r}else{if(cc(n))break;for(var s=n.nextSibling;s&&ac(s,1);)i=s.parentNode,o=Ca(s)+1,s=s.nextSibling;if(s)r=0,a=oc(n=s);else{if((n=n.parentNode)==e.dom)break;r=a=0}}i&&uc(e,i,o)}(e)}function cc(e){var t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function uc(e,t,n){var r,i;3!=t.nodeType&&((i=function(e,t){for(;e&&t==e.childNodes.length&&!Aa(e);)t=Ca(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){var n=e.childNodes[t];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=n,t=0}}(t,n))?(t=i,n=0):(r=function(e,t){for(;e&&!t&&!Aa(e);)t=Ca(e),e=e.parentNode;for(;e&&t;){var n=e.childNodes[t-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=(e=n).childNodes.length}}(t,n))&&(t=r,n=r.nodeValue.length));var o=e.domSelection();if(o){if(Da(o)){var a=document.createRange();a.setEnd(t,n),a.setStart(t,n),o.removeAllRanges(),o.addRange(a)}else o.extend&&o.extend(t,n);e.domObserver.setCurSelection();var s=e.state;setTimeout(function(){e.state==s&&Us(e)},50)}}function lc(e,t){var n=e.state.doc.resolve(t);if(!Wa&&!Ya&&n.parent.inlineContent){var r=e.coordsAtPos(t);if(t>n.start()){var i=e.coordsAtPos(t-1),o=(i.top+i.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(i.left-r.left)>1)return i.left<r.left?"ltr":"rtl"}if(t<n.end()){var a=e.coordsAtPos(t+1),s=(a.top+a.bottom)/2;if(s>r.top&&s<r.bottom&&Math.abs(a.left-r.left)>1)return a.left>r.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function dc(e,t,n){var r=e.state.selection;if(r instanceof Wo&&!r.empty||n.indexOf("s")>-1)return!1;if(Ka&&n.indexOf("m")>-1)return!1;var i=r.$from,o=r.$to;if(!i.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){var a=nc(e.state,t);if(a&&a instanceof Uo)return rc(e,a)}if(!i.parent.inlineContent){var s=t<0?i:o,c=r instanceof Ko?Fo.near(s,t):Fo.findFrom(s,t);return!!c&&rc(e,c)}return!1}function hc(e,t){if(!(e.state.selection instanceof Wo))return!0;var n=e.state.selection,r=n.$head,i=n.$anchor,o=n.empty;if(!r.sameParent(i))return!0;if(!o)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;var a=!r.textOffset&&(t<0?r.nodeBefore:r.nodeAfter);if(a&&!a.isText){var s=e.state.tr;return t<0?s.delete(r.pos-a.nodeSize,r.pos):s.delete(r.pos,r.pos+a.nodeSize),e.dispatch(s),!0}return!1}function fc(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function pc(e,t){var n=t.keyCode,r=function(e){var t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);if(8==n||Ka&&72==n&&"c"==r)return hc(e,-1)||sc(e,-1);if(46==n&&!t.shiftKey||Ka&&68==n&&"c"==r)return hc(e,1)||sc(e,1);if(13==n||27==n)return!0;if(37==n||Ka&&66==n&&"c"==r){var i=37==n?"ltr"==lc(e,e.state.selection.from)?-1:1:-1;return ic(e,i,r)||sc(e,i)}if(39==n||Ka&&70==n&&"c"==r){var o=39==n?"ltr"==lc(e,e.state.selection.from)?1:-1:1;return ic(e,o,r)||sc(e,o)}return 38==n||Ka&&80==n&&"c"==r?dc(e,-1,r)||sc(e,-1):40==n||Ka&&78==n&&"c"==r?function(e){if(!Ua||e.state.selection.$head.parentOffset>0)return!1;var t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(n&&1==n.nodeType&&0==r&&n.firstChild&&"false"==n.firstChild.contentEditable){var i=n.firstChild;fc(e,i,"true"),setTimeout(function(){return fc(e,i,"false")},20)}return!1}(e)||dc(e,1,r)||sc(e,1):r==(Ka?"m":"c")&&(66==n||73==n||89==n||90==n)}function vc(e,t){e.someProp("transformCopied",function(n){t=n(t,e)});for(var n=[],r=t,i=r.content,o=r.openStart,a=r.openEnd;o>1&&a>1&&1==i.childCount&&1==i.firstChild.childCount;){o--,a--;var s=i.firstChild;n.push(s.type.name,s.attrs!=s.type.defaultAttrs?s.attrs:null),i=s.content}var c=e.someProp("clipboardSerializer")||ji.fromSchema(e.state.schema),u=_c(),l=u.createElement("div");l.appendChild(c.serializeFragment(i,{document:u}));for(var d,h=l.firstChild,f=0;h&&1==h.nodeType&&(d=Cc[h.nodeName.toLowerCase()]);){for(var p=d.length-1;p>=0;p--){for(var v=u.createElement(d[p]);l.firstChild;)v.appendChild(l.firstChild);l.appendChild(v),f++}h=l.firstChild}h&&1==h.nodeType&&h.setAttribute("data-pm-slice","".concat(o," ").concat(a).concat(f?" -".concat(f):""," ").concat(JSON.stringify(n)));var m=e.someProp("clipboardTextSerializer",function(n){return n(t,e)})||t.content.textBetween(0,t.content.size,"\n\n");return{dom:l,text:m,slice:t}}function mc(e,t,n,r,i){var o,a,s=i.parent.type.spec.code;if(!n&&!t)return null;var c=!!t&&(r||s||!n);if(c){if(e.someProp("transformPastedText",function(n){t=n(t,s||r,e)}),s)return a=new Ur(Fr.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0),e.someProp("transformPasted",function(t){a=t(a,e,!0)}),a;var u=e.someProp("clipboardTextParser",function(n){return n(t,i,r,e)});if(u)a=u;else{var l=i.marks(),d=e.state.schema,h=ji.fromSchema(d);o=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(function(e){var t=o.appendChild(document.createElement("p"));e&&t.appendChild(h.serializeNode(d.text(e,l)))})}}else e.someProp("transformPastedHTML",function(t){n=t(n,e)}),o=function(e){var t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));var n,r=_c().createElement("div"),i=/<([a-z][^>\s]+)/i.exec(e);(n=i&&Cc[i[1].toLowerCase()])&&(e=n.map(function(e){return"<"+e+">"}).join("")+e+n.map(function(e){return"</"+e+">"}).reverse().join(""));if(r.innerHTML=function(e){var t=window.trustedTypes;if(!t)return e;Mc||(Mc=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:function(e){return e}}));return Mc.createHTML(e)}(e),n)for(var o=0;o<n.length;o++)r=r.querySelector(n[o])||r;return r}(n),Xa&&function(e){for(var t=e.querySelectorAll(Wa?"span:not([class]):not([style])":"span.Apple-converted-space"),n=0;n<t.length;n++){var r=t[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}(o);var f=o&&o.querySelector("[data-pm-slice]"),p=f&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(f.getAttribute("data-pm-slice")||"");if(p&&p[3])for(var v=+p[3];v>0;v--){for(var m=o.firstChild;m&&1!=m.nodeType;)m=m.nextSibling;if(!m)break;o=m}if(!a){var g=e.someProp("clipboardParser")||e.someProp("domParser")||Di.fromSchema(e.state.schema);a=g.parseSlice(o,{preserveWhitespace:!(!c&&!p),context:i,ruleFromNode:function(e){return"BR"!=e.nodeName||e.nextSibling||!e.parentNode||gc.test(e.parentNode.nodeName)?null:{ignore:!0}}})}if(p)a=function(e,t){if(!e.size)return e;var n,r=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(pt){return e}for(var i=e.content,o=e.openStart,a=e.openEnd,s=n.length-2;s>=0;s-=2){var c=r.nodes[n[s]];if(!c||c.hasRequiredAttrs())break;i=Fr.from(c.create(n[s+1],i)),o++,a++}return new Ur(i,o,a)}(xc(a,+p[1],+p[2]),p[4]);else if(a=Ur.maxOpen(function(e,t){if(e.childCount<2)return e;for(var n,r=function(){var n,r=t.node(i).contentMatchAt(t.index(i)),o=[];if(e.forEach(function(e){if(o){var t,i=r.findWrapping(e.type);if(!i)return o=null;if(t=o.length&&n.length&&kc(i,n,e,o[o.length-1],0))o[o.length-1]=t;else{o.length&&(o[o.length-1]=wc(o[o.length-1],n.length));var a=yc(e,i);o.push(a),r=r.matchType(a.type),n=i}}}),o)return{v:Fr.from(o)}},i=t.depth;i>=0;i--)if(n=r())return n.v;return e}(a.content,i),!0),a.openStart||a.openEnd){for(var y=0,k=0,w=a.content.firstChild;y<a.openStart&&!w.type.spec.isolating;y++,w=w.firstChild);for(var b=a.content.lastChild;k<a.openEnd&&!b.type.spec.isolating;k++,b=b.lastChild);a=xc(a,y,k)}return e.someProp("transformPasted",function(t){a=t(a,e,c)}),a}var gc=/^(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 yc(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=t.length-1;r>=n;r--)e=t[r].create(null,Fr.from(e));return e}function kc(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){var o=kc(e,t,n,r.lastChild,i+1);if(o)return r.copy(r.content.replaceChild(r.childCount-1,o));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(Fr.from(yc(n,e,i+1))))}}function wc(e,t){if(0==t)return e;var n=e.content.replaceChild(e.childCount-1,wc(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(Fr.empty,!0);return e.copy(n.append(r))}function bc(e,t,n,r,i,o){var a=t<0?e.firstChild:e.lastChild,s=a.content;return e.childCount>1&&(o=0),i<r-1&&(s=bc(s,t,n,r,i+1,o)),i>=n&&(s=t<0?a.contentMatchAt(0).fillBefore(s,o<=i).append(s):s.append(a.contentMatchAt(a.childCount).fillBefore(Fr.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,a.copy(s))}function xc(e,t,n){return t<e.openStart&&(e=new Ur(bc(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new Ur(bc(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var Cc={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},Sc=null;function _c(){return Sc||(Sc=document.implementation.createHTMLDocument("title"))}var Mc=null;var Tc={},Oc={},Nc={touchstart:!0,touchmove:!0},Ec=S(function e(){x(this,e),this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null});function Ac(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Dc(e){e.someProp("handleDOMEvents",function(t){for(var n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=function(t){return Ic(e,t)})})}function Ic(e,t){return e.someProp("handleDOMEvents",function(n){var r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)})}function zc(e){return{left:e.clientX,top:e.clientY}}function Rc(e,t,n,r,i){if(-1==r)return!1;for(var o,a=e.state.doc.resolve(r),s=function(r){if(e.someProp(t,function(t){return r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)}))return{v:!0}},c=a.depth+1;c>0;c--)if(o=s(c))return o.v;return!1}function Pc(e,t,n){if(e.focused||e.focus(),!e.state.selection.eq(t)){var r=e.state.tr.setSelection(t);"pointer"==n&&r.setMeta("pointer",!0),e.dispatch(r)}}function Lc(e,t,n,r,i){return Rc(e,"handleClickOn",t,n,r)||e.someProp("handleClick",function(n){return n(e,t,r)})||(i?function(e,t){if(-1==t)return!1;var n,r,i=e.state.selection;i instanceof Uo&&(n=i.node);for(var o=e.state.doc.resolve(t),a=o.depth+1;a>0;a--){var s=a>o.depth?o.nodeAfter:o.node(a);if(Uo.isSelectable(s)){r=n&&i.$from.depth>0&&a>=i.$from.depth&&o.before(i.$from.depth+1)==i.$from.pos?o.before(i.$from.depth):o.before(a);break}}return null!=r&&(Pc(e,Uo.create(e.state.doc,r),"pointer"),!0)}(e,n):function(e,t){if(-1==t)return!1;var n=e.state.doc.resolve(t),r=n.nodeAfter;return!!(r&&r.isAtom&&Uo.isSelectable(r))&&(Pc(e,new Uo(n),"pointer"),!0)}(e,n))}function Bc(e,t,n,r){return Rc(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",function(n){return n(e,t,r)})}function Vc(e,t,n,r){return Rc(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",function(n){return n(e,t,r)})||function(e,t,n){if(0!=n.button)return!1;var r=e.state.doc;if(-1==t)return!!r.inlineContent&&(Pc(e,Wo.create(r,0,r.content.size),"pointer"),!0);for(var i=r.resolve(t),o=i.depth+1;o>0;o--){var a=o>i.depth?i.nodeAfter:i.node(o),s=i.before(o);if(a.inlineContent)Pc(e,Wo.create(r,s+1,s+1+a.content.size),"pointer");else{if(!Uo.isSelectable(a))continue;Pc(e,Uo.create(r,s),"pointer")}return!0}}(e,n,r)}function Fc(e){return Kc(e)}Oc.keydown=function(e,t){var n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!Hc(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!Ga||!Wa||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!Ja||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",function(t){return t(e,n)})||pc(e,n)?n.preventDefault():Ac(e,"key");else{var r=Date.now();e.input.lastIOSEnter=r,e.input.lastIOSEnterFallbackTimeout=setTimeout(function(){e.input.lastIOSEnter==r&&(e.someProp("handleKeyDown",function(t){return t(e,Ia(13,"Enter"))}),e.input.lastIOSEnter=0)},200)}},Oc.keyup=function(e,t){16==t.keyCode&&(e.input.shiftKey=!1)},Oc.keypress=function(e,t){var n=t;if(!(Hc(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||Ka&&n.metaKey))if(e.someProp("handleKeyPress",function(t){return t(e,n)}))n.preventDefault();else{var r=e.state.selection;if(!(r instanceof Wo&&r.$from.sameParent(r.$to))){var i=String.fromCharCode(n.charCode),o=function(){return e.state.tr.insertText(i).scrollIntoView()};/[\r\n]/.test(i)||e.someProp("handleTextInput",function(t){return t(e,r.$from.pos,r.$to.pos,i,o)})||e.dispatch(o()),n.preventDefault()}}};var $c=Ka?"metaKey":"ctrlKey";Tc.mousedown=function(e,t){var n=t;e.input.shiftKey=n.shiftKey;var r=Fc(e),i=Date.now(),o="singleClick";i-e.input.lastClick.time<500&&function(e,t){var n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}(n,e.input.lastClick)&&!n[$c]&&e.input.lastClick.button==n.button&&("singleClick"==e.input.lastClick.type?o="doubleClick":"doubleClick"==e.input.lastClick.type&&(o="tripleClick")),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:o,button:n.button};var a=e.posAtCoords(zc(n));a&&("singleClick"==o?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new jc(e,a,n,!!r)):("doubleClick"==o?Bc:Vc)(e,a.pos,a.inside,n)?n.preventDefault():Ac(e,"pointer"))};var jc=function(){return S(function e(t,n,r,i){var o,a,s=this;if(x(this,e),this.view=t,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!r[$c],this.allowDefault=r.shiftKey,n.inside>-1)o=t.state.doc.nodeAt(n.inside),a=n.inside;else{var c=t.state.doc.resolve(n.pos);o=c.parent,a=c.depth?c.before():0}var u=i?null:r.target,l=u?t.docView.nearestDesc(u,!0):null;this.target=l&&1==l.nodeDOM.nodeType?l.nodeDOM:null;var d=t.state.selection;(0==r.button&&o.type.spec.draggable&&!1!==o.type.spec.selectable||d instanceof Uo&&d.from<=a&&d.to>a)&&(this.mightDrag={node:o,pos:a,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!ja||this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(function(){s.view.input.mouseDown==s&&s.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)),Ac(t,"pointer")},[{key:"done",value:function(){var e=this;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(function(){return Us(e.view)}),this.view.input.mouseDown=null}},{key:"up",value:function(e){if(this.done(),this.view.dom.contains(e.target)){var t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(zc(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ac(this.view,"pointer"):Lc(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||Ua&&this.mightDrag&&!this.mightDrag.node.isAtom||Wa&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Pc(this.view,Fo.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Ac(this.view,"pointer")}}},{key:"move",value:function(e){this.updateAllowDefault(e),Ac(this.view,"pointer"),0==e.buttons&&this.done()}},{key:"updateAllowDefault",value:function(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}])}();function Hc(e,t){return!!e.composing||!!(Ua&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}Tc.touchstart=function(e){e.input.lastTouch=Date.now(),Fc(e),Ac(e,"pointer")},Tc.touchmove=function(e){e.input.lastTouch=Date.now(),Ac(e,"pointer")},Tc.contextmenu=function(e){return Fc(e)};var Wc=Ga?5e3:-1;function qc(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(function(){return Kc(e)},t))}function Uc(e){var t;for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=((t=document.createEvent("Event")).initEvent("event",!0,!0),t.timeStamp));e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function Jc(e){var t=e.domSelectionRange();if(!t.focusNode)return null;var n=function(e,t){for(;;){if(3==e.nodeType&&t)return e;if(1==e.nodeType&&t>0){if("false"==e.contentEditable)return null;t=Ea(e=e.childNodes[t-1])}else{if(!e.parentNode||Aa(e))return null;t=Ca(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),r=function(e,t){for(;;){if(3==e.nodeType&&t<e.nodeValue.length)return e;if(1==e.nodeType&&t<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[t],t=0}else{if(!e.parentNode||Aa(e))return null;t=Ca(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(n&&r&&n!=r){var i=r.pmViewDesc,o=e.domObserver.lastChangedTextNode;if(n==o||r==o)return o;if(!i||!i.isText(r.nodeValue))return r;if(e.input.compositionNode==r){var a=n.pmViewDesc;if(a&&a.isText(n.nodeValue))return r}}return n||r}function Kc(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!(Ga&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),Uc(e),t||e.docView&&e.docView.dirty){var n=Ws(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):!e.markCursor&&!t||r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.updateState(e.state):e.dispatch(e.state.tr.deleteSelection()),!0}return!1}}Oc.compositionstart=Oc.compositionupdate=function(e){if(!e.composing){e.domObserver.flush();var t=e.state,n=t.selection.$to;if(t.selection instanceof Wo&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(function(e){return!1===e.type.spec.inclusive})||Wa&&Ya&&function(e){var t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n||1!=n.nodeType||r>=n.childNodes.length)return!1;var i=n.childNodes[r];return 1==i.nodeType&&"false"==i.contentEditable}(e)))e.markCursor=e.state.storedMarks||n.marks(),Kc(e,!0),e.markCursor=null;else if(Kc(e,!t.selection.empty),ja&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length)for(var r=e.domSelectionRange(),i=r.focusNode,o=r.focusOffset;i&&1==i.nodeType&&0!=o;){var a=o<0?i.lastChild:i.childNodes[o-1];if(!a)break;if(3==a.nodeType){var s=e.domSelection();s&&s.collapse(a,a.nodeValue.length);break}i=a,o=-1}e.input.composing=!0}qc(e,Wc)},Oc.compositionend=function(e,t){e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.compositionPendingChanges&&Promise.resolve().then(function(){return e.domObserver.flush()}),e.input.compositionID++,qc(e,20))};var Yc=Fa&&$a<15||Ja&&Za<604;function Gc(e,t,n,r,i){var o=mc(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",function(t){return t(e,i,o||Ur.empty)}))return!0;if(!o)return!1;var a=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(o),s=a?e.state.tr.replaceSelectionWith(a,r):e.state.tr.replaceSelection(o);return e.dispatch(s.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Xc(e){var t=e.getData("text/plain")||e.getData("Text");if(t)return t;var n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Tc.copy=Oc.cut=function(e,t){var n=t,r=e.state.selection,i="cut"==n.type;if(!r.empty){var o=Yc?null:n.clipboardData,a=vc(e,r.content()),s=a.dom,c=a.text;o?(n.preventDefault(),o.clearData(),o.setData("text/html",s.innerHTML),o.setData("text/plain",c)):function(e,t){if(e.dom.parentNode){var n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";var r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(function(){n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}}(e,s),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))}},Oc.paste=function(e,t){var n=t;if(!e.composing||Ga){var r=Yc?null:n.clipboardData,i=e.input.shiftKey&&45!=e.input.lastKeyCode;r&&Gc(e,Xc(r),r.getData("text/html"),i,n)?n.preventDefault():function(e,t){if(e.dom.parentNode){var n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();var i=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout(function(){e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Gc(e,r.value,null,i,t):Gc(e,r.textContent,r.innerHTML,i,t)},50)}}(e,n)}};var Zc=S(function e(t,n,r){x(this,e),this.slice=t,this.move=n,this.node=r}),Qc=Ka?"altKey":"ctrlKey";function eu(e,t){var n=e.someProp("dragCopies",function(e){return!e(t)});return null!=n?n:!t[Qc]}for(var tu in Tc.dragstart=function(e,t){var n=t,r=e.input.mouseDown;if(r&&r.done(),n.dataTransfer){var i,o=e.state.selection,a=o.empty?null:e.posAtCoords(zc(n));if(a&&a.pos>=o.from&&a.pos<=(o instanceof Uo?o.to-1:o.to));else if(r&&r.mightDrag)i=Uo.create(e.state.doc,r.mightDrag.pos);else if(n.target&&1==n.target.nodeType){var s=e.docView.nearestDesc(n.target,!0);s&&s.node.type.spec.draggable&&s!=e.docView&&(i=Uo.create(e.state.doc,s.posBefore))}var c=vc(e,(i||e.state.selection).content()),u=c.dom,l=c.text,d=c.slice;(!n.dataTransfer.files.length||!Wa||qa>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Yc?"Text":"text/html",u.innerHTML),n.dataTransfer.effectAllowed="copyMove",Yc||n.dataTransfer.setData("text/plain",l),e.dragging=new Zc(d,eu(e,n),i)}},Tc.dragend=function(e){var t=e.dragging;window.setTimeout(function(){e.dragging==t&&(e.dragging=null)},50)},Oc.dragover=Oc.dragenter=function(e,t){return t.preventDefault()},Oc.drop=function(e,t){try{!function(e,t,n){if(!t.dataTransfer)return;var r=e.posAtCoords(zc(t));if(!r)return;var i=e.state.doc.resolve(r.pos),o=n&&n.slice;o?e.someProp("transformPasted",function(t){o=t(o,e,!1)}):o=mc(e,Xc(t.dataTransfer),Yc?null:t.dataTransfer.getData("text/html"),!1,i);var a=!(!n||!eu(e,t));if(e.someProp("handleDrop",function(n){return n(e,t,o||Ur.empty,a)}))return void t.preventDefault();if(!o)return;t.preventDefault();var s=o?Co(e.state.doc,i.pos,o):i.pos;null==s&&(s=i.pos);var c=e.state.tr;if(a){var u=n.node;u?u.replace(c):c.deleteSelection()}var l=c.mapping.map(s),d=0==o.openStart&&0==o.openEnd&&1==o.content.childCount,h=c.doc;d?c.replaceRangeWith(l,l,o.content.firstChild):c.replaceRange(l,l,o);if(c.doc.eq(h))return;var f=c.doc.resolve(l);if(d&&Uo.isSelectable(o.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new Uo(f));else{var p=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach(function(e,t,n,r){return p=r}),c.setSelection(Qs(e,f,c.doc.resolve(p)))}e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))}(e,t,e.dragging)}finally{e.dragging=null}},Tc.focus=function(e){e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(function(){e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&Us(e)},20))},Tc.blur=function(e,t){var n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},Tc.beforeinput=function(e,t){if(Wa&&Ga&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();var n=e.input.domChangeCount;setTimeout(function(){if(e.input.domChangeCount==n&&(e.dom.blur(),e.focus(),!e.someProp("handleKeyDown",function(t){return t(e,Ia(8,"Backspace"))}))){var t=e.state.selection.$cursor;t&&t.pos>0&&e.dispatch(e.state.tr.delete(t.pos-1,t.pos).scrollIntoView())}},50)}},Oc)Tc[tu]=Oc[tu];function nu(e,t){if(e==t)return!0;for(var n in e)if(e[n]!==t[n])return!1;for(var r in t)if(!(r in e))return!1;return!0}var ru=function(){function e(t,n){x(this,e),this.toDOM=t,this.spec=n||cu,this.side=this.spec.side||0}return S(e,[{key:"map",value:function(e,t,n,r){var i=e.mapResult(t.from+r,this.side<0?-1:1),o=i.pos;return i.deleted?null:new au(o-n,o-n,this)}},{key:"valid",value:function(){return!0}},{key:"eq",value:function(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&nu(this.spec,t.spec))}},{key:"destroy",value:function(e){this.spec.destroy&&this.spec.destroy(e)}}])}(),iu=function(){function e(t,n){x(this,e),this.attrs=t,this.spec=n||cu}return S(e,[{key:"map",value:function(e,t,n,r){var i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,o=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=o?null:new au(i,o,this)}},{key:"valid",value:function(e,t){return t.from<t.to}},{key:"eq",value:function(t){return this==t||t instanceof e&&nu(this.attrs,t.attrs)&&nu(this.spec,t.spec)}},{key:"destroy",value:function(){}}],[{key:"is",value:function(t){return t.type instanceof e}}])}(),ou=function(){function e(t,n){x(this,e),this.attrs=t,this.spec=n||cu}return S(e,[{key:"map",value:function(e,t,n,r){var i=e.mapResult(t.from+r,1);if(i.deleted)return null;var o=e.mapResult(t.to+r,-1);return o.deleted||o.pos<=i.pos?null:new au(i.pos-n,o.pos-n,this)}},{key:"valid",value:function(e,t){var n,r=e.content.findIndex(t.from),i=r.index,o=r.offset;return o==t.from&&!(n=e.child(i)).isText&&o+n.nodeSize==t.to}},{key:"eq",value:function(t){return this==t||t instanceof e&&nu(this.attrs,t.attrs)&&nu(this.spec,t.spec)}},{key:"destroy",value:function(){}}])}(),au=function(){function e(t,n,r){x(this,e),this.from=t,this.to=n,this.type=r}return S(e,[{key:"copy",value:function(t,n){return new e(t,n,this.type)}},{key:"eq",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}},{key:"map",value:function(e,t,n){return this.type.map(e,this,t,n)}},{key:"spec",get:function(){return this.type.spec}},{key:"inline",get:function(){return this.type instanceof iu}},{key:"widget",get:function(){return this.type instanceof ru}}],[{key:"widget",value:function(t,n,r){return new e(t,t,new ru(n,r))}},{key:"inline",value:function(t,n,r,i){return new e(t,n,new iu(r,i))}},{key:"node",value:function(t,n,r,i){return new e(t,n,new ou(r,i))}}])}(),su=[],cu={},uu=function(){function e(t,n){x(this,e),this.local=t.length?t:su,this.children=n.length?n:su}return S(e,[{key:"find",value:function(e,t,n){var r=[];return this.findInner(null==e?0:e,null==t?1e9:t,r,0,n),r}},{key:"findInner",value:function(e,t,n,r,i){for(var o=0;o<this.local.length;o++){var a=this.local[o];a.from<=t&&a.to>=e&&(!i||i(a.spec))&&n.push(a.copy(a.from+r,a.to+r))}for(var s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){var c=this.children[s]+1;this.children[s+2].findInner(e-c,t-c,n,r+c,i)}}},{key:"map",value:function(e,t,n){return this==lu||0==e.maps.length?this:this.mapInner(e,t,0,0,n||cu)}},{key:"mapInner",value:function(t,n,r,i,o){for(var a,s=0;s<this.local.length;s++){var c=this.local[s].map(t,r,i);c&&c.type.valid(n,c)?(a||(a=[])).push(c):o.onRemove&&o.onRemove(this.local[s].spec)}return this.children.length?hu(this.children,a||[],t,n,r,i,o):a?new e(a.sort(gu),su):lu}},{key:"add",value:function(t,n){return n.length?this==lu?e.create(t,n):this.addInner(t,n,0):this}},{key:"addInner",value:function(t,n,r){var i,o=this,a=0;t.forEach(function(e,t){var s,c=t+r;if(s=pu(n,e,c)){for(i||(i=o.children.slice());a<i.length&&i[a]<t;)a+=3;i[a]==t?i[a+2]=i[a+2].addInner(e,s,c+1):i.splice(a,0,t,t+e.nodeSize,mu(s,e,c+1,cu)),a+=3}});for(var s=fu(a?vu(n):n,-r),c=0;c<s.length;c++)s[c].type.valid(t,s[c])||s.splice(c--,1);return new e(s.length?this.local.concat(s).sort(gu):this.local,i||this.children)}},{key:"remove",value:function(e){return 0==e.length||this==lu?this:this.removeInner(e,0)}},{key:"removeInner",value:function(t,n){for(var r=this.children,i=this.local,o=0;o<r.length;o+=3){for(var a,s=void 0,c=r[o]+n,u=r[o+1]+n,l=0;l<t.length;l++)(a=t[l])&&a.from>c&&a.to<u&&(t[l]=null,(s||(s=[])).push(a));if(s){r==this.children&&(r=this.children.slice());var d=r[o+2].removeInner(s,c+1);d!=lu?r[o+2]=d:(r.splice(o,3),o-=3)}}if(i.length)for(var h,f=0;f<t.length;f++)if(h=t[f])for(var p=0;p<i.length;p++)i[p].eq(h,n)&&(i==this.local&&(i=this.local.slice()),i.splice(p--,1));return r==this.children&&i==this.local?this:i.length||r.length?new e(i,r):lu}},{key:"forChild",value:function(t,n){if(this==lu)return this;if(n.isLeaf)return e.empty;for(var r,i,o=0;o<this.children.length;o+=3)if(this.children[o]>=t){this.children[o]==t&&(r=this.children[o+2]);break}for(var a=t+1,s=a+n.content.size,c=0;c<this.local.length;c++){var u=this.local[c];if(u.from<s&&u.to>a&&u.type instanceof iu){var l=Math.max(a,u.from)-a,d=Math.min(s,u.to)-a;l<d&&(i||(i=[])).push(u.copy(l,d))}}if(i){var h=new e(i.sort(gu),su);return r?new du([h,r]):h}return r||lu}},{key:"eq",value:function(t){if(this==t)return!0;if(!(t instanceof e)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(var n=0;n<this.local.length;n++)if(!this.local[n].eq(t.local[n]))return!1;for(var r=0;r<this.children.length;r+=3)if(this.children[r]!=t.children[r]||this.children[r+1]!=t.children[r+1]||!this.children[r+2].eq(t.children[r+2]))return!1;return!0}},{key:"locals",value:function(e){return yu(this.localsInner(e))}},{key:"localsInner",value:function(e){if(this==lu)return su;if(e.inlineContent||!this.local.some(iu.is))return this.local;for(var t=[],n=0;n<this.local.length;n++)this.local[n].type instanceof iu||t.push(this.local[n]);return t}},{key:"forEachSet",value:function(e){e(this)}}],[{key:"create",value:function(e,t){return t.length?mu(t,e,0,cu):lu}}])}();uu.empty=new uu([],[]),uu.removeOverlap=yu;var lu=uu.empty,du=function(){function e(t){x(this,e),this.members=t}return S(e,[{key:"map",value:function(t,n){var r=this.members.map(function(e){return e.map(t,n,cu)});return e.from(r)}},{key:"forChild",value:function(t,n){if(n.isLeaf)return uu.empty;for(var r=[],i=0;i<this.members.length;i++){var o=this.members[i].forChild(t,n);o!=lu&&(o instanceof e?r=r.concat(o.members):r.push(o))}return e.from(r)}},{key:"eq",value:function(t){if(!(t instanceof e)||t.members.length!=this.members.length)return!1;for(var n=0;n<this.members.length;n++)if(!this.members[n].eq(t.members[n]))return!1;return!0}},{key:"locals",value:function(e){for(var t,n=!0,r=0;r<this.members.length;r++){var i=this.members[r].localsInner(e);if(i.length)if(t){n&&(t=t.slice(),n=!1);for(var o=0;o<i.length;o++)t.push(i[o])}else t=i}return t?yu(n?t:t.sort(gu)):su}},{key:"forEachSet",value:function(e){for(var t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}],[{key:"from",value:function(t){switch(t.length){case 0:return lu;case 1:return t[0];default:return new e(t.every(function(e){return e instanceof uu})?t:t.reduce(function(e,t){return e.concat(t instanceof uu?t:t.members)},[]))}}}])}();function hu(e,t,n,r,i,o,a){for(var s=e.slice(),c=function(e){var t=0;n.maps[u].forEach(function(n,r,i,o){for(var a=o-i-(r-n),c=0;c<s.length;c+=3){var u=s[c+1];if(!(u<0||n>u+e-t)){var l=s[c]+e-t;r>=l?s[c+1]=n<=l?-2:-1:n>=e&&a&&(s[c]+=a,s[c+1]+=a)}}t+=a}),e=n.maps[u].map(e,-1),l=e},u=0,l=o;u<n.maps.length;u++)c(l);for(var d=!1,h=0;h<s.length;h+=3)if(s[h+1]<0){if(-2==s[h+1]){d=!0,s[h+1]=-1;continue}var f=n.map(e[h]+o),p=f-i;if(p<0||p>=r.content.size){d=!0;continue}var v=n.map(e[h+1]+o,-1)-i,m=r.content.findIndex(p),g=m.index,y=m.offset,k=r.maybeChild(g);if(k&&y==p&&y+k.nodeSize==v){var w=s[h+2].mapInner(n,k,f+1,e[h]+o+1,a);w!=lu?(s[h]=p,s[h+1]=v,s[h+2]=w):(s[h+1]=-2,d=!0)}else d=!0}if(d){var b=function(e,t,n,r,i,o,a){function s(e,t){for(var o=0;o<e.local.length;o++){var c=e.local[o].map(r,i,t);c?n.push(c):a.onRemove&&a.onRemove(e.local[o].spec)}for(var u=0;u<e.children.length;u+=3)s(e.children[u+2],e.children[u]+t+1)}for(var c=0;c<e.length;c+=3)-1==e[c+1]&&s(e[c+2],t[c]+o+1);return n}(s,e,t,n,i,o,a),x=mu(b,r,0,a);t=x.local;for(var C=0;C<s.length;C+=3)s[C+1]<0&&(s.splice(C,3),C-=3);for(var S=0,_=0;S<x.children.length;S+=3){for(var M=x.children[S];_<s.length&&s[_]<M;)_+=3;s.splice(_,0,x.children[S],x.children[S+1],x.children[S+2])}}return new uu(t.sort(gu),s)}function fu(e,t){if(!t||!e.length)return e;for(var n=[],r=0;r<e.length;r++){var i=e[r];n.push(new au(i.from+t,i.to+t,i.type))}return n}function pu(e,t,n){if(t.isLeaf)return null;for(var r,i=n+t.nodeSize,o=null,a=0;a<e.length;a++)(r=e[a])&&r.from>n&&r.to<i&&((o||(o=[])).push(r),e[a]=null);return o}function vu(e){for(var t=[],n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function mu(e,t,n,r){var i=[],o=!1;t.forEach(function(t,a){var s=pu(e,t,a+n);if(s){o=!0;var c=mu(s,t,n+a+1,r);c!=lu&&i.push(a,a+t.nodeSize,c)}});for(var a=fu(o?vu(e):e,-n).sort(gu),s=0;s<a.length;s++)a[s].type.valid(t,a[s])||(r.onRemove&&r.onRemove(a[s].spec),a.splice(s--,1));return a.length||i.length?new uu(a,i):lu}function gu(e,t){return e.from-t.from||e.to-t.to}function yu(e){for(var t=e,n=0;n<t.length-1;n++){var r=t[n];if(r.from!=r.to)for(var i=n+1;i<t.length;i++){var o=t[i];if(o.from!=r.from){o.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,o.from),ku(t,i,r.copy(o.from,r.to)));break}o.to!=r.to&&(t==e&&(t=e.slice()),t[i]=o.copy(o.from,r.to),ku(t,i+1,o.copy(r.to,o.to)))}}return t}function ku(e,t,n){for(;t<e.length&&gu(n,e[t])>0;)t++;e.splice(t,0,n)}function wu(e){var t=[];return e.someProp("decorations",function(n){var r=n(e.state);r&&r!=lu&&t.push(r)}),e.cursorWrapper&&t.push(uu.create(e.state.doc,[e.cursorWrapper.deco])),du.from(t)}var bu={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},xu=Fa&&$a<=11,Cu=function(){return S(function e(){x(this,e),this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0},[{key:"set",value:function(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}},{key:"clear",value:function(){this.anchorNode=this.focusNode=null}},{key:"eq",value:function(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}])}(),Su=function(){return S(function e(t,n){var r=this;x(this,e),this.view=t,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Cu,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(function(e){for(var t=0;t<e.length;t++)r.queue.push(e[t]);Fa&&$a<=11&&e.some(function(e){return"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length})?r.flushSoon():r.flush()}),xu&&(this.onCharData=function(e){r.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),r.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)},[{key:"flushSoon",value:function(){var e=this;this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(function(){e.flushingSoon=-1,e.flush()},20))}},{key:"forceFlush",value:function(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}},{key:"start",value:function(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,bu)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}},{key:"stop",value:function(){var e=this;if(this.observer){var t=this.observer.takeRecords();if(t.length){for(var n=0;n<t.length;n++)this.queue.push(t[n]);window.setTimeout(function(){return e.flush()},20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}},{key:"connectSelection",value:function(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}},{key:"disconnectSelection",value:function(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}},{key:"suppressSelectionUpdates",value:function(){var e=this;this.suppressingSelectionUpdates=!0,setTimeout(function(){return e.suppressingSelectionUpdates=!1},50)}},{key:"onSelectionChange",value:function(){if(ec(this.view)){if(this.suppressingSelectionUpdates)return Us(this.view);if(Fa&&$a<=11&&!this.view.state.selection.empty){var e=this.view.domSelectionRange();if(e.focusNode&&Ta(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}},{key:"setCurSelection",value:function(){this.currentSelection.set(this.view.domSelectionRange())}},{key:"ignoreSelectionChange",value:function(e){if(!e.focusNode)return!0;for(var t,n=new Set,r=e.focusNode;r;r=Sa(r))n.add(r);for(var i=e.anchorNode;i;i=Sa(i))if(n.has(i)){t=i;break}var o=t&&this.view.docView.nearestDesc(t);return o&&o.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0}},{key:"pendingRecords",value:function(){if(this.observer){var e,t=l(this.observer.takeRecords());try{for(t.s();!(e=t.n()).done;){var n=e.value;this.queue.push(n)}}catch(r){t.e(r)}finally{t.f()}}return this.queue}},{key:"flush",value:function(){var e=this.view;if(e.docView&&!(this.flushingSoon>-1)){var t=this.pendingRecords();t.length&&(this.queue=[]);var n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&ec(e)&&!this.ignoreSelectionChange(n),i=-1,o=-1,a=!1,s=[];if(e.editable)for(var c=0;c<t.length;c++){var u=this.registerMutation(t[c],s);u&&(i=i<0?u.from:Math.min(u.from,i),o=o<0?u.to:Math.max(u.to,o),u.typeOver&&(a=!0))}if(ja&&s.length){var h=s.filter(function(e){return"BR"==e.nodeName});if(2==h.length){var f=d(h,2),p=f[0],v=f[1];p.parentNode&&p.parentNode.parentNode==v.parentNode?v.remove():p.remove()}else{var m,g=this.currentSelection.focusNode,y=l(h);try{for(y.s();!(m=y.n()).done;){var k=m.value,w=k.parentNode;!w||"LI"!=w.nodeName||g&&Ou(e,g)==w||k.remove()}}catch(M){y.e(M)}finally{y.f()}}}else if((Wa||Ua)&&s.some(function(e){return"BR"==e.nodeName})&&(8==e.input.lastKeyCode||46==e.input.lastKeyCode)){var b,x=l(s);try{for(x.s();!(b=x.n()).done;){var C=b.value;if("BR"==C.nodeName&&C.parentNode){var S=C.nextSibling;S&&1==S.nodeType&&"false"==S.contentEditable&&C.parentNode.removeChild(C)}}}catch(M){x.e(M)}finally{x.f()}}var _=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Da(n)&&(_=Ws(e))&&_.eq(Fo.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Us(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,o),function(e){if(_u.has(e))return;if(_u.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)){if(e.requiresGeckoHackNode=ja,Mu)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Mu=!0}}(e)),this.handleDOMChange(i,o,a,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||Us(e),this.currentSelection.set(n))}}},{key:"registerMutation",value:function(e,t){if(t.indexOf(e.target)>-1)return null;var n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(var r=0;r<e.addedNodes.length;r++){var i=e.addedNodes[r];t.push(i),3==i.nodeType&&(this.lastChangedTextNode=i)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};var o=e.previousSibling,a=e.nextSibling;if(Fa&&$a<=11&&e.addedNodes.length)for(var s=0;s<e.addedNodes.length;s++){var c=e.addedNodes[s],u=c.previousSibling,l=c.nextSibling;(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(o=u),(!l||Array.prototype.indexOf.call(e.addedNodes,l)<0)&&(a=l)}var d=o&&o.parentNode==e.target?Ca(o)+1:0,h=n.localPosFromDOM(e.target,d,-1),f=a&&a.parentNode==e.target?Ca(a):e.target.childNodes.length;return{from:h,to:n.localPosFromDOM(e.target,f,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}])}(),_u=new WeakMap,Mu=!1;function Tu(e,t){var n=t.startContainer,r=t.startOffset,i=t.endContainer,o=t.endOffset,a=e.domAtPos(e.state.selection.anchor);if(Ta(a.node,a.offset,i,o)){var s=[i,o,n,r];n=s[0],r=s[1],i=s[2],o=s[3]}return{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}}function Ou(e,t){for(var n=t.parentNode;n&&n!=e.dom;n=n.parentNode){var r=e.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function Nu(e){var t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(Ua&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){var n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}if(e.parentNode.lastChild==e||Ua&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}var Eu=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Au(e,t,n,r,i){var o=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){var a=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,s=Ws(e,a);if(s&&!e.state.selection.eq(s)){if(Wa&&Ga&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",function(t){return t(e,Ia(13,"Enter"))}))return;var c=e.state.tr.setSelection(s);"pointer"==a?c.setMeta("pointer",!0):"key"==a&&c.scrollIntoView(),o&&c.setMeta("composition",o),e.dispatch(c)}}else{var u=e.state.doc.resolve(t),l=u.sharedDepth(n);t=u.before(l+1),n=e.state.doc.resolve(n).after(l+1);var d,h,f=e.state.selection,p=function(e,t,n){var r,i=e.docView.parseRange(t,n),o=i.node,a=i.fromOffset,s=i.toOffset,c=i.from,u=i.to,l=e.domSelectionRange(),d=l.anchorNode;if(d&&e.dom.contains(1==d.nodeType?d:d.parentNode)&&(r=[{node:d,offset:l.anchorOffset}],Da(l)||r.push({node:l.focusNode,offset:l.focusOffset})),Wa&&8===e.input.lastKeyCode)for(var h=s;h>a;h--){var f=o.childNodes[h-1],p=f.pmViewDesc;if("BR"==f.nodeName&&!p){s=h;break}if(!p||p.size)break}var v=e.state.doc,m=e.someProp("domParser")||Di.fromSchema(e.state.schema),g=v.resolve(c),y=null,k=m.parse(o,{topNode:g.parent,topMatch:g.parent.contentMatchAt(g.index()),topOpen:!0,from:a,to:s,preserveWhitespace:"pre"!=g.parent.type.whitespace||"full",findPositions:r,ruleFromNode:Nu,context:g});if(r&&null!=r[0].pos){var w=r[0].pos,b=r[1]&&r[1].pos;null==b&&(b=w),y={anchor:w+c,head:b+c}}return{doc:k,sel:y,from:c,to:u}}(e,t,n),v=e.state.doc,m=v.slice(p.from,p.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(d=e.state.selection.to,h="end"):(d=e.state.selection.from,h="start"),e.input.lastKeyCode=null;var g=function(e,t,n,r,i){var o=e.findDiffStart(t,n);if(null==o)return null;var a=e.findDiffEnd(t,n+e.size,n+t.size),s=a.a,c=a.b;if("end"==i){r-=s+Math.max(0,o-Math.min(s,c))-o}if(s<o&&e.size<t.size){var u=r<=o&&r>=s?o-r:0;(o-=u)&&o<t.size&&zu(t.textBetween(o-1,o+1))&&(o+=u?1:-1),c=o+(c-s),s=o}else if(c<o){var l=r<=o&&r>=c?o-r:0;(o-=l)&&o<e.size&&zu(e.textBetween(o-1,o+1))&&(o+=l?1:-1),s=o+(s-c),c=o}return{start:o,endA:s,endB:c}}(m.content,p.doc.content,p.from,d,h);if(g&&e.input.domChangeCount++,(Ja&&e.input.lastIOSEnter>Date.now()-225||Ga)&&i.some(function(e){return 1==e.nodeType&&!Eu.test(e.nodeName)})&&(!g||g.endA>=g.endB)&&e.someProp("handleKeyDown",function(t){return t(e,Ia(13,"Enter"))}))e.input.lastIOSEnter=0;else{if(!g){if(!(r&&f instanceof Wo&&!f.empty&&f.$head.sameParent(f.$anchor))||e.composing||p.sel&&p.sel.anchor!=p.sel.head){if(p.sel){var y=Du(e,e.state.doc,p.sel);if(y&&!y.eq(e.state.selection)){var k=e.state.tr.setSelection(y);o&&k.setMeta("composition",o),e.dispatch(k)}}return}g={start:f.from,endA:f.to,endB:f.to}}e.state.selection.from<e.state.selection.to&&g.start==g.endB&&e.state.selection instanceof Wo&&(g.start>e.state.selection.from&&g.start<=e.state.selection.from+2&&e.state.selection.from>=p.from?g.start=e.state.selection.from:g.endA<e.state.selection.to&&g.endA>=e.state.selection.to-2&&e.state.selection.to<=p.to&&(g.endB+=e.state.selection.to-g.endA,g.endA=e.state.selection.to)),Fa&&$a<=11&&g.endB==g.start+1&&g.endA==g.start&&g.start>p.from&&"  "==p.doc.textBetween(g.start-p.from-1,g.start-p.from+1)&&(g.start--,g.endA--,g.endB--);var w=p.doc.resolveNoCache(g.start-p.from),b=p.doc.resolveNoCache(g.endB-p.from),x=v.resolve(g.start),C=w.sameParent(b)&&w.parent.inlineContent&&x.end()>=g.endA;if((Ja&&e.input.lastIOSEnter>Date.now()-225&&(!C||i.some(function(e){return"DIV"==e.nodeName||"P"==e.nodeName}))||!C&&w.pos<p.doc.content.size&&(!w.sameParent(b)||!w.parent.inlineContent)&&w.pos<b.pos&&!/\S/.test(p.doc.textBetween(w.pos,b.pos,"","")))&&e.someProp("handleKeyDown",function(t){return t(e,Ia(13,"Enter"))}))e.input.lastIOSEnter=0;else if(e.state.selection.anchor>g.start&&function(e,t,n,r,i){if(n-t<=i.pos-r.pos||Iu(r,!0,!1)<i.pos)return!1;var o=e.resolve(t);if(!r.parent.isTextblock){var a=o.nodeAfter;return null!=a&&n==t+a.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;var s=e.resolve(Iu(o,!0,!0));return!(!s.parent.isTextblock||s.pos>n||Iu(s,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(s.parent.content)}(v,g.start,g.endA,w,b)&&e.someProp("handleKeyDown",function(t){return t(e,Ia(8,"Backspace"))}))Ga&&Wa&&e.domObserver.suppressSelectionUpdates();else{Wa&&g.endB==g.start&&(e.input.lastChromeDelete=Date.now()),Ga&&!C&&w.start()!=b.start()&&0==b.parentOffset&&w.depth==b.depth&&p.sel&&p.sel.anchor==p.sel.head&&p.sel.head==g.endA&&(g.endB-=2,b=p.doc.resolveNoCache(g.endB-p.from),setTimeout(function(){e.someProp("handleKeyDown",function(t){return t(e,Ia(13,"Enter"))})},20));var S,_=g.start,M=g.endA,T=function(t){var n=t||e.state.tr.replace(_,M,p.doc.slice(g.start-p.from,g.endB-p.from));if(p.sel){var r=Du(e,n.doc,p.sel);r&&!(Wa&&e.composing&&r.empty&&(g.start!=g.endB||e.input.lastChromeDelete<Date.now()-100)&&(r.head==_||r.head==n.mapping.map(M)-1)||Fa&&r.empty&&r.head==_)&&n.setSelection(r)}return o&&n.setMeta("composition",o),n.scrollIntoView()};if(C)if(w.pos==b.pos){Fa&&$a<=11&&0==w.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout(function(){return Us(e)},20));var O=T(e.state.tr.delete(_,M)),N=v.resolve(g.start).marksAcross(v.resolve(g.endA));N&&O.ensureMarks(N),e.dispatch(O)}else if(g.endA==g.endB&&(S=function(e,t){for(var n,r,i,o=e.firstChild.marks,a=t.firstChild.marks,s=o,c=a,u=0;u<a.length;u++)s=a[u].removeFromSet(s);for(var l=0;l<o.length;l++)c=o[l].removeFromSet(c);if(1==s.length&&0==c.length)r=s[0],n="add",i=function(e){return e.mark(r.addToSet(e.marks))};else{if(0!=s.length||1!=c.length)return null;r=c[0],n="remove",i=function(e){return e.mark(r.removeFromSet(e.marks))}}for(var d=[],h=0;h<t.childCount;h++)d.push(i(t.child(h)));if(Fr.from(d).eq(e))return{mark:r,type:n}}(w.parent.content.cut(w.parentOffset,b.parentOffset),x.parent.content.cut(x.parentOffset,g.endA-x.start())))){var E=T(e.state.tr);"add"==S.type?E.addMark(_,M,S.mark):E.removeMark(_,M,S.mark),e.dispatch(E)}else if(w.parent.child(w.index()).isText&&w.index()==b.index()-(b.textOffset?0:1)){var A=w.parent.textBetween(w.parentOffset,b.parentOffset),D=function(){return T(e.state.tr.insertText(A,_,M))};e.someProp("handleTextInput",function(t){return t(e,_,M,A,D)})||e.dispatch(D())}else e.dispatch(T());else e.dispatch(T())}}}}function Du(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Qs(e,t.resolve(n.anchor),t.resolve(n.head))}function Iu(e,t,n){for(var r=e.depth,i=t?e.end():e.pos;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n)for(var o=e.node(r).maybeChild(e.indexAfter(r));o&&!o.isLeaf;)o=o.firstChild,i++;return i}function zu(e){if(2!=e.length)return!1;var t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}var Ru=function(){return S(function e(t,n){var r=this;x(this,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 Ec,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Fu),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=Bu(this),Lu(this),this.nodeViews=Vu(this),this.docView=Os(this.state.doc,Pu(this),wu(this),this.dom,this),this.domObserver=new Su(this,function(e,t,n,i){return Au(r,e,t,n,i)}),this.domObserver.start(),function(e){var t=function(){var t=Tc[n];e.dom.addEventListener(n,e.input.eventHandlers[n]=function(n){!function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(var n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}(e,n)||Ic(e,n)||!e.editable&&n.type in Oc||t(e,n)},Nc[n]?{passive:!0}:void 0)};for(var n in Tc)t();Ua&&e.dom.addEventListener("input",function(){return null}),Dc(e)}(this),this.updatePluginViews()},[{key:"composing",get:function(){return this.input.composing}},{key:"props",get:function(){if(this._props.state!=this.state){var e=this._props;for(var t in this._props={},e)this._props[t]=e[t];this._props.state=this.state}return this._props}},{key:"update",value:function(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Dc(this);var t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Fu),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}},{key:"setProps",value:function(e){var t={};for(var n in this._props)t[n]=this._props[n];for(var r in t.state=this.state,e)t[r]=e[r];this.update(t)}},{key:"updateState",value:function(e){this.updateStateInner(e,this._props)}},{key:"updateStateInner",value:function(e,t){var n,r=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(Uc(this),o=!0),this.state=e;var a=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){var s=Vu(this);(function(e,t){var n=0,r=0;for(var i in e){if(e[i]!=t[i])return!0;n++}for(var o in t)r++;return n!=r})(s,this.nodeViews)&&(this.nodeViews=s,i=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&Dc(this),this.editable=Bu(this),Lu(this);var c=wu(this),u=Pu(this),l=r.plugins==e.plugins||r.doc.eq(e.doc)?e.scrollToSelection>r.scrollToSelection?"to selection":"preserve":"reset",d=i||!this.docView.matchesNode(e.doc,u,c);!d&&e.selection.eq(r.selection)||(o=!0);var h,f,p,v,m,g,y,k,w,b,x,C="preserve"==l&&o&&null==this.dom.style.overflowAnchor&&function(e){for(var t,n,r=e.dom.getBoundingClientRect(),i=Math.max(0,r.top),o=(r.left+r.right)/2,a=i+1;a<Math.min(innerHeight,r.bottom);a+=5){var s=e.root.elementFromPoint(o,a);if(s&&s!=e.dom&&e.dom.contains(s)){var c=s.getBoundingClientRect();if(c.top>=i-20){t=s,n=c.top;break}}}return{refDOM:t,refTop:n,stack:rs(e.dom)}}(this);if(o){this.domObserver.stop();var S=d&&(Fa||Wa)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&(v=r.selection,m=e.selection,g=Math.min(v.$anchor.sharedDepth(v.head),m.$anchor.sharedDepth(m.head)),v.$anchor.start(g)!=m.$anchor.start(g));if(d){var _=Wa?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Jc(this)),!i&&this.docView.update(e.doc,u,c,this)||(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=Os(e.doc,u,c,this.dom,this)),_&&!this.trackWrites&&(S=!0)}S||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&(h=this,f=h.docView.domFromPos(h.state.selection.anchor,0),p=h.domSelectionRange(),Ta(f.node,f.offset,p.anchorNode,p.anchorOffset)))?Us(this,S):(Xs(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!r.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,r),"reset"==l?this.dom.scrollTop=0:"to selection"==l?this.scrollToSelection():C&&(k=(y=C).refDOM,w=y.refTop,b=y.stack,x=k?k.getBoundingClientRect().top:0,is(b,0==x?0:x-w))}},{key:"scrollToSelection",value:function(){var e=this,t=this.domSelectionRange().focusNode;if(t&&this.dom.contains(1==t.nodeType?t:t.parentNode))if(this.someProp("handleScrollToSelection",function(t){return t(e)}));else if(this.state.selection instanceof Uo){var n=this.docView.domAfterPos(this.state.selection.from);1==n.nodeType&&ns(this,n.getBoundingClientRect(),t)}else ns(this,this.coordsAtPos(this.state.selection.head,1),t);else;}},{key:"destroyPluginViews",value:function(){for(var e;e=this.pluginViews.pop();)e.destroy&&e.destroy()}},{key:"updatePluginViews",value:function(e){if(e&&e.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(var t=0;t<this.pluginViews.length;t++){var n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(var r=0;r<this.directPlugins.length;r++){var i=this.directPlugins[r];i.spec.view&&this.pluginViews.push(i.spec.view(this))}for(var o=0;o<this.state.plugins.length;o++){var a=this.state.plugins[o];a.spec.view&&this.pluginViews.push(a.spec.view(this))}}}},{key:"updateDraggedNode",value:function(e,t){var n=e.node,r=-1;if(this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{var i=n.from+(this.state.doc.content.size-t.doc.content.size);(i>0&&this.state.doc.nodeAt(i))==n.node&&(r=i)}this.dragging=new Zc(e.slice,e.move,r<0?void 0:Uo.create(this.state.doc,r))}},{key:"someProp",value:function(e,t){var n,r=this._props&&this._props[e];if(null!=r&&(n=t?t(r):r))return n;for(var i=0;i<this.directPlugins.length;i++){var o=this.directPlugins[i].props[e];if(null!=o&&(n=t?t(o):o))return n}var a=this.state.plugins;if(a)for(var s=0;s<a.length;s++){var c=a[s].props[e];if(null!=c&&(n=t?t(c):c))return n}}},{key:"hasFocus",value:function(){if(Fa){var e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}},{key:"focus",value:function(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(as)return e.focus(as);var t=rs(e);e.focus(null==as?{get preventScroll(){return as={preventScroll:!0},!0}}:void 0),as||(as=!1,is(t,0))}(this.dom),Us(this),this.domObserver.start()}},{key:"root",get:function(){var e=this,t=this._root;if(null==t)for(var n,r=function(t){if(9==t.nodeType||11==t.nodeType&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=function(){return t.ownerDocument.getSelection()}),{v:e._root=t}},i=this.dom.parentNode;i;i=i.parentNode)if(n=r(i))return n.v;return t||document}},{key:"updateRoot",value:function(){this._root=null}},{key:"posAtCoords",value:function(e){return ls(this,e)}},{key:"coordsAtPos",value:function(e){return ps(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:1)}},{key:"domAtPos",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.docView.domFromPos(e,t)}},{key:"nodeDOM",value:function(e){var t=this.docView.descAt(e);return t?t.nodeDOM:null}},{key:"posAtDOM",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,r=this.docView.posFromDOM(e,t,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r}},{key:"endOfTextblock",value:function(e,t){return xs(this,t||this.state,e)}},{key:"pasteHTML",value:function(e,t){return Gc(this,"",e,!1,t||new ClipboardEvent("paste"))}},{key:"pasteText",value:function(e,t){return Gc(this,e,null,!0,t||new ClipboardEvent("paste"))}},{key:"serializeForClipboard",value:function(e){return vc(this,e)}},{key:"destroy",value:function(){this.docView&&(!function(e){for(var t in e.domObserver.stop(),e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],wu(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,_a=null)}},{key:"isDestroyed",get:function(){return null==this.docView}},{key:"dispatchEvent",value:function(e){return function(e,t){Ic(e,t)||!Tc[t.type]||!e.editable&&t.type in Oc||Tc[t.type](e,t)}(this,e)}},{key:"domSelectionRange",value:function(){var e=this.domSelection();return e?Ua&&11===this.root.nodeType&&function(e){for(var t=e.activeElement;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom&&function(e,t){if(t.getComposedRanges){var n=t.getComposedRanges(e.root)[0];if(n)return Tu(e,n)}var r;function i(e){e.preventDefault(),e.stopImmediatePropagation(),r=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",i,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",i,!0),r?Tu(e,r):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}},{key:"domSelection",value:function(){return this.root.getSelection()}}])}();function Pu(e){var t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",function(n){if("function"==typeof n&&(n=n(e.state)),n)for(var r in n)"class"==r?t.class+=" "+n[r]:"style"==r?t.style=(t.style?t.style+";":"")+n[r]:t[r]||"contenteditable"==r||"nodeName"==r||(t[r]=String(n[r]))}),t.translate||(t.translate="no"),[au.node(0,e.state.doc.content.size,t)]}function Lu(e){if(e.markCursor){var t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:au.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Bu(e){return!e.someProp("editable",function(t){return!1===t(e.state)})}function Vu(e){var t=Object.create(null);function n(e){for(var n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function Fu(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}Ru.prototype.dispatch=function(e){var t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};for(var $u={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:"'"},ju={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Hu="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Wu="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),qu=0;qu<10;qu++)$u[48+qu]=$u[96+qu]=String(qu);for(qu=1;qu<=24;qu++)$u[qu+111]="F"+qu;for(qu=65;qu<=90;qu++)$u[qu]=String.fromCharCode(qu+32),ju[qu]=String.fromCharCode(qu);for(var Uu in $u)ju.hasOwnProperty(Uu)||(ju[Uu]=$u[Uu]);var Ju="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Ku="undefined"!=typeof navigator&&/Win/.test(navigator.platform);function Yu(e){var t,n,r,i,o=e.split(/-(?!$)/),a=o[o.length-1];"Space"==a&&(a=" ");for(var s=0;s<o.length-1;s++){var c=o[s];if(/^(cmd|meta|m)$/i.test(c))i=!0;else if(/^a(lt)?$/i.test(c))t=!0;else if(/^(c|ctrl|control)$/i.test(c))n=!0;else if(/^s(hift)?$/i.test(c))r=!0;else{if(!/^mod$/i.test(c))throw new Error("Unrecognized modifier name: "+c);Ju?i=!0:n=!0}}return t&&(a="Alt-"+a),n&&(a="Ctrl-"+a),i&&(a="Meta-"+a),r&&(a="Shift-"+a),a}function Gu(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function Xu(e){var t=function(e){var t=Object.create(null);for(var n in e)t[Yu(n)]=e[n];return t}(e);return function(e,n){var r,i=function(e){var t=!(Hu&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Wu&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?ju:$u)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(n),o=t[Gu(i,n)];if(o&&o(e.state,e.dispatch,e))return!0;if(1==i.length&&" "!=i){if(n.shiftKey){var a=t[Gu(i,n,!1)];if(a&&a(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(Ku&&n.ctrlKey&&n.altKey)&&(r=$u[n.keyCode])&&r!=i){var s=t[Gu(r,n)];if(s&&s(e.state,e.dispatch,e))return!0}}return!1}}var Zu=Object.defineProperty,Qu=function(e,t){for(var n in t)Zu(e,n,{get:t[n],enumerable:!0})};function el(e){var t=e.state,n=e.transaction,r=n.selection,i=n.doc,o=n.storedMarks;return g(g({},t),{},{apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return o},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,o=n.storedMarks,n}})}var tl=function(){return S(function e(t){x(this,e),this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state},[{key:"hasCustomState",get:function(){return!!this.customState}},{key:"state",get:function(){return this.customState||this.editor.state}},{key:"commands",get:function(){var e=this,t=this.rawCommands,n=this.editor,r=this.state,i=n.view,o=r.tr,a=this.buildProps(o);return Object.fromEntries(Object.entries(t).map(function(t){var n=d(t,2),r=n[0],s=n[1];return[r,function(){var t=s.apply(void 0,arguments)(a);return o.getMeta("preventDispatch")||e.hasCustomState||i.dispatch(o),t}]}))}},{key:"chain",get:function(){var e=this;return function(){return e.createChain()}}},{key:"can",get:function(){var e=this;return function(){return e.createCan()}}},{key:"createChain",value:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=this.rawCommands,i=this.editor,o=this.state,a=i.view,s=[],c=!!e,u=e||o.tr,l=g(g({},Object.fromEntries(Object.entries(r).map(function(e){var r=d(e,2),i=r[0],o=r[1];return[i,function(){var e=t.buildProps(u,n),r=o.apply(void 0,arguments)(e);return s.push(r),l}]}))),{},{run:function(){return c||!n||u.getMeta("preventDispatch")||t.hasCustomState||a.dispatch(u),s.every(function(e){return!0===e})}});return l}},{key:"createCan",value:function(e){var t=this,n=this.rawCommands,r=this.state,i=!1,o=e||r.tr,a=this.buildProps(o,i),s=Object.fromEntries(Object.entries(n).map(function(e){var t=d(e,2),n=t[0],r=t[1];return[n,function(){return r.apply(void 0,arguments)(g(g({},a),{},{dispatch:void 0}))}]}));return g(g({},s),{},{chain:function(){return t.createChain(o,i)}})}},{key:"buildProps",value:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=this.rawCommands,i=this.editor,o=this.state,a=i.view,s={tr:e,editor:i,view:a,state:el({state:o,transaction:e}),dispatch:n?function(){}:void 0,chain:function(){return t.createChain(e,n)},can:function(){return t.createCan(e)},get commands(){return Object.fromEntries(Object.entries(r).map(function(e){var t=d(e,2),n=t[0],r=t[1];return[n,function(){return r.apply(void 0,arguments)(s)}]}))}};return s}}])}(),nl={};Qu(nl,{blur:function(){return rl},clearContent:function(){return il},clearNodes:function(){return ol},command:function(){return al},createParagraphNear:function(){return sl},cut:function(){return cl},deleteCurrentNode:function(){return ul},deleteNode:function(){return dl},deleteRange:function(){return hl},deleteSelection:function(){return fl},enter:function(){return pl},exitCode:function(){return vl},extendMarkRange:function(){return xl},first:function(){return Cl},focus:function(){return Ol},forEach:function(){return Nl},insertContent:function(){return El},insertContentAt:function(){return zl},joinBackward:function(){return Ll},joinDown:function(){return Pl},joinForward:function(){return Bl},joinItemBackward:function(){return Vl},joinItemForward:function(){return Fl},joinTextblockBackward:function(){return $l},joinTextblockForward:function(){return jl},joinUp:function(){return Rl},keyboardShortcut:function(){return Wl},lift:function(){return Ul},liftEmptyBlock:function(){return Jl},liftListItem:function(){return Kl},newlineInCode:function(){return Yl},resetAttributes:function(){return Zl},scrollIntoView:function(){return Ql},selectAll:function(){return ed},selectNodeBackward:function(){return td},selectNodeForward:function(){return nd},selectParentNode:function(){return rd},selectTextblockEnd:function(){return id},selectTextblockStart:function(){return od},setContent:function(){return sd},setMark:function(){return Ld},setMeta:function(){return Bd},setNode:function(){return Vd},setNodeSelection:function(){return Fd},setTextDirection:function(){return $d},setTextSelection:function(){return jd},sinkListItem:function(){return Hd},splitBlock:function(){return qd},splitListItem:function(){return Ud},toggleList:function(){return Yd},toggleMark:function(){return Gd},toggleNode:function(){return Xd},toggleWrap:function(){return Zd},undoInputRule:function(){return Qd},unsetAllMarks:function(){return eh},unsetMark:function(){return th},unsetTextDirection:function(){return nh},updateAttributes:function(){return rh},wrapIn:function(){return ih},wrapInList:function(){return oh}});var rl=function(){return function(e){var t=e.editor,n=e.view;return requestAnimationFrame(function(){var e;t.isDestroyed||(n.dom.blur(),null==(e=null==window?void 0:window.getSelection())||e.removeAllRanges())}),!0}},il=function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return function(t){return t.commands.setContent("",{emitUpdate:e})}},ol=function(){return function(e){var t=e.state,n=e.tr,r=e.dispatch,i=n.selection.ranges;return!r||(i.forEach(function(e){var r=e.$from,i=e.$to;t.doc.nodesBetween(r.pos,i.pos,function(e,t){if(!e.type.isText){var r=n.doc,i=n.mapping,o=r.resolve(i.map(t)),a=r.resolve(i.map(t+e.nodeSize)),s=o.blockRange(a);if(s){var c=po(s);if(e.type.isTextblock){var u=o.parent.contentMatchAt(o.index()).defaultType;n.setNodeMarkup(s.start,u)}(c||0===c)&&n.lift(s,c)}}})}),!0)}},al=function(e){return function(t){return e(t)}},sl=function(){return function(e){return function(e,t){var n=e.selection,r=n.$from,i=n.$to;if(n instanceof Ko||r.parent.inlineContent||i.parent.inlineContent)return!1;var o=va(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(t){var a=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,s=e.tr.insert(a,o.createAndFill());s.setSelection(Wo.create(s.doc,a+1)),t(s.scrollIntoView())}return!0}(e.state,e.dispatch)}},cl=function(e,t){return function(n){var r=n.editor,i=n.tr,o=r.state.doc.slice(e.from,e.to);i.deleteRange(e.from,e.to);var a=i.mapping.map(t);return i.insert(a,o.content),i.setSelection(new Wo(i.doc.resolve(Math.max(a-1,0)))),!0}},ul=function(){return function(e){var t=e.tr,n=e.dispatch,r=t.selection.$anchor.node();if(r.content.size>0)return!1;for(var i=t.selection.$anchor,o=i.depth;o>0;o-=1){if(i.node(o).type===r.type){if(n){var a=i.before(o),s=i.after(o);t.delete(a,s).scrollIntoView()}return!0}}return!1}};function ll(e,t){if("string"==typeof e){if(!t.nodes[e])throw Error("There is no node type named '".concat(e,"'. Maybe you forgot to add the extension?"));return t.nodes[e]}return e}var dl=function(e){return function(t){for(var n=t.tr,r=t.state,i=t.dispatch,o=ll(e,r.schema),a=n.selection.$anchor,s=a.depth;s>0;s-=1){if(a.node(s).type===o){if(i){var c=a.before(s),u=a.after(s);n.delete(c,u).scrollIntoView()}return!0}}return!1}},hl=function(e){return function(t){var n=t.tr,r=t.dispatch,i=e.from,o=e.to;return r&&n.delete(i,o),!0}},fl=function(){return function(e){return function(e,t){return!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0)}(e.state,e.dispatch)}},pl=function(){return function(e){return e.commands.keyboardShortcut("Enter")}},vl=function(){return function(e){return function(e,t){var n=e.selection,r=n.$head,i=n.$anchor;if(!r.parent.type.spec.code||!r.sameParent(i))return!1;var o=r.node(-1),a=r.indexAfter(-1),s=va(o.contentMatchAt(a));if(!s||!o.canReplaceWith(a,a,s))return!1;if(t){var c=r.after(),u=e.tr.replaceWith(c,c,s.createAndFill());u.setSelection(Fo.near(u.doc.resolve(c),1)),t(u.scrollIntoView())}return!0}(e.state,e.dispatch)}};function ml(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function gl(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{strict:!0},r=Object.keys(t);return!r.length||r.every(function(r){return n.strict?t[r]===e[r]:ml(t[r])?t[r].test(e[r]):t[r]===e[r]})}function yl(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return e.find(function(e){return e.type===t&&gl(Object.fromEntries(Object.keys(n).map(function(t){return[t,e.attrs[t]]})),n)})}function kl(e,t){return!!yl(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:{})}function wl(e,t,n){var r;if(e&&t){var i=e.parent.childAfter(e.parentOffset);if(i.node&&i.node.marks.some(function(e){return e.type===t})||(i=e.parent.childBefore(e.parentOffset)),i.node&&i.node.marks.some(function(e){return e.type===t}))if(n=n||(null==(r=i.node.marks[0])?void 0:r.attrs),yl(c(i.node.marks),t,n)){for(var o=i.index,a=e.start()+i.offset,s=o+1,u=a+i.node.nodeSize;o>0&&kl(c(e.parent.child(o-1).marks),t,n);)o-=1,a-=e.parent.child(o).nodeSize;for(;s<e.parent.childCount&&kl(c(e.parent.child(s).marks),t,n);)u+=e.parent.child(s).nodeSize,s+=1;return{from:a,to:u}}}}function bl(e,t){if("string"==typeof e){if(!t.marks[e])throw Error("There is no mark type named '".concat(e,"'. Maybe you forgot to add the extension?"));return t.marks[e]}return e}var xl=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.tr,i=n.state,o=n.dispatch,a=bl(e,i.schema),s=r.doc,c=r.selection,u=c.$from,l=c.from,d=c.to;if(o){var h=wl(u,a,t);if(h&&h.from<=l&&h.to>=d){var f=Wo.create(s,h.from,h.to);r.setSelection(f)}}return!0}},Cl=function(e){return function(t){for(var n="function"==typeof e?e(t):e,r=0;r<n.length;r+=1)if(n[r](t))return!0;return!1}};function Sl(e){return e instanceof Wo}function _l(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Math.min(Math.max(e,t),n)}function Ml(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!t)return null;var n=Fo.atStart(e),r=Fo.atEnd(e);if("start"===t||!0===t)return n;if("end"===t)return r;var i=n.from,o=r.to;return"all"===t?Wo.create(e,_l(0,i,o),_l(e.content.size,i,o)):Wo.create(e,_l(t,i,o),_l(t,i,o))}function Tl(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var Ol=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.editor,i=n.view,o=n.tr,a=n.dispatch;t=g({scrollIntoView:!0},t);var s=function(){(Tl()||"Android"===navigator.platform||/android/i.test(navigator.userAgent))&&i.dom.focus(),requestAnimationFrame(function(){r.isDestroyed||(i.focus(),(null==t?void 0:t.scrollIntoView)&&r.commands.scrollIntoView())})};if(i.hasFocus()&&null===e||!1===e)return!0;if(a&&null===e&&!Sl(r.state.selection))return s(),!0;var c=Ml(o.doc,e)||r.state.selection,u=r.state.selection.eq(c);return a&&(u||o.setSelection(c),u&&o.storedMarks&&o.setStoredMarks(o.storedMarks),s()),!0}},Nl=function(e,t){return function(n){return e.every(function(e,r){return t(e,g(g({},n),{},{index:r}))})}},El=function(e,t){return function(n){var r=n.tr;return n.commands.insertContentAt({from:r.selection.from,to:r.selection.to},e,t)}},Al=function(e){for(var t=e.childNodes,n=t.length-1;n>=0;n-=1){var r=t[n];3===r.nodeType&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):1===r.nodeType&&Al(r)}return e};function Dl(e){if("undefined"==typeof window)throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");var t="<body>".concat(e,"</body>"),n=(new window.DOMParser).parseFromString(t,"text/html").body;return Al(n)}function Il(e,t,n){if(e instanceof li||e instanceof Fr)return e;n=g({slice:!0,parseOptions:{}},n);var r="string"==typeof e;if("object"===T(e)&&null!==e)try{if(Array.isArray(e)&&e.length>0)return Fr.fromArray(e.map(function(e){return t.nodeFromJSON(e)}));var i=t.nodeFromJSON(e);return n.errorOnInvalidContent&&i.check(),i}catch(u){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:u});return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",u),Il("",t,n)}if(r){if(n.errorOnInvalidContent){var o=!1,a="",s=new Ei({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:function(e){return o=!0,a="string"==typeof e?e:e.outerHTML,null}}]}})});if(n.slice?Di.fromSchema(s).parseSlice(Dl(e),n.parseOptions):Di.fromSchema(s).parse(Dl(e),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error("Invalid element found: ".concat(a))})}var c=Di.fromSchema(t);return n.slice?c.parseSlice(Dl(e),n.parseOptions).content:c.parse(Dl(e),n.parseOptions)}return Il("",t,n)}var zl=function(e,t,n){return function(r){var i,o=r.tr,a=r.dispatch,s=r.editor;if(a){var c;n=g({parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1},n);var u=function(e){s.emit("contentError",{editor:s,error:e,disableCollaboration:function(){"collaboration"in s.storage&&"object"===T(s.storage.collaboration)&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},l=g({preserveWhitespace:"full"},n.parseOptions);if(!n.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{Il(t,s.schema,{parseOptions:l,errorOnInvalidContent:!0})}catch(pt){u(pt)}try{c=Il(t,s.schema,{parseOptions:l,errorOnInvalidContent:null!=(i=n.errorOnInvalidContent)?i:s.options.enableContentCheck})}catch(pt){return u(pt),!1}var d,h="number"==typeof e?{from:e,to:e}:{from:e.from,to:e.to},f=h.from,p=h.to,v=!0,m=!0;if(("type"in c?[c]:c).forEach(function(e){e.check(),v=!!v&&(e.isText&&0===e.marks.length),m=!!m&&e.isBlock}),f===p&&m){var y=o.doc.resolve(f).parent;y.isTextblock&&!y.type.spec.code&&!y.childCount&&(f-=1,p+=1)}if(v){if(Array.isArray(t))d=t.map(function(e){return e.text||""}).join("");else if(t instanceof Fr){var k="";t.forEach(function(e){e.text&&(k+=e.text)}),d=k}else d="object"===T(t)&&t&&t.text?t.text:t;o.insertText(d,f,p)}else{d=c;var w=o.doc.resolve(f),b=w.node(),x=0===w.parentOffset,C=b.isText||b.isTextblock,S=b.content.size>0;x&&C&&S&&(f=Math.max(0,f-1)),o.replaceWith(f,p,d)}n.updateSelection&&function(e,t,n){var r=e.steps.length-1;if(!(r<t)){var i=e.steps[r];if(i instanceof co||i instanceof uo){var o=e.mapping.maps[r],a=0;o.forEach(function(e,t,n,r){0===a&&(a=r)}),e.setSelection(Fo.near(e.doc.resolve(a),n))}}}(o,o.steps.length-1,-1),n.applyInputRules&&o.setMeta("applyInputRules",{from:f,text:d}),n.applyPasteRules&&o.setMeta("applyPasteRules",{from:f,text:d})}return!0}},Rl=function(){return function(e){return function(e,t){var n,r=e.selection,i=r instanceof Uo;if(i){if(r.node.isTextblock||!wo(e.doc,r.from))return!1;n=r.from}else if(null==(n=xo(e.doc,r.from,-1)))return!1;if(t){var o=e.tr.join(n);i&&o.setSelection(Uo.create(o.doc,n-e.doc.resolve(n).nodeBefore.nodeSize)),t(o.scrollIntoView())}return!0}(e.state,e.dispatch)}},Pl=function(){return function(e){return function(e,t){var n,r=e.selection;if(r instanceof Uo){if(r.node.isTextblock||!wo(e.doc,r.to))return!1;n=r.to}else if(null==(n=xo(e.doc,r.to,1)))return!1;return t&&t(e.tr.join(n).scrollIntoView()),!0}(e.state,e.dispatch)}},Ll=function(){return function(e){return function(e,t,n){var r=ua(e,n);if(!r)return!1;var i=ha(r);if(!i){var o=r.blockRange(),a=o&&po(o);return null!=a&&(t&&t(e.tr.lift(o,a).scrollIntoView()),!0)}var s=i.nodeBefore;if(ma(e,i,t,-1))return!0;if(0==r.parent.content.size&&(da(s,"end")||Uo.isSelectable(s)))for(var c=r.depth;;c--){var u=So(e.doc,r.before(c),r.after(c),Ur.empty);if(u&&u.slice.size<u.to-u.from){if(t){var l=e.tr.step(u);l.setSelection(da(s,"end")?Fo.findFrom(l.doc.resolve(l.mapping.map(i.pos,-1)),-1):Uo.create(l.doc,i.pos-s.nodeSize)),t(l.scrollIntoView())}return!0}if(1==c||r.node(c-1).childCount>1)break}return!(!s.isAtom||i.depth!=r.depth-1||(t&&t(e.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),0))}(e.state,e.dispatch)}},Bl=function(){return function(e){return function(e,t,n){var r=fa(e,n);if(!r)return!1;var i=pa(r);if(!i)return!1;var o=i.nodeAfter;if(ma(e,i,t,1))return!0;if(0==r.parent.content.size&&(da(o,"start")||Uo.isSelectable(o))){var a=So(e.doc,r.before(),r.after(),Ur.empty);if(a&&a.slice.size<a.to-a.from){if(t){var s=e.tr.step(a);s.setSelection(da(o,"start")?Fo.findFrom(s.doc.resolve(s.mapping.map(i.pos)),1):Uo.create(s.doc,s.mapping.map(i.pos))),t(s.scrollIntoView())}return!0}}return!(!o.isAtom||i.depth!=r.depth-1||(t&&t(e.tr.delete(i.pos,i.pos+o.nodeSize).scrollIntoView()),0))}(e.state,e.dispatch)}},Vl=function(){return function(e){var t=e.state,n=e.dispatch,r=e.tr;try{var i=xo(t.doc,t.selection.$from.pos,-1);return null!=i&&(r.join(i,2),n&&n(r),!0)}catch(o){return!1}}},Fl=function(){return function(e){var t=e.state,n=e.dispatch,r=e.tr;try{var i=xo(t.doc,t.selection.$from.pos,1);return null!=i&&(r.join(i,2),n&&n(r),!0)}catch(o){return!1}}},$l=function(){return function(e){return function(e,t,n){var r=ua(e,n);if(!r)return!1;var i=ha(r);return!!i&&la(e,i,t)}(e.state,e.dispatch)}},jl=function(){return function(e){return function(e,t,n){var r=fa(e,n);if(!r)return!1;var i=pa(r);return!!i&&la(e,i,t)}(e.state,e.dispatch)}};function Hl(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}var Wl=function(e){return function(t){var n=t.editor,r=t.view,i=t.tr,o=t.dispatch,a=function(e){var t,n,r,i,o=e.split(/-(?!$)/),a=o[o.length-1];"Space"===a&&(a=" ");for(var s=0;s<o.length-1;s+=1){var c=o[s];if(/^(cmd|meta|m)$/i.test(c))i=!0;else if(/^a(lt)?$/i.test(c))t=!0;else if(/^(c|ctrl|control)$/i.test(c))n=!0;else if(/^s(hift)?$/i.test(c))r=!0;else{if(!/^mod$/i.test(c))throw new Error("Unrecognized modifier name: ".concat(c));Tl()||Hl()?i=!0:n=!0}}return t&&(a="Alt-".concat(a)),n&&(a="Ctrl-".concat(a)),i&&(a="Meta-".concat(a)),r&&(a="Shift-".concat(a)),a}(e).split(/-(?!$)/),s=a.find(function(e){return!["Alt","Ctrl","Meta","Shift"].includes(e)}),c=new KeyboardEvent("keydown",{key:"Space"===s?" ":s,altKey:a.includes("Alt"),ctrlKey:a.includes("Ctrl"),metaKey:a.includes("Meta"),shiftKey:a.includes("Shift"),bubbles:!0,cancelable:!0}),u=n.captureTransaction(function(){r.someProp("handleKeyDown",function(e){return e(r,c)})});return null==u||u.steps.forEach(function(e){var t=e.map(i.mapping);t&&o&&i.maybeStep(t)}),!0}};function ql(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=e.selection,i=r.from,o=r.to,a=r.empty,s=t?ll(t,e.schema):null,c=[];e.doc.nodesBetween(i,o,function(e,t){if(!e.isText){var n=Math.max(i,t),r=Math.min(o,t+e.nodeSize);c.push({node:e,from:n,to:r})}});var u=o-i,l=c.filter(function(e){return!s||s.name===e.node.type.name}).filter(function(e){return gl(e.node.attrs,n,{strict:!1})});return a?!!l.length:l.reduce(function(e,t){return e+t.to-t.from},0)>=u}var Ul=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.state,i=n.dispatch;return!!ql(r,ll(e,r.schema),t)&&function(e,t){var n=e.selection,r=n.$from,i=n.$to,o=r.blockRange(i),a=o&&po(o);return null!=a&&(t&&t(e.tr.lift(o,a).scrollIntoView()),!0)}(r,i)}},Jl=function(){return function(e){return function(e,t){var n=e.selection.$cursor;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){var r=n.before();if(ko(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}var i=n.blockRange(),o=i&&po(i);return null!=o&&(t&&t(e.tr.lift(i,o).scrollIntoView()),!0)}(e.state,e.dispatch)}},Kl=function(e){return function(t){var n=t.state,r=t.dispatch;return xa(ll(e,n.schema))(n,r)}},Yl=function(){return function(e){return function(e,t){var n=e.selection,r=n.$head,i=n.$anchor;return!(!r.parent.type.spec.code||!r.sameParent(i)||(t&&t(e.tr.insertText("\n").scrollIntoView()),0))}(e.state,e.dispatch)}};function Gl(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function Xl(e,t){var n="string"==typeof t?[t]:t;return Object.keys(e).reduce(function(t,r){return n.includes(r)||(t[r]=e[r]),t},{})}var Zl=function(e,t){return function(n){var r=n.tr,i=n.state,o=n.dispatch,a=null,s=null,c=Gl("string"==typeof e?e:e.name,i.schema);if(!c)return!1;"node"===c&&(a=ll(e,i.schema)),"mark"===c&&(s=bl(e,i.schema));var u=!1;return r.selection.ranges.forEach(function(e){i.doc.nodesBetween(e.$from.pos,e.$to.pos,function(e,n){a&&a===e.type&&(u=!0,o&&r.setNodeMarkup(n,void 0,Xl(e.attrs,t))),s&&e.marks.length&&e.marks.forEach(function(i){s===i.type&&(u=!0,o&&r.addMark(n,n+e.nodeSize,s.create(Xl(i.attrs,t))))})})}),u}},Ql=function(){return function(e){var t=e.tr;return e.dispatch&&t.scrollIntoView(),!0}},ed=function(){return function(e){var t=e.tr;if(e.dispatch){var n=new Ko(t.doc);t.setSelection(n)}return!0}},td=function(){return function(e){return function(e,t,n){var r=e.selection,i=r.$head,o=i;if(!r.empty)return!1;if(i.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):i.parentOffset>0)return!1;o=ha(i)}var a=o&&o.nodeBefore;return!(!a||!Uo.isSelectable(a)||(t&&t(e.tr.setSelection(Uo.create(e.doc,o.pos-a.nodeSize)).scrollIntoView()),0))}(e.state,e.dispatch)}},nd=function(){return function(e){return function(e,t,n){var r=e.selection,i=r.$head,o=i;if(!r.empty)return!1;if(i.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):i.parentOffset<i.parent.content.size)return!1;o=pa(i)}var a=o&&o.nodeAfter;return!(!a||!Uo.isSelectable(a)||(t&&t(e.tr.setSelection(Uo.create(e.doc,o.pos)).scrollIntoView()),0))}(e.state,e.dispatch)}},rd=function(){return function(e){return function(e,t){var n,r=e.selection,i=r.$from,o=r.to,a=i.sharedDepth(o);return 0!=a&&(n=i.before(a),t&&t(e.tr.setSelection(Uo.create(e.doc,n))),!0)}(e.state,e.dispatch)}},id=function(){return function(e){var t=e.state,n=e.dispatch;return ka(t,n)}},od=function(){return function(e){var t=e.state,n=e.dispatch;return ya(t,n)}};function ad(e,t){return Il(e,t,{slice:!1,parseOptions:arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},errorOnInvalidContent:(arguments.length>3&&void 0!==arguments[3]?arguments[3]:{}).errorOnInvalidContent})}var sd=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.errorOnInvalidContent,r=t.emitUpdate,i=void 0===r||r,o=t.parseOptions,a=void 0===o?{}:o;return function(t){var r=t.editor,o=t.tr,s=t.dispatch,c=t.commands,u=o.doc;if("full"!==a.preserveWhitespace){var l=ad(e,r.schema,a,{errorOnInvalidContent:null!=n?n:r.options.enableContentCheck});return s&&o.replaceWith(0,u.content.size,l).setMeta("preventUpdate",!i),!0}return s&&o.setMeta("preventUpdate",!i),c.insertContentAt({from:0,to:u.content.size},e,{parseOptions:a,errorOnInvalidContent:null!=n?n:r.options.enableContentCheck})}};function cd(e,t){var n=bl(t,e.schema),r=e.selection,i=r.from,o=r.to,a=r.empty,s=[];a?(e.storedMarks&&s.push.apply(s,c(e.storedMarks)),s.push.apply(s,c(e.selection.$head.marks()))):e.doc.nodesBetween(i,o,function(e){s.push.apply(s,c(e.marks))});var u=s.find(function(e){return e.type.name===n.name});return u?g({},u.attrs):{}}function ud(e){return function(t){return function(e,t){for(var n=e.depth;n>0;n-=1){var r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}(t.$from,e)}}function ld(e,t,n){return void 0===e.config[t]&&e.parent?ld(e.parent,t,n):"function"==typeof e.config[t]?e.config[t].bind(g(g({},n),{},{parent:e.parent?ld(e.parent,t,n):null})):e.config[t]}function dd(e){return e.map(function(e){var t=ld(e,"addExtensions",{name:e.name,options:e.options,storage:e.storage});return t?[e].concat(c(dd(t()))):e}).flat(10)}function hd(e,t){var n=ji.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function fd(e){return"function"==typeof e}function pd(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;if(fd(e)){for(var n=arguments.length,r=new Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return t?e.bind(t).apply(void 0,r):e.apply(void 0,r)}return e}function vd(e){return{baseExtensions:e.filter(function(e){return"extension"===e.type}),nodeExtensions:e.filter(function(e){return"node"===e.type}),markExtensions:e.filter(function(e){return"mark"===e.type})}}function md(e){var t=[],n=vd(e),r=n.nodeExtensions,i=n.markExtensions,o=[].concat(c(r),c(i)),a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return e.forEach(function(e){var n=ld(e,"addGlobalAttributes",{name:e.name,options:e.options,storage:e.storage,extensions:o});n&&n().forEach(function(e){e.types.forEach(function(n){Object.entries(e.attributes).forEach(function(e){var r=d(e,2),i=r[0],o=r[1];t.push({type:n,name:i,attribute:g(g({},a),o)})})})})}),o.forEach(function(e){var n={name:e.name,options:e.options,storage:e.storage},r=ld(e,"addAttributes",n);if(r){var i=r();Object.entries(i).forEach(function(n){var r=d(n,2),i=r[0],o=r[1],s=g(g({},a),o);"function"==typeof(null==s?void 0:s.default)&&(s.default=s.default()),(null==s?void 0:s.isRequired)&&void 0===(null==s?void 0:s.default)&&delete s.default,t.push({type:e.name,name:i,attribute:s})})}}),t}function gd(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter(function(e){return!!e}).reduce(function(e,t){var n=g({},e);return Object.entries(t).forEach(function(e){var t=d(e,2),r=t[0],i=t[1];if(n[r])if("class"===r){var o=i?String(i).split(" "):[],a=n[r]?n[r].split(" "):[],s=o.filter(function(e){return!a.includes(e)});n[r]=[].concat(c(a),c(s)).join(" ")}else if("style"===r){var u=i?i.split(";").map(function(e){return e.trim()}).filter(Boolean):[],l=n[r]?n[r].split(";").map(function(e){return e.trim()}).filter(Boolean):[],h=new Map;l.forEach(function(e){var t=d(e.split(":").map(function(e){return e.trim()}),2),n=t[0],r=t[1];h.set(n,r)}),u.forEach(function(e){var t=d(e.split(":").map(function(e){return e.trim()}),2),n=t[0],r=t[1];h.set(n,r)}),n[r]=Array.from(h.entries()).map(function(e){var t=d(e,2),n=t[0],r=t[1];return"".concat(n,": ").concat(r)}).join("; ")}else n[r]=i;else n[r]=i}),n},{})}function yd(e,t){return t.filter(function(t){return t.type===e.type.name}).filter(function(e){return e.attribute.rendered}).map(function(t){return t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:_({},t.name,e.attrs[t.name])}).reduce(function(e,t){return gd(e,t)},{})}function kd(e,t){return"style"in e?e:g(g({},e),{},{getAttrs:function(n){var r=e.getAttrs?e.getAttrs(n):e.attrs;if(!1===r)return!1;var i=t.reduce(function(e,t){var r=t.attribute.parseHTML?t.attribute.parseHTML(n):function(e){return"string"!=typeof e?e:e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):"true"===e||"false"!==e&&e}(n.getAttribute(t.name));return null==r?e:g(g({},e),{},_({},t.name,r))},{});return g(g({},r),i)}})}function wd(e){return Object.fromEntries(Object.entries(e).filter(function(e){var t=d(e,2),n=t[0],r=t[1];return("attrs"!==n||!function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return 0===Object.keys(e).length&&e.constructor===Object}(r))&&null!=r}))}function bd(e){var t,n,r={};return!(null==(t=null==e?void 0:e.attribute)?void 0:t.isRequired)&&"default"in((null==e?void 0:e.attribute)||{})&&(r.default=e.attribute.default),void 0!==(null==(n=null==e?void 0:e.attribute)?void 0:n.validate)&&(r.validate=e.attribute.validate),[e.name,r]}function xd(e){return e.sort(function(e,t){var n=ld(e,"priority")||100,r=ld(t,"priority")||100;return n>r?-1:n<r?1:0})}function Cd(e){var t,n,r=xd(dd(e)),i=(t=r.map(function(e){return e.name}),n=t.filter(function(e,n){return t.indexOf(e)!==n}),Array.from(new Set(n)));return i.length&&console.warn("[tiptap warn]: Duplicate extension names found: [".concat(i.map(function(e){return"'".concat(e,"'")}).join(", "),"]. This can lead to issues.")),r}function Sd(e,t,n){var r=t.from,i=t.to,o=n||{},a=o.blockSeparator,s=void 0===a?"\n\n":a,c=o.textSerializers,u=void 0===c?{}:c,l="";return e.nodesBetween(r,i,function(e,n,o,a){var c;e.isBlock&&n>r&&(l+=s);var d=null==u?void 0:u[e.type.name];if(d)return o&&(l+=d({node:e,pos:n,parent:o,index:a,range:t})),!1;e.isText&&(l+=null==(c=null==e?void 0:e.text)?void 0:c.slice(Math.max(r,n)-n,i-n))}),l}function _d(e){return Object.fromEntries(Object.entries(e.nodes).filter(function(e){return d(e,2)[1].spec.toText}).map(function(e){var t=d(e,2);return[t[0],t[1].spec.toText]}))}function Md(e,t){var n=Gl("string"==typeof t?t:t.name,e.schema);return"node"===n?function(e,t){var n=ll(t,e.schema),r=e.selection,i=r.from,o=r.to,a=[];e.doc.nodesBetween(i,o,function(e){a.push(e)});var s=a.reverse().find(function(e){return e.type.name===n.name});return s?g({},s.attrs):{}}(e,t):"mark"===n?cd(e,t):{}}function Td(e){var t=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:JSON.stringify,n={};return e.filter(function(e){var r=t(e);return!Object.prototype.hasOwnProperty.call(n,r)&&(n[r]=!0)})}(e);return 1===t.length?t:t.filter(function(e,n){var r=t.filter(function(e,t){return t!==n});return!r.some(function(t){return e.oldRange.from>=t.oldRange.from&&e.oldRange.to<=t.oldRange.to&&e.newRange.from>=t.newRange.from&&e.newRange.to<=t.newRange.to})})}function Od(e,t){return t.nodes[e]||t.marks[e]||null}function Nd(e,t,n){return Object.fromEntries(Object.entries(n).filter(function(n){var r=d(n,1)[0],i=e.find(function(e){return e.type===t&&e.name===r});return!!i&&i.attribute.keepOnSplit}))}function Ed(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=e.selection,i=r.empty,o=r.ranges,a=t?bl(t,e.schema):null;if(i)return!!(e.storedMarks||e.selection.$from.marks()).filter(function(e){return!a||a.name===e.type.name}).find(function(e){return gl(e.attrs,n,{strict:!1})});var s=0,u=[];if(o.forEach(function(t){var n=t.$from,r=t.$to,i=n.pos,o=r.pos;e.doc.nodesBetween(i,o,function(e,t){if(e.isText||e.marks.length){var n=Math.max(i,t),r=Math.min(o,t+e.nodeSize);s+=r-n,u.push.apply(u,c(e.marks.map(function(e){return{mark:e,from:n,to:r}})))}})}),0===s)return!1;var l=u.filter(function(e){return!a||a.name===e.mark.type.name}).filter(function(e){return gl(e.mark.attrs,n,{strict:!1})}).reduce(function(e,t){return e+t.to-t.from},0),d=u.filter(function(e){return!a||e.mark.type!==a&&e.mark.type.excludes(a)}).reduce(function(e,t){return e+t.to-t.from},0);return(l>0?l+d:l)>=s}function Ad(e,t){return Array.isArray(t)?t.some(function(t){return("string"==typeof t?t:t.name)===e.name}):t}function Dd(e,t){var n=vd(t).nodeExtensions.find(function(t){return t.name===e});if(!n)return!1;var r=pd(ld(n,"group",{name:n.name,options:n.options,storage:n.storage}));return"string"==typeof r&&r.split(" ").includes("list")}function Id(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.checkChildren,i=void 0===r||r,o=n.ignoreWhitespace,a=void 0!==o&&o;if(a){if("hardBreak"===e.type.name)return!0;if(e.isText)return/^\s*$/m.test(null!=(t=e.text)?t:"")}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(0===e.content.childCount)return!0;if(i){var s=!0;return e.content.forEach(function(e){!1!==s&&(Id(e,{ignoreWhitespace:a,checkChildren:i})||(s=!1))}),s}return!1}var zd=function(){function e(t){x(this,e),this.position=t}return S(e,[{key:"toJSON",value:function(){return{position:this.position}}}],[{key:"fromJSON",value:function(t){return new e(t.position)}}])}();function Rd(e,t){var n=t.mapping.mapResult(e.position);return{position:new zd(n.pos),mapResult:n}}function Pd(e){return new zd(e)}var Ld=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.tr,i=n.state,o=n.dispatch,a=r.selection,s=a.empty,c=a.ranges,u=bl(e,i.schema);if(o)if(s){var l=cd(i,u);r.addStoredMark(u.create(g(g({},l),t)))}else c.forEach(function(e){var n=e.$from.pos,o=e.$to.pos;i.doc.nodesBetween(n,o,function(e,i){var a=Math.max(i,n),s=Math.min(i+e.nodeSize,o);e.marks.find(function(e){return e.type===u})?e.marks.forEach(function(e){u===e.type&&r.addMark(a,s,u.create(g(g({},e.attrs),t)))}):r.addMark(a,s,u.create(t))})});return function(e,t,n){var r,i=t.selection,o=null;if(Sl(i)&&(o=i.$cursor),o){var a=null!=(r=e.storedMarks)?r:o.marks();return o.parent.type.allowsMarkType(n)&&(!!n.isInSet(a)||!a.some(function(e){return e.type.excludes(n)}))}return i.ranges.some(function(t){var r=t.$from,i=t.$to,o=0===r.depth&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(r.pos,i.pos,function(e,t,r){if(o)return!1;if(e.isInline){var i=!r||r.type.allowsMarkType(n),a=!!n.isInSet(e.marks)||!e.marks.some(function(e){return e.type.excludes(n)});o=i&&a}return!o}),o})}(i,r,u)}},Bd=function(e,t){return function(n){return n.tr.setMeta(e,t),!0}},Vd=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r,i=n.state,o=n.dispatch,a=n.chain,s=ll(e,i.schema);return i.selection.$anchor.sameParent(i.selection.$head)&&(r=i.selection.$anchor.parent.attrs),s.isTextblock?a().command(function(e){var n=e.commands;return!!wa(s,g(g({},r),t))(i)||n.clearNodes()}).command(function(e){var n=e.state;return wa(s,g(g({},r),t))(n,o)}).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)}},Fd=function(e){return function(t){var n=t.tr;if(t.dispatch){var r=n.doc,i=_l(e,0,r.content.size),o=Uo.create(r,i);n.setSelection(o)}return!0}},$d=function(e,t){return function(n){var r,i,o=n.tr,a=n.state,s=n.dispatch,c=a.selection;return"number"==typeof t?(r=t,i=t):t&&"from"in t&&"to"in t?(r=t.from,i=t.to):(r=c.from,i=c.to),s&&o.doc.nodesBetween(r,i,function(t,n){t.isText||o.setNodeMarkup(n,void 0,g(g({},t.attrs),{},{dir:e}))}),!0}},jd=function(e){return function(t){var n=t.tr;if(t.dispatch){var r=n.doc,i="number"==typeof e?{from:e,to:e}:e,o=i.from,a=i.to,s=Wo.atStart(r).from,c=Wo.atEnd(r).to,u=_l(o,s,c),l=_l(a,s,c),d=Wo.create(r,u,l);n.setSelection(d)}return!0}},Hd=function(e){return function(t){var n,r=t.state,i=t.dispatch,o=ll(e,r.schema);return(n=o,function(e,t){var r=e.selection,i=r.$from,o=r.$to,a=i.blockRange(o,function(e){return e.childCount>0&&e.firstChild.type==n});if(!a)return!1;var s=a.startIndex;if(0==s)return!1;var c=a.parent,u=c.child(s-1);if(u.type!=n)return!1;if(t){var l=u.lastChild&&u.lastChild.type==c.type,d=Fr.from(l?n.create():null),h=new Ur(Fr.from(n.create(null,Fr.from(c.type.create(null,d)))),l?3:1,0),f=a.start,p=a.end;t(e.tr.step(new uo(f-(l?3:1),p,f,p,h,1,!0)).scrollIntoView())}return!0})(r,i)}};function Wd(e,t){var n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){var r=n.filter(function(e){return null==t?void 0:t.includes(e.type.name)});e.tr.ensureMarks(r)}}var qd=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).keepMarks,t=void 0===e||e;return function(e){var n=e.tr,r=e.state,i=e.dispatch,o=e.editor,a=n.selection,s=n.doc,c=a.$from,u=a.$to,l=Nd(o.extensionManager.attributes,c.node().type.name,c.node().attrs);if(a instanceof Uo&&a.node.isBlock)return!(!c.parentOffset||!ko(s,c.pos))&&(i&&(t&&Wd(r,o.extensionManager.splittableMarks),n.split(c.pos).scrollIntoView()),!0);if(!c.parent.isBlock)return!1;var d=u.parentOffset===u.parent.content.size,h=0===c.depth?void 0:function(e){for(var t=0;t<e.edgeCount;t+=1){var n=e.edge(t).type;if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}(c.node(-1).contentMatchAt(c.indexAfter(-1))),f=d&&h?[{type:h,attrs:l}]:void 0,p=ko(n.doc,n.mapping.map(c.pos),1,f);if(f||p||!ko(n.doc,n.mapping.map(c.pos),1,h?[{type:h}]:void 0)||(p=!0,f=h?[{type:h,attrs:l}]:void 0),i){if(p&&(a instanceof Wo&&n.deleteSelection(),n.split(n.mapping.map(c.pos),1,f),h&&!d&&!c.parentOffset&&c.parent.type!==h)){var v=n.mapping.map(c.before()),m=n.doc.resolve(v);c.node(-1).canReplaceWith(m.index(),m.index()+1,h)&&n.setNodeMarkup(n.mapping.map(c.before()),h)}t&&Wd(r,o.extensionManager.splittableMarks),n.scrollIntoView()}return p}},Ud=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r,i=n.tr,o=n.state,a=n.dispatch,s=n.editor,c=ll(e,o.schema),u=o.selection,l=u.$from,d=u.$to,h=o.selection.node;if(h&&h.isBlock||l.depth<2||!l.sameParent(d))return!1;var f=l.node(-1);if(f.type!==c)return!1;var p=s.extensionManager.attributes;if(0===l.parent.content.size&&l.node(-1).childCount===l.indexAfter(-1)){if(2===l.depth||l.node(-3).type!==c||l.index(-2)!==l.node(-2).childCount-1)return!1;if(a){for(var v=Fr.empty,m=l.index(-1)?1:l.index(-2)?2:3,y=l.depth-m;y>=l.depth-3;y-=1)v=Fr.from(l.node(y).copy(v));var k=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,w=g(g({},Nd(p,l.node().type.name,l.node().attrs)),t),b=(null==(r=c.contentMatch.defaultType)?void 0:r.createAndFill(w))||void 0;v=v.append(Fr.from(c.createAndFill(null,b)||void 0));var x=l.before(l.depth-(m-1));i.replace(x,l.after(-k),new Ur(v,4-m,0));var C=-1;i.doc.nodesBetween(x,i.doc.content.size,function(e,t){if(C>-1)return!1;e.isTextblock&&0===e.content.size&&(C=t+1)}),C>-1&&i.setSelection(Wo.near(i.doc.resolve(C))),i.scrollIntoView()}return!0}var S=d.pos===l.end()?f.contentMatchAt(0).defaultType:null,_=g(g({},Nd(p,f.type.name,f.attrs)),t),M=g(g({},Nd(p,l.node().type.name,l.node().attrs)),t);i.delete(l.pos,d.pos);var T=S?[{type:c,attrs:_},{type:S,attrs:M}]:[{type:c,attrs:_}];if(!ko(i.doc,l.pos,2))return!1;if(a){var O=o.selection,N=o.storedMarks,E=s.extensionManager.splittableMarks,A=N||O.$to.parentOffset&&O.$from.marks();if(i.split(l.pos,2,T).scrollIntoView(),!A||!a)return!0;var D=A.filter(function(e){return E.includes(e.type.name)});i.ensureMarks(D)}return!0}},Jd=function(e,t){var n=ud(function(e){return e.type===t})(e.selection);if(!n)return!0;var r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===r)return!0;var i=e.doc.nodeAt(r);return n.node.type!==(null==i?void 0:i.type)||!wo(e.doc,n.pos)||(e.join(n.pos),!0)},Kd=function(e,t){var n=ud(function(e){return e.type===t})(e.selection);if(!n)return!0;var r=e.doc.resolve(n.start).after(n.depth);if(void 0===r)return!0;var i=e.doc.nodeAt(r);return n.node.type!==(null==i?void 0:i.type)||!wo(e.doc,r)||(e.join(r),!0)},Yd=function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return function(i){var o=i.editor,a=i.tr,s=i.state,c=i.dispatch,u=i.chain,l=i.commands,d=i.can,h=o.extensionManager,f=h.extensions,p=h.splittableMarks,v=ll(e,s.schema),m=ll(t,s.schema),g=s.selection,y=s.storedMarks,k=g.$from,w=g.$to,b=k.blockRange(w),x=y||g.$to.parentOffset&&g.$from.marks();if(!b)return!1;var C=ud(function(e){return Dd(e.type.name,f)})(g);if(b.depth>=1&&C&&b.depth-C.depth<=1){if(C.node.type===v)return l.liftListItem(m);if(Dd(C.node.type.name,f)&&v.validContent(C.node.content)&&c)return u().command(function(){return a.setNodeMarkup(C.pos,v),!0}).command(function(){return Jd(a,v)}).command(function(){return Kd(a,v)}).run()}return n&&x&&c?u().command(function(){var e=d().wrapInList(v,r),t=x.filter(function(e){return p.includes(e.type.name)});return a.ensureMarks(t),!!e||l.clearNodes()}).wrapInList(v,r).command(function(){return Jd(a,v)}).command(function(){return Kd(a,v)}).run():u().command(function(){return!!d().wrapInList(v,r)||l.clearNodes()}).wrapInList(v,r).command(function(){return Jd(a,v)}).command(function(){return Kd(a,v)}).run()}},Gd=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(r){var i=r.state,o=r.commands,a=n.extendEmptyMarkRange,s=void 0!==a&&a,c=bl(e,i.schema);return Ed(i,c,t)?o.unsetMark(c,{extendEmptyMarkRange:s}):o.setMark(c,t)}},Xd=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(r){var i,o=r.state,a=r.commands,s=ll(e,o.schema),c=ll(t,o.schema),u=ql(o,s,n);return o.selection.$anchor.sameParent(o.selection.$head)&&(i=o.selection.$anchor.parent.attrs),u?a.setNode(c,i):a.setNode(s,g(g({},i),n))}},Zd=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.state,i=n.commands,o=ll(e,r.schema);return ql(r,o,t)?i.lift(o):i.wrapIn(o,t)}},Qd=function(){return function(e){for(var t=e.state,n=e.dispatch,r=t.plugins,i=0;i<r.length;i+=1){var o=r[i],a=void 0;if(o.spec.isInputRules&&(a=o.getState(t))){if(n){for(var s=t.tr,c=a.transform,u=c.steps.length-1;u>=0;u-=1)s.step(c.steps[u].invert(c.docs[u]));if(a.text){var l=s.doc.resolve(a.from).marks();s.replaceWith(a.from,a.to,t.schema.text(a.text,l))}else s.delete(a.from,a.to)}return!0}}return!1}},eh=function(){return function(e){var t=e.tr,n=e.dispatch,r=t.selection,i=r.empty,o=r.ranges;return i||n&&o.forEach(function(e){t.removeMark(e.$from.pos,e.$to.pos)}),!0}},th=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r,i=n.tr,o=n.state,a=n.dispatch,s=t.extendEmptyMarkRange,c=void 0!==s&&s,u=i.selection,l=bl(e,o.schema),d=u.$from,h=u.empty,f=u.ranges;if(!a)return!0;if(h&&c){var p=u.from,v=u.to,m=null==(r=d.marks().find(function(e){return e.type===l}))?void 0:r.attrs,g=wl(d,l,m);g&&(p=g.from,v=g.to),i.removeMark(p,v,l)}else f.forEach(function(e){i.removeMark(e.$from.pos,e.$to.pos,l)});return i.removeStoredMark(l),!0}},nh=function(e){return function(t){var n,r,i=t.tr,o=t.state,a=t.dispatch,s=o.selection;return"number"==typeof e?(n=e,r=e):e&&"from"in e&&"to"in e?(n=e.from,r=e.to):(n=s.from,r=s.to),a&&i.doc.nodesBetween(n,r,function(e,t){if(!e.isText){var n=g({},e.attrs);delete n.dir,i.setNodeMarkup(t,void 0,n)}}),!0}},rh=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.tr,i=n.state,o=n.dispatch,a=null,s=null,c=Gl("string"==typeof e?e:e.name,i.schema);if(!c)return!1;"node"===c&&(a=ll(e,i.schema)),"mark"===c&&(s=bl(e,i.schema));var u=!1;return r.selection.ranges.forEach(function(e){var n,c,l,d,h=e.$from.pos,f=e.$to.pos;r.selection.empty?i.doc.nodesBetween(h,f,function(e,t){a&&a===e.type&&(u=!0,l=Math.max(t,h),d=Math.min(t+e.nodeSize,f),n=t,c=e)}):i.doc.nodesBetween(h,f,function(e,i){i<h&&a&&a===e.type&&(u=!0,l=Math.max(i,h),d=Math.min(i+e.nodeSize,f),n=i,c=e),i>=h&&i<=f&&(a&&a===e.type&&(u=!0,o&&r.setNodeMarkup(i,void 0,g(g({},e.attrs),t))),s&&e.marks.length&&e.marks.forEach(function(n){if(s===n.type&&(u=!0,o)){var a=Math.max(i,h),c=Math.min(i+e.nodeSize,f);r.addMark(a,c,s.create(g(g({},n.attrs),t)))}}))}),c&&(void 0!==n&&o&&r.setNodeMarkup(n,void 0,g(g({},c.attrs),t)),s&&c.marks.length&&c.marks.forEach(function(e){s===e.type&&o&&r.addMark(l,d,s.create(g(g({},e.attrs),t)))}))}),u}},ih=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.state,i=n.dispatch;return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return function(n,r){var i=n.selection,o=i.$from,a=i.$to,s=o.blockRange(a),c=s&&vo(s,e,t);return!!c&&(r&&r(n.tr.wrap(s,c).scrollIntoView()),!0)}}(ll(e,r.schema),t)(r,i)}},oh=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.state,i=n.dispatch;return ba(ll(e,r.schema),t)(r,i)}},ah=function(){return S(function e(){x(this,e),this.callbacks={}},[{key:"on",value:function(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}},{key:"emit",value:function(e){for(var t=this,n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];var o=this.callbacks[e];return o&&o.forEach(function(e){return e.apply(t,r)}),this}},{key:"off",value:function(e,t){var n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(function(e){return e!==t}):delete this.callbacks[e]),this}},{key:"once",value:function(e,t){var n=this,r=function(){n.off(e,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];t.apply(n,o)};return this.on(e,r)}},{key:"removeAllListeners",value:function(){this.callbacks={}}}])}(),sh=S(function e(t){var n;x(this,e),this.find=t.find,this.handler=t.handler,this.undoable=null==(n=t.undoable)||n});function ch(e){var t,n=e.editor,r=e.from,i=e.to,o=e.text,a=e.rules,s=e.plugin,c=n.view;if(c.composing)return!1;var u=c.state.doc.resolve(r);if(u.parent.type.spec.code||(null==(t=u.nodeBefore||u.nodeAfter)?void 0:t.marks.find(function(e){return e.type.spec.code})))return!1;var l=!1,d=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,n="",r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,function(e,t,i,o){var a,s,c=(null==(s=(a=e.type.spec).toText)?void 0:s.call(a,{node:e,pos:t,parent:i,index:o}))||e.textContent||"%leaf%";n+=e.isAtom&&!e.isText?c:c.slice(0,Math.max(0,r-t))}),n}(u)+o;return a.forEach(function(e){if(!l){var t=function(e,t){if(ml(t))return t.exec(e);var n=t(e);if(!n)return null;var r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r}(d,e.find);if(t){var a=c.state.tr,u=el({state:c.state,transaction:a}),h={from:r-(t[0].length-o.length),to:i},f=new tl({editor:n,state:u}),p=f.commands,v=f.chain,m=f.can;null!==e.handler({state:u,range:h,match:t,commands:p,chain:v,can:m})&&a.steps.length&&(e.undoable&&a.setMeta(s,{transform:a,from:r,to:i,text:o}),c.dispatch(a),l=!0)}}}),l}function uh(e){return"Object"===function(e){return Object.prototype.toString.call(e).slice(8,-1)}(e)&&(e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype)}function lh(e,t){var n=g({},e);return uh(e)&&uh(t)&&Object.keys(t).forEach(function(r){uh(t[r])&&uh(e[r])?n[r]=lh(e[r],t[r]):n[r]=t[r]}),n}var dh=function(){return S(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};x(this,e),this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config=g(g({},this.config),t),this.name=this.config.name},[{key:"options",get:function(){return g({},pd(ld(this,"addOptions",{name:this.name}))||{})}},{key:"storage",get:function(){return g({},pd(ld(this,"addStorage",{name:this.name,options:this.options}))||{})}},{key:"configure",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=this.extend(g(g({},this.config),{},{addOptions:function(){return lh(e.options,t)}}));return n.name=this.name,n.parent=this.parent,n}},{key:"extend",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=new this.constructor(g(g({},this.config),e));return t.parent=this,this.child=t,t.name="name"in e?e.name:t.parent.name,t}}])}(),hh=function(t){function n(){var e;return x(this,n),(e=r(this,n,arguments)).type="mark",e}return a(n,t),S(n,[{key:"configure",value:function(t){return e(n,"configure",this,3)([t])}},{key:"extend",value:function(t){var r="function"==typeof t?t():t;return e(n,"extend",this,3)([r])}}],[{key:"create",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new n("function"==typeof e?e():e)}},{key:"handleExit",value:function(e){var t=e.editor,n=e.mark,r=t.state.tr,i=t.state.selection.$from;if(i.pos===i.end()){var o=i.marks(),a=!!o.find(function(e){return(null==e?void 0:e.type.name)===n.name});if(!a)return!1;var s=o.find(function(e){return(null==e?void 0:e.type.name)===n.name});return s&&r.removeStoredMark(s),r.insertText(" ",i.pos),t.view.dispatch(r),!0}return!1}}])}(dh);function fh(e){var t=e.editor,n=e.state,r=e.from,i=e.to,o=e.rule,a=e.pasteEvent,s=e.dropEvent,u=new tl({editor:t,state:n}),l=u.commands,d=u.chain,h=u.can,f=[];return n.doc.nodesBetween(r,i,function(e,t){var u,p,v,m,g;if(!(null==(p=null==(u=e.type)?void 0:u.spec)?void 0:p.code)&&(e.isText||e.isTextblock||e.isInline)){var y=null!=(g=null!=(m=null==(v=e.content)?void 0:v.size)?m:e.nodeSize)?g:0,k=Math.max(r,t),w=Math.min(i,t+y);if(!(k>=w))(function(e,t,n){if(ml(t))return c(e.matchAll(t));var r=t(e,n);return r?r.map(function(t){var n=[t.text];return n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),n.push(t.replaceWith)),n}):[]})(e.isText?e.text||"":e.textBetween(k-t,w-t,void 0,""),o.find,a).forEach(function(e){if(void 0!==e.index){var t=k+e.index+1,r=t+e[0].length,i={from:n.tr.mapping.map(t),to:n.tr.mapping.map(r)},c=o.handler({state:n,range:i,match:e,commands:l,chain:d,can:h,pasteEvent:a,dropEvent:s});f.push(c)}})}}),f.every(function(e){return null!==e})}var ph=null;function vh(e){var t,n=e.editor,r=e.rules,i=null,o=!1,a=!1,s="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null;try{t="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch(u){t=null}var c=function(e){var r=e.state,i=e.from,o=e.to,a=e.rule,c=e.pasteEvt,u=r.tr,l=el({state:r,transaction:u});if(fh({editor:n,state:l,from:Math.max(i-1,0),to:o.b-1,rule:a,pasteEvent:c,dropEvent:t})&&u.steps.length){try{t="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch(d){t=null}return s="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null,u}};return r.map(function(e){return new oa({view:function(e){var t=function(t){var r;(i=(null==(r=e.dom.parentElement)?void 0:r.contains(t.target))?e.dom.parentElement:null)&&(ph=n)},r=function(){ph&&(ph=null)};return window.addEventListener("dragstart",t),window.addEventListener("dragend",r),{destroy:function(){window.removeEventListener("dragstart",t),window.removeEventListener("dragend",r)}}},props:{handleDOMEvents:{drop:function(e,n){if(a=i===e.dom.parentElement,t=n,!a){var r=ph;(null==r?void 0:r.isEditable)&&setTimeout(function(){var e=r.state.selection;e&&r.commands.deleteRange({from:e.from,to:e.to})},10)}return!1},paste:function(e,t){var n,r=null==(n=t.clipboardData)?void 0:n.getData("text/html");return s=t,o=!!(null==r?void 0:r.includes("data-pm-slice")),!1}}},appendTransaction:function(t,n,r){var i=t[0],u="paste"===i.getMeta("uiEvent")&&!o,l="drop"===i.getMeta("uiEvent")&&!a,d=i.getMeta("applyPasteRules"),h=!!d;if(u||l||h){if(h){var f=d.text;"string"==typeof f||(f=hd(Fr.from(f),r.schema));var p=d.from,v=p+f.length,m=function(e){var t,n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return null==(t=n.clipboardData)||t.setData("text/html",e),n}(f);return c({rule:e,state:r,from:p,to:{b:v},pasteEvt:m})}var g=n.doc.content.findDiffStart(r.doc.content),y=n.doc.content.findDiffEnd(r.doc.content);if("number"==typeof g&&y&&g!==y.b)return c({rule:e,state:r,from:g,to:y,pasteEvt:s})}}})})}var mh=function(){return S(function e(t,n){x(this,e),this.splittableMarks=[],this.editor=n,this.baseExtensions=t,this.extensions=Cd(t),this.schema=function(e,t){var n,r=md(e),i=vd(e),o=i.nodeExtensions,a=i.markExtensions,s=null==(n=o.find(function(e){return ld(e,"topNode")}))?void 0:n.name,c=Object.fromEntries(o.map(function(n){var i=r.filter(function(e){return e.type===n.name}),o={name:n.name,options:n.options,storage:n.storage,editor:t},a=e.reduce(function(e,t){var r=ld(t,"extendNodeSchema",o);return g(g({},e),r?r(n):{})},{}),s=wd(g(g({},a),{},{content:pd(ld(n,"content",o)),marks:pd(ld(n,"marks",o)),group:pd(ld(n,"group",o)),inline:pd(ld(n,"inline",o)),atom:pd(ld(n,"atom",o)),selectable:pd(ld(n,"selectable",o)),draggable:pd(ld(n,"draggable",o)),code:pd(ld(n,"code",o)),whitespace:pd(ld(n,"whitespace",o)),linebreakReplacement:pd(ld(n,"linebreakReplacement",o)),defining:pd(ld(n,"defining",o)),isolating:pd(ld(n,"isolating",o)),attrs:Object.fromEntries(i.map(bd))})),c=pd(ld(n,"parseHTML",o));c&&(s.parseDOM=c.map(function(e){return kd(e,i)}));var u=ld(n,"renderHTML",o);u&&(s.toDOM=function(e){return u({node:e,HTMLAttributes:yd(e,i)})});var l=ld(n,"renderText",o);return l&&(s.toText=l),[n.name,s]})),u=Object.fromEntries(a.map(function(n){var i=r.filter(function(e){return e.type===n.name}),o={name:n.name,options:n.options,storage:n.storage,editor:t},a=e.reduce(function(e,t){var r=ld(t,"extendMarkSchema",o);return g(g({},e),r?r(n):{})},{}),s=wd(g(g({},a),{},{inclusive:pd(ld(n,"inclusive",o)),excludes:pd(ld(n,"excludes",o)),group:pd(ld(n,"group",o)),spanning:pd(ld(n,"spanning",o)),code:pd(ld(n,"code",o)),attrs:Object.fromEntries(i.map(bd))})),c=pd(ld(n,"parseHTML",o));c&&(s.parseDOM=c.map(function(e){return kd(e,i)}));var u=ld(n,"renderHTML",o);return u&&(s.toDOM=function(e){return u({mark:e,HTMLAttributes:yd(e,i)})}),[n.name,s]}));return new Ei({topNode:s,nodes:c,marks:u})}(this.extensions,n),this.setupExtensions()},[{key:"commands",get:function(){var e=this;return this.extensions.reduce(function(t,n){var r=ld(n,"addCommands",{name:n.name,options:n.options,storage:e.editor.extensionStorage[n.name],editor:e.editor,type:Od(n.name,e.schema)});return r?g(g({},t),r()):t},{})}},{key:"plugins",get:function(){var e=this,t=this.editor;return xd(c(this.extensions).reverse()).flatMap(function(n){var r={name:n.name,options:n.options,storage:e.editor.extensionStorage[n.name],editor:t,type:Od(n.name,e.schema)},i=[],o=ld(n,"addKeyboardShortcuts",r),a={};if("mark"===n.type&&ld(n,"exitable",r)&&(a.ArrowRight=function(){return hh.handleExit({editor:t,mark:n})}),o){var s=Object.fromEntries(Object.entries(o()).map(function(e){var n=d(e,2),r=n[0],i=n[1];return[r,function(){return i({editor:t})}]}));a=g(g({},a),s)}var u=function(e){return new oa({props:{handleKeyDown:Xu(e)}})}(a);i.push(u);var l=ld(n,"addInputRules",r);if(Ad(n,t.options.enableInputRules)&&l){var h=l();if(h&&h.length){var f=function(e){var t=e.editor,n=e.rules,r=new oa({state:{init:function(){return null},apply:function(e,i,o){var a=e.getMeta(r);if(a)return a;var s=e.getMeta("applyInputRules");return!!s&&setTimeout(function(){var e=s.text;"string"==typeof e||(e=hd(Fr.from(e),o.schema));var i=s.from,a=i+e.length;ch({editor:t,from:i,to:a,text:e,rules:n,plugin:r})}),e.selectionSet||e.docChanged?null:i}},props:{handleTextInput:function(e,i,o,a){return ch({editor:t,from:i,to:o,text:a,rules:n,plugin:r})},handleDOMEvents:{compositionend:function(e){return setTimeout(function(){var i=e.state.selection.$cursor;i&&ch({editor:t,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1}},handleKeyDown:function(e,i){if("Enter"!==i.key)return!1;var o=e.state.selection.$cursor;return!!o&&ch({editor:t,from:o.pos,to:o.pos,text:"\n",rules:n,plugin:r})}},isInputRules:!0});return r}({editor:t,rules:h}),p=Array.isArray(f)?f:[f];i.push.apply(i,c(p))}}var v=ld(n,"addPasteRules",r);if(Ad(n,t.options.enablePasteRules)&&v){var m=v();if(m&&m.length){var y=vh({editor:t,rules:m});i.push.apply(i,c(y))}}var k=ld(n,"addProseMirrorPlugins",r);if(k){var w=k();i.push.apply(i,c(w))}return i})}},{key:"attributes",get:function(){return md(this.extensions)}},{key:"nodeViews",get:function(){var e=this,t=this.editor,n=vd(this.extensions).nodeExtensions;return Object.fromEntries(n.filter(function(e){return!!ld(e,"addNodeView")}).map(function(n){var r=e.attributes.filter(function(e){return e.type===n.name}),i={name:n.name,options:n.options,storage:e.editor.extensionStorage[n.name],editor:t,type:ll(n.name,e.schema)},o=ld(n,"addNodeView",i);if(!o)return[];var a=o();if(!a)return[];return[n.name,function(e,i,o,s,c){var u=yd(e,r);return a({node:e,view:i,getPos:o,decorations:s,innerDecorations:c,editor:t,extension:n,HTMLAttributes:u})}]}))}},{key:"markViews",get:function(){var e=this,t=this.editor,n=vd(this.extensions).markExtensions;return Object.fromEntries(n.filter(function(e){return!!ld(e,"addMarkView")}).map(function(n){var r=e.attributes.filter(function(e){return e.type===n.name}),i={name:n.name,options:n.options,storage:e.editor.extensionStorage[n.name],editor:t,type:bl(n.name,e.schema)},o=ld(n,"addMarkView",i);if(!o)return[];return[n.name,function(e,i,a){var s=yd(e,r);return o()({mark:e,view:i,inline:a,editor:t,extension:n,HTMLAttributes:s,updateAttributes:function(n){!function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=t.state,i=r.doc,o=r.tr,a=e;i.descendants(function(t,r){var i=o.mapping.map(r),s=o.mapping.map(r)+t.nodeSize,c=null;if(t.marks.forEach(function(e){if(e!==a)return!1;c=e}),c){var u=!1;if(Object.keys(n).forEach(function(e){n[e]!==c.attrs[e]&&(u=!0)}),u){var l=e.type.create(g(g({},e.attrs),n));o.removeMark(i,s,e.type),o.addMark(i,s,l)}}}),o.docChanged&&t.view.dispatch(o)}(e,t,n)}})}]}))}},{key:"setupExtensions",value:function(){var e=this,t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(function(e){return[e.name,e.storage]})),t.forEach(function(t){var n,r={name:t.name,options:t.options,storage:e.editor.extensionStorage[t.name],editor:e.editor,type:Od(t.name,e.schema)};"mark"===t.type&&((null==(n=pd(ld(t,"keepOnSplit",r)))||n)&&e.splittableMarks.push(t.name));var i=ld(t,"onBeforeCreate",r),o=ld(t,"onCreate",r),a=ld(t,"onUpdate",r),s=ld(t,"onSelectionUpdate",r),c=ld(t,"onTransaction",r),u=ld(t,"onFocus",r),l=ld(t,"onBlur",r),d=ld(t,"onDestroy",r);i&&e.editor.on("beforeCreate",i),o&&e.editor.on("create",o),a&&e.editor.on("update",a),s&&e.editor.on("selectionUpdate",s),c&&e.editor.on("transaction",c),u&&e.editor.on("focus",u),l&&e.editor.on("blur",l),d&&e.editor.on("destroy",d)})}}])}();mh.resolve=Cd,mh.sort=xd,mh.flatten=dd;Qu({},{ClipboardTextSerializer:function(){return yh},Commands:function(){return kh},Delete:function(){return wh},Drop:function(){return bh},Editable:function(){return xh},FocusEvents:function(){return Sh},Keymap:function(){return _h},Paste:function(){return Mh},Tabindex:function(){return Th},TextDirection:function(){return Oh},focusEventsPluginKey:function(){return Ch}});var gh=function(t){function n(){var e;return x(this,n),(e=r(this,n,arguments)).type="extension",e}return a(n,t),S(n,[{key:"configure",value:function(t){return e(n,"configure",this,3)([t])}},{key:"extend",value:function(t){var r="function"==typeof t?t():t;return e(n,"extend",this,3)([r])}}],[{key:"create",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new n("function"==typeof e?e():e)}}])}(dh),yh=gh.create({name:"clipboardTextSerializer",addOptions:function(){return{blockSeparator:void 0}},addProseMirrorPlugins:function(){var e=this;return[new oa({key:new ca("clipboardTextSerializer"),props:{clipboardTextSerializer:function(){var t=e.editor,n=t.state,r=t.schema,i=n.doc,o=n.selection.ranges,a=Math.min.apply(Math,c(o.map(function(e){return e.$from.pos}))),s=Math.max.apply(Math,c(o.map(function(e){return e.$to.pos}))),u=_d(r);return Sd(i,{from:a,to:s},g(g({},void 0!==e.options.blockSeparator?{blockSeparator:e.options.blockSeparator}:{}),{},{textSerializers:u}))}}})]}}),kh=gh.create({name:"commands",addCommands:function(){return g({},nl)}}),wh=gh.create({name:"delete",onUpdate:function(e){var t,n,r,i=this,o=e.transaction,a=e.appendedTransactions,s=function(){var e,t,n,r;if(!(null!=(r=null==(n=null==(t=null==(e=i.editor.options.coreExtensionOptions)?void 0:e.delete)?void 0:t.filterTransaction)?void 0:n.call(t,o))?r:o.getMeta("y-sync$"))){var s,u,l,d=(s=o.before,u=[o].concat(c(a)),l=new Bo(s),u.forEach(function(e){e.steps.forEach(function(e){l.step(e)})}),l),h=function(e){var t=e.mapping,n=e.steps,r=[];return t.maps.forEach(function(e,i){var o=[];if(e.ranges.length)e.forEach(function(e,t){o.push({from:e,to:t})});else{var a=n[i],s=a.from,c=a.to;if(void 0===s||void 0===c)return;o.push({from:s,to:c})}o.forEach(function(e){var n=e.from,o=e.to,a=t.slice(i).map(n,-1),s=t.slice(i).map(o),c=t.invert().map(a,-1),u=t.invert().map(s);r.push({oldRange:{from:c,to:u},newRange:{from:a,to:s}})})}),Td(r)}(d);h.forEach(function(e){d.mapping.mapResult(e.oldRange.from).deletedAfter&&d.mapping.mapResult(e.oldRange.to).deletedBefore&&d.before.nodesBetween(e.oldRange.from,e.oldRange.to,function(t,n){var r=n+t.nodeSize-2,a=e.oldRange.from<=n&&r<=e.oldRange.to;i.editor.emit("delete",{type:"node",node:t,from:n,to:r,newFrom:d.mapping.map(n),newTo:d.mapping.map(r),deletedRange:e.oldRange,newRange:e.newRange,partial:!a,editor:i.editor,transaction:o,combinedTransform:d})})});var f=d.mapping;d.steps.forEach(function(e,t){var n,r;if(e instanceof oo){var a=f.slice(t).map(e.from,-1),s=f.slice(t).map(e.to),c=f.invert().map(a,-1),u=f.invert().map(s),l=null==(n=d.doc.nodeAt(a-1))?void 0:n.marks.some(function(t){return t.eq(e.mark)}),h=null==(r=d.doc.nodeAt(s))?void 0:r.marks.some(function(t){return t.eq(e.mark)});i.editor.emit("delete",{type:"mark",mark:e.mark,from:e.from,to:e.to,deletedRange:{from:c,to:u},newRange:{from:a,to:s},partial:Boolean(h||l),editor:i.editor,transaction:o,combinedTransform:d})}})}};null==(r=null==(n=null==(t=this.editor.options.coreExtensionOptions)?void 0:t.delete)?void 0:n.async)||r?setTimeout(s,0):s()}}),bh=gh.create({name:"drop",addProseMirrorPlugins:function(){var e=this;return[new oa({key:new ca("tiptapDrop"),props:{handleDrop:function(t,n,r,i){e.editor.emit("drop",{editor:e.editor,event:n,slice:r,moved:i})}}})]}}),xh=gh.create({name:"editable",addProseMirrorPlugins:function(){var e=this;return[new oa({key:new ca("editable"),props:{editable:function(){return e.editor.options.editable}}})]}}),Ch=new ca("focusEvents"),Sh=gh.create({name:"focusEvents",addProseMirrorPlugins:function(){var e=this.editor;return[new oa({key:Ch,props:{handleDOMEvents:{focus:function(t,n){e.isFocused=!0;var r=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1},blur:function(t,n){e.isFocused=!1;var r=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1}}}})]}}),_h=gh.create({name:"keymap",addKeyboardShortcuts:function(){var e=this,t=function(){return e.editor.commands.first(function(e){var t=e.commands;return[function(){return t.undoInputRule()},function(){return t.command(function(e){var n=e.tr,r=n.selection,i=n.doc,o=r.empty,a=r.$anchor,s=a.pos,c=a.parent,u=a.parent.isTextblock&&s>0?n.doc.resolve(s-1):a,l=u.parent.type.spec.isolating,d=a.pos-a.parentOffset,h=l&&1===u.parent.childCount?d===a.pos:Fo.atStart(i).from===s;return!(!o||!c.type.isTextblock||c.textContent.length||!h||h&&"paragraph"===a.parent.type.name)&&t.clearNodes()})},function(){return t.deleteSelection()},function(){return t.joinBackward()},function(){return t.selectNodeBackward()}]})},n=function(){return e.editor.commands.first(function(e){var t=e.commands;return[function(){return t.deleteSelection()},function(){return t.deleteCurrentNode()},function(){return t.joinForward()},function(){return t.selectNodeForward()}]})},r={Enter:function(){return e.editor.commands.first(function(e){var t=e.commands;return[function(){return t.newlineInCode()},function(){return t.createParagraphNear()},function(){return t.liftEmptyBlock()},function(){return t.splitBlock()}]})},"Mod-Enter":function(){return e.editor.commands.exitCode()},Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:n,"Mod-Delete":n,"Mod-a":function(){return e.editor.commands.selectAll()}},i=g({},r),o=g(g({},r),{},{"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":n,"Ctrl-Alt-Backspace":n,"Alt-Delete":n,"Alt-d":n,"Ctrl-a":function(){return e.editor.commands.selectTextblockStart()},"Ctrl-e":function(){return e.editor.commands.selectTextblockEnd()}});return Tl()||Hl()?o:i},addProseMirrorPlugins:function(){var e=this;return[new oa({key:new ca("clearDocument"),appendTransaction:function(t,n,r){if(!t.some(function(e){return e.getMeta("composition")})){var i=t.some(function(e){return e.docChanged})&&!n.doc.eq(r.doc),o=t.some(function(e){return e.getMeta("preventClearDocument")});if(i&&!o){var a=n.selection,s=a.empty,c=a.from,u=a.to,l=Fo.atStart(n.doc).from,d=Fo.atEnd(n.doc).to;if(!s&&(c===l&&u===d))if(Id(r.doc)){var h=r.tr,f=el({state:r,transaction:h});if(new tl({editor:e.editor,state:f}).commands.clearNodes(),h.steps.length)return h}}}}})]}}),Mh=gh.create({name:"paste",addProseMirrorPlugins:function(){var e=this;return[new oa({key:new ca("tiptapPaste"),props:{handlePaste:function(t,n,r){e.editor.emit("paste",{editor:e.editor,event:n,slice:r})}}})]}}),Th=gh.create({name:"tabindex",addProseMirrorPlugins:function(){var e=this;return[new oa({key:new ca("tabindex"),props:{attributes:function(){return e.editor.isEditable?{tabindex:"0"}:{}}}})]}}),Oh=gh.create({name:"textDirection",addOptions:function(){return{direction:void 0}},addGlobalAttributes:function(){var e=this;return this.options.direction?[{types:vd(this.extensions).nodeExtensions.filter(function(e){return"text"!==e.name}).map(function(e){return e.name}),attributes:{dir:{default:this.options.direction,parseHTML:function(t){var n=t.getAttribute("dir");return!n||"ltr"!==n&&"rtl"!==n&&"auto"!==n?e.options.direction:n},renderHTML:function(e){return e.dir?{dir:e.dir}:{}}}}}]:[]},addProseMirrorPlugins:function(){var e=this;return[new oa({key:new ca("textDirection"),props:{attributes:function(){var t=e.options.direction;return t?{dir:t}:{}}}})]}}),Nh=function(){function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;x(this,e),this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=t,this.editor=n,this.currentNode=i}return S(e,[{key:"name",get:function(){return this.node.type.name}},{key:"node",get:function(){return this.currentNode||this.resolvedPos.node()}},{key:"element",get:function(){return this.editor.view.domAtPos(this.pos).node}},{key:"depth",get:function(){var e;return null!=(e=this.actualDepth)?e:this.resolvedPos.depth}},{key:"pos",get:function(){return this.resolvedPos.pos}},{key:"content",get:function(){return this.node.content},set:function(e){var t=this.from,n=this.to;if(this.isBlock){if(0===this.content.size)return void console.error("You can’t set content on a block node. Tried to set content on ".concat(this.name," at ").concat(this.pos));t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},e)}},{key:"attributes",get:function(){return this.node.attrs}},{key:"textContent",get:function(){return this.node.textContent}},{key:"size",get:function(){return this.node.nodeSize}},{key:"from",get:function(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}},{key:"range",get:function(){return{from:this.from,to:this.to}}},{key:"to",get:function(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}},{key:"parent",get:function(){if(0===this.depth)return null;var t=this.resolvedPos.start(this.resolvedPos.depth-1);return new e(this.resolvedPos.doc.resolve(t),this.editor)}},{key:"before",get:function(){var t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new e(t,this.editor)}},{key:"after",get:function(){var t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new e(t,this.editor)}},{key:"children",get:function(){var t=this,n=[];return this.node.content.forEach(function(r,i){var o=r.isBlock&&!r.isTextblock,a=r.isAtom&&!r.isText,s=t.pos+i+(a?0:1);if(!(s<0||s>t.resolvedPos.doc.nodeSize-2)){var c=t.resolvedPos.doc.resolve(s);if(o||!(c.depth<=t.depth)){var u=new e(c,t.editor,o,o?r:null);o&&(u.actualDepth=t.depth+1),n.push(new e(c,t.editor,o,o?r:null))}}}),n}},{key:"firstChild",get:function(){return this.children[0]||null}},{key:"lastChild",get:function(){var e=this.children;return e[e.length-1]||null}},{key:"closest",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,r=this.parent;r&&!n;){if(r.node.type.name===e)if(Object.keys(t).length>0)for(var i=r.node.attrs,o=Object.keys(t),a=0;a<o.length;a+=1){var s=o[a];if(i[s]!==t[s])break}else n=r;r=r.parent}return n}},{key:"querySelector",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.querySelectorAll(e,t,!0)[0]||null}},{key:"querySelectorAll",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=[];if(!this.children||0===this.children.length)return r;var i=Object.keys(t);return this.children.forEach(function(o){if(!(n&&r.length>0)){if(o.node.type.name===e)i.every(function(e){return t[e]===o.node.attrs[e]})&&r.push(o);n&&r.length>0||(r=r.concat(o.querySelectorAll(e,t,n)))}}),r}},{key:"setAttribute",value:function(e){var t=this.editor.state.tr;t.setNodeMarkup(this.from,void 0,g(g({},this.node.attrs),e)),this.editor.view.dispatch(t)}}])}();var Eh=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};x(this,t),(e=r(this,t)).css=null,e.className="tiptap",e.editorView=null,e.isFocused=!1,e.isInitialized=!1,e.extensionStorage={},e.instanceId=Math.random().toString(36).slice(2,9),e.options={element:"undefined"!=typeof document?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:function(){return null},onCreate:function(){return null},onMount:function(){return null},onUnmount:function(){return null},onUpdate:function(){return null},onSelectionUpdate:function(){return null},onTransaction:function(){return null},onFocus:function(){return null},onBlur:function(){return null},onDestroy:function(){return null},onContentError:function(e){throw e.error},onPaste:function(){return null},onDrop:function(){return null},onDelete:function(){return null}},e.isCapturingTransaction=!1,e.capturedTransaction=null,e.utils={getUpdatedPosition:Rd,createMappablePosition:Pd},e.setOptions(n),e.createExtensionManager(),e.createCommandManager(),e.createSchema(),e.on("beforeCreate",e.options.onBeforeCreate),e.emit("beforeCreate",{editor:e}),e.on("mount",e.options.onMount),e.on("unmount",e.options.onUnmount),e.on("contentError",e.options.onContentError),e.on("create",e.options.onCreate),e.on("update",e.options.onUpdate),e.on("selectionUpdate",e.options.onSelectionUpdate),e.on("transaction",e.options.onTransaction),e.on("focus",e.options.onFocus),e.on("blur",e.options.onBlur),e.on("destroy",e.options.onDestroy),e.on("drop",function(t){var n=t.event,r=t.slice,i=t.moved;return e.options.onDrop(n,r,i)}),e.on("paste",function(t){var n=t.event,r=t.slice;return e.options.onPaste(n,r)}),e.on("delete",e.options.onDelete);var i=e.createDoc(),o=Ml(i,e.options.autofocus);return e.editorState=ra.create({doc:i,schema:e.schema,selection:o||void 0}),e.options.element&&e.mount(e.options.element),e}return a(t,e),S(t,[{key:"mount",value:function(e){var t=this;if("undefined"==typeof document)throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(e),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(function(){t.isDestroyed||(!1!==t.options.autofocus&&null!==t.options.autofocus&&t.commands.focus(t.options.autofocus),t.emit("create",{editor:t}),t.isInitialized=!0)},0)}},{key:"unmount",value:function(){if(this.editorView){var e=this.editorView.dom;(null==e?void 0:e.editor)&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(".".concat(this.className)).length)try{"function"==typeof this.css.remove?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}},{key:"storage",get:function(){return this.extensionStorage}},{key:"commands",get:function(){return this.commandManager.commands}},{key:"chain",value:function(){return this.commandManager.chain()}},{key:"can",value:function(){return this.commandManager.can()}},{key:"injectCSS",value:function(){this.options.injectCSS&&"undefined"!=typeof document&&(this.css=function(e,t,n){var r=document.querySelector("style[data-tiptap-style".concat(n?"-".concat(n):"","]"));if(null!==r)return r;var i=document.createElement("style");return t&&i.setAttribute("nonce",t),i.setAttribute("data-tiptap-style".concat(n?"-".concat(n):""),""),i.innerHTML=e,document.getElementsByTagName("head")[0].appendChild(i),i}('.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: "liga" 0; /* the above doesn\'t seem to work in Edge */\n}\n\n.ProseMirror [contenteditable="false"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable="false"] [contenteditable="true"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 0 !important;\n height: 0 !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\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}',this.options.injectNonce))}},{key:"setOptions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.options=g(g({},this.options),e),this.editorView&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}},{key:"setEditable",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}},{key:"isEditable",get:function(){return this.options.editable&&this.view&&this.view.editable}},{key:"view",get:function(){var e=this;return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:function(t){e.editorState=t},dispatch:function(t){e.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:function(t,n){if(e.editorView)return e.editorView[n];if("state"===n)return e.editorState;if(n in t)return Reflect.get(t,n);throw new Error("[tiptap error]: The editor view is not available. Cannot access view['".concat(n,"']. The editor may not be mounted yet."))}})}},{key:"state",get:function(){return this.editorView&&(this.editorState=this.view.state),this.editorState}},{key:"registerPlugin",value:function(e,t){var n=fd(t)?t(e,c(this.state.plugins)):[].concat(c(this.state.plugins),[e]),r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}},{key:"unregisterPlugin",value:function(e){if(!this.isDestroyed){var t=this.state.plugins,n=t;if([].concat(e).forEach(function(e){var t="string"==typeof e?"".concat(e,"$"):e.key;n=n.filter(function(e){return!e.key.startsWith(t)})}),t.length!==n.length){var r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}}}},{key:"createExtensionManager",value:function(){var e,t,n=this,r=this.options.enableCoreExtensions?[xh,yh.configure({blockSeparator:null==(t=null==(e=this.options.coreExtensionOptions)?void 0:e.clipboardTextSerializer)?void 0:t.blockSeparator}),kh,Sh,_h,Th,bh,Mh,wh,Oh.configure({direction:this.options.textDirection})].filter(function(e){return"object"!==T(n.options.enableCoreExtensions)||!1!==n.options.enableCoreExtensions[e.name]}):[],i=[].concat(c(r),c(this.options.extensions)).filter(function(e){return["extension","node","mark"].includes(null==e?void 0:e.type)});this.extensionManager=new mh(i,this)}},{key:"createCommandManager",value:function(){this.commandManager=new tl({editor:this})}},{key:"createSchema",value:function(){this.schema=this.extensionManager.schema}},{key:"createDoc",value:function(){var e,t=this;try{e=ad(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(pt){if(!(pt instanceof Error&&["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(pt.message)))throw pt;this.emit("contentError",{editor:this,error:pt,disableCollaboration:function(){"collaboration"in t.storage&&"object"===T(t.storage.collaboration)&&t.storage.collaboration&&(t.storage.collaboration.isDisabled=!0),t.options.extensions=t.options.extensions.filter(function(e){return"collaboration"!==e.name}),t.createExtensionManager()}}),e=ad(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return e}},{key:"createView",value:function(e){var t;this.editorView=new Ru(e,g(g({},this.options.editorProps),{},{attributes:g({role:"textbox"},null==(t=this.options.editorProps)?void 0:t.attributes),dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews}));var n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.prependClass(),this.injectCSS(),this.view.dom.editor=this}},{key:"createNodeViews",value:function(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}},{key:"prependClass",value:function(){this.view.dom.className="".concat(this.className," ").concat(this.view.dom.className)}},{key:"captureTransaction",value:function(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;var t=this.capturedTransaction;return this.capturedTransaction=null,t}},{key:"dispatchTransaction",value:function(e){var t=this;if(!this.view.isDestroyed){if(this.isCapturingTransaction)return this.capturedTransaction?void e.steps.forEach(function(e){var n;return null==(n=t.capturedTransaction)?void 0:n.step(e)}):void(this.capturedTransaction=e);var n=this.state.applyTransaction(e),r=n.state,i=n.transactions,o=!this.state.selection.eq(r.selection),a=i.includes(e),s=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:e,nextState:r}),a){this.view.updateState(r),this.emit("transaction",{editor:this,transaction:e,appendedTransactions:i.slice(1)}),o&&this.emit("selectionUpdate",{editor:this,transaction:e});var c=i.findLast(function(e){return e.getMeta("focus")||e.getMeta("blur")}),u=null==c?void 0:c.getMeta("focus"),l=null==c?void 0:c.getMeta("blur");u&&this.emit("focus",{editor:this,event:u.event,transaction:c}),l&&this.emit("blur",{editor:this,event:l.event,transaction:c}),e.getMeta("preventUpdate")||!i.some(function(e){return e.docChanged})||s.doc.eq(r.doc)||this.emit("update",{editor:this,transaction:e,appendedTransactions:i.slice(1)})}}}},{key:"getAttributes",value:function(e){return Md(this.state,e)}},{key:"isActive",value:function(e,t){var n="string"==typeof e?e:null,r="string"==typeof e?t:e;return function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!t)return ql(e,null,n)||Ed(e,null,n);var r=Gl(t,e.schema);return"node"===r?ql(e,t,n):"mark"===r&&Ed(e,t,n)}(this.state,n,r)}},{key:"getJSON",value:function(){return this.state.doc.toJSON()}},{key:"getHTML",value:function(){return hd(this.state.doc.content,this.schema)}},{key:"getText",value:function(e){var t=e||{},n=t.blockSeparator,r=void 0===n?"\n\n":n,i=t.textSerializers,o=void 0===i?{}:i;return function(e,t){return Sd(e,{from:0,to:e.content.size},t)}(this.state.doc,{blockSeparator:r,textSerializers:g(g({},_d(this.schema)),o)})}},{key:"isEmpty",get:function(){return Id(this.state.doc)}},{key:"destroy",value:function(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}},{key:"isDestroyed",get:function(){var e,t;return null==(t=null==(e=this.editorView)?void 0:e.isDestroyed)||t}},{key:"$node",value:function(e,t){var n;return(null==(n=this.$doc)?void 0:n.querySelector(e,t))||null}},{key:"$nodes",value:function(e,t){var n;return(null==(n=this.$doc)?void 0:n.querySelectorAll(e,t))||null}},{key:"$pos",value:function(e){var t=this.state.doc.resolve(e);return new Nh(t,this)}},{key:"$doc",get:function(){return this.$pos(0)}}])}(ah);var Ah=function(){return S(function e(t){var n,r,i,o,a,s=this;x(this,e),this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.handleMouseMove=function(e){if(s.isResizing&&s.activeHandle){var t=e.clientX-s.startX,n=e.clientY-s.startY;s.handleResize(t,n)}},this.handleTouchMove=function(e){if(s.isResizing&&s.activeHandle){var t=e.touches[0];if(t){var n=t.clientX-s.startX,r=t.clientY-s.startY;s.handleResize(n,r)}}},this.handleMouseUp=function(){if(s.isResizing){var e=s.element.offsetWidth,t=s.element.offsetHeight;s.onCommit(e,t),s.isResizing=!1,s.activeHandle=null,s.container.dataset.resizeState="false",s.classNames.resizing&&s.container.classList.remove(s.classNames.resizing),document.removeEventListener("mousemove",s.handleMouseMove),document.removeEventListener("mouseup",s.handleMouseUp),document.removeEventListener("keydown",s.handleKeyDown),document.removeEventListener("keyup",s.handleKeyUp)}},this.handleKeyDown=function(e){"Shift"===e.key&&(s.isShiftKeyPressed=!0)},this.handleKeyUp=function(e){"Shift"===e.key&&(s.isShiftKeyPressed=!1)},this.node=t.node,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(null==(n=t.options)?void 0:n.min)&&(this.minSize=g(g({},this.minSize),t.options.min)),(null==(r=t.options)?void 0:r.max)&&(this.maxSize=t.options.max),(null==(i=null==t?void 0:t.options)?void 0:i.directions)&&(this.directions=t.options.directions),(null==(o=t.options)?void 0:o.preserveAspectRatio)&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(null==(a=t.options)?void 0:a.className)&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles()},[{key:"dom",get:function(){return this.container}},{key:"contentDOM",get:function(){return this.contentElement}},{key:"update",value:function(e,t,n){return e.type===this.node.type&&(this.node=e,!this.onUpdate||this.onUpdate(e,t,n))}},{key:"destroy",value:function(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.container.remove()}},{key:"createContainer",value:function(){var e=document.createElement("div");return e.dataset.resizeContainer="",e.dataset.node=this.node.type.name,e.style.display="flex",e.style.justifyContent="flex-start",e.style.alignItems="flex-start",this.classNames.container&&(e.className=this.classNames.container),e.appendChild(this.wrapper),e}},{key:"createWrapper",value:function(){var e=document.createElement("div");return e.style.position="relative",e.style.display="block",e.dataset.resizeWrapper="",this.classNames.wrapper&&(e.className=this.classNames.wrapper),e.appendChild(this.element),e}},{key:"createHandle",value:function(e){var t=document.createElement("div");return t.dataset.resizeHandle=e,t.style.position="absolute",this.classNames.handle&&(t.className=this.classNames.handle),t}},{key:"positionHandle",value:function(e,t){var n=t.includes("top"),r=t.includes("bottom"),i=t.includes("left"),o=t.includes("right");n&&(e.style.top="0"),r&&(e.style.bottom="0"),i&&(e.style.left="0"),o&&(e.style.right="0"),"top"!==t&&"bottom"!==t||(e.style.left="0",e.style.right="0"),"left"!==t&&"right"!==t||(e.style.top="0",e.style.bottom="0")}},{key:"attachHandles",value:function(){var e=this;this.directions.forEach(function(t){var n=e.createHandle(t);e.positionHandle(n,t),n.addEventListener("mousedown",function(n){return e.handleResizeStart(n,t)}),n.addEventListener("touchstart",function(n){return e.handleResizeStart(n,t)}),e.wrapper.appendChild(n)})}},{key:"applyInitialSize",value:function(){var e=this.node.attrs.width,t=this.node.attrs.height;e?(this.element.style.width="".concat(e,"px"),this.initialWidth=e):this.initialWidth=this.element.offsetWidth,t?(this.element.style.height="".concat(t,"px"),this.initialHeight=t):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}},{key:"handleResizeStart",value:function(e,t){e.preventDefault(),e.stopPropagation(),this.isResizing=!0,this.activeHandle=t,!function(e){return"touches"in e}(e)?(this.startX=e.clientX,this.startY=e.clientY):(this.startX=e.touches[0].clientX,this.startY=e.touches[0].clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}},{key:"handleResize",value:function(e,t){if(this.activeHandle){var n=this.preserveAspectRatio||this.isShiftKeyPressed,r=this.calculateNewDimensions(this.activeHandle,e,t),i=r.width,o=r.height,a=this.applyConstraints(i,o,n);this.element.style.width="".concat(a.width,"px"),this.element.style.height="".concat(a.height,"px"),this.onResize&&this.onResize(a.width,a.height)}}},{key:"calculateNewDimensions",value:function(e,t,n){var r=this.startWidth,i=this.startHeight,o=e.includes("right"),a=e.includes("left"),s=e.includes("bottom"),c=e.includes("top");return o?r=this.startWidth+t:a&&(r=this.startWidth-t),s?i=this.startHeight+n:c&&(i=this.startHeight-n),"right"!==e&&"left"!==e||(r=this.startWidth+(o?t:-t)),"top"!==e&&"bottom"!==e||(i=this.startHeight+(s?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,e):{width:r,height:i}}},{key:"applyConstraints",value:function(e,t,n){var r,i,o,a;if(!n){var s=Math.max(this.minSize.width,e),c=Math.max(this.minSize.height,t);return(null==(r=this.maxSize)?void 0:r.width)&&(s=Math.min(this.maxSize.width,s)),(null==(i=this.maxSize)?void 0:i.height)&&(c=Math.min(this.maxSize.height,c)),{width:s,height:c}}var u=e,l=t;return u<this.minSize.width&&(l=(u=this.minSize.width)/this.aspectRatio),l<this.minSize.height&&(u=(l=this.minSize.height)*this.aspectRatio),(null==(o=this.maxSize)?void 0:o.width)&&u>this.maxSize.width&&(l=(u=this.maxSize.width)/this.aspectRatio),(null==(a=this.maxSize)?void 0:a.height)&&l>this.maxSize.height&&(u=(l=this.maxSize.height)*this.aspectRatio),{width:u,height:l}}},{key:"applyAspectRatio",value:function(e,t,n){var r="top"===n||"bottom"===n;return"left"===n||"right"===n?{width:e,height:e/this.aspectRatio}:r?{width:t*this.aspectRatio,height:t}:{width:e,height:e/this.aspectRatio}}}])}();function Dh(e){if(!(null==e?void 0:e.trim()))return{};var t={},n=[],r=e.replace(/["']([^"']*)["']/g,function(e){return n.push(e),"__QUOTED_".concat(n.length-1,"__")}),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){var o=i.map(function(e){return e.trim().slice(1)});t.class=o.join(" ")}var a=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);a&&(t.id=a[1]);Array.from(r.matchAll(/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g)).forEach(function(e){var r,i=d(e,3),o=i[1],a=i[2],s=parseInt((null==(r=a.match(/__QUOTED_(\d+)__/))?void 0:r[1])||"0",10),c=n[s];c&&(t[o]=c.slice(1,-1))});var s=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();s&&s.split(/\s+/).filter(Boolean).forEach(function(e){e.match(/^[a-zA-Z][\w-]*$/)&&(t[e]=!0)});return t}function Ih(e){if(!e||0===Object.keys(e).length)return"";var t=[];e.class&&String(e.class).split(/\s+/).filter(Boolean).forEach(function(e){return t.push(".".concat(e))});return e.id&&t.push("#".concat(e.id)),Object.entries(e).forEach(function(e){var n=d(e,2),r=n[0],i=n[1];"class"!==r&&"id"!==r&&(!0===i?t.push(r):!1!==i&&null!=i&&t.push("".concat(r,'="').concat(String(i),'"')))}),t.join(" ")}function zh(e){var t=e.nodeName,n=e.name,r=e.parseAttributes,i=void 0===r?Dh:r,o=e.serializeAttributes,a=void 0===o?Ih:o,s=e.defaultAttributes,c=void 0===s?{}:s,u=e.requiredAttributes,l=void 0===u?[]:u,d=e.allowedAttributes,h=n||t;return{parseMarkdown:function(e,n){var r=g(g({},c),e.attributes);return n.createNode(t,r,[])},markdownTokenizer:{name:t,level:"block",start:function(e){var t,n=new RegExp("^:::".concat(h,"(?:\\s|$)"),"m"),r=null==(t=e.match(n))?void 0:t.index;return void 0!==r?r:-1},tokenize:function(e,n,r){var o=new RegExp("^:::".concat(h,"(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)")),a=e.match(o);if(a){var s=a[1]||"",c=i(s);if(!l.find(function(e){return!(e in c)}))return{type:t,raw:a[0],attributes:c}}}},renderMarkdown:function(e){var t=function(e){if(!d)return e;var t={};return d.forEach(function(n){n in e&&(t[n]=e[n])}),t}(e.attrs||{}),n=a(t),r=n?" {".concat(n,"}"):"";return":::".concat(h).concat(r," :::")}}}function Rh(e){var t=e.nodeName,n=e.name,r=e.getContent,i=e.parseAttributes,o=void 0===i?Dh:i,a=e.serializeAttributes,s=void 0===a?Ih:a,c=e.defaultAttributes,u=void 0===c?{}:c,l=e.content,h=void 0===l?"block":l,f=e.allowedAttributes,p=n||t;return{parseMarkdown:function(e,n){var i;if(r){var o=r(e);i="string"==typeof o?[{type:"text",text:o}]:o}else i="block"===h?n.parseChildren(e.tokens||[]):n.parseInline(e.tokens||[]);var a=g(g({},u),e.attributes);return n.createNode(t,a,i)},markdownTokenizer:{name:t,level:"block",start:function(e){var t,n=new RegExp("^:::".concat(p),"m"),r=null==(t=e.match(n))?void 0:t.index;return void 0!==r?r:-1},tokenize:function(e,n,r){var i,a=new RegExp("^:::".concat(p,"(?:\\s+\\{([^}]*)\\})?\\s*\\n")),s=e.match(a);if(s){var c=d(s,2),u=c[0],l=c[1],f=o(void 0===l?"":l),v=1,m=u.length,g="",y=/^:::([\w-]*)(\s.*)?/gm,k=e.slice(m);for(y.lastIndex=0;;){var w=y.exec(k);if(null===w)break;var b=w.index,x=w[1];if(!(null==(i=w[2])?void 0:i.endsWith(":::")))if(x)v+=1;else if(0===(v-=1)){var C=k.slice(0,b);g=C.trim();var S=e.slice(0,m+b+w[0].length),_=[];if(g)if("block"===h)for((_=r.blockTokens(C)).forEach(function(e){!e.text||e.tokens&&0!==e.tokens.length||(e.tokens=r.inlineTokens(e.text))});_.length>0;){var M=_[_.length-1];if("paragraph"!==M.type||M.text&&""!==M.text.trim())break;_.pop()}else _=r.inlineTokens(g);return{type:t,raw:S,attributes:f,content:g,tokens:_}}}}}},renderMarkdown:function(e,t){var n=function(e){if(!f)return e;var t={};return f.forEach(function(n){n in e&&(t[n]=e[n])}),t}(e.attrs||{}),r=s(n),i=r?" {".concat(r,"}"):"",o=t.renderChildren(e.content||[],"\n\n");return":::".concat(p).concat(i,"\n\n").concat(o,"\n\n:::")}}}function Ph(e){if(!e.trim())return{};for(var t={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g,r=n.exec(e);null!==r;){var i=d(r,4),o=i[1],a=i[2],s=i[3];t[o]=a||s,r=n.exec(e)}return t}function Lh(e){return Object.entries(e).filter(function(e){var t=d(e,2)[1];return null!=t}).map(function(e){var t=d(e,2),n=t[0],r=t[1];return"".concat(n,'="').concat(r,'"')}).join(" ")}function Bh(e){var t=e.nodeName,n=e.name,r=e.getContent,i=e.parseAttributes,o=void 0===i?Ph:i,a=e.serializeAttributes,s=void 0===a?Lh:a,c=e.defaultAttributes,u=void 0===c?{}:c,l=e.selfClosing,h=void 0!==l&&l,f=e.allowedAttributes,p=n||t,v=p.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:function(e,n){var i=g(g({},u),e.attributes);if(h)return n.createNode(t,i);var o=r?r(e):e.content||"";return o?n.createNode(t,i,[n.createTextNode(o)]):n.createNode(t,i,[])},markdownTokenizer:{name:t,level:"inline",start:function(e){var t=h?new RegExp("\\[".concat(v,"\\s*[^\\]]*\\]")):new RegExp("\\[".concat(v,"\\s*[^\\]]*\\][\\s\\S]*?\\[\\/").concat(v,"\\]")),n=e.match(t),r=null==n?void 0:n.index;return void 0!==r?r:-1},tokenize:function(e,n,r){var i=h?new RegExp("^\\[".concat(v,"\\s*([^\\]]*)\\]")):new RegExp("^\\[".concat(v,"\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/").concat(v,"\\]")),a=e.match(i);if(a){var s="",c="";if(h){c=d(a,2)[1]}else{var u=d(a,3);c=u[1],s=u[2]||""}var l=o(c.trim());return{type:t,raw:a[0],content:s.trim(),attributes:l}}}},renderMarkdown:function(e){var t="";r?t=r(e):e.content&&e.content.length>0&&(t=e.content.filter(function(e){return"text"===e.type}).map(function(e){return e.text}).join(""));var n=function(e){if(!f)return e;var t={};return f.forEach(function(n){n in e&&(t[n]=e[n])}),t}(e.attrs||{}),i=s(n),o=i?" ".concat(i):"";return h?"[".concat(p).concat(o,"]"):"[".concat(p).concat(o,"]").concat(t,"[/").concat(p,"]")}}}function Vh(e,t,n){for(var r,i,o,a,s,c=e.split("\n"),u=[],l="",d=0,h=t.baseIndentSize||2,f=function(){var e=c[d],s=e.match(t.itemPattern);if(!s)return u.length>0?0:""===e.trim()?(d+=1,l="".concat(l).concat(e,"\n"),1):{v:void 0};var f=t.extractItemData(s),p=f.indentLevel,v=f.mainContent;l="".concat(l).concat(e,"\n");var m,g=[v];for(d+=1;d<c.length;){var y=c[d];if(""===y.trim()){var k=c.slice(d+1).findIndex(function(e){return""!==e.trim()});if(-1===k)break;var w=c[d+1+k];if(((null==(i=null==(r=w.match(/^(\s*)/))?void 0:r[1])?void 0:i.length)||0)>p){g.push(y),l="".concat(l).concat(y,"\n"),d+=1;continue}break}if(!(((null==(a=null==(o=y.match(/^(\s*)/))?void 0:o[1])?void 0:a.length)||0)>p))break;g.push(y),l="".concat(l).concat(y,"\n"),d+=1}var b=g.slice(1);if(b.length>0){var x=b.map(function(e){return e.slice(p+h)}).join("\n");x.trim()&&(m=t.customNestedParser?t.customNestedParser(x):n.blockTokens(x))}var C=t.createToken(f,m);u.push(C)};d<c.length&&0!==(s=f());)if(1!==s&&s)return s.v;if(0!==u.length)return{items:u,raw:l}}function Fh(e,t,n,r){if(!e||!Array.isArray(e.content))return"";var i="function"==typeof n?n(r):n,o=function(e){return v(e)||u(e)||f(e)||h()}(e.content),a=o[0],s=o.slice(1),c=t.renderChildren([a]),l=["".concat(i).concat(c)];return s&&s.length>0&&s.forEach(function(e){var n=t.renderChildren([e]);if(n){var r=n.split("\n").map(function(e){return e?t.indent(e):""}).join("\n");l.push(r)}}),l.join("\n")}Qu({},{createAtomBlockMarkdownSpec:function(){return zh},createBlockMarkdownSpec:function(){return Rh},createInlineMarkdownSpec:function(){return Bh},parseAttributes:function(){return Dh},parseIndentedBlocks:function(){return Vh},renderNestedMarkdownContent:function(){return Fh},serializeAttributes:function(){return Ih}});var $h=function(t){function n(){var e;return x(this,n),(e=r(this,n,arguments)).type="node",e}return a(n,t),S(n,[{key:"configure",value:function(t){return e(n,"configure",this,3)([t])}},{key:"extend",value:function(t){var r="function"==typeof t?t():t;return e(n,"extend",this,3)([r])}}],[{key:"create",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new n("function"==typeof e?e():e)}}])}(dh),jh=$h.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:function(e,t){return e.content?t.renderChildren(e.content,"\n\n"):""}}),Hh=jh,Wh=$h.create({name:"text",group:"inline",parseMarkdown:function(e){return{type:"text",text:e.text||""}},renderMarkdown:function(e){return e.text||""}}),qh=$h.create({name:"paragraph",priority:1e3,addOptions:function(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML:function(){return[{tag:"p"}]},renderHTML:function(e){var t=e.HTMLAttributes;return["p",gd(this.options.HTMLAttributes,t),0]},parseMarkdown:function(e,t){var n=e.tokens||[];return 1===n.length&&"image"===n[0].type?t.parseChildren([n[0]]):t.createNode("paragraph",void 0,t.parseInline(n))},renderMarkdown:function(e,t){return e&&Array.isArray(e.content)?t.renderChildren(e.content):""},addCommands:function(){var e=this;return{setParagraph:function(){return function(t){return t.commands.setNode(e.name)}}}},addKeyboardShortcuts:function(){var e=this;return{"Mod-Alt-0":function(){return e.editor.commands.setParagraph()}}}}),Uh=qh;function Jh(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new oa({view:function(t){return new Kh(t,e)}})}var Kh=function(){return S(function e(t,n){var r,i=this;x(this,e),this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!==(r=n.width)&&void 0!==r?r:1,this.color=!1===n.color?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(function(e){var n=function(t){i[e](t)};return t.dom.addEventListener(e,n),{name:e,handler:n}})},[{key:"destroy",value:function(){var e=this;this.handlers.forEach(function(t){var n=t.name,r=t.handler;return e.editorView.dom.removeEventListener(n,r)})}},{key:"update",value:function(e,t){null!=this.cursorPos&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}},{key:"setCursor",value:function(e){e!=this.cursorPos&&(this.cursorPos=e,null==e?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}},{key:"updateOverlay",value:function(){var e,t=this.editorView.state.doc.resolve(this.cursorPos),n=!t.parent.inlineContent,r=this.editorView.dom,i=r.getBoundingClientRect(),o=i.width/r.offsetWidth,a=i.height/r.offsetHeight;if(n){var s=t.nodeBefore,c=t.nodeAfter;if(s||c){var u=this.editorView.nodeDOM(this.cursorPos-(s?s.nodeSize:0));if(u){var l=u.getBoundingClientRect(),d=s?l.bottom:l.top;s&&c&&(d=(d+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);var h=this.width/2*a;e={left:l.left,right:l.right,top:d-h,bottom:d+h}}}}if(!e){var f=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*o;e={left:f.left-p,right:f.left+p,top:f.top,bottom:f.bottom}}var v,m,g=this.editorView.dom.offsetParent;if(this.element||(this.element=g.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n),!g||g==document.body&&"static"==getComputedStyle(g).position)v=-pageXOffset,m=-pageYOffset;else{var y=g.getBoundingClientRect(),k=y.width/g.offsetWidth,w=y.height/g.offsetHeight;v=y.left-g.scrollLeft*k,m=y.top-g.scrollTop*w}this.element.style.left=(e.left-v)/o+"px",this.element.style.top=(e.top-m)/a+"px",this.element.style.width=(e.right-e.left)/o+"px",this.element.style.height=(e.bottom-e.top)/a+"px"}},{key:"scheduleRemoval",value:function(e){var t=this;clearTimeout(this.timeout),this.timeout=setTimeout(function(){return t.setCursor(null)},e)}},{key:"dragover",value:function(e){if(this.editorView.editable){var t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i="function"==typeof r?r(this.editorView,t,e):r;if(t&&!i){var o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){var a=Co(this.editorView.state.doc,o,this.editorView.dragging.slice);null!=a&&(o=a)}this.setCursor(o),this.scheduleRemoval(5e3)}}}},{key:"dragend",value:function(){this.scheduleRemoval(20)}},{key:"drop",value:function(){this.scheduleRemoval(20)}},{key:"dragleave",value:function(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}])}(),Yh=function(e){function t(e){return x(this,t),r(this,t,[e,e])}return a(t,e),S(t,[{key:"map",value:function(e,n){var r=e.resolve(n.map(this.head));return t.valid(r)?new t(r):Fo.near(r)}},{key:"content",value:function(){return Ur.empty}},{key:"eq",value:function(e){return e instanceof t&&e.head==this.head}},{key:"toJSON",value:function(){return{type:"gapcursor",pos:this.head}}},{key:"getBookmark",value:function(){return new Gh(this.anchor)}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new t(e.resolve(n.pos))}},{key:"valid",value:function(e){var t=e.parent;if(t.isTextblock||!function(e){for(var t=e.depth;t>=0;t--){var n=e.index(t),r=e.node(t);if(0!=n)for(var i=r.child(n-1);;i=i.lastChild){if(0==i.childCount&&!i.inlineContent||Xh(i.type))return!0;if(i.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(e)||!function(e){for(var t=e.depth;t>=0;t--){var n=e.indexAfter(t),r=e.node(t);if(n!=r.childCount)for(var i=r.child(n);;i=i.firstChild){if(0==i.childCount&&!i.inlineContent||Xh(i.type))return!0;if(i.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(e))return!1;var n=t.type.spec.allowGapCursor;if(null!=n)return n;var r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}},{key:"findGapCursorFrom",value:function(e,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];e:for(;;){if(!r&&t.valid(e))return e;for(var i=e.pos,o=null,a=e.depth;;a--){var s=e.node(a);if(n>0?e.indexAfter(a)<s.childCount:e.index(a)>0){o=s.child(n>0?e.indexAfter(a):e.index(a)-1);break}if(0==a)return null;i+=n;var c=e.doc.resolve(i);if(t.valid(c))return c}for(;;){var u=n>0?o.firstChild:o.lastChild;if(!u){if(o.isAtom&&!o.isText&&!Uo.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*n),r=!1;continue e}break}o=u,i+=n;var l=e.doc.resolve(i);if(t.valid(l))return l}return null}}}])}(Fo);Yh.prototype.visible=!1,Yh.findFrom=Yh.findGapCursorFrom,Fo.jsonID("gapcursor",Yh);var Gh=function(){function e(t){x(this,e),this.pos=t}return S(e,[{key:"map",value:function(t){return new e(t.map(this.pos))}},{key:"resolve",value:function(e){var t=e.resolve(this.pos);return Yh.valid(t)?new Yh(t):Fo.near(t)}}])}();function Xh(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}var Zh=Xu({ArrowLeft:Qh("horiz",-1),ArrowRight:Qh("horiz",1),ArrowUp:Qh("vert",-1),ArrowDown:Qh("vert",1)});function Qh(e,t){var n="vert"==e?t>0?"down":"up":t>0?"right":"left";return function(e,r,i){var o=e.selection,a=t>0?o.$to:o.$from,s=o.empty;if(o instanceof Wo){if(!i.endOfTextblock(n)||0==a.depth)return!1;s=!1,a=e.doc.resolve(t>0?a.after():a.before())}var c=Yh.findGapCursorFrom(a,t,s);return!!c&&(r&&r(e.tr.setSelection(new Yh(c))),!0)}}function ef(e,t,n){if(!e||!e.editable)return!1;var r=e.state.doc.resolve(t);if(!Yh.valid(r))return!1;var i=e.posAtCoords({left:n.clientX,top:n.clientY});return!(i&&i.inside>-1&&Uo.isSelectable(e.state.doc.nodeAt(i.inside)))&&(e.dispatch(e.state.tr.setSelection(new Yh(r))),!0)}function tf(e,t){if("insertCompositionText"!=t.inputType||!(e.state.selection instanceof Yh))return!1;var n=e.state.selection.$from,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;for(var i=Fr.empty,o=r.length-1;o>=0;o--)i=Fr.from(r[o].createAndFill(null,i));var a=e.state.tr.replace(n.pos,n.pos,new Ur(i,0,0));return a.setSelection(Wo.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function nf(e){if(!(e.selection instanceof Yh))return null;var t=document.createElement("div");return t.className="ProseMirror-gapcursor",uu.create(e.doc,[au.widget(e.selection.head,t,{key:"gapcursor"})])}var rf=200,of=function(){};of.prototype.append=function(e){return e.length?(e=of.from(e),!this.length&&e||e.length<rf&&this.leafAppend(e)||this.length<rf&&e.leafPrepend(this)||this.appendInner(e)):this},of.prototype.prepend=function(e){return e.length?of.from(e).append(this):this},of.prototype.appendInner=function(e){return new sf(this,e)},of.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?of.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},of.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},of.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},of.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},of.from=function(e){return e instanceof of?e:e&&e.length?new af(e):of.empty};var af=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(!1===e(this.values[i],r+i))return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(!1===e(this.values[i],r+i))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=rf)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=rf)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(of);of.empty=new af([]);var sf=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;return!(t<i&&!1===this.left.forEachInner(e,t,Math.min(n,i),r))&&(!(n>i&&!1===this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i))&&void 0)},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;return!(t>i&&!1===this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i))&&(!(n<i&&!1===this.left.forEachInvertedInner(e,Math.min(t,i),n,r))&&void 0)},t.prototype.sliceInner=function(e,t){if(0==e&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(of),cf=function(){function e(t,n){x(this,e),this.items=t,this.eventCount=n}return S(e,[{key:"popEvent",value:function(t,n){var r=this;if(0==this.eventCount)return null;for(var i,o,a=this.items.length;;a--){if(this.items.get(a-1).selection){--a;break}}n&&(i=this.remapping(a,this.items.length),o=i.maps.length);var s,c,u=t.tr,l=[],d=[];return this.items.forEach(function(t,n){if(!t.step)return i||(i=r.remapping(a,n+1),o=i.maps.length),o--,void d.push(t);if(i){d.push(new uf(t.map));var h,f=t.step.map(i.slice(o));f&&u.maybeStep(f).doc&&(h=u.mapping.maps[u.mapping.maps.length-1],l.push(new uf(h,void 0,void 0,l.length+d.length))),o--,h&&i.appendMap(h,o)}else u.maybeStep(t.step);return t.selection?(s=i?t.selection.map(i.slice(o)):t.selection,c=new e(r.items.slice(0,a).append(d.reverse().concat(l)),r.eventCount-1),!1):void 0},this.items.length,0),{remaining:c,transform:u,selection:s}}},{key:"addTransform",value:function(t,n,r,i){for(var o=[],a=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null,u=0;u<t.steps.length;u++){var l,d=t.steps[u].invert(t.docs[u]),h=new uf(t.mapping.maps[u],d,n);(l=c&&c.merge(h))&&(h=l,u?o.pop():s=s.slice(0,s.length-1)),o.push(h),n&&(a++,n=void 0),i||(c=h)}var f=a-r.depth;return f>df&&(s=function(e,t){var n;return e.forEach(function(e,r){if(e.selection&&0==t--)return n=r,!1}),e.slice(n)}(s,f),a-=f),new e(s.append(o),a)}},{key:"remapping",value:function(e,t){var n=new Qi;return this.items.forEach(function(t,r){var i=null!=t.mirrorOffset&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}},{key:"addMaps",value:function(t){return 0==this.eventCount?this:new e(this.items.append(t.map(function(e){return new uf(e)})),this.eventCount)}},{key:"rebased",value:function(t,n){if(!this.eventCount)return this;var r=[],i=Math.max(0,this.items.length-n),o=t.mapping,a=t.steps.length,s=this.eventCount;this.items.forEach(function(e){e.selection&&s--},i);var c=n;this.items.forEach(function(e){var n=o.getMirror(--c);if(null!=n){a=Math.min(a,n);var i=o.maps[n];if(e.step){var u=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(o.slice(c+1,n));l&&s++,r.push(new uf(i,u,l))}else r.push(new uf(i))}},i);for(var u=[],l=n;l<a;l++)u.push(new uf(o.maps[l]));var d=new e(this.items.slice(0,i).append(u).append(r),s);return d.emptyItemCount()>500&&(d=d.compress(this.items.length-r.length)),d}},{key:"emptyItemCount",value:function(){var e=0;return this.items.forEach(function(t){t.step||e++}),e}},{key:"compress",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.items.length,n=this.remapping(0,t),r=n.maps.length,i=[],o=0;return this.items.forEach(function(e,a){if(a>=t)i.push(e),e.selection&&o++;else if(e.step){var s=e.step.map(n.slice(r)),c=s&&s.getMap();if(r--,c&&n.appendMap(c,r),s){var u=e.selection&&e.selection.map(n.slice(r));u&&o++;var l,d=new uf(c.invert(),s,u),h=i.length-1;(l=i.length&&i[h].merge(d))?i[h]=l:i.push(d)}}else e.map&&r--},this.items.length,0),new e(of.from(i.reverse()),o)}}])}();cf.empty=new cf(of.empty,0);var uf=function(){function e(t,n,r,i){x(this,e),this.map=t,this.step=n,this.selection=r,this.mirrorOffset=i}return S(e,[{key:"merge",value:function(t){if(this.step&&t.step&&!t.selection){var n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}}])}(),lf=S(function e(t,n,r,i,o){x(this,e),this.done=t,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}),df=20;function hf(e){for(var t=[],n=e.length-1;n>=0&&0==t.length;n--)e[n].forEach(function(e,n,r,i){return t.push(r,i)});return t}function ff(e,t){if(!e)return null;for(var n=[],r=0;r<e.length;r+=2){var i=t.map(e[r],1),o=t.map(e[r+1],-1);i<=o&&n.push(i,o)}return n}var pf=!1,vf=null;function mf(e){var t=e.plugins;if(vf!=t){pf=!1,vf=t;for(var n=0;n<t.length;n++)if(t[n].spec.historyPreserveItems){pf=!0;break}}return pf}var gf=new ca("history"),yf=new ca("closeHistory");function kf(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new oa({key:gf,state:{init:function(){return new lf(cf.empty,cf.empty,null,0,-1)},apply:function(t,n,r){return function(e,t,n,r){var i,o=n.getMeta(gf);if(o)return o.historyState;n.getMeta(yf)&&(e=new lf(e.done,e.undone,null,0,-1));var a=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(a&&a.getMeta(gf))return a.getMeta(gf).redo?new lf(e.done.addTransform(n,void 0,r,mf(t)),e.undone,hf(n.mapping.maps),e.prevTime,e.prevComposition):new lf(e.done,e.undone.addTransform(n,void 0,r,mf(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||a&&!1===a.getMeta("addToHistory"))return(i=n.getMeta("rebased"))?new lf(e.done.rebased(n,i),e.undone.rebased(n,i),ff(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new lf(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),ff(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);var s=n.getMeta("composition"),c=0==e.prevTime||!a&&e.prevComposition!=s&&(e.prevTime<(n.time||0)-r.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;var n=!1;return e.mapping.maps[0].forEach(function(e,r){for(var i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}(n,e.prevRanges)),u=a?ff(e.prevRanges,n.mapping):hf(n.mapping.maps);return new lf(e.done.addTransform(n,c?t.selection.getBookmark():void 0,r,mf(t)),cf.empty,u,n.time,null==s?e.prevComposition:s)}(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput:function(e,t){var n=t.inputType,r="historyUndo"==n?bf:"historyRedo"==n?xf:null;return!(!r||!e.editable)&&(t.preventDefault(),r(e.state,e.dispatch))}}}})}function wf(e,t){return function(n,r){var i=gf.getState(n);if(!i||0==(e?i.undone:i.done).eventCount)return!1;if(r){var o=function(e,t,n){var r=mf(t),i=gf.get(t).spec.config,o=(n?e.undone:e.done).popEvent(t,r);if(!o)return null;var a=o.selection.resolve(o.transform.doc),s=(n?e.done:e.undone).addTransform(o.transform,t.selection.getBookmark(),i,r),c=new lf(n?s:o.remaining,n?o.remaining:s,null,0,-1);return o.transform.setSelection(a).setMeta(gf,{redo:n,historyState:c})}(i,n,e);o&&r(t?o.scrollIntoView():o)}return!0}}var bf=wf(!1,!0),xf=wf(!0,!0);function Cf(e){var t=e.types,n=e.node;return n&&Array.isArray(t)&&t.includes(n.type)||(null==n?void 0:n.type)===t}gh.create({name:"characterCount",addOptions:function(){return{limit:null,mode:"textSize",textCounter:function(e){return e.length},wordCounter:function(e){return e.split(" ").filter(function(e){return""!==e}).length}}},addStorage:function(){return{characters:function(){return 0},words:function(){return 0}}},onBeforeCreate:function(){var e=this;this.storage.characters=function(t){var n=(null==t?void 0:t.node)||e.editor.state.doc;if("textSize"===((null==t?void 0:t.mode)||e.options.mode)){var r=n.textBetween(0,n.content.size,void 0," ");return e.options.textCounter(r)}return n.nodeSize},this.storage.words=function(t){var n=(null==t?void 0:t.node)||e.editor.state.doc,r=n.textBetween(0,n.content.size," "," ");return e.options.wordCounter(r)}},addProseMirrorPlugins:function(){var e=this,t=!1;return[new oa({key:new ca("characterCount"),appendTransaction:function(n,r,i){if(!t){var o=e.options.limit;if(null!=o&&0!==o){var a=e.storage.characters({node:i.doc});if(a>o){var s=a-o;console.warn("[CharacterCount] Initial content exceeded limit of ".concat(o," characters. Content was automatically trimmed."));var c=i.tr.deleteRange(0,s);return t=!0,c}t=!0}else t=!0}},filterTransaction:function(t,n){var r=e.options.limit;if(!t.docChanged||0===r||null==r)return!0;var i=e.storage.characters({node:n.doc}),o=e.storage.characters({node:t.doc});if(o<=r)return!0;if(i>r&&o>r&&o<=i)return!0;if(i>r&&o>r&&o>i)return!1;if(!t.getMeta("paste"))return!1;var a=t.selection.$head.pos,s=a-(o-r),c=a;return t.deleteRange(s,c),!(e.storage.characters({node:t.doc})>r)}})]}}),gh.create({name:"dropCursor",addOptions:function(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins:function(){return[Jh(this.options)]}}),gh.create({name:"focus",addOptions:function(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins:function(){var e=this;return[new oa({key:new ca("focus"),props:{decorations:function(t){var n=t.doc,r=t.selection,i=e.editor,o=i.isEditable,a=i.isFocused,s=r.anchor,c=[];if(!o||!a)return uu.create(n,[]);var u=0;"deepest"===e.options.mode&&n.descendants(function(e,t){if(!e.isText){if(!(s>=t&&s<=t+e.nodeSize-1))return!1;u+=1}});var l=0;return n.descendants(function(t,n){return!t.isText&&(s>=n&&s<=n+t.nodeSize-1&&(l+=1,"deepest"===e.options.mode&&u-l>0||"shallowest"===e.options.mode&&l>1?"deepest"===e.options.mode:void c.push(au.node(n,n+t.nodeSize,{class:e.options.className}))))}),uu.create(n,c)}}})]}}),gh.create({name:"gapCursor",addProseMirrorPlugins:function(){return[new oa({props:{decorations:nf,createSelectionBetween:function(e,t,n){return t.pos==n.pos&&Yh.valid(n)?new Yh(n):null},handleClick:ef,handleKeyDown:Zh,handleDOMEvents:{beforeinput:tf}}})]},extendNodeSchema:function(e){var t;return{allowGapCursor:null!=(t=pd(ld(e,"allowGapCursor",{name:e.name,options:e.options,storage:e.storage})))?t:null}}}),gh.create({name:"placeholder",addOptions:function(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins:function(){var e=this;return[new oa({key:new ca("placeholder"),props:{decorations:function(t){var n=t.doc,r=t.selection,i=e.editor.isEditable||!e.options.showOnlyWhenEditable,o=r.anchor,a=[];if(!i)return null;var s=e.editor.isEmpty;return n.descendants(function(t,n){var r=o>=n&&o<=n+t.nodeSize,i=!t.isLeaf&&Id(t);if((r||!e.options.showOnlyCurrent)&&i){var c=[e.options.emptyNodeClass];s&&c.push(e.options.emptyEditorClass);var u=au.node(n,n+t.nodeSize,{class:c.join(" "),"data-placeholder":"function"==typeof e.options.placeholder?e.options.placeholder({editor:e.editor,node:t,pos:n,hasAnchor:r}):e.options.placeholder});a.push(u)}return e.options.includeChildren}),uu.create(n,a)}}})]}}),gh.create({name:"selection",addOptions:function(){return{className:"selection"}},addProseMirrorPlugins:function(){var e=this.editor,t=this.options;return[new oa({key:new ca("selection"),props:{decorations:function(n){return n.selection.empty||e.isFocused||!e.isEditable||n.selection instanceof Uo||e.view.dragging?null:uu.create(n.doc,[au.inline(n.selection.from,n.selection.to,{class:t.className})])}}})]}}),gh.create({name:"trailingNode",addOptions:function(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins:function(){var e,t=this,n=new ca(this.name),r=this.options.node||(null==(e=this.editor.schema.topNodeType.contentMatch.defaultType)?void 0:e.name)||"paragraph",i=Object.entries(this.editor.schema.nodes).map(function(e){return d(e,2)[1]}).filter(function(e){return(t.options.notAfter||[]).concat(r).includes(e.name)});return[new oa({key:n,appendTransaction:function(e,t,i){var o=i.doc,a=i.tr,s=i.schema,c=n.getState(i),u=o.content.size,l=s.nodes[r];if(c)return a.insert(u,l.create())},state:{init:function(e,t){return!Cf({node:t.tr.doc.lastChild,types:i})},apply:function(e,t){return e.docChanged?e.getMeta("__uniqueIDTransaction")?t:!Cf({node:e.doc.lastChild,types:i}):t}}})]}});var Sf=gh.create({name:"undoRedo",addOptions:function(){return{depth:100,newGroupDelay:500}},addCommands:function(){return{undo:function(){return function(e){var t=e.state,n=e.dispatch;return bf(t,n)}},redo:function(){return function(e){var t=e.state,n=e.dispatch;return xf(t,n)}}}},addProseMirrorPlugins:function(){return[kf(this.options)]},addKeyboardShortcuts:function(){var e=this;return{"Mod-z":function(){return e.editor.commands.undo()},"Shift-Mod-z":function(){return e.editor.commands.redo()},"Mod-y":function(){return e.editor.commands.redo()},"Mod-я":function(){return e.editor.commands.undo()},"Shift-Mod-я":function(){return e.editor.commands.redo()}}}}),_f=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Mf=$h.create({name:"image",addOptions:function(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline:function(){return this.options.inline},group:function(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes:function(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML:function(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML:function(e){var t=e.HTMLAttributes;return["img",gd(this.options.HTMLAttributes,t)]},parseMarkdown:function(e,t){return t.createNode("image",{src:e.href,title:e.title,alt:e.text})},renderMarkdown:function(e){var t,n,r,i,o,a,s=null!=(n=null==(t=e.attrs)?void 0:t.src)?n:"",c=null!=(i=null==(r=e.attrs)?void 0:r.alt)?i:"",u=null!=(a=null==(o=e.attrs)?void 0:o.title)?a:"";return u?"![".concat(c,"](").concat(s,' "').concat(u,'")'):"![".concat(c,"](").concat(s,")")},addNodeView:function(){var e=this;if(!this.options.resize||!this.options.resize.enabled||"undefined"==typeof document||!this.editor.isEditable)return null;var t=this.options.resize,n=t.directions,r=t.minWidth,i=t.minHeight,o=t.alwaysPreserveAspectRatio;return function(t){var a=t.node,s=t.getPos,c=t.HTMLAttributes,u=document.createElement("img");Object.entries(c).forEach(function(e){var t=d(e,2),n=t[0],r=t[1];if(null!=r)switch(n){case"width":case"height":break;default:u.setAttribute(n,r)}}),u.src=c.src;var l=new Ah({element:u,node:a,getPos:s,onResize:function(e,t){u.style.width="".concat(e,"px"),u.style.height="".concat(t,"px")},onCommit:function(t,n){var r=s();void 0!==r&&e.editor.chain().setNodeSelection(r).updateAttributes(e.name,{width:t,height:n}).run()},onUpdate:function(e,t,n){return e.type===a.type},options:{directions:n,min:{width:r,height:i},preserveAspectRatio:!0===o}}),h=l.dom;return h.style.visibility="hidden",h.style.pointerEvents="none",u.onload=function(){h.style.visibility="",h.style.pointerEvents=""},l}},addCommands:function(){var e=this;return{setImage:function(t){return function(n){return n.commands.insertContent({type:e.name,attrs:t})}}}},addInputRules:function(){return[(e={find:_f,type:this.type,getAttributes:function(e){var t=d(e,5),n=t[2];return{src:t[3],alt:n,title:t[4]}}},new sh({find:e.find,handler:function(t){var n=t.state,r=t.range,i=t.match,o=pd(e.getAttributes,void 0,i)||{},a=n.tr,s=r.from,c=r.to,u=e.type.create(o);if(i[1]){var l=s+i[0].lastIndexOf(i[1]);l>c?l=c:c=l+i[1].length;var d=i[0][i[0].length-1];a.insertText(d,s+i[0].length-1),a.replaceWith(l,c,u)}else if(i[0]){var h=e.type.isInline?s:s-1;a.insert(h,e.type.create(o)).delete(a.mapping.map(s),a.mapping.map(c))}a.scrollIntoView()},undoable:e.undoable}))];var e}}),Tf=gh.create({name:"fileHandler",addOptions:function(){return{onPaste:void 0,onDrop:void 0,allowedMimeTypes:void 0}},addProseMirrorPlugins:function(){return[(e={key:new ca(this.name),editor:this.editor,allowedMimeTypes:this.options.allowedMimeTypes,onDrop:this.options.onDrop,onPaste:this.options.onPaste},t=e.key,n=e.editor,r=e.onPaste,i=e.onDrop,o=e.allowedMimeTypes,new oa({key:t||new ca("fileHandler"),props:{handleDrop:function(e,t){var r;if(!i)return!1;if(!(null==(r=t.dataTransfer)?void 0:r.files.length))return!1;var a=e.posAtCoords({left:t.clientX,top:t.clientY}),s=Array.from(t.dataTransfer.files);return o&&(s=s.filter(function(e){return o.includes(e.type)})),0!==s.length&&(t.preventDefault(),t.stopPropagation(),i(n,s,(null==a?void 0:a.pos)||0),!0)},handlePaste:function(e,t){var i;if(!r)return!1;if(!(null==(i=t.clipboardData)?void 0:i.files.length))return!1;var a=Array.from(t.clipboardData.files),s=t.clipboardData.getData("text/html");return o&&(a=a.filter(function(e){return o.includes(e.type)})),0!==a.length&&(t.preventDefault(),t.stopPropagation(),r(n,a,s),!(s.length>0))}}}))];var e,t,n,r,i,o}}),Of=new pe("chat-editor"),Nf=function(e){var t=e.c,n=e.value,r=e.disabled,i=e.onCreate,o=e.onChange,a=e.onKeyDown,s=Je(null),c=Je(null);return Ue(function(){if(c.current){var e,r,u=window.ibiz.util.file.getUploadHeaders(),l=window.ibiz.util.file.calcFileUpDownUrl(t.context,t.params,{},{enableNoAccess:!0}),d=l.uploadUrl,h=l.downloadUrl,f=function(){var e=b(y().m(function e(t){var n,r,i,o;return y().w(function(e){for(;;)switch(e.n){case 0:return(n=new FormData).append("file",t),e.n=1,window.ibiz.net.axios({url:d,method:"post",headers:u,data:n});case 1:if(r=e.v,i=r.data){e.n=2;break}return e.a(2,{name:"",url:""});case 2:return o=h.replace("%fileId%",i.fileid),e.a(2,{name:i.name,url:o})}},e)}));return function(t){return e.apply(this,arguments)}}(),p=new Eh({element:c.current,extensions:[Hh,Wh.extend({addKeyboardShortcuts:function(){return{"Mod-Enter":function(){var e,t;return null===(e=s.current)||void 0===e||e.commands.enter(),null===(t=s.current)||void 0===t||t.commands.scrollIntoView(),!0},"Shift-Enter":function(){var e,t;return null===(e=s.current)||void 0===e||e.commands.enter(),null===(t=s.current)||void 0===t||t.commands.scrollIntoView(),!0}}}}),Uh,Sf,Mf.configure({inline:!0,allowBase64:!0,HTMLAttributes:{draggable:"false"}}).extend({draggable:!1}),Tf.configure({onDrop:(r=b(y().m(function e(t,n){var r;return y().w(function(e){for(;;)switch(e.n){case 0:if((n=n.filter(function(e){return e.type.startsWith("image/")})).length){e.n=1;break}return e.a(2);case 1:return e.n=2,Promise.all(n.map(function(e){return f(e)}));case 2:if(r=e.v,!t.isDestroyed){e.n=3;break}return e.a(2);case 3:t.chain().deleteSelection().insertContentAt(t.state.selection.from,r.map(function(e){return{type:"image",attrs:{src:e.url,alt:e.name}}})).focus().scrollIntoView().run();case 4:return e.a(2)}},e)})),function(e,t){return r.apply(this,arguments)}),onPaste:(e=b(y().m(function e(t,n){var r;return y().w(function(e){for(;;)switch(e.n){case 0:if((n=n.filter(function(e){return e.type.startsWith("image/")})).length){e.n=1;break}return e.a(2);case 1:return e.n=2,Promise.all(n.map(function(e){return f(e)}));case 2:if(r=e.v,!t.isDestroyed){e.n=3;break}return e.a(2);case 3:t.chain().deleteSelection().insertContentAt(t.state.selection.from,r.map(function(e){return{type:"image",attrs:{src:e.url,alt:e.name}}})).focus().scrollIntoView().run();case 4:return e.a(2)}},e)})),function(t,n){return e.apply(this,arguments)})})],content:n||"",editorProps:{handleKeyDown:function(e,t){return a(t)}},onUpdate:function(){o(p.getHTML())},onCreate:function(){i(p)}});return s.current=p,function(){s.current&&(s.current.destroy(),s.current=null)}}},[]),he("div",{className:"".concat(Of.b()," ").concat(r?Of.m("disabled"):""),children:he("div",{ref:c})})},Ef=new pe("chat-input"),Af=window.SpeechRecognition||window.webkitSpeechRecognition,Df=function(e){var t,n=d(qe(!1),2),r=n[0],i=n[1];Ge($f);var o=e.controller.input,a=At(!1),s=Je(),c=Je(null);Af&&!s.current&&(s.current=new Af,s.current.onstart=function(){a.value=!0},s.current.onend=function(){a.value=!1},s.current.onresult=function(e){var t,n,r=null===(t=e.results)||void 0===t||null===(t=t[0])||void 0===t||null===(t=t[0])||void 0===t?void 0:t.transcript;r&&(null===(n=c.current)||void 0===n||n.commands.insertContent(r))});var u=function(e){var t=(new DOMParser).parseFromString(e,"text/html");var n=Array.from(t.body.childNodes).map(function e(t){if(t.nodeType===Node.TEXT_NODE)return t.textContent||"";if(t.nodeType!==Node.ELEMENT_NODE)return"";var n=t,r=n.tagName.toLowerCase(),i=Array.from(n.childNodes).map(function(t){return e(t)}).join("");switch(r){case"p":return"".concat(i,"\n");case"img":var o=n.getAttribute("src")||"",a=n.getAttribute("alt")||"";return o?"\n![".concat(a,"](").concat(o,")\n"):"";default:return t.textContent||""}}).join("").replace(/\n+/g,"\n").replace(/^\n|\n$/g,"");return n},l=Dt(function(){return u(o.value).length<=0}),h=Ye(b(y().m(function t(){var n,r,i;return y().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,r=u(o.value),o.value="",null===(n=c.current)||void 0===n||n.chain().clearContent().run(),t.n=1,e.controller.question(r);case 1:t.n=3;break;case 2:t.p=2,i=t.v,console.error(i);case 3:return t.p=3,c.current&&!c.current.isDestroyed&&c.current.chain().focus().run(),t.f(3);case 4:return t.a(2)}},t,null,[[0,2,3,4]])})),[o]),f=Ye(b(y().m(function t(){return y().w(function(t){for(;;)switch(t.n){case 0:try{e.controller.abortQuestion()}catch(n){console.error(n)}case 1:return t.a(2)}},t)})),[o]),p=function(){var t=b(y().m(function t(n){var r;return y().w(function(t){for(;;)switch(t.n){case 0:return r=Dr.getMaterialHelper("ossfile",e.controller),t.n=1,r.excuteAction(n);case 1:i(!1);case 2:return t.a(2)}},t)}));return function(e){return t.apply(this,arguments)}}(),v=function(){var t=b(y().m(function t(n,r){var o;return y().w(function(t){for(;;)switch(t.n){case 0:return o=Dr.getMaterialHelper("common",e.controller),t.n=1,o.excuteAction(n,r);case 1:i(!1);case 2:return t.a(2)}},t)}));return function(e,n){return t.apply(this,arguments)}}();return he("div",{className:Ef.b("wrapper"),children:[he("div",{className:Ef.b("material-wrapper"),children:he(Rr,{controller:e.controller})}),he("div",{className:Ef.b("main-wrapper"),children:[he(Nf,{c:e.controller,value:o.value,disabled:e.controller.isLoading.value,onCreate:function(e){c.current=e},onChange:function(e){o.value=e},onKeyDown:function(e){if("Enter"===e.code&&!e.isComposing&&!1===e.shiftKey)return h(),!0}}),he("div",{className:Ef.b("action-wrapper"),children:[he("div",{className:Ef.b("left-action-wrapper"),children:he(kn,{options:e.controller.agentList.value,defaultValue:e.controller.activeAIAgentID,onChange:function(t){var n;n=t,e.controller.setActiveAIAgentID(n)},placeholder:"Auto",disabled:!e.controller.enableAIAgentChange})}),he("div",{className:Ef.b("right-action-wrapper"),children:[he("div",{className:"".concat(Ef.be("right-action-wrapper","action-item")," ").concat(Ef.is("disabled",e.controller.isLoading.value)),title:"上传资料",children:he(Pr,{content:he("div",{className:Ef.b("pop-actions"),children:[he("div",{className:Ef.b("pop-action-item"),onClick:function(e){p(e)},children:[he("span",{className:Ef.b("pop-action-item-icon"),children:he(Qt,{})}),he("span",{className:Ef.b("pop-action-item-title"),children:"文件资料"})]}),null===(t=e.questionToolbarItems)||void 0===t?void 0:t.map(function(e){var t,n,r;return he("div",{className:Ef.b("pop-action-item"),onClick:function(t){v(t,e)},children:[he("span",{className:Ef.b("pop-action-item-icon"),children:"function"==typeof e.icon?e.icon():(null===(t=e.icon)||void 0===t?void 0:t.showIcon)&&he(H,{children:null!==(n=e.icon)&&void 0!==n&&n.cssClass?he("i",{className:e.icon.cssClass}):null!==(r=e.icon)&&void 0!==r&&r.imagePath?xe(e.icon.imagePath)?he("div",{dangerouslySetInnerHTML:{__html:e.icon.imagePath}}):he("img",{src:e.icon.imagePath}):null})}),he("span",{className:Ef.b("pop-action-item-title"),children:e.label})]},e.id)})]}),position:"top-left",isOpen:r,onToggleOpen:i,children:he(Zt,{})})}),he("div",{title:a.value?"语音输入中...":"语音输入",className:"".concat(Ef.be("right-action-wrapper","action-item")," ").concat(Ef.is("disabled",e.controller.isLoading.value)),onClick:function(){s.current&&!a.value&&s.current.start()},children:a.value?he(qt,{}):he(Wt,{})}),e.controller.isLoading.value?he("div",{title:"停止生成",className:"".concat(Ef.be("right-action-wrapper","action-item")),onClick:f,children:he(nn,{})}):he("div",{title:"发送消息",className:"".concat(Ef.be("right-action-wrapper","action-item")," ").concat(Ef.is("disabled",l.value)),onClick:h,children:he(Rt,{})})]})]})]})]})},If=new pe("chat-topic-item"),zf=function(e){var t=e.controller,n=e.topic,r=e.onClick,i=e.onAction,o=Je(null),a=Dt(function(){var e;return(null===(e=t.activedTopic.value)||void 0===e?void 0:e.id)===n.id}),s=d(qe(!1),2),c=s[0],u=s[1],l=At(!1);return he("div",{className:"".concat(If.b()," ").concat(If.is("active",a.value)," ").concat(If.is("edit",l.value)),onClick:r.bind(void 0),children:[he("div",{className:If.e("caption"),title:n.caption,children:l.value?he("input",{ref:o,value:n.caption,onBlur:function(e){e.stopPropagation(),l.value=!1,i("RENAME",e)},onKeyDown:function(e){e.stopPropagation(),"Enter"===e.key&&(l.value=!1)},onClick:function(e){return e.stopPropagation()},onChange:function(e){return(t=e).stopPropagation(),void(n.data.caption=null===(r=t.target)||void 0===r?void 0:r.value);var t,r},className:If.em("caption","editor")}):he("div",{className:If.em("caption","readonly"),children:[he("span",{className:If.em("caption","text"),children:n.caption}),n.isTop?he("span",{className:If.em("caption","icon"),children:he(hn,{})}):null]})}),!l.value&&he("div",{className:If.e("icon"),children:[he("span",{title:"跳转主视图",className:If.em("icon","item"),onClick:function(e){e.stopPropagation(),i("LINK",e)}.bind(void 0),children:he(Jt,{className:If.b("link-icon")})}),a.value?null:he(Pr,{actions:[{id:"PINNED",caption:n.isTop?"取消置顶":"置顶",icon:n.isTop?he(fn,{}):he(hn,{})},{id:"RENAME",caption:"重命名",icon:he(sn,{})},{id:"DELETE",caption:"删除话题",icon:he(Kt,{})}],position:"bottom",isOpen:c,onToggleOpen:u,onAction:function(e,t){"RENAME"===e?(l.value=!0,setTimeout(function(){var e;null===(e=o.current)||void 0===e||e.focus()},100)):i(e,t),u(!1)}.bind(void 0),children:he("span",{className:If.em("icon","item"),title:"更多",children:he(Ut,{className:If.e("more-icon")})})})]})]})},Rf=new pe("chat-search"),Pf=function(e){var t=e.className,n=e.value,r=e.placeholder,i=e.onChange,o=d(qe(!1),2),a=o[0],s=o[1],c=function(e){var t;e.stopPropagation(),null==i||i(null===(t=e.target)||void 0===t?void 0:t.value)};return he("div",{className:"".concat(Rf.b()," ").concat(Rf.is("focus",a)," ").concat(t||""),children:[he("div",{className:Rf.e("prefix"),children:he(un,{})}),he("input",{value:n,className:Rf.e("inner"),placeholder:r,onFocus:function(){return s(!0)},onBlur:function(){return s(!1)},onChange:function(e){return c(e)}})]})},Lf=new pe("chat-topics"),Bf=function(e){var t=Je(null),n=At(void 0),r=At([]);Ue(function(){var t=e.controller.topics.value.sort(function(e,t){return e.isTop!==t.isTop?t.isTop?1:-1:e.sequence-t.sequence});r.value=t.filter(function(e){var t,r;return null===(t=e.caption)||void 0===t?void 0:t.toLowerCase().includes((null===(r=n.value)||void 0===r?void 0:r.trim().toLowerCase())||"")})},[e.controller.topics.value]);return Ue(function(){var e=t.current;if(e){var n=e.querySelector(".ibiz-chat-topic-item.is-active");null==n||n.scrollIntoView({behavior:"smooth",block:"nearest"})}},[e.controller.activedTopic.value]),he("div",{className:Lf.b(),children:[he("div",{className:Lf.e("header"),children:he(Pf,{value:n.value,placeholder:"搜索话题",onChange:function(t){n.value=t,r.value=e.controller.topics.value.filter(function(e){var t,r;return null===(t=e.caption)||void 0===t?void 0:t.toLowerCase().includes((null===(r=n.value)||void 0===r?void 0:r.trim().toLowerCase())||"")})}.bind(void 0)})}),he("div",{ref:t,className:Lf.e("main"),children:r.value&&r.value.length>0?r.value.map(function(t){return he(zf,{topic:t,controller:e.controller,onClick:function(){return function(t){e.controller.handleTopicChange(t)}(t)},onAction:function(n,r){return function(t,n,r){e.controller.handleTopicAction(t,n,r)}(n,t,r)}},t.id)}):he("div",{className:Lf.e("empty"),children:"暂无话题"})}),he("div",{className:Lf.e("footer"),children:he("div",{title:"清空会话",className:Lf.e("action"),onClick:function(){return e.controller.clearTopic()},children:[he(Kt,{}),he("span",{children:"清空会话"})]})})]})},Vf=new pe("chat-minimize"),Ff=function(e){var t=Je(null),n=d(qe(""),2),r=n[0],i=n[1],o=d(qe(0),2),a=o[0],s=o[1],c=Je(!1),u={x:(window.innerWidth-86)/window.innerWidth,y:(window.innerHeight-86)/window.innerHeight},l=Dt(function(){var t=e.controller.messages.value[e.controller.messages.value.length-1];return!!t&&("ASSISTANT"===t.role&&20===t.state&&!0!==t.completed)}),h=Dt(function(){var t="";if(!l.value)return i(""),s(0),t;var n=e.controller.messages.value[e.controller.messages.value.length-1];if(t=n.content,-1!==n.content.indexOf("<think>")){var r=function(e){var t=e.indexOf("<think>"),n=e.indexOf("</think>"),r="",i="";return-1===n?(r=e.slice(t+7),i=""):(r=e.slice(t+7,n),i=e.slice(n+8)),{thoughtContent:r,answerContent:i}}(n.content);t=r.thoughtContent+r.answerContent}return t}),f=function(){Object.assign(t.current.style,{left:"".concat(100*u.x,"%"),top:"".concat(100*u.y,"%")}),localStorage.setItem(Cr.MINIMIZE_STYLY_CHCHE,JSON.stringify(u))};return Ue(function(){var e,n=localStorage.getItem(Cr.MINIMIZE_STYLY_CHCHE);if(n){var r=JSON.parse(n);Oe(r)&&Object.assign(u,r)}f(),(e=t.current)&&(e.onmousedown=function(t){document.body.style.userSelect="none";var n=t.clientX-e.offsetLeft,r=t.clientY-e.offsetTop,i=Date.now(),o=function(e){var t=56/window.innerWidth,i=56/window.innerHeight,o=Ne(e.clientX-n,e.clientY-r,t,i),a=o.x,s=o.y;Object.assign(u,{x:a,y:s}),requestAnimationFrame(function(){f()})},a=function(){var e=Date.now();c.current=e-i>300,document.body.style.userSelect="",document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",a)};document.addEventListener("mousemove",o),document.addEventListener("mouseup",a)})},[]),Ue(function(){if(a<h.value.length){var e=setTimeout(function(){i(function(e){return e+h.value[a]}),s(function(e){return e+1})},100);return function(){return clearTimeout(e)}}},[a,h.value]),he("div",{ref:t,title:e.title,className:"".concat(Vf.b()," ").concat(Vf.is("hidden",!e.isMinimize)," ").concat(Vf.is("show-halo",l.value)),onClick:function(){c.current||e.onClick()},children:he("div",{className:"".concat(Vf.e("content")," ").concat(Vf.is("show-border",!l.value)),children:[r&&he("div",{className:"".concat(Vf.em("content","popover")),children:he("div",{className:"typewriter",children:r})}),he(jt,{})]})})},$f=function(e){function t(e){var n,r;return this.getChildContext||(n=new Set,(r={})[t.__c]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&n.forEach(function(e){e.__e=!0,J(e)})},this.sub=function(e){n.add(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n&&n.delete(e),t&&t.call(e)}}),e.children}return t.__c="__cC"+z++,t.__=e,t.Provider=t.__l=(t.Consumer=function(e,t){return e.children(t)}).contextType=t,t}({zIndex:10,enableBackFill:!0}),jf=function(e){function t(e){var n,i,o,a,s,c;return x(this,t),_(c=r(this,t,[e]),"ns",new pe("chat-container")),_(c,"containerRef",{current:null}),_(c,"dragHandle",{current:null}),_(c,"data",{side:{y:0,height:1,width:750/window.innerWidth,x:(window.innerWidth-750)/window.innerWidth},window:{y:0,width:750/window.innerWidth,height:750/window.innerHeight,x:(window.innerWidth-750)/window.innerWidth},minWidth:500,minHeight:300,showMode:"side"}),_(c,"disabled",!1),_(c,"isDragging",!1),_(c,"containerContext",{zIndex:(null===(n=c.props.containerOptions)||void 0===n?void 0:n.zIndex)||10,enableBackFill:void 0===(null===(i=c.props)||void 0===i?void 0:i.enableBackFill)||null===(null===(o=c.props)||void 0===o?void 0:o.enableBackFill)||(null===(a=c.props)||void 0===a?void 0:a.enableBackFill)}),c.state={isFullScreen:!1,isMinimize:!("minimize"!==(null==e?void 0:e.openMode)&&"autoexpand"!==(null==e?void 0:e.openMode)),enableAIMinimize:!0===(null==e||null===(s=e.containerOptions)||void 0===s?void 0:s.enableAIMinimize)},null==e||e.aiChat.evt.on("onCompleteMessage",function(){if(e.autoClose){var t=e.autoClose,n=t.mode,r=t.duration,i=void 0===r?3:r;switch(n){case"minimize":c.minimize();break;case"close":c.close();break;case"closetime":setTimeout(function(){c.close()},1e3*i)}}"autoexpand"===e.openMode&&c.exitMinimize()}),c}return a(t,e),S(t,[{key:"calcWindowStyle",value:function(){var e,t="window"===this.data.showMode?this.data.window:this.data.side;return{left:"".concat(100*t.x,"%"),top:"".concat(100*t.y,"%"),width:"".concat(100*t.width,"%"),height:"".concat(100*t.height,"%"),minWidth:"".concat(this.data.minWidth,"px"),minHeight:"".concat(this.data.minHeight,"px"),"z-index":(null===(e=this.props.containerOptions)||void 0===e||null===(e=e.zIndex)||void 0===e?void 0:e.toString())||"10"}}},{key:"calcSideModeStyle",value:function(e){Object.assign(this.data,{side:{y:0,x:"left"===e?0:(window.innerWidth-750)/window.innerWidth,height:1,width:750/window.innerWidth},showMode:"side"})}},{key:"setStyle",value:function(){Object.assign(this.containerRef.current.style,this.calcWindowStyle()),localStorage.setItem(Cr.STYLE_CACHE,JSON.stringify(this.data))}},{key:"snapToEdge",value:function(){var e=20/window.innerWidth,t=20/window.innerHeight,n=this.data.window,r=n.x,i=n.y,o=n.width,a=n.height;r<e||r+o>1-e?this.calcSideModeStyle(r<e?"left":"right"):(i<t&&(this.data.window.y=0),i+a>1-t&&(this.data.window.y=1-a)),this.setStyle()}},{key:"registerDragDialog",value:function(){var e=this;this.dragHandle.current.onmousedown=function(t){if(!e.state.isFullScreen){document.body.style.userSelect="none";var n=t.clientX-e.containerRef.current.offsetLeft,r=t.clientY-e.containerRef.current.offsetTop,i=function(t){if(!e.disabled){e.data.showMode="window";var i=Ne(t.clientX-n,t.clientY-r,e.data.window.width,e.data.window.height),o=i.x,a=i.y;Object.assign(e.data.window,{x:o,y:a}),e.setStyle()}},o=function(){document.body.style.userSelect="",document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",o),e.disabled||e.snapToEdge()};document.addEventListener("mousemove",i),document.addEventListener("mouseup",o)}}}},{key:"registerDragDialogBorder",value:function(){var e=this;o(this.containerRef.current).resizable({edges:{top:!0,right:!0,bottom:!0,left:!0},margin:6,modifiers:[o.modifiers.restrictEdges({outer:document.body}),o.modifiers.restrictSize({min:{width:this.data.minWidth,height:this.data.minHeight}})],inertia:!0,listeners:{move:function(t){if(!e.state.isFullScreen){var n="side"===e.data.showMode?e.data.side:e.data.window;n.x=t.rect.left/window.innerWidth,n.y=t.rect.top/window.innerHeight,n.width=t.rect.width/window.innerWidth,n.height=t.rect.height/window.innerHeight,e.setStyle()}},start:function(){e.disabled=!0,document.body.style.userSelect="none"},end:function(){e.disabled=!1,document.body.style.userSelect=""}}})}},{key:"handleFullScreenChange",value:function(){this.setState({isFullScreen:null!==document.fullscreenElement})}},{key:"componentDidMount",value:function(){this.handleFullScreenChange=this.handleFullScreenChange.bind(this);var e=localStorage.getItem(Cr.STYLE_CACHE);if(e){var t=JSON.parse(e);t.side&&Oe(t.side)&&t.window&&Oe(t.window)&&Object.assign(this.data,t)}this.setStyle(),this.registerDragDialog(),this.registerDragDialogBorder(),document.addEventListener("fullscreenchange",this.handleFullScreenChange)}},{key:"componentWillUnmount",value:function(){document.removeEventListener("fullscreenchange",this.handleFullScreenChange)}},{key:"close",value:function(){this.props.close()}},{key:"fullScreen",value:function(){var e=this.containerRef.current;e&&(e.requestFullscreen(),this.props.fullscreen(!0))}},{key:"closeFullScreen",value:function(){var e;this.state.isFullScreen&&(null===(e=document)||void 0===e||e.exitFullscreen(),this.props.fullscreen(!1),this.setStyle())}},{key:"minimize",value:function(){this.closeFullScreen(),this.setState({isMinimize:!0}),this.props.minimize(!0)}},{key:"exitMinimize",value:function(){this.setState({isMinimize:!1}),this.props.minimize(!1)}},{key:"stopPropagation",value:function(e){e.stopPropagation()}},{key:"render",value:function(){return he($f.Provider,{value:this.containerContext,children:he("div",{className:"".concat(this.ns.b()),children:[he("div",{className:"".concat(this.ns.e("dialog")," ").concat(this.ns.is("full-screen",this.state.isFullScreen)," ").concat(this.ns.is("hidden",this.state.isMinimize)),ref:this.containerRef,children:[he("div",{ref:this.dragHandle,className:this.ns.b("header"),children:[he("div",{className:this.ns.b("header-caption"),children:this.props.caption||"AI助手"}),he("div",{className:this.ns.b("header-action-wrapper"),children:[this.state.enableAIMinimize&&he("div",{title:"最小化",className:"".concat(this.ns.be("header-action-wrapper","action-item")," ").concat(this.ns.be("header-action-wrapper","minimize")),onMouseDown:this.stopPropagation.bind(this),onClick:this.minimize.bind(this),children:he($t,{})}),this.state.isFullScreen?he("div",{title:"退出全屏",className:"".concat(this.ns.be("header-action-wrapper","action-item")," ").concat(this.ns.be("header-action-wrapper","close-full-screen")),onMouseDown:this.stopPropagation.bind(this),onClick:this.closeFullScreen.bind(this),children:he(Ft,{})}):he("div",{title:"全屏",className:"".concat(this.ns.be("header-action-wrapper","action-item")," ").concat(this.ns.be("header-action-wrapper","full-screen")),onMouseDown:this.stopPropagation.bind(this),onClick:this.fullScreen.bind(this),children:he(Vt,{})}),he("div",{title:"关闭",className:"".concat(this.ns.be("header-action-wrapper","action-item")," ").concat(this.ns.be("header-action-wrapper","action-close")),onMouseDown:this.stopPropagation.bind(this),onClick:this.close.bind(this),children:he(It,{})})]})]}),"TOPIC"===this.props.mode?he("div",{className:"".concat(this.ns.b("main")),children:[!this.props.hideTopicSidebar&&he("div",{className:"".concat(this.ns.be("main","left")),children:he(Bf,{controller:this.props.aiTopic})}),he("div",{className:"".concat(this.ns.be("main","right")),style:{width:this.props.hideTopicSidebar?"100%":"calc(100% - 200px)"},children:[he("div",{className:this.ns.b("content"),children:he(Kn,{controller:this.props.aiChat,toolbarItems:this.props.contentToolbarItems})}),he(qn,{type:"footer",mode:this.props.mode,hideTopicSidebar:this.props.hideTopicSidebar,data:this.props.aiTopic.activedTopic.value,className:"".concat(this.ns.e("toolbar")," ").concat(this.ns.is("has-materials",this.props.aiChat.materials.value.length>0)),controller:this.props.aiChat,items:this.props.footerToolbarItems}),he("div",{className:this.ns.b("footer"),children:he(Df,{controller:this.props.aiChat,questionToolbarItems:this.props.questionToolbarItems})})]})]}):he("div",{className:"".concat(this.ns.be("main","default")),children:[he("div",{className:this.ns.b("content"),children:he(Kn,{controller:this.props.aiChat,toolbarItems:this.props.contentToolbarItems})}),he(qn,{type:"footer",mode:this.props.mode,hideTopicSidebar:this.props.hideTopicSidebar,data:this.props.aiTopic.activedTopic.value,className:"".concat(this.ns.e("toolbar")," ").concat(this.ns.is("has-materials",this.props.aiChat.materials.value.length>0)),controller:this.props.aiChat,items:this.props.footerToolbarItems}),he("div",{className:this.ns.b("footer"),children:he(Df,{controller:this.props.aiChat,questionToolbarItems:this.props.questionToolbarItems})})]})]}),he(Ff,{title:this.props.caption||"AI助手",controller:this.props.aiChat,isMinimize:this.state.isMinimize,onClick:this.exitMinimize.bind(this)})]})})}}])}(W);t("ChatContainer",jf)}}})}();
1
+ !function(){function e(e,n,r,i){var a=t(o(1&i?e.prototype:e),n,r);return 2&i&&"function"==typeof a?function(e){return a.apply(r,e)}:a}function t(){return t="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=o(e)););return e}(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},t.apply(null,arguments)}function n(e){var t="function"==typeof Map?new Map:void 0;return n=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(i())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var o=new(e.bind.apply(e,r));return n&&s(o,n.prototype),o}(e,arguments,o(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),s(n,e)},n(e)}function r(e,t,n){return t=o(t),function(e,t){if(t&&("object"==T(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,i()?Reflect.construct(t,n||[],o(e).constructor):t.apply(e,n))}function i(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(i=function(){return!!e})()}function o(e){return o=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},o(e)}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&s(e,t)}function s(e,t){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},s(e,t)}function c(e){return function(e){if(Array.isArray(e))return p(e)}(e)||u(e)||f(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function l(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=f(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function d(e,t){return v(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],c=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){u=!0,i=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(e,t)||f(e,t)||h()}function h(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function f(e,t){if(e){if("string"==typeof e)return p(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?p(e,t):void 0}}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function v(e){if(Array.isArray(e))return e}function m(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function g(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?m(Object(n),!0).forEach(function(t){_(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):m(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function y(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var c=r&&r.prototype instanceof s?r:s,u=Object.create(c.prototype);return k(u,"_invoke",function(n,r,i){var o,s,c,u=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,c=e,h.n=n,a}};function f(n,r){for(s=n,c=r,t=0;!d&&u&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(c=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(u>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,c=p;(t=s<2?e:c)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,c)):h.n=c:h.v=c);try{if(u=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(c=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?c:n.call(r,h))!==a)break}catch(t){o=e,s=1,c=t}finally{u=1}}return{value:t,done:d}}}(n,i,o),!0),u}var a={};function s(){}function c(){}function u(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(k(t={},r,function(){return this}),t),d=u.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,k(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return c.prototype=u,k(d,"constructor",u),k(u,"constructor",c),c.displayName="GeneratorFunction",k(u,i,"GeneratorFunction"),k(d),k(d,i,"Generator"),k(d,r,function(){return this}),k(d,"toString",function(){return"[object Generator]"}),(y=function(){return{w:o,m:h}})()}function k(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}k=function(e,t,n,r){function o(t,n){k(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},k(e,t,n,r)}function w(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function b(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var o=e.apply(t,n);function a(e){w(o,r,i,a,s,"next",e)}function s(e){w(o,r,i,a,s,"throw",e)}a(void 0)})}}function x(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function C(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,M(r.key),r)}}function S(e,t,n){return t&&C(e.prototype,t),n&&C(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function _(e,t,n){return(t=M(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function M(e){var t=function(e,t){if("object"!=T(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=T(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==T(t)?t:t+""}function T(e){return T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},T(e)}System.register(["interactjs","cherry-markdown","qx-util"],function(t,i){"use strict";var o,s,p;return{setters:[function(e){o=e.default},function(e){s=e.default},function(e){p=e.QXEvent}],execute:function(){var i,m,k,w,C,M,O,N,E,A,D,I,z,R={},P=[],L=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,B=Array.isArray;function V(e,t){for(var n in t)e[n]=t[n];return e}function F(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function $(e,t,n){var r,o,a,s={};for(a in t)"key"==a?r=t[a]:"ref"==a?o=t[a]:s[a]=t[a];if(arguments.length>2&&(s.children=arguments.length>3?i.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(a in e.defaultProps)void 0===s[a]&&(s[a]=e.defaultProps[a]);return j(e,s,r,o,null)}function j(e,t,n,r,i){var o={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:null==i?++k:i,__i:-1,__u:0};return null==i&&null!=m.vnode&&m.vnode(o),o}function H(e){return e.children}function W(e,t){this.props=e,this.context=t}function q(e,t){if(null==t)return e.__?q(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e)return n.__e;return"function"==typeof e.type?q(e):null}function U(e){var t,n;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e){e.__e=e.__c.base=n.__e;break}return U(e)}}function J(e){(!e.__d&&(e.__d=!0)&&C.push(e)&&!K.__r++||M!=m.debounceRendering)&&((M=m.debounceRendering)||O)(K)}function K(){for(var e,t,n,r,i,o,a,s=1;C.length;)C.length>s&&C.sort(N),e=C.shift(),s=C.length,e.__d&&(n=void 0,r=void 0,i=(r=(t=e).__v).__e,o=[],a=[],t.__P&&((n=V({},r)).__v=r.__v+1,m.vnode&&m.vnode(n),ne(t.__P,n,r,t.__n,t.__P.namespaceURI,32&r.__u?[i]:null,o,null==i?q(r):i,!!(32&r.__u),a),n.__v=r.__v,n.__.__k[n.__i]=n,ie(o,n,a),r.__e=r.__=null,n.__e!=i&&U(n)));K.__r=0}function Y(e,t,n,r,i,o,a,s,c,u,l){var d,h,f,p,v,m,g,y=r&&r.__k||P,k=t.length;for(c=function(e,t,n,r,i){var o,a,s,c,u,l=n.length,d=l,h=0;for(e.__k=new Array(i),o=0;o<i;o++)null!=(a=t[o])&&"boolean"!=typeof a&&"function"!=typeof a?(c=o+h,(a=e.__k[o]="string"==typeof a||"number"==typeof a||"bigint"==typeof a||a.constructor==String?j(null,a,null,null,null):B(a)?j(H,{children:a},null,null,null):null==a.constructor&&a.__b>0?j(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):a).__=e,a.__b=e.__b+1,s=null,-1!=(u=a.__i=Z(a,n,c,d))&&(d--,(s=n[u])&&(s.__u|=2)),null==s||null==s.__v?(-1==u&&(i>l?h--:i<l&&h++),"function"!=typeof a.type&&(a.__u|=4)):u!=c&&(u==c-1?h--:u==c+1?h++:(u>c?h--:h++,a.__u|=4))):e.__k[o]=null;if(d)for(o=0;o<l;o++)null!=(s=n[o])&&!(2&s.__u)&&(s.__e==r&&(r=q(s)),ce(s,s));return r}(n,t,y,c,k),d=0;d<k;d++)null!=(f=n.__k[d])&&(h=-1==f.__i?R:y[f.__i]||R,f.__i=d,m=ne(e,f,h,i,o,a,s,c,u,l),p=f.__e,f.ref&&h.ref!=f.ref&&(h.ref&&se(h.ref,null,f),l.push(f.ref,f.__c||p,f)),null==v&&null!=p&&(v=p),(g=!!(4&f.__u))||h.__k===f.__k?c=G(f,c,e,g):"function"==typeof f.type&&void 0!==m?c=m:p&&(c=p.nextSibling),f.__u&=-7);return n.__e=v,c}function G(e,t,n,r){var i,o;if("function"==typeof e.type){for(i=e.__k,o=0;i&&o<i.length;o++)i[o]&&(i[o].__=e,t=G(i[o],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=q(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do{t=t&&t.nextSibling}while(null!=t&&8==t.nodeType);return t}function X(e,t){return t=t||[],null==e||"boolean"==typeof e||(B(e)?e.some(function(e){X(e,t)}):t.push(e)),t}function Z(e,t,n,r){var i,o,a,s=e.key,c=e.type,u=t[n],l=null!=u&&!(2&u.__u);if(null===u&&null==e.key||l&&s==u.key&&c==u.type)return n;if(r>(l?1:0))for(i=n-1,o=n+1;i>=0||o<t.length;)if(null!=(u=t[a=i>=0?i--:o++])&&!(2&u.__u)&&s==u.key&&c==u.type)return a;return-1}function Q(e,t,n){"-"==t[0]?e.setProperty(t,null==n?"":n):e[t]=null==n?"":"number"!=typeof n||L.test(t)?n:n+"px"}function ee(e,t,n,r,i){var o,a;e:if("style"==t)if("string"==typeof n)e.style.cssText=n;else{if("string"==typeof r&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||Q(e.style,t,"");if(n)for(t in n)r&&n[t]==r[t]||Q(e.style,t,n[t])}else if("o"==t[0]&&"n"==t[1])o=t!=(t=t.replace(E,"$1")),a=t.toLowerCase(),t=a in e||"onFocusOut"==t||"onFocusIn"==t?a.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+o]=n,n?r?n.u=r.u:(n.u=A,e.addEventListener(t,o?I:D,o)):e.removeEventListener(t,o?I:D,o);else{if("http://www.w3.org/2000/svg"==i)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=t&&"height"!=t&&"href"!=t&&"list"!=t&&"form"!=t&&"tabIndex"!=t&&"download"!=t&&"rowSpan"!=t&&"colSpan"!=t&&"role"!=t&&"popover"!=t&&t in e)try{e[t]=null==n?"":n;break e}catch(e){}"function"==typeof n||(null==n||!1===n&&"-"!=t[4]?e.removeAttribute(t):e.setAttribute(t,"popover"==t&&1==n?"":n))}}function te(e){return function(t){if(this.l){var n=this.l[t.type+e];if(null==t.t)t.t=A++;else if(t.t<n.u)return;return n(m.event?m.event(t):t)}}}function ne(e,t,n,r,i,o,a,s,c,u){var l,d,h,f,p,v,g,y,k,w,b,x,C,S,_,M,T,O=t.type;if(null!=t.constructor)return null;128&n.__u&&(c=!!(32&n.__u),o=[s=t.__e=n.__e]),(l=m.__b)&&l(t);e:if("function"==typeof O)try{if(y=t.props,k="prototype"in O&&O.prototype.render,w=(l=O.contextType)&&r[l.__c],b=l?w?w.props.value:l.__:r,n.__c?g=(d=t.__c=n.__c).__=d.__E:(k?t.__c=d=new O(y,b):(t.__c=d=new W(y,b),d.constructor=O,d.render=ue),w&&w.sub(d),d.props=y,d.state||(d.state={}),d.context=b,d.__n=r,h=d.__d=!0,d.__h=[],d._sb=[]),k&&null==d.__s&&(d.__s=d.state),k&&null!=O.getDerivedStateFromProps&&(d.__s==d.state&&(d.__s=V({},d.__s)),V(d.__s,O.getDerivedStateFromProps(y,d.__s))),f=d.props,p=d.state,d.__v=t,h)k&&null==O.getDerivedStateFromProps&&null!=d.componentWillMount&&d.componentWillMount(),k&&null!=d.componentDidMount&&d.__h.push(d.componentDidMount);else{if(k&&null==O.getDerivedStateFromProps&&y!==f&&null!=d.componentWillReceiveProps&&d.componentWillReceiveProps(y,b),!d.__e&&null!=d.shouldComponentUpdate&&!1===d.shouldComponentUpdate(y,d.__s,b)||t.__v==n.__v){for(t.__v!=n.__v&&(d.props=y,d.state=d.__s,d.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),x=0;x<d._sb.length;x++)d.__h.push(d._sb[x]);d._sb=[],d.__h.length&&a.push(d);break e}null!=d.componentWillUpdate&&d.componentWillUpdate(y,d.__s,b),k&&null!=d.componentDidUpdate&&d.__h.push(function(){d.componentDidUpdate(f,p,v)})}if(d.context=b,d.props=y,d.__P=e,d.__e=!1,C=m.__r,S=0,k){for(d.state=d.__s,d.__d=!1,C&&C(t),l=d.render(d.props,d.state,d.context),_=0;_<d._sb.length;_++)d.__h.push(d._sb[_]);d._sb=[]}else do{d.__d=!1,C&&C(t),l=d.render(d.props,d.state,d.context),d.state=d.__s}while(d.__d&&++S<25);d.state=d.__s,null!=d.getChildContext&&(r=V(V({},r),d.getChildContext())),k&&!h&&null!=d.getSnapshotBeforeUpdate&&(v=d.getSnapshotBeforeUpdate(f,p)),M=l,null!=l&&l.type===H&&null==l.key&&(M=oe(l.props.children)),s=Y(e,B(M)?M:[M],t,n,r,i,o,a,s,c,u),d.base=t.__e,t.__u&=-161,d.__h.length&&a.push(d),g&&(d.__E=d.__=null)}catch(e){if(t.__v=null,c||null!=o)if(e.then){for(t.__u|=c?160:128;s&&8==s.nodeType&&s.nextSibling;)s=s.nextSibling;o[o.indexOf(s)]=null,t.__e=s}else{for(T=o.length;T--;)F(o[T]);re(t)}else t.__e=n.__e,t.__k=n.__k,e.then||re(t);m.__e(e,t,n)}else null==o&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=ae(n.__e,t,n,r,i,o,a,c,u);return(l=m.diffed)&&l(t),128&t.__u?void 0:s}function re(e){e&&e.__c&&(e.__c.__e=!0),e&&e.__k&&e.__k.forEach(re)}function ie(e,t,n){for(var r=0;r<n.length;r++)se(n[r],n[++r],n[++r]);m.__c&&m.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){m.__e(e,t.__v)}})}function oe(e){return"object"!=T(e)||null==e||e.__b&&e.__b>0?e:B(e)?e.map(oe):V({},e)}function ae(e,t,n,r,o,a,s,c,u){var l,d,h,f,p,v,g,y=n.props,k=t.props,w=t.type;if("svg"==w?o="http://www.w3.org/2000/svg":"math"==w?o="http://www.w3.org/1998/Math/MathML":o||(o="http://www.w3.org/1999/xhtml"),null!=a)for(l=0;l<a.length;l++)if((p=a[l])&&"setAttribute"in p==!!w&&(w?p.localName==w:3==p.nodeType)){e=p,a[l]=null;break}if(null==e){if(null==w)return document.createTextNode(k);e=document.createElementNS(o,w,k.is&&k),c&&(m.__m&&m.__m(t,a),c=!1),a=null}if(null==w)y===k||c&&e.data==k||(e.data=k);else{if(a=a&&i.call(e.childNodes),y=n.props||R,!c&&null!=a)for(y={},l=0;l<e.attributes.length;l++)y[(p=e.attributes[l]).name]=p.value;for(l in y)if(p=y[l],"children"==l);else if("dangerouslySetInnerHTML"==l)h=p;else if(!(l in k)){if("value"==l&&"defaultValue"in k||"checked"==l&&"defaultChecked"in k)continue;ee(e,l,null,p,o)}for(l in k)p=k[l],"children"==l?f=p:"dangerouslySetInnerHTML"==l?d=p:"value"==l?v=p:"checked"==l?g=p:c&&"function"!=typeof p||y[l]===p||ee(e,l,p,y[l],o);if(d)c||h&&(d.__html==h.__html||d.__html==e.innerHTML)||(e.innerHTML=d.__html),t.__k=[];else if(h&&(e.innerHTML=""),Y("template"==t.type?e.content:e,B(f)?f:[f],t,n,r,"foreignObject"==w?"http://www.w3.org/1999/xhtml":o,a,s,a?a[0]:n.__k&&q(n,0),c,u),null!=a)for(l=a.length;l--;)F(a[l]);c||(l="value","progress"==w&&null==v?e.removeAttribute("value"):null!=v&&(v!==e[l]||"progress"==w&&!v||"option"==w&&v!=y[l])&&ee(e,l,v,y[l],o),l="checked",null!=g&&g!=e[l]&&ee(e,l,g,y[l],o))}return e}function se(e,t,n){try{if("function"==typeof e){var r="function"==typeof e.__u;r&&e.__u(),r&&null==t||(e.__u=e(t))}else e.current=t}catch(e){m.__e(e,n)}}function ce(e,t,n){var r,i;if(m.unmount&&m.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||se(r,null,t)),null!=(r=e.__c)){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){m.__e(e,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&ce(r[i],t,n||"function"!=typeof e.type);n||F(e.__e),e.__c=e.__=e.__e=void 0}function ue(e,t,n){return this.constructor(e,n)}function le(e,t,n){var r,o,a,s;t==document&&(t=document.documentElement),m.__&&m.__(e,t),o=(r="function"==typeof n)?null:n&&n.__k||t.__k,a=[],s=[],ne(t,e=(!r&&n||t).__k=$(H,null,[e]),o||R,R,t.namespaceURI,!r&&n?[n]:o?null:t.firstChild?i.call(t.childNodes):null,a,!r&&n?n:o?o.__e:t.firstChild,r,s),ie(a,e,s)}i=P.slice,m={__e:function(e,t,n,r){for(var i,o,a;t=t.__;)if((i=t.__c)&&!i.__)try{if((o=i.constructor)&&null!=o.getDerivedStateFromError&&(i.setState(o.getDerivedStateFromError(e)),a=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(e,r||{}),a=i.__d),a)return i.__E=i}catch(t){e=t}throw e}},k=0,w=function(e){return null!=e&&null==e.constructor},W.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!=this.state?this.__s:this.__s=V({},this.state),"function"==typeof e&&(e=e(V({},n),this.props)),e&&V(n,e),null!=e&&this.__v&&(t&&this._sb.push(t),J(this))},W.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),J(this))},W.prototype.render=H,C=[],O="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,N=function(e,t){return e.__v.__b-t.__v.__b},K.__r=0,E=/(PointerCapture)$|Capture$/i,A=0,D=te(!1),I=te(!0),z=0;var de=0;function he(e,t,n,r,i,o){t||(t={});var a,s,c=t;if("ref"in c)for(s in c={},t)"ref"==s?a=t[s]:c[s]=t[s];var u={type:e,props:c,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--de,__i:-1,__u:0,__source:i,__self:o};if("function"==typeof e&&(a=e.defaultProps))for(s in a)void 0===c[s]&&(c[s]=a[s]);return m.vnode&&m.vnode(u),u}function fe(e,t,n,r,i){var o="".concat(e,"-").concat(t);return n&&(o+="-".concat(n)),r&&(o+="__".concat(r)),i&&(o+="--".concat(i)),o}var pe=function(){return S(function e(t,n){x(this,e),_(this,"namespace",void 0),this.block=t,this.namespace=n||"ibiz"},[{key:"b",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return fe(this.namespace,this.block,e,"","")}},{key:"e",value:function(e){return e?fe(this.namespace,this.block,"",e,""):""}},{key:"m",value:function(e){return e?fe(this.namespace,this.block,"","",e):""}},{key:"be",value:function(e,t){return e&&t?fe(this.namespace,this.block,e,t,""):""}},{key:"em",value:function(e,t){return e&&t?fe(this.namespace,this.block,"",e,t):""}},{key:"bm",value:function(e,t){return e&&t?fe(this.namespace,this.block,e,"",t):""}},{key:"bem",value:function(e,t,n){return e&&t&&n?fe(this.namespace,this.block,e,t,n):""}},{key:"is",value:function(e,t){return e&&t?"".concat("is-").concat(e):""}},{key:"cssVar",value:function(e){var t={};for(var n in e)e[n]&&(t[this.cssVarName(n)]=e[n]);return t}},{key:"cssVarBlock",value:function(e){var t={};for(var n in e)e[n]&&(t[this.cssVarBlockName(n)]=e[n]);return t}},{key:"cssVarName",value:function(e){return"--".concat(this.namespace,"-").concat(e)}},{key:"cssVarBlockName",value:function(e){return"--".concat(this.namespace,"-").concat(this.block,"-").concat(e)}}])}();function ve(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function me(e,t){for(var n,r="",i=0,o=-1,a=0,s=0;s<=e.length;++s){if(s<e.length)n=e.charCodeAt(s);else{if(47===n)break;n=47}if(47===n){if(o===s-1||1===a);else if(o!==s-1&&2===a){if(r.length<2||2!==i||46!==r.charCodeAt(r.length-1)||46!==r.charCodeAt(r.length-2))if(r.length>2){var c=r.lastIndexOf("/");if(c!==r.length-1){-1===c?(r="",i=0):i=(r=r.slice(0,c)).length-1-r.lastIndexOf("/"),o=s,a=0;continue}}else if(2===r.length||1===r.length){r="",i=0,o=s,a=0;continue}t&&(r.length>0?r+="/..":r="..",i=2)}else r.length>0?r+="/"+e.slice(o+1,s):r=e.slice(o+1,s),i=s-o-1;o=s,a=0}else 46===n&&-1!==a?++a:a=-1}return r}var ge={resolve:function(){for(var e,t="",n=!1,r=arguments.length-1;r>=-1&&!n;r--){var i;r>=0?i=arguments[r]:(void 0===e&&(e=process.cwd()),i=e),ve(i),0!==i.length&&(t=i+"/"+t,n=47===i.charCodeAt(0))}return t=me(t,!n),n?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(e){if(ve(e),0===e.length)return".";var t=47===e.charCodeAt(0),n=47===e.charCodeAt(e.length-1);return 0!==(e=me(e,!t)).length||t||(e="."),e.length>0&&n&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return ve(e),e.length>0&&47===e.charCodeAt(0)},join:function(){if(0===arguments.length)return".";for(var e,t=0;t<arguments.length;++t){var n=arguments[t];ve(n),n.length>0&&(void 0===e?e=n:e+="/"+n)}return void 0===e?".":ge.normalize(e)},relative:function(e,t){if(ve(e),ve(t),e===t)return"";if((e=ge.resolve(e))===(t=ge.resolve(t)))return"";for(var n=1;n<e.length&&47===e.charCodeAt(n);++n);for(var r=e.length,i=r-n,o=1;o<t.length&&47===t.charCodeAt(o);++o);for(var a=t.length-o,s=i<a?i:a,c=-1,u=0;u<=s;++u){if(u===s){if(a>s){if(47===t.charCodeAt(o+u))return t.slice(o+u+1);if(0===u)return t.slice(o+u)}else i>s&&(47===e.charCodeAt(n+u)?c=u:0===u&&(c=0));break}var l=e.charCodeAt(n+u);if(l!==t.charCodeAt(o+u))break;47===l&&(c=u)}var d="";for(u=n+c+1;u<=r;++u)u!==r&&47!==e.charCodeAt(u)||(0===d.length?d+="..":d+="/..");return d.length>0?d+t.slice(o+c):(o+=c,47===t.charCodeAt(o)&&++o,t.slice(o))},_makeLong:function(e){return e},dirname:function(e){if(ve(e),0===e.length)return".";for(var t=e.charCodeAt(0),n=47===t,r=-1,i=!0,o=e.length-1;o>=1;--o)if(47===(t=e.charCodeAt(o))){if(!i){r=o;break}}else i=!1;return-1===r?n?"/":".":n&&1===r?"//":e.slice(0,r)},basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');ve(e);var n,r=0,i=-1,o=!0;if(void 0!==t&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var a=t.length-1,s=-1;for(n=e.length-1;n>=0;--n){var c=e.charCodeAt(n);if(47===c){if(!o){r=n+1;break}}else-1===s&&(o=!1,s=n+1),a>=0&&(c===t.charCodeAt(a)?-1===--a&&(i=n):(a=-1,i=s))}return r===i?i=s:-1===i&&(i=e.length),e.slice(r,i)}for(n=e.length-1;n>=0;--n)if(47===e.charCodeAt(n)){if(!o){r=n+1;break}}else-1===i&&(o=!1,i=n+1);return-1===i?"":e.slice(r,i)},extname:function(e){ve(e);for(var t=-1,n=0,r=-1,i=!0,o=0,a=e.length-1;a>=0;--a){var s=e.charCodeAt(a);if(47!==s)-1===r&&(i=!1,r=a+1),46===s?-1===t?t=a:1!==o&&(o=1):-1!==t&&(o=-1);else if(!i){n=a+1;break}}return-1===t||-1===r||0===o||1===o&&t===r-1&&t===n+1?"":e.slice(t,r)},format:function(e){if(null===e||"object"!==T(e))throw new TypeError('The "pathObject" argument must be of type Object. Received type '+T(e));return function(e,t){var n=t.dir||t.root,r=t.base||(t.name||"")+(t.ext||"");return n?n===t.root?n+r:n+e+r:r}("/",e)},parse:function(e){ve(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return t;var n,r=e.charCodeAt(0),i=47===r;i?(t.root="/",n=1):n=0;for(var o=-1,a=0,s=-1,c=!0,u=e.length-1,l=0;u>=n;--u)if(47!==(r=e.charCodeAt(u)))-1===s&&(c=!1,s=u+1),46===r?-1===o?o=u:1!==l&&(l=1):-1!==o&&(l=-1);else if(!c){a=u+1;break}return-1===o||-1===s||0===l||1===l&&o===s-1&&o===a+1?-1!==s&&(t.base=t.name=0===a&&i?e.slice(1,s):e.slice(a,s)):(0===a&&i?(t.name=e.slice(1,o),t.base=e.slice(1,s)):(t.name=e.slice(a,o),t.base=e.slice(a,s)),t.ext=e.slice(o,s)),a>0?t.dir=e.slice(0,a-1):i&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};function ye(){return(65536*(1+Math.random())|0).toString(16).substring(1)}function ke(){return"".concat(ye()+ye(),"-").concat(ye(),"-").concat(ye(),"-").concat(ye(),"-").concat(ye()).concat(ye()).concat(ye())}function we(e){var t=e.lastIndexOf("@");return-1===t?e:e.substring(0,t)}ge.posix=ge;var be=/<svg\b[^>]*>[\s\S]*?<\/svg>/;function xe(e){return be.test(e)}var Ce=function(){return S(function e(){x(this,e)},null,[{key:"copy",value:function(e){return this.inputElement||(this.inputElement=document.createElement("input"),this.inputElement.style.position="absolute",this.inputElement.style.left="-9999px",document.body.appendChild(this.inputElement)),this.inputElement.value=e,this.inputElement.select(),document.execCommand("copy")}}])}();_(Ce,"inputElement",null);var Se=function(){function e(){x(this,e)}return S(e,null,[{key:"checkDataBaseExists",value:(l=b(y().m(function e(t){var n,r;return y().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,indexedDB.databases();case 1:return n=e.v,e.a(2,n.some(function(e){return e.name===t}));case 2:return e.p=2,r=e.v,console.error("检查数据库是否存在时出错:",r),e.a(2,!1)}},e,null,[[0,2]])})),function(e){return l.apply(this,arguments)})},{key:"deleteDatabase",value:(u=b(y().m(function t(n){var r,i;return y().w(function(t){for(;;)if(0===t.n)return e.lastLink&&(null===(r=(i=e.lastLink).close)||void 0===r||r.call(i)),t.a(2,new Promise(function(e,t){var r=indexedDB.deleteDatabase(n);r.onsuccess=function(){e(!0)},r.onerror=function(){e(!1)},r.onblocked=function(){console.warn("删除数据库 ".concat(n," 被阻塞,可能有其他连接正在使用该数据库。")),t(new Error("删除数据库 ".concat(n," 被阻塞")))}}))},t)})),function(e){return u.apply(this,arguments)})},{key:"checkTableExists",value:(c=b(y().m(function t(n,r){return y().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,e.checkDataBaseExists(n);case 1:if(t.v){t.n=2;break}return t.a(2,!1);case 2:return t.a(2,new Promise(function(t,i){var o=indexedDB.open(n);o.onupgradeneeded=function(t){e.db=t.target.result,e.version=e.db.version},o.onsuccess=function(n){e.db=n.target.result,e.lastLink=o.result;var i=e.db.objectStoreNames.contains(r);o.result.close(),t(i)},o.onerror=function(e){i(e.target.error)}}))}},t)})),function(e,t){return c.apply(this,arguments)})},{key:"createTable",value:(s=b(y().m(function t(n,r,i){var o,a=arguments;return y().w(function(t){for(;;)if(0===t.n)return o=a.length>3&&void 0!==a[3]&&a[3],t.a(2,new Promise(function(t){var a,s;e.version+=1,e.lastLink&&(null===(a=(s=e.lastLink).close)||void 0===a||a.call(s));var c=indexedDB.open(n,e.version);c.onupgradeneeded=function(t){if(e.db=t.target.result,!e.db.objectStoreNames.contains(r)){var n={};i?n.keyPath=i:o&&(n.autoIncrement=!0),e.db.createObjectStore(r,n)}},c.onsuccess=function(){e.lastLink=c.result,c.result.close(),t(!0)},c.onerror=function(){t(!1)}}))},t)})),function(e,t,n){return s.apply(this,arguments)})},{key:"deleteTable",value:(a=b(y().m(function t(n,r){return y().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t){var i,o;e.version+=1,e.lastLink&&(null===(i=(o=e.lastLink).close)||void 0===i||i.call(o));var a=indexedDB.open(n,e.version);a.onupgradeneeded=function(t){e.db=t.target.result,e.lastLink=a.result,e.db.objectStoreNames.contains(r)&&e.db.deleteObjectStore(r)},a.onsuccess=function(n){e.db=n.target.result,e.lastLink=a.result,a.result.close(),t(!0)},a.onerror=function(){a.result.close(),t(!1)}}))},t)})),function(e,t){return a.apply(this,arguments)})},{key:"addData",value:(o=b(y().m(function t(n,r,i){return y().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t,o){var a=indexedDB.open(n);a.onsuccess=function(n){if(e.db=n.target.result,e.lastLink=a.result,e.db.objectStoreNames.contains(r)){var o=e.db.transaction([r],"readwrite").objectStore(r).add(i);o.onsuccess=function(e){t(i)},o.onerror=function(){t(null)}}a.result.close()},a.onerror=function(){a.result.close(),o()}}))},t)})),function(e,t,n){return o.apply(this,arguments)})},{key:"deleteData",value:(i=b(y().m(function t(n,r,i){return y().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t,o){var a=indexedDB.open(n);a.onsuccess=function(n){if(e.db=n.target.result,e.lastLink=a.result,e.db.objectStoreNames.contains(r)){var o=e.db.transaction([r],"readwrite").objectStore(r).delete(i);o.onsuccess=function(e){t(!0)},o.onerror=function(){t(!1)}}a.result.close()},a.onerror=function(){a.result.close(),o()}}))},t)})),function(e,t,n){return i.apply(this,arguments)})},{key:"updateData",value:(r=b(y().m(function t(n,r,i){return y().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t,o){var a=indexedDB.open(n);a.onsuccess=function(n){if(e.db=n.target.result,e.lastLink=a.result,e.db.objectStoreNames.contains(r)){var o=e.db.transaction([r],"readwrite").objectStore(r).put(i);o.onsuccess=function(e){t(i)},o.onerror=function(){t(i)}}a.result.close()},a.onerror=function(){a.result.close(),o()}}))},t)})),function(e,t,n){return r.apply(this,arguments)})},{key:"getData",value:(n=b(y().m(function t(n,r,i){return y().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t,o){var a=indexedDB.open(n);a.onsuccess=function(n){if(e.db=n.target.result,e.lastLink=a.result,e.db.objectStoreNames.contains(r)){var s=e.db.transaction([r],"readonly").objectStore(r).get(i);s.onsuccess=function(e){t(s.result)},s.onerror=function(){o(new Error("未找到数据".concat(i)))}}a.result.close()},a.onerror=function(){a.result.close(),o()}}))},t)})),function(e,t,r){return n.apply(this,arguments)})},{key:"getAllData",value:(t=b(y().m(function t(n,r){return y().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t,i){var o=indexedDB.open(n);o.onsuccess=function(n){if(e.db=n.target.result,e.lastLink=o.result,e.db.objectStoreNames.contains(r)){var i=e.db.transaction([r],"readonly").objectStore(r).getAll();i.onsuccess=function(e){t(i.result)},i.onerror=function(){t([])}}o.result.close()},o.onerror=function(){o.result.close(),i()}}))},t)})),function(e,n){return t.apply(this,arguments)})}]);var t,n,r,i,o,a,s,c,u,l}();_(Se,"version",1),_(Se,"db",null),_(Se,"lastLink",void 0);var _e=function(){return S(function e(t){x(this,e),_(this,"options",void 0),this.options=g({multiple:!0,accept:"*/*",maxSize:5242880},t)},[{key:"openFilePicker",value:function(){var e=this,t=document.createElement("input");t.type="file",t.multiple=this.options.multiple,t.accept=this.options.accept||"",t.onchange=function(t){var n=Array.from(t.target.files||[]);e.handleFiles(n)},t.click()}},{key:"handleFiles",value:(t=b(y().m(function e(t){var n,r,i,o=this;return y().w(function(e){for(;;)switch(e.n){case 0:if(0!==t.length){e.n=1;break}return e.a(2);case 1:return i=t.filter(function(e){var t,n;return!(o.options.maxSize&&e.size>o.options.maxSize&&(null===(t=(n=o.options).onError)||void 0===t||t.call(n,new Error("文件大小超过限制 (".concat(o.formatSize(e.size)," > ").concat(o.formatSize(o.options.maxSize),")")),e),1))}),null===(n=(r=this.options).onSelect)||void 0===n||n.call(r,i),e.n=2,Promise.all(i.map(function(e){return o.processFile(e)}));case 2:return e.a(2)}},e,this)})),function(e){return t.apply(this,arguments)})},{key:"processFile",value:(e=b(y().m(function e(t){var n,r,i,o,a,s,c,u,l,d=this;return y().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,a=function(e){var n,r;null===(n=(r=d.options).onProgress)||void 0===n||n.call(r,t,e)},e.n=1,this.options.onUpload(t,a);case 1:s=e.v,null===(n=(r=this.options).onProgress)||void 0===n||n.call(r,t,100),null===(i=(o=this.options).onSuccess)||void 0===i||i.call(o,s,t),e.n=3;break;case 2:e.p=2,l=e.v,null===(c=(u=this.options).onError)||void 0===c||c.call(u,l instanceof Error?l:new Error("上传失败"),t);case 3:return e.a(2)}},e,this,[[0,2]])})),function(t){return e.apply(this,arguments)})},{key:"formatSize",value:function(e){if(0===e)return"0 B";var t=Math.floor(Math.log(e)/Math.log(1024));return"".concat((e/Math.pow(1024,t)).toFixed(2)," ").concat(["B","KB","MB","GB"][t])}}]);var e,t}(),Me=function(){return S(function e(){x(this,e)},null,[{key:"getCdataContent",value:function(e){if(!e)return null;var t=Array.from(e.childNodes).find(function(e){return e.nodeType===e.CDATA_SECTION_NODE});return(null==t?void 0:t.nodeValue)||e.textContent}},{key:"parse",value:function(e){var t=this,n=(new DOMParser).parseFromString(e,"text/xml");return Array.from(n.querySelectorAll("resource")).map(function(e){var n=e.getAttribute("type")||"",r=e.querySelector("data"),i=e.querySelector("metadata");try{var o=t.getCdataContent(r),a=t.getCdataContent(i),s=o?JSON.parse(o):{},c=a?JSON.parse(a):{};return{id:s.id,type:n,data:s,metadata:c}}catch(pt){throw new Error("XML 解析错误: ".concat(pt.message))}})}},{key:"parseMixedContent",value:function(e){var t=/<resources\b[^>]*>[\s\S]*?<\/resources>/i.exec(e);if(!t)return{resources:[],remainingText:e,hasResources:!1};var n=d(t,1)[0],r=t.index,i=r+n.length,o=(e.slice(0,r)+e.slice(i)).replace(/\n/g,"").replace(/(!\[[^\]]*\]\([^)]+\))/g,"\n$1\n").replace(/\n+/g,"\n").replace(/^\n|\n$/g,"");try{return{resources:this.parse(n),remainingText:o,hasResources:!0}}catch(a){return{resources:[],remainingText:o,hasResources:!0,error:"资源解析失败: ".concat(a.message)}}}},{key:"stringify",value:function(e){var t=document.implementation.createDocument(null,null,null),n=t.createElement("resources");n.setAttribute("version","1.0");var r=function(e){return"\n".concat(" ".repeat(e))};return e.forEach(function(e){n.appendChild(t.createTextNode(r(1)));var i=t.createElement("resource");i.setAttribute("type",e.type),i.setAttribute("version","1.0");var o=function(e,n){var i=t.createElement(e);i.appendChild(t.createTextNode(r(2)));var o=t.createCDATASection(JSON.stringify(n));return i.appendChild(o),i.appendChild(t.createTextNode(r(1))),i};i.appendChild(t.createTextNode(r(2))),i.appendChild(o("data",e.data)),i.appendChild(t.createTextNode(r(2))),i.appendChild(o("metadata",e.metadata)),i.appendChild(t.createTextNode(r(1))),n.appendChild(i)}),n.appendChild(t.createTextNode("\n")),t.appendChild(n),(new XMLSerializer).serializeToString(t).replace(/></g,">\n<")}}])}(),Te=function(){return S(function e(){x(this,e)},null,[{key:"getCdataContent",value:function(e){if(!e)return null;var t=Array.from(e.childNodes).find(function(e){return e.nodeType===e.CDATA_SECTION_NODE});return(null==t?void 0:t.nodeValue)||e.textContent}},{key:"parse",value:function(e){var t=this,n=(new DOMParser).parseFromString(e,"text/xml");return Array.from(n.querySelectorAll("suggestion")).map(function(e){var n=e.getAttribute("type")||"",r=e.querySelector("data"),i=e.querySelector("metadata");try{var o=t.getCdataContent(r),a=t.getCdataContent(i);return{type:n,data:o?JSON.parse(o):{},metadata:a?JSON.parse(a):{}}}catch(pt){throw new Error("XML 解析错误: ".concat(pt.message))}})}},{key:"parseMixedContent",value:function(e){var t=/<suggestions\b[^>]*>[\s\S]*?<\/suggestions>/i.exec(e);if(!t)return{suggestions:[],remainingText:e,hasSuggestions:!1};var n=d(t,1)[0],r=t.index,i=r+n.length,o=(e.slice(0,r)+e.slice(i)).replace(/\n/g,"");try{return{suggestions:this.parse(n),remainingText:o,hasSuggestions:!0}}catch(a){return{suggestions:[],remainingText:o,hasSuggestions:!0,error:"资源解析失败: ".concat(a.message)}}}},{key:"stringify",value:function(e){var t=document.implementation.createDocument(null,null,null),n=t.createElement("suggestions");n.setAttribute("version","1.0");var r=function(e){return"\n".concat(" ".repeat(e))};return e.forEach(function(e){n.appendChild(t.createTextNode(r(1)));var i=t.createElement("suggestion");i.setAttribute("type",e.type),i.setAttribute("version","1.0");var o=function(e,n){var i=t.createElement(e);i.appendChild(t.createTextNode(r(2)));var o=t.createCDATASection(JSON.stringify(n));return i.appendChild(o),i.appendChild(t.createTextNode(r(1))),i};i.appendChild(t.createTextNode(r(2))),i.appendChild(o("data",e.data)),i.appendChild(t.createTextNode(r(2))),i.appendChild(o("metadata",e.metadata)),i.appendChild(t.createTextNode(r(1))),n.appendChild(i)}),n.appendChild(t.createTextNode("\n")),t.appendChild(n),(new XMLSerializer).serializeToString(t).replace(/></g,">\n<")}}])}();function Oe(e){return e.x>=0&&e.x<=1&&e.y>=0&&e.y<=1}function Ne(e,t,n,r){var i=e/window.innerWidth,o=t/window.innerHeight;return{x:Math.max(0,Math.min(i,1-n)),y:Math.max(0,Math.min(o,1-r))}}var Ee,Ae,De,Ie,ze=function(){return S(function e(){x(this,e)},null,[{key:"parse",value:function(e){var t,n=new RegExp("<tool_call>\\s*({[\\s\\S]*?})\\s*</tool_call>","g"),r=[],i=l(e.matchAll(n));try{for(i.s();!(t=i.n()).done;){var o=t.value;try{var a=JSON.parse(o[1]),s={name:a.name,parameters:a.parameters,error:a.error||!1};a.result&&Object.assign(s,{result:a.result}),r.push(s)}catch(pt){console.error("解析工具调用失败:",pt)}}}catch(c){i.e(c)}finally{i.f()}return r}}])}(),Re=0,Pe=[],Le=m,Be=Le.__b,Ve=Le.__r,Fe=Le.diffed,$e=Le.__c,je=Le.unmount,He=Le.__;function We(e,t){Le.__h&&Le.__h(Ae,e,Re||t),Re=0;var n=Ae.__H||(Ae.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function qe(e){return Re=1,function(e,t,n){var r=We(Ee++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):rt(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=Ae,!Ae.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=r.__c.__H.__.filter(function(e){return!!e.__c});if(i.every(function(e){return!e.__N}))return!o||o.call(this,e,t,n);var a=r.__c.props!==e;return i.forEach(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(a=!0)}}),o&&o.call(this,e,t,n)||a};Ae.__f=!0;var o=Ae.shouldComponentUpdate,a=Ae.componentWillUpdate;Ae.componentWillUpdate=function(e,t,n){if(this.__e){var r=o;o=void 0,i(e,t,n),o=r}a&&a.call(this,e,t,n)},Ae.shouldComponentUpdate=i}return r.__N||r.__}(rt,e)}function Ue(e,t){var n=We(Ee++,3);!Le.__s&&nt(n.__H,t)&&(n.__=e,n.u=t,Ae.__H.__h.push(n))}function Je(e){return Re=5,Ke(function(){return{current:e}},[])}function Ke(e,t){var n=We(Ee++,7);return nt(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Ye(e,t){return Re=8,Ke(function(){return e},t)}function Ge(e){var t=Ae.context[e.__c],n=We(Ee++,9);return n.c=e,t?(null==n.__&&(n.__=!0,t.sub(Ae)),t.props.value):e.__}function Xe(){for(var e;e=Pe.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(et),e.__H.__h.forEach(tt),e.__H.__h=[]}catch(ot){e.__H.__h=[],Le.__e(ot,e.__v)}}Le.__b=function(e){Ae=null,Be&&Be(e)},Le.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),He&&He(e,t)},Le.__r=function(e){Ve&&Ve(e),Ee=0;var t=(Ae=e.__c).__H;t&&(De===Ae?(t.__h=[],Ae.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.forEach(et),t.__h.forEach(tt),t.__h=[],Ee=0)),De=Ae},Le.diffed=function(e){Fe&&Fe(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(1!==Pe.push(t)&&Ie===Le.requestAnimationFrame||((Ie=Le.requestAnimationFrame)||Qe)(Xe)),t.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),De=Ae=null},Le.__c=function(e,t){t.some(function(e){try{e.__h.forEach(et),e.__h=e.__h.filter(function(e){return!e.__||tt(e)})}catch(Ae){t.some(function(e){e.__h&&(e.__h=[])}),t=[],Le.__e(Ae,e.__v)}}),$e&&$e(e,t)},Le.unmount=function(e){je&&je(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(e){try{et(e)}catch(e){t=e}}),n.__H=void 0,t&&Le.__e(t,n.__v))};var Ze="function"==typeof requestAnimationFrame;function Qe(e){var t,n=function(){clearTimeout(r),Ze&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Ze&&(t=requestAnimationFrame(n))}function et(e){var t=Ae,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),Ae=t}function tt(e){var t=Ae;e.__c=e.__(),Ae=t}function nt(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function rt(e,t){return"function"==typeof t?t(e):t}var it=Symbol.for("preact-signals");function ot(){if(dt>1)dt--;else{for(var e,t=!1;void 0!==lt;){var n=lt;for(lt=void 0,ht++;void 0!==n;){var r=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&gt(n))try{n.c()}catch(n){t||(e=n,t=!0)}n=r}}if(ht=0,dt--,t)throw e}}var at=void 0;function st(e){var t=at;at=void 0;try{return e()}finally{at=t}}var ct,ut,lt=void 0,dt=0,ht=0,ft=0;function pt(e){if(void 0!==at){var t=e.n;if(void 0===t||t.t!==at)return t={i:0,S:e,p:at.s,n:void 0,t:at,e:void 0,x:void 0,r:t},void 0!==at.s&&(at.s.n=t),at.s=t,e.n=t,32&at.f&&e.S(t),t;if(-1===t.i)return t.i=0,void 0!==t.n&&(t.n.p=t.p,void 0!==t.p&&(t.p.n=t.n),t.p=at.s,t.n=void 0,at.s.n=t,at.s=t),t}}function vt(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.W=null==t?void 0:t.watched,this.Z=null==t?void 0:t.unwatched,this.name=null==t?void 0:t.name}function mt(e,t){return new vt(e,t)}function gt(e){for(var t=e.s;void 0!==t;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function yt(e){for(var t=e.s;void 0!==t;t=t.n){var n=t.S.n;if(void 0!==n&&(t.r=n),t.S.n=t,t.i=-1,void 0===t.n){e.s=t;break}}}function kt(e){for(var t=e.s,n=void 0;void 0!==t;){var r=t.p;-1===t.i?(t.S.U(t),void 0!==r&&(r.n=t.n),void 0!==t.n&&(t.n.p=r)):n=t,t.S.n=t.r,void 0!==t.r&&(t.r=void 0),t=r}e.s=n}function wt(e,t){vt.call(this,void 0),this.x=e,this.s=void 0,this.g=ft-1,this.f=4,this.W=null==t?void 0:t.watched,this.Z=null==t?void 0:t.unwatched,this.name=null==t?void 0:t.name}function bt(e,t){return new wt(e,t)}function xt(e){var t=e.u;if(e.u=void 0,"function"==typeof t){dt++;var n=at;at=void 0;try{t()}catch(ot){throw e.f&=-2,e.f|=8,Ct(e),ot}finally{at=n,ot()}}}function Ct(e){for(var t=e.s;void 0!==t;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,xt(e)}function St(e){if(at!==this)throw new Error("Out-of-order effect");kt(this),at=e,this.f&=-2,8&this.f&&Ct(this),ot()}function _t(e,t){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==t?void 0:t.name}function Mt(e,t){var n=new _t(e,t);try{n.c()}catch(e){throw n.d(),e}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}function Tt(e,t){m[e]=t.bind(null,m[e]||function(){})}function Ot(e){ut&&ut(),ut=e&&e.S()}function Nt(e){var t=this,n=e.data,r=At(n);r.value=n;var i=Ke(function(){for(var e=t.__v;e=e.__;)if(e.__c){e.__c.__$f|=4;break}return t.__$u.c=function(){var e,n=t.__$u.S(),r=i.value;n(),w(r)||3!==(null==(e=t.base)?void 0:e.nodeType)?(t.__$f|=1,t.setState({})):t.base.data=r},bt(function(){var e=r.value.value;return 0===e?0:!0===e?"":e||""})},[]);return i.value}function Et(e,t,n,r){var i=t in e&&void 0===e.ownerSVGElement,o=mt(n);return{o:function(e,t){o.value=e,r=t},d:Mt(function(){var n=o.value.value;r[t]!==n&&(r[t]=n,i?e[t]=n:n?e.setAttribute(t,n):e.removeAttribute(t))})}}function At(e){return Ke(function(){return mt(e)},[])}function Dt(e){var t=Je(e);return t.current=e,ct.__$f|=4,Ke(function(){return bt(function(){return t.current()})},[])}vt.prototype.brand=it,vt.prototype.h=function(){return!0},vt.prototype.S=function(e){var t=this,n=this.t;n!==e&&void 0===e.e&&(e.x=n,this.t=e,void 0!==n?n.e=e:st(function(){var e;null==(e=t.W)||e.call(t)}))},vt.prototype.U=function(e){var t=this;if(void 0!==this.t){var n=e.e,r=e.x;void 0!==n&&(n.x=r,e.e=void 0),void 0!==r&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,void 0===r&&st(function(){var e;null==(e=t.Z)||e.call(t)}))}},vt.prototype.subscribe=function(e){var t=this;return Mt(function(){var n=t.value,r=at;at=void 0;try{e(n)}finally{at=r}},{name:"sub"})},vt.prototype.valueOf=function(){return this.value},vt.prototype.toString=function(){return this.value+""},vt.prototype.toJSON=function(){return this.value},vt.prototype.peek=function(){var e=at;at=void 0;try{return this.value}finally{at=e}},Object.defineProperty(vt.prototype,"value",{get:function(){var e=pt(this);return void 0!==e&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(ht>100)throw new Error("Cycle detected");this.v=e,this.i++,ft++,dt++;try{for(var t=this.t;void 0!==t;t=t.x)t.t.N()}finally{ot()}}}}),wt.prototype=new vt,wt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===ft)return!0;if(this.g=ft,this.f|=1,this.i>0&&!gt(this))return this.f&=-2,!0;var e=at;try{yt(this),at=this;var t=this.x();(16&this.f||this.v!==t||0===this.i)&&(this.v=t,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return at=e,kt(this),this.f&=-2,!0},wt.prototype.S=function(e){if(void 0===this.t){this.f|=36;for(var t=this.s;void 0!==t;t=t.n)t.S.S(t)}vt.prototype.S.call(this,e)},wt.prototype.U=function(e){if(void 0!==this.t&&(vt.prototype.U.call(this,e),void 0===this.t)){this.f&=-33;for(var t=this.s;void 0!==t;t=t.n)t.S.U(t)}},wt.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;void 0!==e;e=e.x)e.t.N()}},Object.defineProperty(wt.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=pt(this);if(this.h(),void 0!==e&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),_t.prototype.c=function(){var e=this.S();try{if(8&this.f)return;if(void 0===this.x)return;var t=this.x();"function"==typeof t&&(this.u=t)}finally{e()}},_t.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,xt(this),yt(this),dt++;var e=at;return at=this,St.bind(this,e)},_t.prototype.N=function(){2&this.f||(this.f|=2,this.o=lt,lt=this)},_t.prototype.d=function(){this.f|=8,1&this.f||Ct(this)},_t.prototype.dispose=function(){this.d()},Nt.displayName="_st",Object.defineProperties(vt.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:Nt},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}}),Tt("__b",function(e,t){if("string"==typeof t.type){var n,r=t.props;for(var i in r)if("children"!==i){var o=r[i];o instanceof vt&&(n||(t.__np=n={}),n[i]=o,r[i]=o.peek())}}e(t)}),Tt("__r",function(e,t){Ot();var n,r=t.__c;r&&(r.__$f&=-2,void 0===(n=r.__$u)&&(r.__$u=n=function(){var e;return Mt(function(){e=this}),e.c=function(){r.__$f|=1,r.setState({})},e}())),ct=r,Ot(n),e(t)}),Tt("__e",function(e,t,n,r){Ot(),ct=void 0,e(t,n,r)}),Tt("diffed",function(e,t){var n;if(Ot(),ct=void 0,"string"==typeof t.type&&(n=t.__e)){var r=t.__np,i=t.props;if(r){var o=n.U;if(o)for(var a in o){var s=o[a];void 0===s||a in r||(s.d(),o[a]=void 0)}else n.U=o={};for(var c in r){var u=o[c],l=r[c];void 0===u?(u=Et(n,c,l,i),o[c]=u):u.o(l,i)}}}e(t)}),Tt("unmount",function(e,t){if("string"==typeof t.type){var n=t.__e;if(n){var r=n.U;if(r)for(var i in n.U=void 0,r){var o=r[i];o&&o.d()}}}else{var a=t.__c;if(a){var s=a.__$u;s&&(a.__$u=void 0,s.d())}}e(t)}),Tt("__h",function(e,t,n,r){(r<3||9===r)&&(t.__$f|=2),e(t,n,r)}),W.prototype.shouldComponentUpdate=function(e,t){var n=this.__$u,r=n&&void 0!==n.s;for(var i in t)return!0;if(this.__f||"boolean"==typeof this.u&&!0===this.u){if(!(r||2&this.__$f||4&this.__$f))return!0;if(1&this.__$f)return!0}else{if(!(r||4&this.__$f))return!0;if(3&this.__$f)return!0}for(var o in e)if("__source"!==o&&e[o]!==this.props[o])return!0;for(var a in this.props)if(!(a in e))return!0;return!1};var It=function(){return he("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M843.904 783.573333 783.573333 843.904 512.042667 572.373333 240.512 843.904 180.181333 783.573333 451.712 512.042667 180.181333 240.512 240.512 180.181333 512.042667 451.712 783.573333 180.181333 843.904 240.512 572.373333 512.042667 843.904 783.573333Z"})})},zt=function(){return he("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M900.64 379.808l-263.072-256.032c-36.448-35.328-105.76-35.392-142.304 0.096l-327.04 319.904c-56.416 54.72-70.72 76.704-70.72 150.976l0 143.936c0 132.768 26.976 192 186.912 192l131.872 0c81.12 0 128.448-46.656 193.952-111.264l290.016-297.696c18.592-17.984 29.248-43.968 29.248-71.264C929.504 423.36 918.976 397.6 900.64 379.808zM323.008 786.752c-52.928 0-96-43.072-96-96s43.072-96 96-96 96 43.072 96 96S375.936 786.752 323.008 786.752z"})})},Rt=function(e){return he("svg",{viewBox:"0 0 1024 1024",id:"send",className:e.className,version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M931.4 498.9L94.9 79.5c-3.4-1.7-7.3-2.1-11-1.2-8.5 2.1-13.8 10.7-11.7 19.3l86.2 352.2c1.3 5.3 5.2 9.6 10.4 11.3l147.7 50.7-147.6 50.7c-5.2 1.8-9.1 6-10.3 11.3L72.2 926.5c-0.9 3.7-0.5 7.6 1.2 10.9 3.9 7.9 13.5 11.1 21.5 7.2l836.5-417c3.1-1.5 5.6-4.1 7.2-7.1 3.9-8 0.7-17.6-7.2-21.6zM170.8 826.3l50.3-205.6 295.2-101.3c2.3-0.8 4.2-2.6 5-5 1.4-4.2-0.8-8.7-5-10.2L221.1 403 171 198.2l628 314.9-628.2 313.2z"})})},Pt=function(){return he("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M962 197.61H747v-60c0-55.14-44.86-100-100-100H377c-55.14 0-100 44.86-100 100v60H62c-11.05 0-20 8.95-20 20s8.95 20 20 20h60v630.57c0 66.17 53.83 120 120 120h540c66.17 0 120-53.83 120-120V237.61h60c11.05 0 20-8.95 20-20s-8.95-20-20-20zM637.34 457.66v260c0 12.01-10.72 21.63-23.06 19.77-9.84-1.48-16.94-10.25-16.94-20.2V458.09c0-9.95 7.1-18.72 16.94-20.2 12.34-1.86 23.06 7.76 23.06 19.77z m-210.68 0v260c0 11-9 20-20 20s-20-9-20-20v-260c0-11 9-20 20-20s20 9 20 20zM317 137.61c0-33.08 26.92-60 60-60h270c33.08 0 60 26.92 60 60v60H317v-60z"})})},Lt=function(){return he("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M511.582491 63.413262C265.134543 63.413262 64.62588 263.921925 64.62588 510.369873s200.508663 446.957635 446.957635 446.957635 446.957635-200.508663 446.957635-446.957635S758.031463 63.413262 511.582491 63.413262zM509.001713 751.859903c-98.517781 0-182.467775-62.623269-214.771505-150.056598l0.327458-0.134053c-2.007727-4.036943-3.38305-8.422833-3.38305-13.237489 0-16.647145 13.494339-30.142507 30.142507-30.142507 13.389962 0 24.358781 8.877181 28.2893 20.955264l0.422625-0.172939c23.269983 65.442478 85.645612 112.503307 158.972665 112.503307 93.106538 0 168.845523-75.738985 168.845523-168.845523s-75.738985-168.845523-168.845523-168.845523c-20.432355 0-39.874149 3.980661-58.013275 10.66899l21.248953 40.742936c2.486634 2.677992 4.0175 6.2831 4.0175 10.243295 0 8.417717-8.404414 14.921851-15.365966 15.07023-0.102331 0-0.206708 0-0.309038 0-0.220011 0-0.427742 0-0.647753-0.013303l-150.579507-6.463202c-5.372358-0.234337-10.229992-3.310396-12.716626-8.093329-2.486634-4.76963-2.236947-10.509355 0.647753-15.055904l80.890308-127.179564c2.8847-4.533246 8.006348-7.151887 13.365402-6.960529 5.372358 0.234337 10.227945 3.312442 12.71458 8.095375l18.580171 35.625382c26.629497-10.855232 55.683207-16.963347 86.168522-16.963347 126.338407 0 229.130537 102.791108 229.130537 229.130537S635.340119 751.859903 509.001713 751.859903z"})})},Bt=function(){return he("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M891.072 822.144V167.36a34.432 34.432 0 0 0-34.432-34.432H201.856C201.856 94.848 232.704 64 270.784 64h620.288C929.152 64 960 94.848 960 132.928v620.288c0 38.08-30.848 68.928-68.928 68.928z m-68.928-551.36v620.288c0 38.08-30.848 68.928-68.928 68.928H132.928A68.928 68.928 0 0 1 64 891.072V270.784c0-38.08 30.848-68.928 68.928-68.928h620.288c38.08 0 68.928 30.848 68.928 68.928z m-137.856 137.856H201.856a34.432 34.432 0 0 0 0 68.864h482.432a34.432 34.432 0 0 0 0-68.864z m0 206.72H201.856a34.432 34.432 0 0 0 0 68.864h482.432a34.432 34.432 0 0 0 0-68.864z"})})},Vt=function(){return he("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M547.4 197.4v46l200.3 0.1L546.1 444l32.4 32.6 201.9-200.7v200.9h46V197.5zM471.4 584.4l-32.6-32.6L243.6 747V547.9h-46v278.7h279v-46H275z"})})},Ft=function(){return he("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M544 480V282.944h52.224l0.064 107.968L763.072 224l36.928 36.928-166.976 166.976 108.032-0.128V480H544zM260.928 800l-36.928-36.928 166.912-166.784-107.968-0.064V544H480v197.056h-52.224l0.064-107.968L260.928 800z"})})},$t=function(){return he("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M960 544H64a32 32 0 1 1 0-64h896a32 32 0 1 1 0 64"})})},jt=function(){return he("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:[he("path",{d:"M481.0752 263.3728l50.9952 1.024 1.8432-105.8816-50.9952-0.8192z"}),he("path",{d:"M486.441426 180.895362a66.56 66.56 0 1 0 42.091944-126.290153 66.56 66.56 0 1 0-42.091944 126.290153Z"}),he("path",{d:"M138.8544 664.3712c-52.8384 0-95.8464-43.008-95.8464-95.8464s43.008-95.8464 95.8464-95.8464M880.0256 472.6784c52.8384 0 95.8464 43.008 95.8464 95.8464s-43.008 95.8464-95.8464 95.8464"}),he("path",{d:"M507.4944 220.5696c-220.16 0-398.7456 162.816-398.7456 363.7248s178.5856 363.7248 398.7456 363.7248 398.7456-162.816 398.7456-363.7248-178.5856-363.7248-398.7456-363.7248z m0 559.9232c-166.2976 0-301.2608-100.5568-301.2608-224.4608s134.9632-224.4608 301.2608-224.4608S808.7552 432.128 808.7552 556.032 673.792 780.4928 507.4944 780.4928z"}),he("path",{d:"M319.6928 556.032a47.9232 38.912 90 1 0 77.824 0 47.9232 38.912 90 1 0-77.824 0Z"}),he("path",{d:"M617.472 556.032a47.9232 38.912 90 1 0 77.824 0 47.9232 38.912 90 1 0-77.824 0Z"})]})},Ht=function(){return he("svg",{viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[he("path",{d:"M5.856 17.121a.979.979 0 0 1-.327-.06.839.839 0 0 1-.283-.177.739.739 0 0 1-.187-.255.724.724 0 0 1-.07-.303l-.02-1.609a4.663 4.663 0 0 1-1.446-.455 4.252 4.252 0 0 1-.637-.401c-.199-.146-.385-.31-.553-.492a4.442 4.442 0 0 1-.45-.577 4.303 4.303 0 0 1-.327-.637 3.823 3.823 0 0 1-.206-.686 3.729 3.729 0 0 1-.064-.704V6.478c0-.261.025-.516.077-.771a4.43 4.43 0 0 1 .244-.747 4.062 4.062 0 0 1 .932-1.28c.2-.183.418-.347.65-.493.23-.145.482-.267.739-.364a4.21 4.21 0 0 1 .81-.225c.27-.054.553-.078.835-.078H8.55c.103 0 .2.018.29.054a.7.7 0 0 1 .411.376.667.667 0 0 1-.161.766.736.736 0 0 1-.25.151.764.764 0 0 1-.29.055H5.573c-.186 0-.366.012-.54.049-.18.03-.353.079-.52.145-.167.061-.328.14-.482.237-.148.091-.29.2-.418.316a2.897 2.897 0 0 0-.347.388c-.097.14-.187.286-.257.444a2.473 2.473 0 0 0-.206.977v4.287c0 .17.013.333.051.503a2.549 2.549 0 0 0 .772 1.33 2.721 2.721 0 0 0 .913.559c.167.066.347.115.527.152.18.03.36.048.546.048a.904.904 0 0 1 .61.23.848.848 0 0 1 .194.262.84.84 0 0 1 .07.303l.007.99 1.915-1.293a2.877 2.877 0 0 1 1.64-.492h2.372c.186 0 .366-.018.54-.048.18-.03.353-.08.52-.146.168-.067.329-.146.483-.237.148-.091.29-.2.418-.316.128-.121.244-.249.347-.388a2.8 2.8 0 0 0 .257-.444 2.47 2.47 0 0 0 .206-.977V8.585a.646.646 0 0 1 .225-.492.679.679 0 0 1 .244-.152.814.814 0 0 1 .585 0c.09.03.174.085.244.152a.657.657 0 0 1 .225.492V10.8c0 .261-.032.516-.083.771a4.192 4.192 0 0 1-.245.74c-.109.244-.244.468-.398.687a3.735 3.735 0 0 1-.534.6c-.2.183-.418.347-.65.493a4.134 4.134 0 0 1-.738.364 4.7 4.7 0 0 1-.81.225c-.27.054-.553.079-.836.079h-1.877c-.604 0-1.144.164-1.633.491l-2.54 1.713a.913.913 0 0 1-.514.157z",fill:"currentColor"}),he("path",{d:"M15.866 4.125h-4.174c-.41 0-.741.313-.741.7 0 .387.332.7.741.7h4.174c.41 0 .742-.313.742-.7 0-.387-.332-.7-.742-.7z",fill:"currentColor"}),he("path",{d:"M14.537 2.932c0-.396-.34-.717-.759-.717s-.758.32-.758.717v3.786c0 .396.34.717.758.717.42 0 .76-.321.76-.717V2.932z",fill:"currentColor"})]})},Wt=function(){return he("svg",{viewBox:"64 64 896 896",focusable:"false",width:"1em",height:"1em",fill:"currentColor","aria-hidden":"true",children:he("path",{d:"M842 454c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8 0 140.3-113.7 254-254 254S258 594.3 258 454c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8 0 168.7 126.6 307.9 290 327.6V884H326.7c-13.7 0-24.7 14.3-24.7 32v36c0 4.4 2.8 8 6.2 8h407.6c3.4 0 6.2-3.6 6.2-8v-36c0-17.7-11-32-24.7-32H548V782.1c165.3-18 294-158 294-328.1zM512 624c93.9 0 170-75.2 170-168V232c0-92.8-76.1-168-170-168s-170 75.2-170 168v224c0 92.8 76.1 168 170 168zm-94-392c0-50.6 41.9-92 94-92s94 41.4 94 92v224c0 50.6-41.9 92-94 92s-94-41.4-94-92V232z"})})},qt=function(){var e=1e3,t=140,n=250,r=.8;return he("svg",{fill:"currentColor",viewBox:"0 0 ".concat(e," ").concat(e),xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",children:Array.from({length:4}).map(function(e,i){return he("rect",{fill:"currentColor",rx:70,ry:70,height:n,width:t,x:i*(440/3+t),y:375,children:[he("animate",{attributeName:"height",values:"".concat(n,"; ").concat(500,"; ").concat(n),keyTimes:"0; 0.5; 1",dur:"".concat(r,"s"),begin:"".concat(.2*i,"s"),repeatCount:"indefinite"}),he("animate",{attributeName:"y",values:"".concat(375,"; ").concat(250,"; ").concat(375),keyTimes:"0; 0.5; 1",dur:"".concat(r,"s"),begin:"".concat(.2*i,"s"),repeatCount:"indefinite"})]},i)})})},Ut=function(e){return he("svg",{className:e.className,onClick:e.onClick,viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M128 384a128 128 0 1 1 0 256 128 128 0 0 1 0-256z m768 0a128 128 0 1 1 0 256 128 128 0 0 1 0-256z m-372.4288 0a128 128 0 1 1 0 256 128 128 0 0 1 0-256z"})})},Jt=function(e){return he("svg",{className:e.className,viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M498.33984 607.8464c-10.99776-32.9728-50.09408-73.5232-82.6368-85.74976L150.9376 422.8096c-38.54336-14.4384-36.98688-69.46816 2.27328-81.73568L844.92288 124.90752c33.30048-10.40384 64.57344 20.8896 54.1696 54.1696L682.92608 870.78912a43.2128 43.2128 0 0 1-81.36704 3.25632 121682.5344 121682.5344 0 0 1-103.2192-266.19904z"})})},Kt=function(){return he("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M972.657609 209.348408C987.158609 209.36839 998.930114 197.571202 998.949999 182.99865 998.969882 168.426097 987.230618 156.59651 972.729617 156.576528L32.457975 155.280806C17.956974 155.260823 6.18547 167.058012 6.165585 181.630564 6.1457 196.203116 17.884965 208.032703 32.385966 208.052686L972.657609 209.348408ZM180.466902 992.356169 180.466902 1019.014859 206.993296 1018.74074 833.361858 1012.267947 859.348284 1011.999407 859.348284 985.883377 859.348284 289.397297C859.348284 274.824732 847.59289 263.011332 833.091874 263.011332 818.590859 263.011332 806.835465 274.824732 806.835465 289.397297L806.835465 985.883377 832.82189 959.498805 206.453329 965.971599 232.979723 992.356169 232.979723 282.67005C232.979723 268.097483 221.224329 256.284085 206.723313 256.284085 192.222298 256.284085 180.466902 268.097483 180.466902 282.67005L180.466902 992.356169ZM656.410257 847.079027C656.410257 861.651593 668.165651 873.464992 682.666667 873.464992 697.167682 873.464992 708.923076 861.651593 708.923076 847.079027L708.923076 372.131659C708.923076 357.559091 697.167682 345.745694 682.666667 345.745694 668.165651 345.745694 656.410257 357.559091 656.410257 372.131659L656.410257 847.079027ZM341.333333 847.079027C341.333333 861.651593 353.08873 873.464992 367.589743 873.464992 382.090758 873.464992 393.846155 861.651593 393.846155 847.079027L393.846155 372.131659C393.846155 357.559091 382.090758 345.745694 367.589743 345.745694 353.08873 345.745694 341.333333 357.559091 341.333333 372.131659L341.333333 847.079027ZM498.871795 847.079027C498.871795 861.651593 510.627189 873.464992 525.128205 873.464992 539.62922 873.464992 551.384614 861.651593 551.384614 847.079027L551.384614 372.131659C551.384614 357.559091 539.62922 345.745694 525.128205 345.745694 510.627189 345.745694 498.871795 357.559091 498.871795 372.131659L498.871795 847.079027ZM392.147755 116.721777C392.147755 102.063669 403.758665 90.363507 418.40134 90.363507L622.925796 90.363507C637.408947 90.363507 649.179381 102.1619 649.179381 116.549585L649.179381 171.644875 701.692203 171.644875 701.692203 116.549585C701.692203 72.986607 666.38105 37.591577 622.925796 37.591577L418.40134 37.591577C374.724427 37.591577 339.634933 72.950804 339.634933 116.721777L339.634933 165.310801 392.147755 165.310801 392.147755 116.721777Z"})})},Yt=function(e){return he("svg",{xmlns:"http://www.w3.org/2000/svg",className:e.className,viewBox:"0 0 512 512",children:he("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"48",d:"M112 184l144 144 144-144"})})},Gt=function(e){return he("svg",{xmlns:"http://www.w3.org/2000/svg",className:"".concat(e.className," icon"),viewBox:"0 0 512 512",children:he("path",{d:"M256 48C141.31 48 48 141.31 48 256s93.31 208 208 208 208-93.31 208-208S370.69 48 256 48zm108.25 138.29l-134.4 160a16 16 0 01-12 5.71h-.27a16 16 0 01-11.89-5.3l-57.6-64a16 16 0 1123.78-21.4l45.29 50.32 122.59-145.91a16 16 0 0124.5 20.58z"})})},Xt=function(e){return he("svg",{className:e.className,width:"16",height:"16",viewBox:"0 0 50 50",xmlns:"http://www.w3.org/2000/svg",children:he("circle",{cx:"25",cy:"25",r:"20",stroke:"currentColor",strokeWidth:"5",fill:"none",strokeDasharray:"31.415, 31.415",strokeLinecap:"round",children:he("animateTransform",{attributeName:"transform",type:"rotate",from:"0 25 25",to:"360 25 25",dur:"1s",repeatCount:"indefinite"})})})},Zt=function(){return he("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:he("path",{d:"M704 256v490.666667a170.666667 170.666667 0 0 1-170.666667 170.666666 170.666667 170.666667 0 0 1-170.666666-170.666666V213.333333A106.666667 106.666667 0 0 1 469.333333 106.666667 106.666667 106.666667 0 0 1 576 213.333333v448a42.666667 42.666667 0 0 1-42.666667 42.666667 42.666667 42.666667 0 0 1-42.666666-42.666667V256H426.666667v405.333333a106.666667 106.666667 0 0 0 106.666666 106.666667 106.666667 106.666667 0 0 0 106.666667-106.666667V213.333333a170.666667 170.666667 0 0 0-170.666667-170.666666 170.666667 170.666667 0 0 0-170.666666 170.666666v533.333334a234.666667 234.666667 0 0 0 234.666666 234.666666 234.666667 234.666667 0 0 0 234.666667-234.666666V256h-64z"})})},Qt=function(){return he("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:[he("path",{d:"M842.666667 285.866667l-187.733334-187.733334c-14.933333-14.933333-32-21.333333-53.333333-21.333333H234.666667C194.133333 74.666667 160 108.8 160 149.333333v725.333334c0 40.533333 34.133333 74.666667 74.666667 74.666666h554.666666c40.533333 0 74.666667-34.133333 74.666667-74.666666V337.066667c0-19.2-8.533333-38.4-21.333333-51.2z m-44.8 44.8c-2.133333 2.133333-4.266667 0-8.533334 0h-170.666666c-6.4 0-10.666667-4.266667-10.666667-10.666667V149.333333c0-2.133333 0-6.4-2.133333-8.533333 0 0 2.133333 0 2.133333 2.133333l189.866667 187.733334z m-8.533334 554.666666H234.666667c-6.4 0-10.666667-4.266667-10.666667-10.666666V149.333333c0-6.4 4.266667-10.666667 10.666667-10.666666h311.466666c-2.133333 4.266667-2.133333 6.4-2.133333 10.666666v170.666667c0 40.533333 34.133333 74.666667 74.666667 74.666667h170.666666c4.266667 0 6.4 0 10.666667-2.133334V874.666667c0 6.4-4.266667 10.666667-10.666667 10.666666z",fill:"currentColor"}),he("path",{d:"M640 693.333333H341.333333c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h298.666667c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM640 522.666667H341.333333c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h298.666667c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM341.333333 416h85.333334c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32h-85.333334c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32z",fill:"currentColor"})]})},en=function(){return he("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:he("path",{d:"M557.248 511.68l135.776-135.744-45.248-45.28L512 466.432l-135.776-135.776-45.248 45.28 135.776 135.744-135.776 135.776 45.248 45.248L512 556.928l135.776 135.776 45.248-45.248-135.776-135.776zM512 64c247.136 0 448 200.864 448 448s-200.864 448-448 448S64 759.136 64 512 264.864 64 512 64z",fill:"currentColor"})})},tn=function(){return he("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:he("path",{d:"M512.43945313 904.51953125c-6.06445313 0-12.12890625-1.58203125-17.57812501-4.74609375L136.70703125 689.71484375c-10.63476563-6.24023438-17.13867188-17.66601563-17.13867188-29.97070313s6.50390625-23.73046875 17.13867188-29.97070312l76.37695313-44.91210938L136.97070312 540.125c-10.63476563-6.24023438-17.13867188-17.66601563-17.13867187-29.97070313s6.50390625-23.73046875 17.13867188-29.97070312l73.38867187-43.15429688-73.125-42.890625C126.51171875 387.81054687 120.0078125 376.38476562 120.0078125 364.08007812c0-12.3046875 6.50390625-23.73046875 17.13867188-29.97070312L495.828125 122.99609375c10.8984375-6.41601563 24.34570313-6.41601563 35.24414063 0l358.15429687 210.05859375c10.63476563 6.24023438 17.13867188 17.66601563 17.13867188 29.97070313s-6.50390625 23.73046875-17.13867188 29.97070312l-73.38867188 43.15429688 73.12500001 42.890625c10.63476563 6.24023438 17.13867188 17.66601563 17.13867187 29.97070312s-6.50390625 23.73046875-17.13867187 29.97070313L812.5859375 583.89453125l76.11328125 44.6484375c10.63476563 6.24023438 17.13867188 17.66601563 17.13867188 29.97070313s-6.50390625 23.73046875-17.13867188 29.97070312l-358.59375 211.2890625c-5.44921875 3.1640625-11.6015625 4.74609375-17.66601563 4.74609375zM223.015625 659.65625l289.42382813 169.8046875 290.12695312-170.77148438-58.44726563-34.27734374L530.28125 750.18359375a34.67285156 34.67285156 0 0 1-35.24414063 0L281.7265625 625.02734375 223.015625 659.65625z m76.90429688-104.58984375l212.69531249 124.8046875 290.12695313-170.77148438-55.546875-32.60742187-216.65039063 127.6171875a34.67285156 34.67285156 0 0 1-35.24414062 0L279.00195312 477.28320312l-55.81054687 32.78320313 75.49804688 44.296875c0.43945313 0.26367188 0.79101563 0.52734375 1.23046874 0.703125z m-2.81250001-147.83203125l215.68359376 126.5625 216.12304687-127.17773438c0.3515625-0.26367188 0.703125-0.43945313 1.0546875-0.61523437l72.86132813-42.890625-289.33593751-169.8046875-290.12695312 170.68359375 72.59765625 42.62695313c0.43945313 0.17578125 0.79101563 0.43945313 1.14257813 0.61523437z"})})},nn=function(e){return he("svg",{className:e.className,id:"stop",viewBox:"0 0 1025 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:[he("path",{d:"M512.268258 1022.835842c-68.658678 0-135.399619-13.564433-198.369591-40.316509-60.752236-25.809077-115.373446-62.712976-162.346233-109.685763-46.971763-46.971763-83.875662-101.592974-109.685763-162.346233C15.115619 647.517366 1.551186 580.777449 1.551186 512.118771S15.115619 376.719151 41.866671 313.74918c25.810101-60.752236 62.714-115.373446 109.685763-162.346233 46.972787-46.971763 101.593997-83.875662 162.346233-109.685763 62.969971-26.751052 129.710912-40.315485 198.369591-40.315485s135.398595 13.564433 198.368567 40.315485c60.752236 25.810101 115.373446 62.714 162.346233 109.685763 46.971763 46.972787 83.875662 101.593997 109.685763 162.346233 26.752076 62.969971 40.316509 129.710912 40.316509 198.369591s-13.564433 135.398595-40.316509 198.368567c-25.809077 60.75326-62.712976 115.37447-109.685763 162.346233-46.971763 46.972787-101.592974 83.876686-162.346233 109.685763C647.666853 1009.27141 580.925912 1022.835842 512.268258 1022.835842zM512.268258 50.548195c-62.018782 0-122.293887 12.247716-179.152287 36.403219-54.923257 23.333323-104.317532 56.709936-146.810821 99.204249s-75.870926 91.888588-99.204249 146.810821c-24.155503 56.8584-36.403219 117.133505-36.403219 179.152287 0 62.017758 12.247716 122.292863 36.403219 179.152287 23.333323 54.923257 56.709936 104.317532 99.204249 146.811845 42.493289 42.493289 91.888588 75.870926 146.810821 99.204249 56.8584 24.155503 117.133505 36.403219 179.152287 36.403219 62.017758 0 122.292863-12.247716 179.152287-36.403219 54.923257-23.333323 104.317532-56.71096 146.811845-99.204249 42.493289-42.494313 75.870926-91.888588 99.204249-146.811845 24.155503-56.8584 36.403219-117.133505 36.403219-179.152287s-12.247716-122.293887-36.403219-179.152287c-23.334347-54.923257-56.71096-104.317532-99.205273-146.810821-42.493289-42.493289-91.887565-75.870926-146.810821-99.204249C634.561121 62.795911 574.286016 50.548195 512.268258 50.548195z",fill:"currentColor"}),he("path",{d:"M655.434047 694.244421 367.12637 694.244421c-21.046987 0-38.170445-17.123458-38.170445-38.170445L328.955925 367.766298c0-21.046987 17.123458-38.170445 38.170445-38.170445l288.307678 0c21.048011 0 38.170445 17.123458 38.170445 38.170445l0 288.307678C693.604492 677.120962 676.482058 694.244421 655.434047 694.244421zM380.150191 643.050154l262.260035 0L642.410226 380.79012 380.150191 380.79012 380.150191 643.050154z",fill:"currentColor"})]})},rn=function(e){return he("svg",{xmlns:"http://www.w3.org/2000/svg",className:e.className,viewBox:"0 0 512 512",children:he("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"48",d:"M112 268l144 144 144-144M256 392V100"})})},on=function(){return he("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:[he("path",{d:"M394.688 126.208a32 32 0 0 1 32-32h170.688a32 32 0 0 1 32 32v138.624h288a32 32 0 0 1 32 32v170.688a32 32 0 0 1-32 32H106.688a32 32 0 0 1-32-32V296.832a32 32 0 0 1 32-32h288V126.208z m64 32v138.624a32 32 0 0 1-32 32h-288v106.688h746.688V328.832h-288a32 32 0 0 1-32-32V158.208H458.688z"}),he("path",{d:"M138.688 469.376a32 32 0 0 1 32-32h682.688a32 32 0 0 1 32 32v384a32 32 0 0 1-32 32H170.688a32 32 0 0 1-32-32v-384z m64 32v320h618.688v-320H202.688z"}),he("path",{d:"M341.376 691.52a32 32 0 0 1 32 32V851.2a32 32 0 1 1-64 0v-127.68a32 32 0 0 1 32-32zM512 691.2a32 32 0 0 1 32 32v128a32 32 0 0 1-64 0v-128a32 32 0 0 1 32-32zM682.688 691.52a32 32 0 0 1 32 32V851.2a32 32 0 1 1-64 0v-127.68a32 32 0 0 1 32-32z"})]})},an=function(){return he("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:he("path",{d:"M843.251 424.407l43.828-74.898c10.194-17.946 32.596-22.158 48.956-11.598 16.298 10.499 23.44 32.658 14.223 49.566l-113.11 195.212-61.164-40.044-126.418-82.285c-16.115-11.598-20.632-34.428-10.194-51.702 9.705-17.397 31.009-23.501 47.857-13.734l89.67 59.028C748.576 295.547 615.81 180.667 461.008 180.667c-177.387 0-320.042 148.758-320.042 331.335 0 183.613 143.692 331.334 319.981 331.334 107.861 0.184 208.58-56.158 268.034-149.858 1.099-1.038 1.099-2.075 2.075-2.075 6.348-9.949 17.092-15.871 28.568-15.81 19.35 0 35.648 16.848 35.648 36.93 0 7.508-2.137 14.833-6.104 21.059-72.823 114.698-196.066 183.675-328.099 183.614-216.088 0-391.4-181.478-391.4-405.195 0-223.718 175.312-405.195 391.339-405.195 183.125-0.427 342.016 131.606 382.243 317.601z"})})},sn=function(){return he("svg",{version:"1.1",className:"icon",viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M627.498667 55.168l170.666666 170.666667a42.624 42.624 0 0 1 0 60.330666l-469.333333 469.333334A42.538667 42.538667 0 0 1 298.666667 768H128a42.666667 42.666667 0 0 1-42.666667-42.666667v-170.666666c0-11.306667 4.48-22.186667 12.501334-30.165334l469.333333-469.333333a42.624 42.624 0 0 1 60.330667 0zM896 896a42.666667 42.666667 0 0 1 0 85.333333H128a42.666667 42.666667 0 0 1 0-85.333333h768zM597.333333 145.664l-426.666666 426.666667V682.666667h110.336l426.666666-426.666667L597.333333 145.664z"})})},cn=function(e){return he("svg",{xmlns:"http://www.w3.org/2000/svg",className:e.className,viewBox:"0 0 512 512",children:he("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"48",d:"M184 112l144 144-144 144"})})},un=function(){return he("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M896 870.4l-128-128c55.467-68.267 89.6-149.333 89.6-238.933 0-98.134-38.4-192-110.933-264.534-149.334-149.333-384-149.333-533.334-4.266-145.066 145.066-145.066 384 0 529.066 72.534 72.534 166.4 110.934 264.534 110.934 89.6 0 174.933-29.867 238.933-89.6l128 128c4.267 4.266 12.8 8.533 21.333 8.533s17.067-4.267 21.334-8.533c17.066-8.534 17.066-29.867 8.533-42.667zM260.267 721.067c-119.467-123.734-119.467-320 0-439.467 59.733-59.733 140.8-89.6 217.6-89.6 81.066 0 157.866 29.867 217.6 89.6 59.733 59.733 89.6 136.533 89.6 217.6 0 81.067-34.134 162.133-89.6 217.6-55.467 59.733-132.267 93.867-217.6 93.867-81.067 0-157.867-34.134-217.6-89.6z"})})},ln=function(){return he("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:[he("path",{d:"M190.193225 471.411583c14.446014 0 26.139334-11.718903 26.139334-26.13831 0-14.44499-11.69332-26.164916-26.139334-26.164916-0.271176 0-0.490164 0.149403-0.73678 0.149403l-62.496379 0.146333c-1.425466-0.195451-2.90005-0.295735-4.373611-0.295735-19.677155 0-35.621289 16.141632-35.621289 36.114522L86.622358 888.550075c0 19.949354 15.96767 35.597753 35.670407 35.597753 1.916653 0 3.808746 0.292666 5.649674 0l61.022819 0.022513c0.099261 0 0.148379 0.048095 0.24764 0.048095 0.097214 0 0.146333-0.048095 0.24457-0.048095l0.73678 0 0-0.148379c13.413498-0.540306 24.174586-11.422144 24.174586-24.960485 0-13.55983-10.760065-24.441669-24.174586-24.981974l0-0.393973-50.949392 0 1.450025-402.275993L190.193225 471.409536z"}),he("path",{d:"M926.52241 433.948343c-19.283182-31.445176-47.339168-44.172035-81.289398-45.546336-1.77032-0.246617-3.536546-0.39295-5.380544-0.39295l-205.447139-0.688685c13.462616-39.059598 22.698978-85.58933 22.698978-129.317251 0-28.349675-3.193739-55.962569-9.041934-82.542948l-0.490164 0.049119c-10.638291-46.578852-51.736315-81.31498-100.966553-81.31498-57.264215 0-95.466282 48.15065-95.466282 106.126063 0 3.241834-0.294712 6.387477 0 9.532097-2.996241 108.386546-91.240027 195.548698-196.23636 207.513194l0 54.881958-0.785899 222.227314 0 229.744521 10.709923 0 500.025271 0.222057 8.746198-0.243547c19.35686 0.049119 30.239721-4.817726 47.803749-16.116049 16.682961-10.761088 29.236881-25.50079 37.490869-42.156122 2.260483-3.341095 4.028757-7.075139 5.106298-11.20111l77.018118-344.324116c1.056052-4.053316 1.348718-8.181333 1.056052-12.160971C943.643346 476.446249 938.781618 453.944769 926.52241 433.948343zM893.82573 486.837924l-82.983993 367.783411-0.099261-0.049119c-2.555196 6.141884-6.879688 11.596106-12.872169 15.427364-4.177136 2.727111-8.773827 4.351098-13.414521 4.964058-1.49812-0.195451-3.046383 0-4.620227 0l-477.028511-0.540306-0.171915-407.408897c89.323375-40.266076 154.841577-79.670527 188.596356-173.661202 0.072655 0.024559 0.124843 0.049119 0.195451 0.072655 2.99931-9.137101 6.313799-20.73423 8.697079-33.164331 5.551436-29.185716 5.258771-58.123792 5.258771-58.123792-4.937452-37.98001 25.940812-52.965306 44.364417-52.965306 25.304316 0.860601 50.263777 33.656541 50.263777 52.326762 0 0 5.600555 27.563776 5.649674 57.190537 0.048095 37.366026-4.6673 56.847729-4.6673 56.847729l-0.466628 0c-5.872754 30.879288-16.214287 60.138682-30.464849 86.964654l0.36839 0.342808c-2.358721 4.815679-3.709485 10.220782-3.709485 15.943111 0 19.922748 19.088754 21.742187 38.765909 21.742187l238.761895 0.270153c0 0 14.666024 0.465604 14.690584 0.465604l0 0.100284c12.132318-0.638543 24.221658 5.207605 31.100322 16.409738 5.504364 9.016351 6.437619 19.6045 3.486404 28.988218L893.82573 486.837924z"}),he("path",{d:"M264.827039 924.31872c0.319272 0.024559 0.441045 0.024559 0.295735-0.024559 0.243547-0.048095 0.367367-0.074701-0.295735-0.074701s-0.539282 0.026606-0.271176 0.074701C264.43409 924.343279 264.532327 924.343279 264.827039 924.31872z"})]})},dn=function(){return he("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:he("path",{d:"M190.208 552.576a26.176 26.176 0 0 1 0 52.288L189.44 604.8l-62.464-0.128a35.84 35.84 0 0 1-40-35.84l-0.384-433.28c0-19.968 16-35.648 35.712-35.648 1.92 0 3.84-0.256 5.632 0h62.272v0.128c13.44 0.576 24.192 11.456 24.192 24.96a25.024 25.024 0 0 1-24.192 24.96v0.448h-50.944l1.408 402.24h49.536z m736.32 37.504c-19.264 31.36-47.36 44.16-81.28 45.504a38.656 38.656 0 0 1-5.376 0.384l-205.44 0.704c13.44 39.04 22.656 85.568 22.656 129.28 0 28.416-3.2 56-9.024 82.56h-0.512a103.936 103.936 0 0 1-100.928 81.28c-57.28 0-95.488-48.128-95.488-106.112 0-3.2-0.32-6.4 0-9.536-3.008-108.352-91.264-195.52-196.224-207.488V551.68L254.08 329.6v-229.76h10.688l500.032-0.192 8.704 0.192c19.392 0 30.272 4.864 47.808 16.128 16.704 10.752 29.248 25.536 37.504 42.176 2.304 3.328 4.032 7.04 5.12 11.2l76.992 344.32a37.568 37.568 0 0 1 1.088 12.16c1.536 21.76-3.328 44.288-15.552 64.32z m-32.704-52.928l-83.008-367.744h-0.064a33.408 33.408 0 0 0-26.24-20.352c-1.536 0.192-3.072 0-4.672 0l-477.056 0.512-0.128 407.424c89.28 40.32 154.88 79.68 188.544 173.632h0.256c2.944 9.088 6.272 20.672 8.64 33.088 5.568 29.184 5.312 58.176 5.312 58.176-4.992 37.952 25.92 52.928 44.352 52.928 25.28-0.832 50.24-33.664 50.24-52.288 0 0 5.632-27.584 5.632-57.216 0.064-37.376-4.608-56.832-4.608-56.832h-0.512a307.84 307.84 0 0 0-30.464-87.04l0.384-0.256a36.16 36.16 0 0 1-3.712-16c0-19.84 19.072-21.76 38.784-21.76l238.72-0.192 14.72-0.512v-0.064c12.16 0.64 24.192-5.248 31.104-16.448a35.2 35.2 0 0 0 3.456-28.992h0.32zM267.52 96.768c2.048-0.192 2.816-0.192 1.92 0.128 1.536 0.32 2.304 0.512-1.92 0.512s-3.456-0.192-1.728-0.512c-0.768-0.32-0.192-0.32 1.728-0.128z"})})},hn=function(){return he("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M413.610667 336.192l226.346666-125.461333-11.114666-76.586667c-5.909333-40.64 43.349333-65.344 72.384-36.309333l241.365333 241.344c29.013333 29.013333 4.373333 78.250667-36.245333 72.405333l-76.458667-10.965333-126.165333 227.029333 2.176 5.12c34.56 84.330667 27.413333 153.962667-30.208 214.549333l-4.416 4.544a42.666667 42.666667 0 0 1-60.330667 0l-139.968-139.968L153.365333 946.730667c-38.528 28.48-86.677333-18.133333-61.44-57.109334l1.706667-2.474666 234.154667-318.442667-136.810667-136.832-4.906667-5.12a42.666667 42.666667 0 0 1 2.496-57.6c62.272-62.293333 139.157333-71.445333 222.122667-34.304l2.922667 1.344zM795.733333 313.024l-68.138666-68.117333-0.96 3.136a42.666667 42.666667 0 0 1-19.52 23.04L435.306667 421.76a42.666667 42.666667 0 0 1-41.216 0.085333c-42.197333-23.146667-76.565333-29.290667-106.581334-18.218666l-2.944 1.173333 129.493334 129.493333a42.666667 42.666667 0 0 1 4.202666 55.466667l-88.661333 120.533333 120.213333-88.853333a42.666667 42.666667 0 0 1 52.821334 1.642667l2.709333 2.496 130.282667 130.282666 1.685333-4.522666c8.917333-27.008 3.242667-58.24-16.704-100.608l-2.944-6.144A42.666667 42.666667 0 0 1 618.666667 605.077333l150.912-271.573333a42.666667 42.666667 0 0 1 23.018666-19.498667l3.157334-0.981333z"})})},fn=function(){return he("svg",{viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:he("path",{d:"M342.464 368.576l73.344 42.368-8.512 7.936a32 32 0 0 1-14.272 7.68l-5.44 0.832-2.88 0.192-19.456 2.24a442.88 442.88 0 0 0-53.504 10.688 245.12 245.12 0 0 0-64.32 25.984l-7.488 4.928 150.144 86.784a32 32 0 0 1 15.808 31.168l-1.024 5.312-61.568 215.168 155.584-160.896a32 32 0 0 1 34.112-7.744l4.928 2.304 152.32 87.872 1.472-8.192c4.992-38.272-7.68-83.456-31.552-128.832l-6.784-12.416a32 32 0 0 1-3.456-23.04l2.56-11.328 78.016 44.992c27.328 61.44 36.672 122.816 15.168 177.856l-5.12 11.84-6.208 11.648a32 32 0 0 1-43.712 11.712l-163.072-94.272-227.2 235.072c-21.632 22.336-57.728 3.84-55.04-24.768l1.28-6.272L336.448 600.96l-163.072-94.08a32 32 0 0 1-14.144-38.464l2.432-5.248c23.936-41.6 71.36-67.84 133.504-84.48 20.48-5.568 41.28-9.6 61.312-12.288l-14.016 2.112zM267.968 218.688l609.664 352a32 32 0 1 1-32 55.424l-609.664-352a32 32 0 1 1 32-55.424z m258.816-106.24a32 32 0 0 1 40.384-42.752l5.056 2.432 295.552 170.624a32 32 0 0 1-12.16 59.52l-83.584 9.984-31.68 138.24-57.984-33.408 32.32-140.992a32 32 0 0 1 21.76-23.424l5.632-1.216 10.56-1.344-129.28-74.624 4.16 9.856a32 32 0 0 1-3.84 31.808l-3.84 4.224L513.92 319.808l-57.984-33.472 104-96.64z"})})},pn=function(e){var t=e.items,n=At([]),r=new pe("chat-thought-chain"),i=At([]);Ue(function(){i.value=t.filter(function(e){return e.description}),i.value.length>0&&i.value.forEach(function(e,t){e.done&&(n.value=[].concat(c(n.value),[t]))})},[t]);return 0===i.value.length?null:he("div",{className:"".concat(r.b()," ").concat(r.is("single",1===i.value.length)),children:i.value.map(function(e,t){if(e.description){var i=n.value.includes(t);return he("div",{className:"".concat(r.e("item")," ").concat(r.is("collapsed",i)),children:[he("div",{className:r.e("item-icon"),children:e.icon||he("span",{children:t})}),he("div",{className:r.e("item-content"),children:[he("div",{className:r.e("item-title"),onClick:function(){return function(e){n.value.includes(e)?n.value=n.value.filter(function(t){return t!==e}):n.value=[].concat(c(n.value),[e])}(t)},children:[e.title,he(Yt,{className:r.e("icon")})]}),he("div",{className:r.e("item-description"),children:e.description})]})]},t)}})})},vn=function(e){var t=e.items,n=e.onItemClick,r=new pe("chat-suggestions");return he("div",{className:"".concat(r.b()),children:t.map(function(e,t){return he("div",{className:"".concat(r.e("item")," ").concat(r.is("action","action"===e.type)),onClick:function(t){return function(e,t){null==n||n(e,t)}(e,t)},title:e.metadata.content_name,children:[e.metadata.content_name,he(cn,{className:"".concat(r.e("item-icon"))})]},t)})})},mn=function(e){var t,n,r=new pe("chat-tool-call-item"),i=At(!1),o=At(!1),a=ke();Ue(function(){return function(){n&&clearTimeout(n)}},[]);var s=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=document.getElementById(e);r&&(r.innerHTML="",i.value&&u(t,n).forEach(function(e,t){var n=document.createElement("div");n.className="code-line";var i=document.createElement("span");i&&(i.className="line-number",i.textContent=(t+1).toString(),n.appendChild(i),n.innerHTML+=e,r.appendChild(n))}))},u=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=" ".repeat(t),r=[];if(Array.isArray(e)){if(0===e.length)return["".concat(n,'<span class="array">[]</span>')];r.push("".concat(n,'<span class="array">[</span>')),e.forEach(function(n,i){var o=u(n,t+1),a=i<e.length-1?",":"";"object"===T(n)&&null!==n?(r.push.apply(r,c(o.slice(0,-1))),r.push("".concat(o[o.length-1]).concat(a))):r.push("".concat(o[0]).concat(a))}),r.push("".concat(n,'<span class="array">]</span>'))}else if("object"===T(e)&&null!==e){var i=Object.keys(e);if(0===i.length)return["".concat(n,'<span class="property">{}</span>')];r.push("".concat(n,'<span class="property">{</span>')),i.forEach(function(o,a){var s=e[o],d=a<i.length-1?",":"",h='<span class="json-key">"'.concat(o,'":</span>');if("object"===T(s)&&null!==s){var f=u(s,t+1);r.push("".concat(n," ").concat(h," ").concat(f[0].trim())),f.length>1&&(r.push.apply(r,c(f.slice(1,-1))),r.push("".concat(f[f.length-1]).concat(d)))}else{var p=l(s);r.push("".concat(n," ").concat(h," ").concat(p).concat(d))}}),r.push("".concat(n,'<span class="property">}</span>'))}else r.push("".concat(n).concat(l(e)));return r},l=function(e){return"string"==typeof e?e.includes("Failed")||e.includes("Error")||e.includes("ERR_")?'<span class="error">"'.concat(e,'"</span>'):'<span class="string">"'.concat(e,'"</span>'):"number"==typeof e?'<span class="number">'.concat(e,"</span>"):"boolean"==typeof e?'<span class="boolean">'.concat(e,"</span>"):null===e?'<span class="null">null</span>':""};return he("div",{className:"".concat(r.b()),children:[he("div",{className:r.e("header"),onClick:function(){return i.value=!i.value,void s("code-block-".concat(a),e.item)},children:[he("div",{className:r.e("header-left"),children:[he("div",{className:r.em("header-left","caption"),children:e.item.name}),he("div",{className:r.em("header-left","desc"),children:(null===(t=e.item.parameters)||void 0===t?void 0:t.desc)||""})]}),he("div",{className:r.e("header-right"),children:[e.item.error&&he("span",{style:"color: red;",children:"发生错误"}),e.item.error&&he("svg",{xmlns:"http://www.w3.org/2000/svg",width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"red",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:"margin-left: 6px;",children:[he("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}),he("path",{d:"M12 9v4"}),he("path",{d:"M12 17h.01"})]}),he("span",{className:r.e("copy"),title:"复制",children:o.value?he("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"rgb(0, 185, 107)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-check","aria-hidden":"true",style:"margin-left: 6px;",onClick:function(e){return e.stopPropagation()},children:he("path",{d:"M20 6 9 17l-5-5"})}):he("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:"margin-left: 6px;",onClick:function(t){return function(t){t.stopPropagation(),n&&clearTimeout(n),o.value=!0,navigator.clipboard.writeText(JSON.stringify(e.item,void 0,2)),window.ibiz.message.success("已复制"),n=setTimeout(function(){o.value=!1},2e3)}(t)},children:[he("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),he("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})}),he("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{"margin-left":" 6px",transform:i.value?"rotate(90deg)":"rotate(0deg)"},children:he("path",{d:"m9 18 6-6-6-6"})})]})]}),he("div",{className:r.e("content"),id:"code-block-".concat(a)})]})},gn=function(e){var t=e.items,n=new pe("chat-tool-call"),r=At([]),i=At(!1),o=At(!1);Ue(function(){r.value=t.filter(function(e){return e}),o.value=t.length>4},[t]);var a=Dt(function(){return o.value&&!i.value?r.value.slice(0,4):r.value});return he("div",{className:"".concat(n.b()),children:[a.value.map(function(e,t){return he(mn,{item:e},t)}),o.value&&he("div",{className:n.e("toggle"),onClick:function(){i.value=!i.value},children:i.value?"收起工具调用":"展开全部 ".concat(r.value.length," 个工具调用")})]})},yn=new pe("chat-select"),kn=function(e){var t,n=e.options,r=e.value,i=e.defaultValue,o=e.className,a=e.placeholder,s=void 0===a?"请选择":a,c=e.onChange,u=e.disabled,l=void 0!==u&&u,h=Je(null),f=Je(null),p=d(qe(r||i||""),2),v=p[0],m=p[1],g=d(qe(!1),2),y=g[0],k=g[1];Ue(function(){void 0!==r&&m(r)},[r]);Ue(function(){var e=function(e){var t,n;l||null!==(t=f.current)&&void 0!==t&&t.contains(e.target)||(null!==(n=h.current)&&void 0!==n&&n.contains(e.target)?k(function(e){return!e}):k(!1))};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}},[]);var w=(null==n||null===(t=n.find(function(e){return e.value===v}))||void 0===t?void 0:t.label)||s,b=!(null==n||!n.length);return he("div",{className:"".concat(yn.b()," ").concat(o||""," ").concat(yn.is("visble",y)," ").concat(yn.is("disabled",l)," ").concat(yn.is("no-options",!b)),children:[he("div",{className:yn.e("header"),ref:h,children:[he("span",{className:yn.em("header","prefix"),title:"智能体",children:he("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",width:"1em",height:"1em",children:he("path",{d:"M497.0496 55.7056a38.4 38.4 0 0 1 38.912 0l362.7008 213.2992c11.776 6.912 18.944 19.456 18.944 33.1264v426.6496a38.4 38.4 0 0 1-18.944 33.0752l-362.6496 213.3504a38.4 38.4 0 0 1-38.912 0L134.3488 761.856a38.4 38.4 0 0 1-18.944-33.0752V302.1312a38.4 38.4 0 0 1 18.944-33.1264z m19.456 77.6192L192.3072 324.096v382.72l324.3008 190.7712 324.2496-190.7712V324.096l-324.2496-190.7712zM345.9584 370.3296c7.68 0 14.848 2.2528 20.8384 6.144l149.6576 93.696 149.8624-93.696a38.4512 38.4512 0 0 1 49.1008 58.2656l-1.792 1.792a38.6048 38.6048 0 0 1-6.656 5.12l-152.0128 94.976v170.4448a38.4 38.4 0 0 1-0.1536 3.7376l-0.512 3.7376a38.0928 38.0928 0 0 1-23.04 27.9552 38.0928 38.0928 0 0 1-35.9936-3.5328 38.1952 38.1952 0 0 1-17.0496-31.8976v-170.2912l-152.064-95.1296a38.4 38.4 0 0 1 19.7632-71.3216z"})})}),he("span",{className:yn.em("header","display-value"),title:w,children:w}),b?he("span",{className:"".concat(yn.em("header","suffix")," ").concat(yn.is("disabled",l)),children:he("svg",{className:"icon",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",width:"1em",height:"1em",children:he("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M19 9l-7 7-7-7"})})}):null]}),b?he("div",{className:yn.e("dropdown"),ref:f,children:he("ul",{className:yn.em("dropdown","list"),children:null==n?void 0:n.map(function(e){return he("li",{className:"".concat(yn.em("dropdown","item")," ").concat(yn.is("active",e.value===v)),title:e.label,onClick:function(){return function(e){m(e.value),null==c||c(e.value),k(!1)}(e)},children:e.label},e.value)})})}):null]})},wn=new pe("messsage-toolbar"),bn=function(e){var t=e.controller,n=e.message,r=[{id:"islike",label:"点赞",title:"点赞",icon:function(){return he(ln,{})},onClick:function(){t.messageLike(n._origin)}},{id:"isdislike",label:"点踩",title:"点踩",icon:function(){return he(dn,{})},onClick:function(){t.messageDisLike(n._origin)}}],i=function(e){var t,n,r,i;return"function"==typeof e.icon?e.icon():null!==(t=e.icon)&&void 0!==t&&t.showIcon&&null!==(n=e.icon)&&void 0!==n&&n.cssClass?he("i",{className:e.icon.cssClass}):null!==(r=e.icon)&&void 0!==r&&r.showIcon&&null!==(i=e.icon)&&void 0!==i&&i.imagePath?xe(e.icon.imagePath)?he("div",{dangerouslySetInnerHTML:{__html:e.icon.imagePath}}):he("img",{src:e.icon.imagePath}):void 0};return Ke(function(){return 20===n.state&&!0!==n.completed||"REMOTE"!==t.resourceMode||!n.realmessageid||t.currentTopicDisableStorage},[n.state,n.completed])?he(H,{}):he("div",{className:"".concat(wn.b()),children:r.map(function(e,r){var o="islike"===e.id&&"1"===n.islike||"isdislike"===e.id&&"1"===n.isdislike;return he("div",{title:e.title,onClick:function(r){return function(e,r){var i;null===(i=r.onClick)||void 0===i||i.call(r,e,r,t.context,t.params,n)}(r,e)},className:"".concat(wn.e("item")," ").concat(wn.is("actived",o)),children:i(e)},r)})})},xn=new pe("markdown-message"),Cn=function(e){var t=e.message,n=e.size,r=At(ke()),i=At(null),o=Ke(function(){return 20===t.state&&!0!==t.completed},[t.state,t.completed]),a=Ke(function(){return 20===t.state&&!0===t.completed},[t.state,t.completed]),c=At({title:"",description:"",icon:he(Xt,{})}),u=At({hasSuggestions:!1,suggestions:[]}),l=function(e){e&&e.length>0?u.value={hasSuggestions:!0,suggestions:e}:u.value={hasSuggestions:!1,suggestions:[]}},d=function(e){var t=e.indexOf("<think>"),n=e.indexOf("</think>"),r="",i="",o=!1;return-1===n?(o=!1,r=e.slice(t+7),i=""):(o=!0,r=e.slice(t+7,n),i=e.slice(n+8)),{isThoughtCompleted:o,thoughtContent:r,answerContent:i}};return Ue(function(){if(n>=0&&i.value){if(-1!==t.content.indexOf("<think>")){var e=d(t.content),r=e.isThoughtCompleted,o=e.thoughtContent,a=e.answerContent;r?(c.value.icon=he(Gt,{}),c.value.title="思考完成"):!0===t.completed?(c.value.icon=he(Gt,{}),c.value.title="思考已停止"):(c.value.icon=he(Xt,{}),c.value.title="思考中..."),c.value.description=o||"",i.value.setMarkdown(a||"")}else if(-1!==t.content.indexOf("<tool_call>")){var s=t.content.replace(/<tool_call>[^]*?<\/tool_call>/g,"").trim();i.value.setMarkdown(s||"")}else i.value.setMarkdown(t.content||"");l(t.suggestions)}},[t,n]),Ue(function(){var e="";if(-1!==t.content.indexOf("<think>")){var n=d(t.content),o=n.isThoughtCompleted,a=n.thoughtContent,u=n.answerContent;c.value={title:o?"思考完成":!0===t.completed?"思考已停止":"思考中...",description:a||"",icon:o||!0===t.completed?he(Gt,{}):he(Xt,{})},u&&(e=u)}else e=-1!==t.content.indexOf("<tool_call>")?t.content.replace(/<tool_call>[^]*?<\/tool_call>/g,"").trim():t.content;l(t.suggestions),i.value=new s({id:r,value:e||"",editor:{defaultModel:"previewOnly"},themeSettings:{mainTheme:"dark",codeBlockTheme:"dark"},previewer:{enablePreviewerBubble:!1},engine:{syntax:{table:{enableChart:!1,externals:["echarts"]}}}})},[]),he("div",{className:"".concat(xn.b()," ").concat(xn.is("loading",o)),children:[he("div",{className:xn.b("header"),children:[he("div",{className:xn.be("header","caption"),children:"AI "}),e.children,a?he("div",{className:xn.be("header","timeout"),children:"请求超时"}):null]}),he("div",{className:"".concat(xn.b("content")," pre-wrap-container"),children:[he(pn,{items:[c.value]}),t.toolcalls&&t.toolcalls.length>0?he(gn,{items:t.toolcalls||[]}):null,he("div",{id:r})]}),he("div",{className:xn.b("footer"),children:[he(bn,{message:t,controller:e.controller},"".concat(t.messageid,"_").concat(t.islike,"_").concat(t.isdislike)),u.value.hasSuggestions?he(vn,{items:u.value.suggestions,onItemClick:function(t,n){!function(t,n){e.controller.handleSuggestionClick(e.message,t,n)}(t,n)}}):null]})]})},Sn=new pe("ossfile-material"),_n=function(e){var t=Dt(function(){return e.material.data.name}),n=Dt(function(){return e.material.metadata.size}),r=Dt(function(){var t=e.material.metadata.state;return"successed"===t?"上传成功":"uploading"===t?"上传中":"failed"===t?"上传失败":"未知状态"}),i=Dt(function(){switch(e.material.metadata.state){case"successed":return"#1890ff";case"uploading":return"#52c41a";default:return"#ff4d4f"}});return he("div",{className:Sn.b(),children:[he("div",{className:Sn.b("left"),children:he(Qt,{})}),he("div",{className:Sn.b("right"),children:[he("div",{className:Sn.e("name"),title:t,children:t}),he("div",{className:Sn.e("metadata"),children:[he("div",{children:[n,"B"]}),he("div",{style:{color:i.value},children:r})]})]})]})},Mn=new pe("common-material"),Tn=function(e){var t,n,r,i,o=null===(t=e.controller.opts.questionToolbarItems)||void 0===t?void 0:t.find(function(t){return t.id===e.material.metadata.actionId}),a=Dt(function(){return e.material.metadata.name});return he("div",{className:Mn.b(),children:[he("div",{className:Mn.b("left"),children:o&&o.icon?"function"==typeof o.icon?o.icon():(null===(n=o.icon)||void 0===n?void 0:n.showIcon)&&he(H,{children:null!==(r=o.icon)&&void 0!==r&&r.cssClass?he("i",{className:o.icon.cssClass}):null!==(i=o.icon)&&void 0!==i&&i.imagePath?xe(o.icon.imagePath)?he("div",{dangerouslySetInnerHTML:{__html:o.icon.imagePath}}):he("img",{src:o.icon.imagePath}):null}):he(tn,{})}),he("div",{className:Mn.b("right"),children:[he("div",{className:Mn.e("name"),title:a,children:a}),he("div",{className:Mn.e("metadata"),children:he("div",{children:(null==o?void 0:o.label)||"素材资源"})})]})]})},On=new pe("chat-input-material-item"),Nn=function(e){var t=e.material,n=null;if("ossfile"===t.type)n=_n;else n=Tn;return he("div",{className:"".concat(On.b()," ").concat(On.is("disabled",e.disabled)),children:[he("div",{className:On.e("icon"),onClick:function(){e.controller.deleteMaterial(t)},children:he(en,{})}),$(n,{material:t,controller:e.controller})]})},En=new pe("user-message-question"),An=function(e){var t=At(ke()),n=At(null),r=At(135),i=At(!0),o=At(!1),a=Je(null),c=Dt(function(){return e.message.content}),u=Dt(function(){return Me.parseMixedContent(c.value)});return Ue(function(){n.value=new s({id:t,value:u.value.remainingText||"",editor:{defaultModel:"previewOnly"},themeSettings:{mainTheme:"dark",codeBlockTheme:"dark"},previewer:{enablePreviewerBubble:!1},engine:{syntax:{table:{enableChart:!1,externals:["echarts"]}}}})},[u.value.remainingText]),Ue(function(){if(a.current&&window.ResizeObserver){var e=new ResizeObserver(function(){var e,t=null===(e=n.value)||void 0===e?void 0:e.previewer.options.previewerDom;t&&(o.value=t.scrollHeight>r.value)});return e.observe(a.current),function(){e.disconnect()}}},[a.current]),he("div",{className:En.b(),children:[he("div",{className:En.e("user-header"),children:[e.children,he("div",{className:En.e("user"),children:"我"})]}),he("div",{className:En.e("content"),children:he("div",{className:En.em("content","body"),children:[u.value.hasResources&&he("div",{className:En.em("content","material"),children:u.value.resources.map(function(t){return he(Nn,{material:t,disabled:!0,controller:e.controller},t.id)})}),he("div",{className:"pre-wrap-container",children:[he("div",{className:"".concat(En.e("text-content")," ").concat(En.is("collapse",i.value)),id:t,ref:a,style:{maxHeight:i.value?"".concat(r.value,"px"):""}}),he("div",{className:"".concat(En.e("collapse-btn")," ").concat(En.is("visible",o.value)),title:i.value?"展开":"收起",onClick:function(){i.value=!i.value},children:i.value?he("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",children:he("path",{fill:"currentColor",d:"M104.704 338.752a64 64 0 0 1 90.496 0l316.8 316.8 316.8-316.8a64 64 0 0 1 90.496 90.496L557.248 791.296a64 64 0 0 1-90.496 0L104.704 429.248a64 64 0 0 1 0-90.496"})}):he("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",children:he("path",{fill:"currentColor",d:"M104.704 685.248a64 64 0 0 0 90.496 0l316.8-316.8 316.8 316.8a64 64 0 0 0 90.496-90.496L557.248 232.704a64 64 0 0 0-90.496 0L104.704 594.752a64 64 0 0 0 0 90.496"})})})]})]})})]})},Dn=new pe("error-message"),In=function(e){var t=Dt(function(){return e.message.content});return he("div",{className:Dn.b(),children:[he("div",{className:Dn.b("header"),children:[he("div",{className:Dn.be("header","caption"),children:"AI "}),e.children]}),he("div",{className:"".concat(Dn.e("content")," pre-wrap-container"),children:he("span",{children:t})})]})},zn=new pe("unknown-message"),Rn=function(e){return he("div",{className:zn.b(),children:he("div",{className:"".concat(zn.e("content")," pre-wrap-container"),children:["暂未支持的消息类型: ",e.message.type]})})},Pn=new pe("chat-message-item"),Ln=function(e){var t=e.message,n=e.size,r=null;switch(t.type){case"DEFAULT":r="ASSISTANT"===t.role?Cn:An;break;case"ERROR":r=In;break;default:r=Rn}return he("div",{className:Pn.b(),children:$(r,{size:n,message:t,controller:e.controller,children:e.children})})},Bn=function(){return S(function e(t){x(this,e),_(this,"toolcalls",[]),_(this,"allcontent",""),this.msg=t,this.toolcalls=t.toolcalls||[],this.allcontent=t.content},[{key:"messageid",get:function(){return this.msg.messageid}},{key:"state",get:function(){return this.msg.state}},{key:"role",get:function(){return this.msg.role}},{key:"type",get:function(){return this.msg.type}},{key:"realcontent",get:function(){var e=this.msg.content;if(-1!==e.indexOf("<think>")&&-1===e.indexOf("</think>"))return"";if(-1!==(e=e.replace(/<think>[^]*?<\/think>/g,"").trim()).indexOf("<tool_call>")&&-1===e.indexOf("</tool_call>"))return"";if(-1!==(e=e.replace(/<tool_call>[^]*?<\/tool_call>/g,"").trim()).indexOf("<resources>")&&-1===e.indexOf("</resources>"))return"";var t=(e=e.replace(/<resources>[^]*?<\/resources>/g,"").trim()).indexOf("<suggestions>");return-1!==t&&(e=e.substring(0,t).trim()),e}},{key:"content",get:function(){return this.msg.content}},{key:"completed",get:function(){return this.msg.completed}},{key:"suggestions",get:function(){return this.msg.suggestions}},{key:"_origin",get:function(){return this.msg}},{key:"islike",get:function(){return this.msg.islike}},{key:"isdislike",get:function(){return this.msg.isdislike}},{key:"feedbackcontent",get:function(){return this.msg.feedbackcontent}},{key:"realmessageid",get:function(){return this.msg.realmessageid}},{key:"update",value:function(e){e.content||(e.content=""),this.allcontent+=e.content,-1!==e.content.indexOf("<think>")&&this.msg.content&&(this.msg.content=""),this.msg.content+=e.content,this.computeToolCalls()}},{key:"replace",value:function(e){this.msg=e}},{key:"updateCompleted",value:function(e){this.msg.completed=e}},{key:"computeToolCalls",value:function(){this.toolcalls=ze.parse(this.allcontent)}}])}(),Vn=function(){return S(function e(t){x(this,e),this.data=t},[{key:"appid",get:function(){return this.data.appid}},{key:"id",get:function(){return this.data.id}},{key:"type",get:function(){return this.data.type}},{key:"caption",get:function(){return this.data.caption}},{key:"sourceCaption",get:function(){return this.data.sourceCaption}},{key:"url",get:function(){return this.data.url}},{key:"aiChat",get:function(){return this.data.aiChat}},{key:"captionMode",get:function(){return this.data.captionMode}},{key:"captionFilled",get:function(){return this.data.captionFilled}},{key:"realid",get:function(){return this.data.realid}},{key:"sequence",get:function(){return this.data.sequence}},{key:"isTop",get:function(){return this.data.isTop}},{key:"disableStorage",get:function(){return this.data.disableStorage||!1}}])}(),Fn=function(){return S(function e(t){x(this,e),this.material=t},[{key:"id",get:function(){return this.material.id}},{key:"type",get:function(){return this.material.type}},{key:"metadata",get:function(){return this.material.metadata}},{key:"data",get:function(){return this.material.data}}])}(),$n=function(){return S(function e(t){x(this,e),this.agent=t},[{key:"id",get:function(){return this.agent.id}},{key:"caption",get:function(){return this.agent.caption}},{key:"default",get:function(){return this.agent.default}},{key:"order",get:function(){return this.agent.order}},{key:"value",get:function(){return this.agent.id}},{key:"label",get:function(){return this.agent.caption}}])}(),jn=new pe("chat-toolbar-item"),Hn=function(e){var t,n,r,i=e.model,o=e.data,a=e.className,s=e.disabled,c=void 0!==s&&s,u=e.buttonType,l=void 0===u?"default":u,h=e.onClick,f=d(qe(!1),2),p=f[0],v=f[1],m=Je(null),g=function(e){return"function"==typeof e.hidden?e.hidden(o):!0===e.hidden};if(g(i))return he(H,{});var y=function(e){return!!c||("function"==typeof e.disabled?e.disabled(o):!0===e.disabled)},k=function(e){var t,n,r,i;return"function"==typeof e.icon?e.icon():null!==(t=e.icon)&&void 0!==t&&t.showIcon&&null!==(n=e.icon)&&void 0!==n&&n.cssClass?he("i",{className:e.icon.cssClass}):null!==(r=e.icon)&&void 0!==r&&r.showIcon&&null!==(i=e.icon)&&void 0!==i&&i.imagePath?xe(e.icon.imagePath)?he("div",{dangerouslySetInnerHTML:{__html:e.icon.imagePath}}):he("img",{src:e.icon.imagePath}):void 0},w=function(e,t){y(t)||(v(!1),h(e,t))};return Ue(function(){var e=function(e){m.current&&m.current.contains(e.target)||v(!1)};return p&&document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}},[p]),he("div",{className:"".concat(jn.b()," ").concat(jn.b(l)," ").concat(i.customClass||""," ").concat(a||""," ").concat(jn.is("disabled",y(i))," ").concat(jn.is("more",!(null===(t=i.children)||void 0===t||!t.length))),children:[he("div",{title:i.title,className:jn.e("content"),onClick:function(e){return w(e,i)},children:[he("div",{className:jn.em("content","icon"),children:k(i)}),he("div",{className:jn.em("content","label"),children:i.label})]}),(null===(n=i.children)||void 0===n?void 0:n.length)&&he("div",{title:"更多",className:jn.e("more"),onClick:function(e){y(i)||v(!0)},children:he("i",{"aria-hidden":"true",className:"fa fa-angle-down ".concat(jn.em("more","icon"))})}),p&&he("div",{ref:m,className:jn.b("dropdown"),children:null===(r=i.children)||void 0===r?void 0:r.map(function(e,t){if(!g(e))return he("div",{title:e.title,onClick:function(t){return w(t,e)},className:"".concat(jn.be("dropdown","item")," ").concat(e.customClass||""," ").concat(jn.is("disabled",y(e))),children:[he("div",{className:jn.bem("dropdown","item","icon"),children:k(e)}),he("div",{className:jn.bem("dropdown","item","label"),children:e.label})]},t)})})]})},Wn=new pe("chat-toolbar"),qn=function(e){var t=e.controller,n=e.items,r=void 0===n?[]:n,i=e.data,o=e.type,a=e.className,s=e.mode,u=e.hideTopicSidebar,l=[],d=[{label:"重置对话",title:"重置对话",icon:function(){return he(an,{})},onClick:function(){t.resetTopic()},children:[{label:"清空对话",title:"清空对话",icon:function(){return he(on,{})},onClick:function(){t.clearTopic()}},{label:"新建对话",title:"新建对话",hidden:"TOPIC"!==s||u,icon:function(){return he(Ht,{})},onClick:function(){t.newTopic()}}]}],h=[{label:"刷新",title:"刷新",icon:function(){return he(Lt,{})},onClick:function(){t.refreshMessage(i)}},{label:"删除",title:"删除",hidden:function(){return!i.realmessageid},icon:function(){return he(Pt,{})},onClick:function(){t.deleteMessage(i)}},{label:"复制",title:"复制",icon:function(){return he(Bt,{})},onClick:function(){t.copyMessage(i)}}];Ge($f).enableBackFill&&h.unshift.apply(h,[{label:"回填",title:"回填",icon:function(){return he(zt,{})},onClick:function(){t.backfill(i)}}]);var f=[{label:"刷新",title:"刷新",icon:function(){return he(Lt,{})},onClick:function(){t.refreshMessage(i,!0)}}];if("content"===o)switch(i.type){case"DEFAULT":l="ASSISTANT"===i.role?[].concat(h,c(r)):[].concat(f);break;case"ERROR":l=[].concat(h,c(r))}else l=[].concat(d,c(r));var p=function(n,r){var o=g({},i);if(i instanceof Bn?(Object.assign(o,{topic:t.topic}),o.msg.realcontent=i.realcontent):(o.data||(o.data={}),Object.assign(o.data,{messages:t.messages.value})),r.onClick&&"function"==typeof r.onClick)r.onClick(n,r,t.context,t.params,o);else{var a=e.controller.opts.extendToolbarClick;a&&"function"==typeof a&&a(n,r,t.context,t.params,o)}},v=Ke(function(){return"content"===o&&20===(null==i?void 0:i.state)&&!0!==(null==i?void 0:i.completed)},[null==i?void 0:i.state,null==i?void 0:i.completed]);return he("div",{className:"".concat(Wn.b()," ").concat(a||""),children:l.map(function(e,t){return he(Hn,{data:i,model:e,disabled:v,buttonType:"content"===o?"circle":"default",onClick:p.bind(void 0)},t)})})};var Un=function(e){var t=At(!1),n=At({}),r=new pe("chat-back-bottom"),i=At(null),o=function(){if(i.value){var n=e.visibilityHeight||200,r=i.value.scrollHeight-i.value.scrollTop-i.value.offsetHeight;t.value=r>=n}},a=function(e,t){var n=null;return function(){for(var r=this,i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];n||(n=setTimeout(function(){e.apply(r,o),n=null},t))}}(o,300);return Ke(function(){n.value={right:"".concat(e.right,"px"),bottom:"".concat(e.bottom,"px")}},[e.right,e.bottom]),Ue(function(){if(e.target){var t,n=null!==(t=document.querySelector(e.target))&&void 0!==t?t:void 0;n&&(i.value=n,n.addEventListener("scroll",a),o())}},[]),he("div",{className:"".concat(r.b()," ").concat(r.is("visible",t.value)),style:n.value,onClick:function(){var t;i.value&&(i.value.scrollTo({top:i.value.scrollHeight,behavior:"smooth"}),null===(t=e.onClick)||void 0===t||t.call(e))},children:he(rn,{className:r.e("icon")})})},Jn=new pe("chat-messages"),Kn=function(e){var t=Je(null),n=d(qe(5),2),r=n[0],i=n[1],o=d(qe(!1),2),a=o[0],s=o[1],c=d(qe(!0),2),u=c[0],l=c[1],h=Je(!1),f=e.controller.messages,p=Ke(function(){var e=Math.max(0,f.value.length-r);return f.value.slice(e)},[f.value,r]),v=Ke(function(){return r<f.value.length},[f.value,r]);Ue(function(){var e;u&&((e=t.current)&&(h.current=!0,e.scrollTo({top:e.scrollHeight,behavior:"auto"}),setTimeout(function(){h.current=!1},500)))},[f.value]);return he("div",{ref:t,className:Jn.b(),onScroll:function(){if(!h.current){var e=t.current;if(e){var n=e.scrollTop,o=e.scrollHeight,c=e.clientHeight;n<100&&!a&&v&&(s(!0),setTimeout(function(){var t=Math.min(r+5,f.value.length);i(t);var n=e.scrollHeight;setTimeout(function(){var t=e.scrollHeight;e.scrollTop=t-n+e.scrollTop,s(!1)},0)},300)),l(o-(n+c)<50)}}},children:[p.map(function(t){var n,r=(null===(n=t.content)||void 0===n?void 0:n.length)||0;return"SYSTEM"!==t.role?he(Ln,{size:r,message:t,controller:e.controller,children:he(qn,{type:"content",mode:"DEFAULT",hideTopicSidebar:!1,data:t,items:e.toolbarItems,controller:e.controller})},t.messageid):null}),he(Un,{right:20,bottom:14,target:".".concat(Jn.b()),onClick:function(){h.current=!0,l(!0)}})]})};function Yn(e,t){for(var n in e)if("__source"!==n&&!(n in t))return!0;for(var r in t)if("__source"!==r&&e[r]!==t[r])return!0;return!1}function Gn(e,t){this.props=e,this.context=t}(Gn.prototype=new W).isPureReactComponent=!0,Gn.prototype.shouldComponentUpdate=function(e,t){return Yn(this.props,e)||Yn(this.state,t)};var Xn=m.__b;m.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Xn&&Xn(e)};var Zn=m.__e;m.__e=function(e,t,n,r){if(e.then)for(var i,o=t;o=o.__;)if((i=o.__c)&&i.__c)return null==t.__e&&(t.__e=n.__e,t.__k=n.__k),i.__c(e,t);Zn(e,t,n,r)};var Qn=m.unmount;function er(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(e){"function"==typeof e.__c&&e.__c()}),e.__c.__H=null),null!=(e=function(e,t){for(var n in t)e[n]=t[n];return e}({},e)).__c&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(e){return er(e,t,n)})),e}function tr(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(e){return tr(e,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function nr(){this.__u=0,this.o=null,this.__b=null}function rr(e){var t=e.__.__c;return t&&t.__a&&t.__a(e)}function ir(){this.i=null,this.l=null}m.unmount=function(e){var t=e.__c;t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Qn&&Qn(e)},(nr.prototype=new W).__c=function(e,t){var n=t.__c,r=this;null==r.o&&(r.o=[]),r.o.push(n);var i=rr(r.__v),o=!1,a=function(){o||(o=!0,n.__R=null,i?i(s):s())};n.__R=a;var s=function(){if(! --r.__u){if(r.state.__a){var e=r.state.__a;r.__v.__k[0]=tr(e,e.__c.__P,e.__c.__O)}var t;for(r.setState({__a:r.__b=null});t=r.o.pop();)t.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(a,a)},nr.prototype.componentWillUnmount=function(){this.o=[]},nr.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),r=this.__v.__k[0].__c;this.__v.__k[0]=er(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&$(H,null,e.fallback);return i&&(i.__u&=-33),[$(H,null,t.__a?null:e.children),i]};var or=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&("t"!==e.props.revealOrder[0]||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}};function ar(e){return this.getChildContext=function(){return e.context},e.children}function sr(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){le(null,t.v),t.v=null,t.h=null},t.h&&t.h!==n&&t.componentWillUnmount(),!t.v){for(var r=t.__v;null!==r&&!r.__m&&null!==r.__;)r=r.__;t.h=n,t.v={nodeType:1,parentNode:n,childNodes:[],__k:{__m:r.__m},contains:function(){return!0},insertBefore:function(e,n){this.childNodes.push(e),t.h.insertBefore(e,n)},removeChild:function(e){this.childNodes.splice(this.childNodes.indexOf(e)>>>1,1),t.h.removeChild(e)}}}le($(ar,{context:t.context},e.__v),t.v)}function cr(e,t){var n=$(sr,{__v:e,h:t});return n.containerInfo=t,n}(ir.prototype=new W).__a=function(e){var t=this,n=rr(t.__v),r=t.l.get(e);return r[0]++,function(i){var o=function(){t.props.revealOrder?(r.push(i),or(t,e,r)):i()};n?n(o):o()}},ir.prototype.render=function(e){this.i=null,this.l=new Map;var t=X(e.children);e.revealOrder&&"b"===e.revealOrder[0]&&t.reverse();for(var n=t.length;n--;)this.l.set(t[n],this.i=[1,0,this.i]);return e.children},ir.prototype.componentDidUpdate=ir.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){or(e,n,t)})};var ur="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,lr=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,dr=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,hr=/[A-Z0-9]/g,fr="undefined"!=typeof document,pr=function(e){return("undefined"!=typeof Symbol&&"symbol"==T(Symbol())?/fil|che|rad/:/fil|che|ra/).test(e)};W.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(W.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var vr=m.event;function mr(){}function gr(){return this.cancelBubble}function yr(){return this.defaultPrevented}m.event=function(e){return vr&&(e=vr(e)),e.persist=mr,e.isPropagationStopped=gr,e.isDefaultPrevented=yr,e.nativeEvent=e};var kr={enumerable:!1,configurable:!0,get:function(){return this.class}},wr=m.vnode;m.vnode=function(e){"string"==typeof e.type&&function(e){var t=e.props,n=e.type,r={},i=-1===n.indexOf("-");for(var o in t){var a=t[o];if(!("value"===o&&"defaultValue"in t&&null==a||fr&&"children"===o&&"noscript"===n||"class"===o||"className"===o)){var s=o.toLowerCase();"defaultValue"===o&&"value"in t&&null==t.value?o="value":"download"===o&&!0===a?a="":"translate"===s&&"no"===a?a=!1:"o"===s[0]&&"n"===s[1]?"ondoubleclick"===s?o="ondblclick":"onchange"!==s||"input"!==n&&"textarea"!==n||pr(t.type)?"onfocus"===s?o="onfocusin":"onblur"===s?o="onfocusout":dr.test(o)&&(o=s):s=o="oninput":i&&lr.test(o)?o=o.replace(hr,"-$&").toLowerCase():null===a&&(a=void 0),"oninput"===s&&r[o=s]&&(o="oninputCapture"),r[o]=a}}"select"==n&&r.multiple&&Array.isArray(r.value)&&(r.value=X(t.children).forEach(function(e){e.props.selected=-1!=r.value.indexOf(e.props.value)})),"select"==n&&null!=r.defaultValue&&(r.value=X(t.children).forEach(function(e){e.props.selected=r.multiple?-1!=r.defaultValue.indexOf(e.props.value):r.defaultValue==e.props.value})),t.class&&!t.className?(r.class=t.class,Object.defineProperty(r,"className",kr)):(t.className&&!t.class||t.class&&t.className)&&(r.class=r.className=t.className),e.props=r}(e),e.$$typeof=ur,wr&&wr(e)};var br=m.__r;m.__r=function(e){br&&br(e),e.__c};var xr=m.diffed;m.diffed=function(e){xr&&xr(e);var t=e.props,n=e.__e;null!=n&&"textarea"===e.type&&"value"in t&&t.value!==n.value&&(n.value=null==t.value?"":t.value)};var Cr=function(e){return e.STYLE_CACHE="ai-chat-style-cache",e.MINIMIZE_STYLY_CHCHE="ai-chat-minimize-style-cache",e.DATA_BASE_NAME="ibiz-chat",e.DATA_TABLE_NAME="history-message",e.DATA_TABLE_KEY_NAME="id",e}(Cr||{});function Sr(e){switch(e){case"user":default:return"USER";case"agent":return"ASSISTANT";case"system":return"SYSTEM"}}function _r(e){switch(e){case"pending":return 20;case"sent":case"cancelled":default:return 30;case"failed":return 40}}function Mr(e){switch(e){case"pending":case"sent":case"cancelled":default:return"DEFAULT";case"failed":return"ERROR"}}var Tr=function(){return S(function e(t,n){x(this,e),_(this,"evt",new p),_(this,"messages",mt([])),_(this,"materials",mt([])),_(this,"input",mt("")),_(this,"isLoading",mt(!1)),_(this,"enableAIAgentChange",!0),_(this,"activeAIAgentID",void 0),_(this,"agentList",mt([])),_(this,"context",void 0),_(this,"params",void 0),_(this,"appDataEntityId",void 0),_(this,"topicId",void 0),_(this,"topic",void 0),_(this,"aiTopic",void 0),_(this,"chatSessionid",""),_(this,"chatMode",void 0),this.opts=t,this.resourceOptions=n,this.context=t.context,this.params=t.params,this.appDataEntityId=t.appDataEntityId,this.aiTopic=t.aiTopic,this.topicId=t.topicId,this.topic=t.topic,this.activeAIAgentID=t.activeAIAgentID,this.enableAIAgentChange=!!t.enableAIAgentChange,this.chatMode=t.srfMode,this.chatSessionid=t.sessionid,this.initAIChat()},[{key:"resourceMode",get:function(){var e;return(null===(e=this.resourceOptions)||void 0===e?void 0:e.resourceMode)||"LOCAL"}},{key:"currentTopicDisableStorage",get:function(){if(this.topicId&&this.aiTopic){var e=this.aiTopic.getCurrentTopicByID(this.topicId);if(e&&e.disableStorage)return!0}return!1}},{key:"initAIChat",value:(T=b(y().m(function e(){return y().w(function(e){for(;;)switch(e.n){case 0:return this.messages.value=[],e.n=1,this.initAIChatAgent();case 1:return e.n=2,this.fecthHistory();case 2:return e.a(2)}},e,this)})),function(){return T.apply(this,arguments)})},{key:"initAIChatAgent",value:(M=b(y().m(function e(){var t=this;return y().w(function(e){for(;;)switch(e.n){case 0:this.opts.aiAgentlist&&this.opts.aiAgentlist.length>0&&this.opts.aiAgentlist.forEach(function(e){t.agentList.value=[].concat(c(t.agentList.value),[new $n(e)])});case 1:return e.a(2)}},e,this)})),function(){return M.apply(this,arguments)})},{key:"getHistoryStoreKey",value:function(e){return"".concat(e)}},{key:"fecthHistory",value:(C=b(y().m(function e(){var t,n,r,i=this;return y().w(function(e){for(;;)switch(e.n){case 0:if(!this.topicId){e.n=7;break}if(t={},!this.currentTopicDisableStorage){e.n=1;break}t.data=[],e.n=5;break;case 1:if("LOCAL"!==this.resourceMode){e.n=3;break}return e.n=2,Se.getData(Cr.DATA_BASE_NAME,Cr.DATA_TABLE_NAME,this.getHistoryStoreKey(this.topicId));case 2:t=e.v,e.n=5;break;case 3:if("REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=5;break}return e.n=4,this.resourceOptions.getMessages({n_session_id_eq:this.chatSessionid});case 4:(n=e.v)&&n.length>0&&(r=[],n.forEach(function(e){var t;r.push({messageid:(t=e).id,state:_r(t.status),type:Mr(t.status),role:Sr(t.sender_type),content:t.content,completed:!0,islike:t.is_like,isdislike:t.is_dislike,feedbackcontent:t.feedback_content,realmessageid:t.id})}),t.data=r);case 5:if(!(t&&t.data&&t.data.length>0)){e.n=7;break}return t.data.forEach(function(e){var t={messageid:e.messageid,state:e.state,type:e.type,role:e.role,islike:e.islike,isdislike:e.isdislike,feedbackcontent:e.feedbackcontent,content:e.content,suggestions:e.suggestions,completed:!0,toolcalls:e.toolcalls,realmessageid:e.realmessageid};i.addMessage(t)}),e.n=6,this.afterFecthHistory();case 6:return e.a(2,!0);case 7:return e.n=8,this.opts.history(this.context,this.params,{appDataEntityId:this.appDataEntityId,appendCurData:this.opts.appendCurData,sessionid:this.chatSessionid,srfaiagent:this.activeAIAgentID,srfmode:this.chatMode});case 8:if(!e.v){e.n=9;break}return e.n=9,this.afterFecthHistory();case 9:return e.a(2,!0)}},e,this)})),function(){return C.apply(this,arguments)})},{key:"afterFecthHistory",value:(w=b(y().m(function e(){var t,n,r,i,o,a,s,u,l=this;return y().w(function(e){for(;;)switch(e.p=e.n){case 0:if(this.opts.appendCurContent&&this.addMessage({state:30,messageid:ke(),role:"USER",type:"DEFAULT",content:this.opts.appendCurContent,completed:!0}),this.opts.appendCurResource&&(t=Me.parseMixedContent(this.opts.appendCurResource),n=t.hasResources,r=t.resources,n&&r&&r.length>0&&r.forEach(function(e){l.replaceMaterial(e.id,e)})),!1===this.opts.autoQuestion){e.n=4;break}if(i=this.messages.value.length-1,!(o=this.messages.value[i])||"USER"!==o.role){e.n=4;break}return(a=this.stringlyMaterialResource(!1))&&(s=a+o.content,u=g(g({},o._origin),{},{messageid:ke(),content:s}),this.messages.value[i]=new Bn(u),this.messages.value=c(this.messages.value)),e.p=1,this.isLoading.value=!0,e.n=2,this.opts.question(this,this.context,this.params,{appDataEntityId:this.appDataEntityId},this.getMessages(),this.chatSessionid,this.activeAIAgentID,this.chatMode);case 2:if(!this.opts.action){e.n=3;break}return e.n=3,this.opts.action("question",o.content);case 3:return e.p=3,this.isLoading.value=!1,e.f(3);case 4:return e.n=5,this.updateTopicCaption();case 5:return e.a(2)}},e,this,[[1,,3,4]])})),function(){return w.apply(this,arguments)})},{key:"asyncToIndexDB",value:(k=b(y().m(function e(){var t;return y().w(function(e){for(;;)switch(e.n){case 0:if(this.topicId&&"LOCAL"===this.resourceMode){e.n=1;break}return e.a(2);case 1:if(!this.currentTopicDisableStorage){e.n=2;break}return e.a(2);case 2:return t={id:this.getHistoryStoreKey(this.topicId),data:this.messages.value.map(function(e){return g(g({},e._origin),{},{toolcalls:e.toolcalls})}),timestamp:(new Date).getTime()},e.n=3,Se.updateData(Cr.DATA_BASE_NAME,Cr.DATA_TABLE_NAME,t);case 3:return e.a(2)}},e,this)})),function(){return k.apply(this,arguments)})},{key:"setInput",value:function(e){this.input.value=e||""}},{key:"addMessage",value:function(e){var t=this.messages.value.find(function(t){return t.messageid===e.messageid});t?(t.update(e),this.messages.value=c(this.messages.value)):this.messages.value=[].concat(c(this.messages.value),[new Bn(e)]),this.asyncToIndexDB()}},{key:"completeMessage",value:(m=b(y().m(function e(t,n){var r,i;return y().w(function(e){for(;;)switch(e.n){case 0:if(!(r=this.messages.value.find(function(e){return e.messageid===t}))){e.n=1;break}return r.updateCompleted(n),this.messages.value=c(this.messages.value),e.n=1,this.asyncToIndexDB();case 1:!0===this.opts.autoFill&&"ASSISTANT"===(i=r||this.messages.value[this.messages.value.length-1]).role&&30===i.state&&this.backfill(i),this.evt.emit("onCompleteMessage",{messageid:t,completed:n});case 2:return e.a(2)}},e,this)})),function(e,t){return m.apply(this,arguments)})},{key:"replaceMessage",value:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=this.messages.value.findIndex(function(t){return t.messageid===e.messageid});-1!==r?(this.messages.value[r].replace(e),this.messages.value=c(this.messages.value)):this.messages.value=[].concat(c(this.messages.value),[new Bn(e)]),this.asyncToIndexDB(),"DEFAULT"===e.type&&this.opts.recommendPrompt&&n&&this.opts.recommendPrompt(this.context,this.params,{appDataEntityId:this.appDataEntityId,message:{messages:[e],sessionid:this.chatSessionid,srfaiagent:this.activeAIAgentID}}).then(function(n){n&&n.content&&t.updateRecommendPrompt(e,n.content)})}},{key:"stopMessage",value:(v=b(y().m(function e(t){var n,r;return y().w(function(e){for(;;)switch(e.n){case 0:return-1!==(n=this.messages.value.findIndex(function(e){return e.messageid===t.messageid}))?(r=this.messages.value[n],t.content=r.content,this.messages.value[n].replace(t),this.messages.value=c(this.messages.value)):this.messages.value=[].concat(c(this.messages.value),[new Bn(t)]),e.n=1,this.asyncToIndexDB();case 1:return e.a(2)}},e,this)})),function(e){return v.apply(this,arguments)})},{key:"stringlyMaterialResource",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t="",n=[];return this.materials.value&&this.materials.value.length>0&&(this.materials.value.forEach(function(e){if("ossfile"===e.type){var t=e.metadata;t.state&&"successed"===t.state&&n.push(e)}else n.push(e)}),e&&(this.materials.value=[])),n&&n.length>0&&(t=Me.stringify(n)),t}},{key:"getMessages",value:function(){var e=this.messages.value.filter(function(e){return"ERROR"!==e.type}).map(function(e){return e._origin});return e.forEach(function(e){e.content=e.content.replace(/<tool_call>[^]*?<\/tool_call>/g,"").trim()}),e}},{key:"getAllMessages",value:function(){return this.messages.value.map(function(e){return e._origin})}},{key:"question",value:(f=b(y().m(function e(t){var n,r=this;return y().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,this.isLoading.value=!0,this.messages.value.forEach(function(e,t){var n=e._origin;n.suggestions&&(n.suggestions=void 0,r.messages.value[t].replace(n))}),this.messages.value=c(this.messages.value),this.asyncToIndexDB(),(n=this.stringlyMaterialResource(!1))?n+="\n".concat(t):n=t,this.addMessage({state:30,messageid:ke(),role:"USER",type:"DEFAULT",content:n}),e.n=1,this.opts.question(this,this.context,this.params,{appDataEntityId:this.appDataEntityId},this.getMessages(),this.chatSessionid,this.activeAIAgentID,this.chatMode);case 1:return e.n=2,this.updateTopicCaption();case 2:this.opts.action&&this.opts.action("question",t),this.isLoading.value=!1;case 3:return e.p=3,this.isLoading.value=!1,e.f(3);case 4:return e.a(2)}},e,this,[[0,,3,4]])})),function(e){return f.apply(this,arguments)})},{key:"abortQuestion",value:(h=b(y().m(function e(){return y().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,this.opts.abortQuestion(this,this.context,this.params,{appDataEntityId:this.appDataEntityId,sessionid:this.chatSessionid,srfaiagent:this.activeAIAgentID,srfmode:this.chatMode});case 1:return e.p=1,this.isLoading.value=!1,e.f(1);case 2:return e.a(2)}},e,this,[[0,,1,2]])})),function(){return h.apply(this,arguments)})},{key:"backfill",value:function(e){this.opts.action&&this.opts.action("backfill",e)}},{key:"deleteMessage",value:(d=b(y().m(function e(t){var n;return y().w(function(e){for(;;)switch(e.n){case 0:if(-1!==(n=this.messages.value.findIndex(function(e){return e.messageid===t.messageid}))&&(this.messages.value.splice(n,1),this.messages.value=c(this.messages.value)),this.asyncToIndexDB(),"REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=1;break}if(!t.realmessageid){e.n=1;break}return e.n=1,this.resourceOptions.deleteMessage(t.realmessageid);case 1:this.opts.action&&this.opts.action("deletemsg",t);case 2:return e.a(2)}},e,this)})),function(e){return d.apply(this,arguments)})},{key:"refreshMessage",value:(l=b(y().m(function e(t){var n,r,i,o=arguments;return y().w(function(e){for(;;)switch(e.p=e.n){case 0:if(n=o.length>1&&void 0!==o[1]&&o[1],this.isLoading.value=!0,e.p=1,r=this.messages.value.findIndex(function(e){return e.messageid===t.messageid}),!n){e.n=3;break}return this.messages.value.splice(r+1,this.messages.value.length-r-1),this.messages.value=c(this.messages.value),e.n=2,this.opts.question(this,this.context,this.params,{appDataEntityId:this.appDataEntityId},this.getMessages(),this.chatSessionid,this.activeAIAgentID,this.chatMode);case 2:e.n=6;break;case 3:if(r!==this.messages.value.length-1){e.n=5;break}return this.messages.value.pop(),this.messages.value=c(this.messages.value),e.n=4,this.opts.question(this,this.context,this.params,{appDataEntityId:this.appDataEntityId},this.getMessages(),this.chatSessionid,this.activeAIAgentID,this.chatMode);case 4:e.n=6;break;case 5:i=this.messages.value[r-1].content,this.messages.value.splice(r-1,2),this.question(i);case 6:this.asyncToIndexDB(),this.opts.action&&this.opts.action("refreshmsg",t);case 7:return e.p=7,this.isLoading.value=!1,e.f(7);case 8:return e.a(2)}},e,this,[[1,,7,8]])})),function(e){return l.apply(this,arguments)})},{key:"copyMessage",value:function(e){var t=e.realcontent;Ce.copy(t),this.opts.action&&this.opts.action("copymsg",e)}},{key:"resetTopic",value:(u=b(y().m(function e(){var t;return y().w(function(e){for(;;)switch(e.n){case 0:return t=!0,e.n=1,this.clearTopic();case 1:if(t=e.v){e.n=2;break}return e.a(2,t);case 2:return e.n=3,this.fecthHistory();case 3:return e.a(2,t)}},e,this)})),function(){return u.apply(this,arguments)})},{key:"clearTopic",value:(s=b(y().m(function e(){var t,n;return y().w(function(e){for(;;)switch(e.n){case 0:return t=!0,e.n=1,this.abortQuestion();case 1:if(!this.topicId){e.n=7;break}if(!this.topicId||!this.aiTopic){e.n=6;break}if(!this.currentTopicDisableStorage){e.n=2;break}t=!0,e.n=6;break;case 2:if("LOCAL"!==this.resourceMode){e.n=4;break}return e.n=3,Se.deleteData(Cr.DATA_BASE_NAME,Cr.DATA_TABLE_NAME,this.getHistoryStoreKey(this.topicId));case 3:t=e.v,e.n=6;break;case 4:if("REMOTE"!==this.resourceMode){e.n=6;break}return e.n=5,this.aiTopic.clearMessagesByTopicId(this.topicId);case 5:t=e.v;case 6:e.n=10;break;case 7:if("REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=10;break}return e.n=8,this.resourceOptions.getSessionList({n_session_id_eq:this.chatSessionid});case 8:if(!((n=e.v)&&n.length>0)){e.n=10;break}return e.n=9,this.resourceOptions.clearAllMessageBySessionId(n[0].realid);case 9:t=e.v;case 10:if(t){e.n=11;break}return e.a(2,t);case 11:return this.messages.value=[],e.a(2,t)}},e,this)})),function(){return s.apply(this,arguments)})},{key:"newTopic",value:(a=b(y().m(function e(){return y().w(function(e){for(;;)switch(e.n){case 0:this.topicId&&this.aiTopic&&this.aiTopic.newTopic(this.topicId,{activeAIAgentID:this.activeAIAgentID,sessionid:"".concat(we(this.chatSessionid),"@").concat((new Date).getTime())});case 1:return e.a(2)}},e,this)})),function(){return a.apply(this,arguments)})},{key:"addMaterial",value:function(e){var t=this.materials.value.find(function(t){return t.id===e.id});this.materials.value=t?c(this.materials.value):[].concat(c(this.materials.value),[new Fn(e)])}},{key:"replaceMaterial",value:function(e,t){var n=this.materials.value.findIndex(function(t){return t.id===e});-1!==n?(this.materials.value[n]=new Fn(t),this.materials.value=c(this.materials.value)):this.materials.value=[].concat(c(this.materials.value),[new Fn(t)])}},{key:"deleteMaterial",value:function(e){var t=this.materials.value.findIndex(function(t){return t.id===e.id});-1!==t&&(this.materials.value.splice(t,1),this.materials.value=c(this.materials.value))}},{key:"updateRecommendPrompt",value:function(e,t){if(t){var n=this.messages.value.findIndex(function(t){return t.messageid===e.messageid}),r=Te.parseMixedContent(t).suggestions;r&&r.length>0&&(e.suggestions=r,-1!==n?(this.messages.value[n]=new Bn(e),this.messages.value=c(this.messages.value)):this.messages.value=[].concat(c(this.messages.value),[new Bn(e)]),this.asyncToIndexDB())}}},{key:"handleSuggestionClick",value:(o=b(y().m(function e(t,n,r){var i,o,a,s,u,l,d,h,f,p;return y().w(function(e){for(;;)switch(e.n){case 0:-1!==(i=this.messages.value.findIndex(function(e){return e.messageid===t.messageid}))&&((o=this.messages.value[i]._origin).suggestions=void 0,this.messages.value[i].replace(o),this.messages.value=c(this.messages.value)),this.asyncToIndexDB(),a=n.type,s=n.metadata,p=a,e.n="action"===p?1:"raw"===p?5:7;break;case 1:if(!this.opts.extendToolbarClick){e.n=4;break}if(l=n.data.actionid){e.n=2;break}throw new Error("actionid不能为空");case 2:return this.addMessage({messageid:ke(),state:30,type:"DEFAULT",role:"USER",content:s.content_name}),d=g({},t),Object.assign(d,{topic:this.topic}),d.msg.realcontent=t.realcontent,e.n=3,this.opts.extendToolbarClick(r,{id:l,appId:this.context.srfappid},this.context,this.params,d);case 3:h=e.v,(f=null==h||null===(u=h.data)||void 0===u?void 0:u[0]).content&&this.addMessage({messageid:ke(),state:30,type:f.type||"DEFAULT",role:f.role||"ASSISTANT",content:f.content});case 4:return e.a(3,8);case 5:return e.n=6,this.question(n.data.content);case 6:return e.a(3,8);case 7:throw new Error("不支持".concat(a,"推荐类型"));case 8:return e.a(2)}},e,this)})),function(e,t,n){return o.apply(this,arguments)})},{key:"setActiveAIAgentID",value:(i=b(y().m(function e(t){return y().w(function(e){for(;;)switch(e.n){case 0:this.activeAIAgentID=t,this.topicId&&this.aiTopic&&this.aiTopic.updateTopicChatByID(this.topicId,{activeAIAgentID:t});case 1:return e.a(2)}},e,this)})),function(e){return i.apply(this,arguments)})},{key:"updateTopicCaption",value:(r=b(y().m(function e(){var t,n,r;return y().w(function(e){for(;;)switch(e.n){case 0:if(!(t=this.messages.value.find(function(e){return"USER"===e.role}))){e.n=4;break}if(!this.topicId||!this.aiTopic){e.n=1;break}this.aiTopic.updateTopicCaption(this.topicId,t.content),e.n=4;break;case 1:if("REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=4;break}return e.n=2,this.resourceOptions.getSessionList({n_session_id_eq:this.chatSessionid});case 2:if(!((n=e.v)&&n.length>0)){e.n=4;break}if(r=t.content.substring(0,15)||this.opts.caption,n[0].caption!==r){e.n=3;break}return e.a(2);case 3:return e.n=4,this.resourceOptions.updateSession(n[0].realid,{caption:r});case 4:return e.a(2)}},e,this)})),function(){return r.apply(this,arguments)})},{key:"messageLike",value:(n=b(y().m(function e(t){var n,r,i;return y().w(function(e){for(;;)switch(e.n){case 0:if(n="1"===t.islike,(r=t.realmessageid)&&this.resourceOptions){e.n=1;break}return e.a(2);case 1:if(!n){e.n=3;break}return e.n=2,this.resourceOptions.cancelFeedback(r);case 2:i=e.v,e.n=5;break;case 3:return e.n=4,this.resourceOptions.likeMessage(r);case 4:i=e.v;case 5:i&&(t.islike=n?"0":"1",n||"1"!==t.isdislike||(t.isdislike="0"),this.replaceMessage(t,!1));case 6:return e.a(2)}},e,this)})),function(e){return n.apply(this,arguments)})},{key:"messageDisLike",value:(t=b(y().m(function e(t){var n,r,i,o;return y().w(function(e){for(;;)switch(e.n){case 0:if(n="1"===t.isdislike,r=t.realmessageid,i=t.feedbackcontent,r&&this.resourceOptions){e.n=1;break}return e.a(2);case 1:if(!n){e.n=3;break}return e.n=2,this.resourceOptions.cancelFeedback(r);case 2:o=e.v,e.n=5;break;case 3:return e.n=4,this.resourceOptions.dislikeMessage(r,i);case 4:o=e.v;case 5:o&&(t.isdislike=n?"0":"1",n||"1"!==t.islike||(t.islike="0"),this.replaceMessage(t,!1));case 6:return e.a(2)}},e,this)})),function(e){return t.apply(this,arguments)})},{key:"destroyed",value:(e=b(y().m(function e(){return y().w(function(e){for(;;)switch(e.n){case 0:this.evt.reset();case 1:return e.a(2)}},e,this)})),function(){return e.apply(this,arguments)})}]);var e,t,n,r,i,o,a,s,u,l,d,h,f,v,m,k,w,C,M,T}(),Or=function(){return S(function e(t){x(this,e),_(this,"topics",mt([])),_(this,"activedTopic",mt(void 0)),_(this,"backupOptions",void 0),_(this,"remoteSessionList",[]),_(this,"resourceMode","LOCAL"),_(this,"resourceOptions",void 0),this.chat=t},[{key:"injectResourceOptions",value:function(e){this.resourceMode=(null==e?void 0:e.resourceMode)||"LOCAL",this.resourceOptions=e}},{key:"fetchHistory",value:(d=b(y().m(function e(t){var n,r,i=this;return y().w(function(e){for(;;)switch(e.n){case 0:return this.topics.value=[],n=t.configService(t.appid,"aitopics",t.type),e.n=1,n.load();case 1:if(!((r=e.v)&&r.length>0)){e.n=5;break}if("REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=4;break}return e.n=2,this.resourceOptions.getSessionList();case 2:return this.remoteSessionList=e.v,e.n=3,this.asyncRemoteSession(r);case 3:e.n=5;break;case 4:r.forEach(function(e,t){Object.prototype.hasOwnProperty.call(e,"sequence")||(e.sequence=t),Object.prototype.hasOwnProperty.call(e,"isTop")||(e.isTop=0),i.topics.value=[].concat(c(i.topics.value),[new Vn(e)])});case 5:return e.a(2)}},e,this)})),function(e){return d.apply(this,arguments)})},{key:"asyncRemoteSession",value:(l=b(y().m(function e(t){var n=this;return y().w(function(e){for(;;)switch(e.n){case 0:if(this.remoteSessionList&&0!==this.remoteSessionList.length&&t&&0!==t.length){e.n=1;break}return e.a(2);case 1:this.remoteSessionList.forEach(function(e){var r=t.find(function(t){var n;return(null===(n=t.aiChat)||void 0===n?void 0:n.sessionid)===e.session_id});r&&(r.realid=e.realid,r.sequence=e.sequence,r.isTop=e.is_top?e.is_top:0,e.caption&&(r.caption=e.caption),n.topics.value=[].concat(c(n.topics.value),[new Vn(r)]))});case 2:return e.a(2)}},e,this)})),function(e){return l.apply(this,arguments)})},{key:"asyncTopic",value:(u=b(y().m(function e(t){var n,r;return y().w(function(e){for(;;)switch(e.n){case 0:return this.backupOptions=t,n=this.topics.value.findIndex(function(e){return e.id===t.id}),r=new Vn(t),-1!==n?this.topics.value.splice(n,1,r):this.topics.value=[].concat(c(this.topics.value),[r]),e.n=1,this.updateTopic(t);case 1:this.activedTopic.value=r;case 2:return e.a(2)}},e,this)})),function(e){return u.apply(this,arguments)})},{key:"getCurrentTopicByID",value:function(e){var t=this.topics.value.find(function(t){return t.id===e});return t&&t.data?new Vn(g({},t.data)):void 0}},{key:"updateTopicChatByID",value:(s=b(y().m(function e(t,n){var r;return y().w(function(e){for(;;)switch(e.n){case 0:if(t&&n&&this.backupOptions){e.n=1;break}return e.a(2);case 1:if(-1!==(r=this.topics.value.findIndex(function(e){return e.id===t}))&&this.topics.value[r].data.aiChat){e.n=2;break}return e.a(2);case 2:return this.topics.value[r].data.aiChat=g(g({},this.topics.value[r].data.aiChat),n),e.n=3,this.updateTopic(this.backupOptions);case 3:return e.a(2)}},e,this)})),function(e,t){return s.apply(this,arguments)})},{key:"removeTopic",value:(a=b(y().m(function e(t,n,r,i,o){var a,s,u,l,d;return y().w(function(e){for(;;)switch(e.n){case 0:if(s=!0,!t.beforeDelete){e.n=2;break}return e.n=1,t.beforeDelete(n,r,i,o);case 1:s=e.v;case 2:if(s){e.n=3;break}return e.a(2);case 3:if(u=!1,!i||!i.disableStorage){e.n=4;break}u=!0,e.n=12;break;case 4:if("LOCAL"!==this.resourceMode){e.n=6;break}return e.n=5,Se.deleteData(Cr.DATA_BASE_NAME,Cr.DATA_TABLE_NAME,i.id);case 5:u=e.v,e.n=12;break;case 6:if("REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=12;break}if(!i.realid){e.n=8;break}return e.n=7,this.resourceOptions.deleteSession(i.realid);case 7:u=e.v,e.n=12;break;case 8:if(!i.aiChat||!i.aiChat.sessionid){e.n=12;break}return e.n=9,this.resourceOptions.getSessionList({n_session_id_eq:i.aiChat.sessionid});case 9:if(!((l=e.v)&&l.length>0)){e.n=11;break}return e.n=10,this.resourceOptions.deleteSession(l[0].realid);case 10:u=e.v,e.n=12;break;case 11:u=!0;case 12:if(u){e.n=13;break}return e.a(2);case 13:return-1!==(d=this.topics.value.findIndex(function(e){return e.id===i.id}))&&(this.topics.value.splice(d,1),this.topics.value=c(this.topics.value)),e.n=14,this.updateTopic(t);case 14:this.topics.value.length>0&&i.id===(null===(a=this.activedTopic.value)||void 0===a?void 0:a.id)&&this.handleTopicChange(this.topics.value[0]);case 15:return e.a(2)}},e,this)})),function(e,t,n,r,i){return a.apply(this,arguments)})},{key:"handleTopicChange",value:function(e){var t;(null===(t=this.activedTopic.value)||void 0===t?void 0:t.id)!==e.id&&(this.activedTopic.value=e,this.chat.switchAiChatController(e))}},{key:"handleTopicAction",value:(o=b(y().m(function e(t,n,r){var i,o,a,s,u,l,d,h;return y().w(function(e){for(;;)switch(e.n){case 0:if(i=this.topics.value.find(function(e){return e.id===n.id}),!(this.backupOptions&&i&&i.aiChat)){e.n=10;break}s=i.aiChat,u=s.context,l=s.params,h=t,e.n="DELETE"===h?1:"RENAME"===h||"PINNED"===h?3:9;break;case 1:return e.n=2,this.removeTopic(this.backupOptions,u,l,i,r);case 2:return e.a(3,9);case 3:if("PINNED"===t&&(n.data.isTop=0===n.data.isTop?1:0,this.topics.value=c(this.topics.value)),!n||n.disableStorage){e.n=8;break}return e.n=4,this.updateTopic(this.backupOptions);case 4:if(!n||"REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=8;break}if(!n.realid){e.n=6;break}return e.n=5,this.resourceOptions.updateSession(n.realid,{caption:n.caption,is_top:n.isTop});case 5:e.n=8;break;case 6:if(!n.aiChat||!n.aiChat.sessionid){e.n=8;break}return e.n=7,this.resourceOptions.getSessionList({n_session_id_eq:n.aiChat.sessionid});case 7:if(!((d=e.v)&&d.length>0)){e.n=8;break}return e.n=8,this.resourceOptions.updateSession(d[0].realid,{caption:n.caption,is_top:n.isTop});case 8:return e.a(3,9);case 9:null===(o=(a=this.backupOptions).action)||void 0===o||o.call(a,t,u,l,n,r);case 10:return e.a(2)}},e,this)})),function(e,t,n){return o.apply(this,arguments)})},{key:"clearMessagesByTopicId",value:(i=b(y().m(function e(t){var n,r,i,o;return y().w(function(e){for(;;)switch(e.n){case 0:if(n=!0,t&&this.backupOptions){e.n=1;break}return e.a(2,n);case 1:if(-1!==(r=this.topics.value.findIndex(function(e){return e.id===t}))&&this.topics.value[r].data){e.n=2;break}return e.a(2,n);case 2:if(i=this.topics.value[r]){e.n=3;break}return e.a(2,n);case 3:if(!i.disableStorage){e.n=4;break}return e.a(2,n);case 4:if("REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=10;break}if(!i.realid){e.n=6;break}return e.n=5,this.resourceOptions.clearAllMessageBySessionId(i.realid);case 5:n=e.v,e.n=9;break;case 6:if(!i.aiChat||!i.aiChat.sessionid){e.n=9;break}return e.n=7,this.resourceOptions.getSessionList({n_session_id_eq:i.aiChat.sessionid});case 7:if(!((o=e.v)&&o.length>0)){e.n=9;break}return e.n=8,this.resourceOptions.clearAllMessageBySessionId(o[0].realid);case 8:n=e.v;case 9:if(n){e.n=10;break}return e.a(2,n);case 10:return e.a(2,n)}},e,this)})),function(e){return i.apply(this,arguments)})},{key:"newTopic",value:(r=b(y().m(function e(t,n){var r,i,o,a,s,u,l,d;return y().w(function(e){for(;;)switch(e.n){case 0:if(t){e.n=1;break}return e.a(2);case 1:if(r=this.getCurrentTopicByID(t)){e.n=2;break}return e.a(2);case 2:if(i=we(r.id),o=this.topics.value.filter(function(e){return e.id.startsWith(i)}),n&&r.aiChat&&(r.data.aiChat=g(g({},r.aiChat),n)),a="",a="default"===r.captionMode?"".concat(null===(s=r.sourceCaption)||void 0===s?void 0:s.split("_")[0],"_").concat(o.length):"新会话",u=Math.max.apply(Math,c(this.topics.value.map(function(e){return e.sequence}))),l={appid:r.appid,id:"".concat(i,"@").concat(Date.now()),type:r.type,captionMode:r.captionMode,captionFilled:!1,caption:a,sourceCaption:r.sourceCaption,url:r.url,aiChat:r.aiChat,sequence:u+1,isTop:0,disableStorage:r.disableStorage},d=new Vn(l),this.topics.value=[].concat(c(this.topics.value),[d]),!this.backupOptions){e.n=3;break}return e.n=3,this.updateTopic(this.backupOptions);case 3:this.handleTopicChange(d);case 4:return e.a(2)}},e,this)})),function(e,t){return r.apply(this,arguments)})},{key:"clearTopic",value:(n=b(y().m(function e(){var t,n,r,i,o,a=this;return y().w(function(e){for(;;)switch(e.n){case 0:if(t=this.topics.value.find(function(e){var t;return e.id===(null===(t=a.activedTopic.value)||void 0===t?void 0:t.id)}),this.backupOptions&&t){e.n=1;break}return e.a(2);case 1:if(n=!0,!this.backupOptions.beforeDelete){e.n=3;break}return e.n=2,this.backupOptions.beforeDelete(t.aiChat.context,t.aiChat.params,t,void 0,!0);case 2:n=e.v;case 3:if(n){e.n=4;break}return e.a(2);case 4:if(r=!1,"LOCAL"!==this.resourceMode){e.n=6;break}return e.n=5,Promise.all(this.topics.value.map(function(e){if(e.id!==(null==t?void 0:t.id)&&!e.disableStorage)return Se.deleteData(Cr.DATA_BASE_NAME,Cr.DATA_TABLE_NAME,e.id)}));case 5:r=!0,e.n=11;break;case 6:if("REMOTE"!==this.resourceMode){e.n=11;break}if(!t||!this.resourceOptions){e.n=10;break}if(!(o=null===(i=t.aiChat)||void 0===i?void 0:i.sessionid)){e.n=8;break}return e.n=7,this.resourceOptions.clearAllSession(o);case 7:r=e.v,e.n=9;break;case 8:r=!0;case 9:e.n=11;break;case 10:r=!0;case 11:if(r){e.n=12;break}return e.a(2);case 12:return this.topics.value=t?[t]:[],e.n=13,this.updateTopic(this.backupOptions);case 13:return e.a(2)}},e,this)})),function(){return n.apply(this,arguments)})},{key:"updateTopicCaption",value:(t=b(y().m(function e(t,n){var r,i,o;return y().w(function(e){for(;;)switch(e.n){case 0:if(!(r=this.topics.value.find(function(e){return e.id===t}))||r.captionFilled){e.n=10;break}if("default"===r.captionMode){e.n=3;break}o=r.captionMode,e.n="snippet"===o?1:2;break;case 1:return r.data.caption=n.substring(0,15),e.a(3,2);case 2:if(this.topics.value=c(this.topics.value),!this.backupOptions){e.n=3;break}return e.n=3,this.updateTopic(this.backupOptions);case 3:if(!r.disableStorage){e.n=4;break}return e.a(2);case 4:if("REMOTE"!==this.resourceMode||!this.resourceOptions){e.n=9;break}if(!r.realid){e.n=6;break}return e.n=5,this.resourceOptions.updateSession(r.realid,{caption:r.caption});case 5:e.n=9;break;case 6:if(!r.aiChat||!r.aiChat.sessionid){e.n=9;break}return e.n=7,this.resourceOptions.getSessionList({n_session_id_eq:r.aiChat.sessionid});case 7:if(!((i=e.v)&&i.length>0)){e.n=9;break}if(i[0].caption!==r.caption){e.n=8;break}return e.a(2);case 8:return e.n=9,this.resourceOptions.updateSession(i[0].realid,{caption:r.caption});case 9:r.data.captionFilled=!0;case 10:return e.a(2)}},e,this)})),function(e,n){return t.apply(this,arguments)})},{key:"updateTopic",value:(e=b(y().m(function e(t){var n,r;return y().w(function(e){for(;;)switch(e.n){case 0:if(t){e.n=1;break}return e.a(2);case 1:return n=[],this.topics.value.forEach(function(e){e.disableStorage||n.push({appid:e.appid,id:e.id,type:e.type,captionMode:e.captionMode,captionFilled:e.captionFilled,caption:e.caption||e.sourceCaption,sourceCaption:e.sourceCaption,url:e.url,aiChat:e.aiChat,isTop:e.isTop,sequence:e.sequence})}),r=t.configService(t.appid,"aitopics",t.type),e.n=2,null==r?void 0:r.save(n);case 2:return e.a(2)}},e,this)})),function(t){return e.apply(this,arguments)})}]);var e,t,n,r,i,o,a,s,u,l,d}(),Nr=S(function e(t){x(this,e),this.aiChat=t}),Er=function(e){function t(){return x(this,t),r(this,t,arguments)}return a(t,e),S(t,[{key:"excuteAction",value:(n=b(y().m(function e(t,n){var r,i,o,a;return y().w(function(e){for(;;)switch(e.n){case 0:if(!n||!n.onClick||"function"!=typeof n.onClick){e.n=2;break}return e.n=1,n.onClick(t,n,this.aiChat.context,this.aiChat.params);case 1:r=e.v,e.n=5;break;case 2:if(!(i=this.aiChat.opts.extendToolbarClick)){e.n=4;break}return e.n=3,i(t,n,this.aiChat.context,this.aiChat.params,{});case 3:r=e.v,e.n=5;break;case 4:console.error("未找到扩展工具栏点击事件");case 5:r&&r.data&&r.data.length>0&&(o=r.data[0],a={id:o.id,type:o.type,data:o.data||{},metadata:o.metadata||{}},n.id&&Object.assign(a.metadata,{actionId:n.id}),this.aiChat.addMaterial(a));case 6:return e.a(2)}},e,this)})),function(e,t){return n.apply(this,arguments)})}]);var n}(Nr),Ar=function(e){function t(){return x(this,t),r(this,t,arguments)}return a(t,e),S(t,[{key:"excuteAction",value:(n=b(y().m(function e(t,n){var r,i,o,a,s,c,u,l,d,h,f=this;return y().w(function(e){for(;;)switch(e.n){case 0:r=this.aiChat.opts.uploader,i=r.multiple,o=r.accept,a=r.maxSize,s=r.onSelect,c=r.onUpload,u=r.onSuccess,l=r.onError,d=r.onProgress,h={multiple:i||!0,accept:o||"*/*",maxSize:a||5242880,onSelect:function(e){null==s||s(e),e.length>0&&e.forEach(function(e){var t=f.buildMaterialObject(e);Object.assign(t.metadata,{state:"uploading"}),f.aiChat.addMaterial(t)})},onUpload:function(){var e=b(y().m(function e(t,n){return y().w(function(e){for(;;)if(0===e.n)return e.a(2,c(t,n,{context:f.aiChat.context,params:f.aiChat.params}))},e)}));return function(t,n){return e.apply(this,arguments)}}(),onSuccess:function(e,t){var n={id:e.id,type:"ossfile",data:{id:e.id,name:e.name},metadata:{ext:e.ext,fileext:e.fileext,fileid:e.fileid,filename:e.filename,size:e.size,filesize:e.filesize,state:"successed"}};f.aiChat.replaceMaterial(t.name,n),null==u||u(e,t)},onError:function(e,t){var n=f.buildMaterialObject(t);Object.assign(n.metadata,{state:"failed"}),f.aiChat.replaceMaterial(t.name,n),null==l||l(e,t)},onProgress:function(e,t){null==d||d(e,t)}},new _e(h).openFilePicker();case 1:return e.a(2)}},e,this)})),function(e,t){return n.apply(this,arguments)})},{key:"buildMaterialObject",value:function(e){return{id:e.name,type:"ossfile",data:{name:e.name,id:e.name},metadata:{size:e.size,type:e.type,lastModified:e.lastModified}}}}]);var n}(Nr),Dr=function(){return S(function e(){x(this,e)},null,[{key:"getMaterialHelper",value:function(e,t){return"ossfile"===e?new Ar(t):new Er(t)}}])}(),Ir=function(){return S(function e(){x(this,e),_(this,"container",void 0),_(this,"mode","DEFAULT"),_(this,"resourceOptions",void 0),_(this,"backupChatOptions",void 0),_(this,"aiTopic",void 0),_(this,"aiTopicMap",new Map),this.aiTopic=new Or(this)},[{key:"aiChat",get:function(){var e;return this.aiTopicMap.get("".concat(null===(e=this.aiTopic.activedTopic.value)||void 0===e?void 0:e.id))}},{key:"initIndexDB",value:(t=b(y().m(function e(){return y().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,Se.checkTableExists(Cr.DATA_BASE_NAME,Cr.DATA_TABLE_NAME);case 1:if(e.v){e.n=2;break}return e.n=2,Se.createTable(Cr.DATA_BASE_NAME,Cr.DATA_TABLE_NAME,Cr.DATA_TABLE_KEY_NAME,!1);case 2:return e.a(2)}},e)})),function(){return t.apply(this,arguments)})},{key:"create",value:(e=b(y().m(function e(t){var n,r,i,o,a,s,c,u,l,d,h=this;return y().w(function(e){for(;;)switch(e.n){case 0:if(this.resourceOptions=t.resourceOptions,"LOCAL"!==((null===(n=t.resourceOptions)||void 0===n?void 0:n.resourceMode)||"LOCAL")){e.n=1;break}return e.n=1,this.initIndexDB();case 1:if(this.backupChatOptions=t,this.close(),this.container=document.createElement("div"),this.container.classList.add("ibiz-ai-chat"),document.body.appendChild(this.container),u=t.chatOptions,!t.mode||"TOPIC"!==t.mode){e.n=4;break}return this.aiTopic.injectResourceOptions(t.resourceOptions),e.n=2,this.aiTopic.fetchHistory(t.topicOptions);case 2:return l=t.topicOptions,Object.assign(l,{aiChat:{caption:u.caption,context:u.context,params:u.params,appDataEntityId:u.appDataEntityId,sessionid:u.sessionid,contentToolbarItems:u.contentToolbarItems,footerToolbarItems:u.footerToolbarItems,questionToolbarItems:u.questionToolbarItems,otherToolbarItems:u.otherToolbarItems,appendCurData:u.appendCurData,appendCurContent:u.appendCurContent,enableAIAgentChange:u.enableAIAgentChange,activeAIAgentID:u.activeAIAgentID,aiAgentlist:u.aiAgentlist,srfMode:u.srfMode,appendCurResource:u.appendCurResource}}),this.syncHistoryOptions(l,u,t.resourceOptions),e.n=3,this.aiTopic.asyncTopic(l);case 3:e.n=5;break;case 4:this.aiTopic.activedTopic.value=void 0;case 5:return Object.assign(u,{topicId:null===(r=l)||void 0===r?void 0:r.id,topic:l,aiTopic:this.aiTopic}),d=new Tr(u,this.resourceOptions),this.aiTopicMap.set("".concat(null===(i=l)||void 0===i?void 0:i.id),d),le($(jf,{aiChat:d,aiTopic:this.aiTopic,mode:t.mode?t.mode:"DEFAULT",containerOptions:t.containerOptions,caption:t.mode&&"TOPIC"===t.mode?"AI助手":u.caption,enableBackFill:null===(o=t.containerOptions)||void 0===o?void 0:o.enableBackFill,contentToolbarItems:u.contentToolbarItems,footerToolbarItems:u.footerToolbarItems,questionToolbarItems:u.questionToolbarItems,autoClose:null===(a=t.containerOptions)||void 0===a?void 0:a.autoClose,openMode:null===(s=t.containerOptions)||void 0===s?void 0:s.openMode,hideTopicSidebar:(null===(c=t.topicOptions)||void 0===c?void 0:c.hideTopicSidebar)||!1,close:function(){h.close(),u.closed&&u.closed(u.context,u.params,d.getAllMessages())},fullscreen:function(e){u.fullscreen&&u.fullscreen(e,u.context,u.params)},minimize:function(e){u.minimize&&u.minimize(e,u.context,u.params)}}),this.container),e.a(2,d)}},e,this)})),function(t){return e.apply(this,arguments)})},{key:"syncHistoryOptions",value:function(e,t,n){if(e.disableStorage){var r=function(e,t){var n="";switch(e){case"TOPIC":n+="topic";break;case"INLINE":n+="inline";break;case"TEMP":n+="temp";break;default:n+="unknow"}return n+"@".concat(t||ke(),"@").concat((new Date).getTime())}("TEMP");return t.sessionid=r,e.aiChat.sessionid=r,e.caption="临时会话",e.sourceCaption="临时会话",void(e.captionFilled=!0)}var i=this.aiTopic.getCurrentTopicByID(e.id);if(i&&(e.sequence=i.sequence,e.isTop=i.isTop),i&&i.aiChat&&i.aiChat.activeAIAgentID)t.activeAIAgentID=i.aiChat.activeAIAgentID,e.aiChat.activeAIAgentID=i.aiChat.activeAIAgentID;else if(t.aiAgentlist&&t.aiAgentlist.length>0&&!t.activeAIAgentID){var o=t.aiAgentlist.find(function(e){return 1===e.default});o?(t.activeAIAgentID=o.id,e.aiChat.activeAIAgentID=o.id):(t.activeAIAgentID=t.aiAgentlist[0].id,e.aiChat.activeAIAgentID=t.aiAgentlist[0].id)}i&&i.aiChat&&i.aiChat.sessionid&&(t.sessionid=i.aiChat.sessionid,e.aiChat.sessionid=i.aiChat.sessionid);var a=n.resourceMode;"LOCAL"===a?"default"!==e.captionMode?(e.sourceCaption="新会话",i&&i.captionFilled&&i.caption?(e.captionFilled=i.captionFilled,e.caption=i.caption):e.caption="新会话"):(e.sourceCaption=e.caption,e.captionFilled=!0):"REMOTE"===a&&(e.sourceCaption=e.caption,i&&i.caption&&(e.caption=i.caption),e.captionFilled=!1),"REMOTE"===a&&i&&i.realid&&(e.realid=i.realid)}},{key:"switchAiChatController",value:function(e){var t=this,n=g({},this.backupChatOptions.chatOptions);e.aiChat&&Object.assign(n,{caption:e.aiChat.caption,context:e.aiChat.context,params:e.aiChat.params,sessionid:e.aiChat.sessionid,contentToolbarItems:e.aiChat.contentToolbarItems,footerToolbarItems:e.aiChat.footerToolbarItems,questionToolbarItems:e.aiChat.questionToolbarItems,otherToolbarItems:e.aiChat.otherToolbarItems,appendCurData:e.aiChat.appendCurData,appendCurContent:e.aiChat.appendCurContent,aiAgentlist:e.aiChat.aiAgentlist,activeAIAgentID:e.aiChat.activeAIAgentID,enableAIAgentChange:e.aiChat.enableAIAgentChange,srfMode:e.aiChat.srfMode,appendCurResource:e.aiChat.appendCurResource,appDataEntityId:e.aiChat.appDataEntityId,topicId:e.id,topic:e,aiTopic:this.aiTopic,extendToolbarClick:this.backupChatOptions.chatOptions.extendToolbarClick,recommendPrompt:this.backupChatOptions.chatOptions.recommendPrompt});var r,i,o,a,s,c,u,l=new Tr(n,this.resourceOptions);(this.aiTopicMap.set("".concat(e.id),l),this.container)&&(le(null,this.container),le($(jf,{aiChat:l,aiTopic:this.aiTopic,mode:null!==(r=this.backupChatOptions)&&void 0!==r&&r.mode?this.backupChatOptions.mode:"DEFAULT",containerOptions:null===(i=this.backupChatOptions)||void 0===i?void 0:i.containerOptions,caption:null!==(o=this.backupChatOptions)&&void 0!==o&&o.mode&&"TOPIC"===this.backupChatOptions.mode?"AI助手":n.caption,enableBackFill:null===(a=this.backupChatOptions)||void 0===a||null===(a=a.containerOptions)||void 0===a?void 0:a.enableBackFill,contentToolbarItems:n.contentToolbarItems,footerToolbarItems:n.footerToolbarItems,questionToolbarItems:n.questionToolbarItems,autoClose:null===(s=this.backupChatOptions)||void 0===s||null===(s=s.containerOptions)||void 0===s?void 0:s.autoClose,openMode:null===(c=this.backupChatOptions)||void 0===c||null===(c=c.containerOptions)||void 0===c?void 0:c.openMode,hideTopicSidebar:(null===(u=this.backupChatOptions)||void 0===u||null===(u=u.topicOptions)||void 0===u?void 0:u.hideTopicSidebar)||!1,close:function(){t.close(),n.closed&&n.closed(n.context,n.params,l.getAllMessages())},fullscreen:function(e){n.fullscreen&&n.fullscreen(e,n.context,n.params)},minimize:function(e){n.minimize&&n.minimize(e,n.context,n.params)}}),this.container))}},{key:"hidden",value:function(){this.container&&(this.container.style.display="none")}},{key:"show",value:function(){this.container&&(this.container.style.display="flex")}},{key:"close",value:function(){this.container&&(le(null,this.container),this.container.remove(),this.container=void 0),this.aiTopicMap.forEach(function(e){e.destroyed()})}}]);var e,t}(),zr=(t("chat",new Ir),new pe("chat-input-material")),Rr=function(e){var t=e.controller.materials;return he("div",{className:zr.b(),children:t.value.map(function(t){return he(Nn,{material:t,disabled:!1,controller:e.controller},t.id)})})},Pr=function(e){var t=e.children,n=e.actions,r=e.content,i=e.position,o=void 0===i?"bottom":i,a=e.isOpen,s=e.onToggleOpen,c=e.onAction,u=new pe("pop"),l=Ge($f),h=d(qe(a||!1),2),f=h[0],p=h[1],v=Je(null),m=Je(null);Ue(function(){void 0!==a&&p(a)},[a]),Ue(function(){return m.current||(m.current=document.createElement("div"),m.current.className=u.b("content-container"),document.body.appendChild(m.current)),function(){m.current&&document.body.removeChild(m.current)}},[]),Ue(function(){var e=function(e){!v.current||v.current.contains(e.target)||e.target.closest(".".concat(u.b()))||e.target.closest(".ibiz-quick-edit")||e.target.closest(".ibiz-picker__transfer")||(p(!1),null==s||s(!1))};return f&&document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}},[f,s]);return he("span",{className:"".concat(u.b("trigger-container")),children:[he("span",{className:"".concat(u.b("trigger-element")),ref:v,onClick:function(e){e.stopPropagation();var t=!f;p(t),null==s||s(t)},children:t}),f&&m.current&&cr(he("div",{className:"".concat(u.b()," pop-").concat(o),style:function(){if(!v.current)return{};var e=v.current.getBoundingClientRect(),t={position:"absolute",zIndex:l.zIndex+1},n={bottom:{top:e.bottom+window.scrollY,left:e.left+window.scrollX},top:{bottom:window.innerHeight-e.top+window.scrollY,left:e.left+window.scrollX},left:{top:e.top+window.scrollY,right:window.innerWidth-e.left+window.scrollX},right:{top:e.top+window.scrollY,left:e.right+window.scrollX},"top-left":{bottom:window.innerHeight-e.top+window.scrollY,right:window.innerWidth-e.left+window.scrollX}};return g(g({},t),n[o])}(),children:r||(null==n?void 0:n.map(function(e){return he("div",{title:e.caption,className:u.e("item"),onMouseDown:function(t){t.stopPropagation(),null==c||c(e.id,t)},children:[e.icon,he("div",{className:u.em("item","caption"),children:e.caption})]},e.id)}))}),m.current)]})};function Lr(e){this.content=e}function Br(e,t,n){for(var r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;var i=e.child(r),o=t.child(r);if(i!=o){if(!i.sameMarkup(o))return n;if(i.isText&&i.text!=o.text){for(var a=0;i.text[a]==o.text[a];a++)n++;return n}if(i.content.size||o.content.size){var s=Br(i.content,o.content,n+1);if(null!=s)return s}n+=i.nodeSize}else n+=i.nodeSize}}function Vr(e,t,n,r){for(var i=e.childCount,o=t.childCount;;){if(0==i||0==o)return i==o?null:{a:n,b:r};var a=e.child(--i),s=t.child(--o),c=a.nodeSize;if(a!=s){if(!a.sameMarkup(s))return{a:n,b:r};if(a.isText&&a.text!=s.text){for(var u=0,l=Math.min(a.text.length,s.text.length);u<l&&a.text[a.text.length-u-1]==s.text[s.text.length-u-1];)u++,n--,r--;return{a:n,b:r}}if(a.content.size||s.content.size){var d=Vr(a.content,s.content,n-1,r-1);if(d)return d}n-=c,r-=c}else n-=c,r-=c}}Lr.prototype={constructor:Lr,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return-1==t?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),o=r.content.slice();return-1==i?o.push(n||e,t):(o[i+1]=t,n&&(o[i]=n)),new Lr(o)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new Lr(n)},addToStart:function(e,t){return new Lr([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new Lr(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),o=r.find(e);return i.splice(-1==o?i.length:o,0,t,n),new Lr(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=Lr.from(e)).size?new Lr(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=Lr.from(e)).size?new Lr(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=Lr.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},Lr.from=function(e){if(e instanceof Lr)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new Lr(t)};var Fr=function(){function e(t,n){if(x(this,e),this.content=t,this.size=n||0,null==n)for(var r=0;r<t.length;r++)this.size+=t[r].nodeSize}return S(e,[{key:"nodesBetween",value:function(e,t,n){for(var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4?arguments[4]:void 0,o=0,a=0;a<t;o++){var s=this.content[o],c=a+s.nodeSize;if(c>e&&!1!==n(s,r+a,i||null,o)&&s.content.size){var u=a+1;s.nodesBetween(Math.max(0,e-u),Math.min(s.content.size,t-u),n,r+u)}a=c}}},{key:"descendants",value:function(e){this.nodesBetween(0,this.size,e)}},{key:"textBetween",value:function(e,t,n,r){var i="",o=!0;return this.nodesBetween(e,t,function(a,s){var c=a.isText?a.text.slice(Math.max(e,s)-s,t-s):a.isLeaf?r?"function"==typeof r?r(a):r:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&c||a.isTextblock)&&n&&(o?o=!1:i+=n),i+=c},0),i}},{key:"append",value:function(t){if(!t.size)return this;if(!this.size)return t;var n=this.lastChild,r=t.firstChild,i=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),o=1);o<t.content.length;o++)i.push(t.content[o]);return new e(i,this.size+t.size)}},{key:"cut",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.size;if(0==t&&n==this.size)return this;var r=[],i=0;if(n>t)for(var o=0,a=0;a<n;o++){var s=this.content[o],c=a+s.nodeSize;c>t&&((a<t||c>n)&&(s=s.isText?s.cut(Math.max(0,t-a),Math.min(s.text.length,n-a)):s.cut(Math.max(0,t-a-1),Math.min(s.content.size,n-a-1))),r.push(s),i+=s.nodeSize),a=c}return new e(r,i)}},{key:"cutByIndex",value:function(t,n){return t==n?e.empty:0==t&&n==this.content.length?this:new e(this.content.slice(t,n))}},{key:"replaceChild",value:function(t,n){var r=this.content[t];if(r==n)return this;var i=this.content.slice(),o=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,o)}},{key:"addToStart",value:function(t){return new e([t].concat(this.content),this.size+t.nodeSize)}},{key:"addToEnd",value:function(t){return new e(this.content.concat(t),this.size+t.nodeSize)}},{key:"eq",value:function(e){if(this.content.length!=e.content.length)return!1;for(var t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}},{key:"firstChild",get:function(){return this.content.length?this.content[0]:null}},{key:"lastChild",get:function(){return this.content.length?this.content[this.content.length-1]:null}},{key:"childCount",get:function(){return this.content.length}},{key:"child",value:function(e){var t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}},{key:"maybeChild",value:function(e){return this.content[e]||null}},{key:"forEach",value:function(e){for(var t=0,n=0;t<this.content.length;t++){var r=this.content[t];e(r,n,t),n+=r.nodeSize}}},{key:"findDiffStart",value:function(e){return Br(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0)}},{key:"findDiffEnd",value:function(e){return Vr(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.size,arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.size)}},{key:"findIndex",value:function(e){if(0==e)return jr(0,e);if(e==this.size)return jr(this.content.length,e);if(e>this.size||e<0)throw new RangeError("Position ".concat(e," outside of fragment (").concat(this,")"));for(var t=0,n=0;;t++){var r=n+this.child(t).nodeSize;if(r>=e)return r==e?jr(t+1,r):jr(t,n);n=r}}},{key:"toString",value:function(){return"<"+this.toStringInner()+">"}},{key:"toStringInner",value:function(){return this.content.join(", ")}},{key:"toJSON",value:function(){return this.content.length?this.content.map(function(e){return e.toJSON()}):null}}],[{key:"fromJSON",value:function(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new e(n.map(t.nodeFromJSON))}},{key:"fromArray",value:function(t){if(!t.length)return e.empty;for(var n,r=0,i=0;i<t.length;i++){var o=t[i];r+=o.nodeSize,i&&o.isText&&t[i-1].sameMarkup(o)?(n||(n=t.slice(0,i)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new e(n||t,r)}},{key:"from",value:function(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}])}();Fr.empty=new Fr([],0);var $r={index:0,offset:0};function jr(e,t){return $r.index=e,$r.offset=t,$r}function Hr(e,t){if(e===t)return!0;if(!e||"object"!=T(e)||!t||"object"!=T(t))return!1;var n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(var r=0;r<e.length;r++)if(!Hr(e[r],t[r]))return!1}else{for(var i in e)if(!(i in t)||!Hr(e[i],t[i]))return!1;for(var o in t)if(!(o in e))return!1}return!0}var Wr=function(){function e(t,n){x(this,e),this.type=t,this.attrs=n}return S(e,[{key:"addToSet",value:function(e){for(var t,n=!1,r=0;r<e.length;r++){var i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,r));else{if(i.type.excludes(this.type))return e;!n&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(i)}}return t||(t=e.slice()),n||t.push(this),t}},{key:"removeFromSet",value:function(e){for(var t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}},{key:"isInSet",value:function(e){for(var t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}},{key:"eq",value:function(e){return this==e||this.type==e.type&&Hr(this.attrs,e.attrs)}},{key:"toJSON",value:function(){var e={type:this.type.name};for(var t in this.attrs){e.attrs=this.attrs;break}return e}}],[{key:"fromJSON",value:function(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");var n=e.marks[t.type];if(!n)throw new RangeError("There is no mark type ".concat(t.type," in this schema"));var r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}},{key:"sameSet",value:function(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}},{key:"setFrom",value:function(t){if(!t||Array.isArray(t)&&0==t.length)return e.none;if(t instanceof e)return[t];var n=t.slice();return n.sort(function(e,t){return e.type.rank-t.type.rank}),n}}])}();Wr.none=[];var qr=function(e){function t(){return x(this,t),r(this,t,arguments)}return a(t,e),S(t)}(n(Error)),Ur=function(){function e(t,n,r){x(this,e),this.content=t,this.openStart=n,this.openEnd=r}return S(e,[{key:"size",get:function(){return this.content.size-this.openStart-this.openEnd}},{key:"insertAt",value:function(t,n){var r=Kr(this.content,t+this.openStart,n);return r&&new e(r,this.openStart,this.openEnd)}},{key:"removeBetween",value:function(t,n){return new e(Jr(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}},{key:"eq",value:function(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}},{key:"toString",value:function(){return this.content+"("+this.openStart+","+this.openEnd+")"}},{key:"toJSON",value:function(){if(!this.content.size)return null;var e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}}],[{key:"fromJSON",value:function(t,n){if(!n)return e.empty;var r=n.openStart||0,i=n.openEnd||0;if("number"!=typeof r||"number"!=typeof i)throw new RangeError("Invalid input for Slice.fromJSON");return new e(Fr.fromJSON(t,n.content),r,i)}},{key:"maxOpen",value:function(t){for(var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=0,i=0,o=t.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)r++;for(var a=t.lastChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.lastChild)i++;return new e(t,r,i)}}])}();function Jr(e,t,n){var r=e.findIndex(t),i=r.index,o=r.offset,a=e.maybeChild(i),s=e.findIndex(n),c=s.index,u=s.offset;if(o==t||a.isText){if(u!=n&&!e.child(c).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(i!=c)throw new RangeError("Removing non-flat range");return e.replaceChild(i,a.copy(Jr(a.content,t-o-1,n-o-1)))}function Kr(e,t,n,r){var i=e.findIndex(t),o=i.index,a=i.offset,s=e.maybeChild(o);if(a==t||s.isText)return r&&!r.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));var c=Kr(s.content,t-a-1,n,s);return c&&e.replaceChild(o,s.copy(c))}function Yr(e,t,n){if(n.openStart>e.depth)throw new qr("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new qr("Inconsistent open depths");return Gr(e,t,n,0)}function Gr(e,t,n,r){var i=e.index(r),o=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){var a=Gr(e,t,n,r+1);return o.copy(o.content.replaceChild(i,a))}if(n.content.size){if(n.openStart||n.openEnd||e.depth!=r||t.depth!=r){var s=function(e,t){for(var n=t.depth-e.openStart,r=t.node(n).copy(e.content),i=n-1;i>=0;i--)r=t.node(i).copy(Fr.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}(n,e);return ti(o,ni(e,s.start,s.end,t,r))}var c=e.parent,u=c.content;return ti(c,u.cut(0,e.parentOffset).append(n.content).append(u.cut(t.parentOffset)))}return ti(o,ri(e,t,r))}function Xr(e,t){if(!t.type.compatibleContent(e.type))throw new qr("Cannot join "+t.type.name+" onto "+e.type.name)}function Zr(e,t,n){var r=e.node(n);return Xr(r,t.node(n)),r}function Qr(e,t){var n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function ei(e,t,n,r){var i=(t||e).node(n),o=0,a=t?t.index(n):i.childCount;e&&(o=e.index(n),e.depth>n?o++:e.textOffset&&(Qr(e.nodeAfter,r),o++));for(var s=o;s<a;s++)Qr(i.child(s),r);t&&t.depth==n&&t.textOffset&&Qr(t.nodeBefore,r)}function ti(e,t){return e.type.checkContent(t),e.copy(t)}function ni(e,t,n,r,i){var o=e.depth>i&&Zr(e,t,i+1),a=r.depth>i&&Zr(n,r,i+1),s=[];return ei(null,e,i,s),o&&a&&t.index(i)==n.index(i)?(Xr(o,a),Qr(ti(o,ni(e,t,n,r,i+1)),s)):(o&&Qr(ti(o,ri(e,t,i+1)),s),ei(t,n,i,s),a&&Qr(ti(a,ri(n,r,i+1)),s)),ei(r,null,i,s),new Fr(s)}function ri(e,t,n){var r=[];(ei(null,e,n,r),e.depth>n)&&Qr(ti(Zr(e,t,n+1),ri(e,t,n+1)),r);return ei(t,null,n,r),new Fr(r)}Ur.empty=new Ur(Fr.empty,0,0);var ii=function(){function e(t,n,r){x(this,e),this.pos=t,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}return S(e,[{key:"resolveDepth",value:function(e){return null==e?this.depth:e<0?this.depth+e:e}},{key:"parent",get:function(){return this.node(this.depth)}},{key:"doc",get:function(){return this.node(0)}},{key:"node",value:function(e){return this.path[3*this.resolveDepth(e)]}},{key:"index",value:function(e){return this.path[3*this.resolveDepth(e)+1]}},{key:"indexAfter",value:function(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}},{key:"start",value:function(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}},{key:"end",value:function(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}},{key:"before",value:function(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}},{key:"after",value:function(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}},{key:"textOffset",get:function(){return this.pos-this.path[this.path.length-1]}},{key:"nodeAfter",get:function(){var e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;var n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}},{key:"nodeBefore",get:function(){var e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}},{key:"posAtIndex",value:function(e,t){t=this.resolveDepth(t);for(var n=this.path[3*t],r=0==t?0:this.path[3*t-1]+1,i=0;i<e;i++)r+=n.child(i).nodeSize;return r}},{key:"marks",value:function(){var e=this.parent,t=this.index();if(0==e.content.size)return Wr.none;if(this.textOffset)return e.child(t).marks;var n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){var i=n;n=r,r=i}for(var o=n.marks,a=0;a<o.length;a++)!1!==o[a].type.spec.inclusive||r&&o[a].isInSet(r.marks)||(o=o[a--].removeFromSet(o));return o}},{key:"marksAcross",value:function(e){var t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;for(var n=t.marks,r=e.parent.maybeChild(e.index()),i=0;i<n.length;i++)!1!==n[i].type.spec.inclusive||r&&n[i].isInSet(r.marks)||(n=n[i--].removeFromSet(n));return n}},{key:"sharedDepth",value:function(e){for(var t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}},{key:"blockRange",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this,t=arguments.length>1?arguments[1]:void 0;if(e.pos<this.pos)return e.blockRange(this);for(var n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new ci(this,e,n);return null}},{key:"sameParent",value:function(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}},{key:"max",value:function(e){return e.pos>this.pos?e:this}},{key:"min",value:function(e){return e.pos<this.pos?e:this}},{key:"toString",value:function(){for(var e="",t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}}],[{key:"resolve",value:function(t,n){if(!(n>=0&&n<=t.content.size))throw new RangeError("Position "+n+" out of range");for(var r=[],i=0,o=n,a=t;;){var s=a.content.findIndex(o),c=s.index,u=s.offset,l=o-u;if(r.push(a,c,i+u),!l)break;if((a=a.child(c)).isText)break;o=l-1,i+=u+1}return new e(n,r,o)}},{key:"resolveCached",value:function(t,n){var r=si.get(t);if(r)for(var i=0;i<r.elts.length;i++){var o=r.elts[i];if(o.pos==n)return o}else si.set(t,r=new oi);var a=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%ai,a}}])}(),oi=S(function e(){x(this,e),this.elts=[],this.i=0}),ai=12,si=new WeakMap,ci=function(){return S(function e(t,n,r){x(this,e),this.$from=t,this.$to=n,this.depth=r},[{key:"start",get:function(){return this.$from.before(this.depth+1)}},{key:"end",get:function(){return this.$to.after(this.depth+1)}},{key:"parent",get:function(){return this.$from.node(this.depth)}},{key:"startIndex",get:function(){return this.$from.index(this.depth)}},{key:"endIndex",get:function(){return this.$to.indexAfter(this.depth)}}])}(),ui=Object.create(null),li=function(){function e(t,n,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Wr.none;x(this,e),this.type=t,this.attrs=n,this.marks=i,this.content=r||Fr.empty}return S(e,[{key:"children",get:function(){return this.content.content}},{key:"nodeSize",get:function(){return this.isLeaf?1:2+this.content.size}},{key:"childCount",get:function(){return this.content.childCount}},{key:"child",value:function(e){return this.content.child(e)}},{key:"maybeChild",value:function(e){return this.content.maybeChild(e)}},{key:"forEach",value:function(e){this.content.forEach(e)}},{key:"nodesBetween",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;this.content.nodesBetween(e,t,n,r,this)}},{key:"descendants",value:function(e){this.nodesBetween(0,this.content.size,e)}},{key:"textContent",get:function(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}},{key:"textBetween",value:function(e,t,n,r){return this.content.textBetween(e,t,n,r)}},{key:"firstChild",get:function(){return this.content.firstChild}},{key:"lastChild",get:function(){return this.content.lastChild}},{key:"eq",value:function(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}},{key:"sameMarkup",value:function(e){return this.hasMarkup(e.type,e.attrs,e.marks)}},{key:"hasMarkup",value:function(e,t,n){return this.type==e&&Hr(this.attrs,t||e.defaultAttrs||ui)&&Wr.sameSet(this.marks,n||Wr.none)}},{key:"copy",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}},{key:"mark",value:function(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}},{key:"cut",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.content.size;return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}},{key:"slice",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.content.size,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e==t)return Ur.empty;var r=this.resolve(e),i=this.resolve(t),o=n?0:r.sharedDepth(t),a=r.start(o),s=r.node(o).content.cut(r.pos-a,i.pos-a);return new Ur(s,r.depth-o,i.depth-o)}},{key:"replace",value:function(e,t,n){return Yr(this.resolve(e),this.resolve(t),n)}},{key:"nodeAt",value:function(e){for(var t=this;;){var n=t.content.findIndex(e),r=n.index,i=n.offset;if(!(t=t.maybeChild(r)))return null;if(i==e||t.isText)return t;e-=i+1}}},{key:"childAfter",value:function(e){var t=this.content.findIndex(e),n=t.index,r=t.offset;return{node:this.content.maybeChild(n),index:n,offset:r}}},{key:"childBefore",value:function(e){if(0==e)return{node:null,index:0,offset:0};var t=this.content.findIndex(e),n=t.index,r=t.offset;if(r<e)return{node:this.content.child(n),index:n,offset:r};var i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}},{key:"resolve",value:function(e){return ii.resolveCached(this,e)}},{key:"resolveNoCache",value:function(e){return ii.resolve(this,e)}},{key:"rangeHasMark",value:function(e,t,n){var r=!1;return t>e&&this.nodesBetween(e,t,function(e){return n.isInSet(e.marks)&&(r=!0),!r}),r}},{key:"isBlock",get:function(){return this.type.isBlock}},{key:"isTextblock",get:function(){return this.type.isTextblock}},{key:"inlineContent",get:function(){return this.type.inlineContent}},{key:"isInline",get:function(){return this.type.isInline}},{key:"isText",get:function(){return this.type.isText}},{key:"isLeaf",get:function(){return this.type.isLeaf}},{key:"isAtom",get:function(){return this.type.isAtom}},{key:"toString",value:function(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);var e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),hi(this.marks,e)}},{key:"contentMatchAt",value:function(e){var t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}},{key:"canReplace",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Fr.empty,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:n.childCount,o=this.contentMatchAt(e).matchFragment(n,r,i),a=o&&o.matchFragment(this.content,t);if(!a||!a.validEnd)return!1;for(var s=r;s<i;s++)if(!this.type.allowsMarks(n.child(s).marks))return!1;return!0}},{key:"canReplaceWith",value:function(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;var i=this.contentMatchAt(e).matchType(n),o=i&&i.matchFragment(this.content,t);return!!o&&o.validEnd}},{key:"canAppend",value:function(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}},{key:"check",value:function(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);for(var e=Wr.none,t=0;t<this.marks.length;t++){var n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!Wr.sameSet(e,this.marks))throw new RangeError("Invalid collection of marks for node ".concat(this.type.name,": ").concat(this.marks.map(function(e){return e.type.name})));this.content.forEach(function(e){return e.check()})}},{key:"toJSON",value:function(){var e={type:this.type.name};for(var t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(function(e){return e.toJSON()})),e}}],[{key:"fromJSON",value:function(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");var n=void 0;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}var r=Fr.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}}])}();li.prototype.text=void 0;var di=function(t){function n(e,t,i,o){var a;if(x(this,n),a=r(this,n,[e,t,null,o]),!i)throw new RangeError("Empty text nodes are not allowed");return a.text=i,a}return a(n,t),S(n,[{key:"toString",value:function(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):hi(this.marks,JSON.stringify(this.text))}},{key:"textContent",get:function(){return this.text}},{key:"textBetween",value:function(e,t){return this.text.slice(e,t)}},{key:"nodeSize",get:function(){return this.text.length}},{key:"mark",value:function(e){return e==this.marks?this:new n(this.type,this.attrs,this.text,e)}},{key:"withText",value:function(e){return e==this.text?this:new n(this.type,this.attrs,e,this.marks)}},{key:"cut",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.text.length;return 0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))}},{key:"eq",value:function(e){return this.sameMarkup(e)&&this.text==e.text}},{key:"toJSON",value:function(){var t=e(n,"toJSON",this,3)([]);return t.text=this.text,t}}])}(li);function hi(e,t){for(var n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}var fi=function(){function e(t){x(this,e),this.validEnd=t,this.next=[],this.wrapCache=[]}return S(e,[{key:"matchType",value:function(e){for(var t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}},{key:"matchFragment",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.childCount,r=this,i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}},{key:"inlineContent",get:function(){return 0!=this.next.length&&this.next[0].type.isInline}},{key:"defaultType",get:function(){for(var e=0;e<this.next.length;e++){var t=this.next[e].type;if(!t.isText&&!t.hasRequiredAttrs())return t}return null}},{key:"compatible",value:function(e){for(var t=0;t<this.next.length;t++)for(var n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}},{key:"fillBefore",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=[this];return function i(o,a){var s=o.matchFragment(e,n);if(s&&(!t||s.validEnd))return Fr.from(a.map(function(e){return e.createAndFill()}));for(var c=0;c<o.next.length;c++){var u=o.next[c],l=u.type,d=u.next;if(!l.isText&&!l.hasRequiredAttrs()&&-1==r.indexOf(d)){r.push(d);var h=i(d,a.concat(l));if(h)return h}}return null}(this,[])}},{key:"findWrapping",value:function(e){for(var t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];var n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}},{key:"computeWrapping",value:function(e){for(var t=Object.create(null),n=[{match:this,type:null,via:null}];n.length;){var r=n.shift(),i=r.match;if(i.matchType(e)){for(var o=[],a=r;a.type;a=a.via)o.push(a.type);return o.reverse()}for(var s=0;s<i.next.length;s++){var c=i.next[s],u=c.type,l=c.next;u.isLeaf||u.hasRequiredAttrs()||u.name in t||r.type&&!l.validEnd||(n.push({match:u.contentMatch,type:u,via:r}),t[u.name]=!0)}}return null}},{key:"edgeCount",get:function(){return this.next.length}},{key:"edge",value:function(e){if(e>=this.next.length)throw new RangeError("There's no ".concat(e,"th edge in this content match"));return this.next[e]}},{key:"toString",value:function(){var e=[];return function t(n){e.push(n);for(var r=0;r<n.next.length;r++)-1==e.indexOf(n.next[r].next)&&t(n.next[r].next)}(this),e.map(function(t,n){for(var r=n+(t.validEnd?"*":" ")+" ",i=0;i<t.next.length;i++)r+=(i?", ":"")+t.next[i].type.name+"->"+e.indexOf(t.next[i].next);return r}).join("\n")}}],[{key:"parse",value:function(t,n){var r=new pi(t,n);if(null==r.next)return e.empty;var i=vi(r);r.next&&r.err("Unexpected trailing text");var o=xi(function(e){var t=[[]];return i(o(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){var i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(function(e){return e.to=t})}function o(e,t){if("choice"==e.type)return e.exprs.reduce(function(e,n){return e.concat(o(n,t))},[]);if("seq"!=e.type){if("star"==e.type){var a=n();return r(t,a),i(o(e.expr,a),a),[r(a)]}if("plus"==e.type){var s=n();return i(o(e.expr,t),s),i(o(e.expr,s),s),[r(s)]}if("opt"==e.type)return[r(t)].concat(o(e.expr,t));if("range"==e.type){for(var c=t,u=0;u<e.min;u++){var l=n();i(o(e.expr,c),l),c=l}if(-1==e.max)i(o(e.expr,c),c);else for(var d=e.min;d<e.max;d++){var h=n();r(c,h),i(o(e.expr,c),h),c=h}return[r(c)]}if("name"==e.type)return[r(t,void 0,e.value)];throw new Error("Unknown expr type")}for(var f=0;;f++){var p=o(e.exprs[f],t);if(f==e.exprs.length-1)return p;i(p,t=n())}}}(i));return function(e,t){for(var n=0,r=[e];n<r.length;n++){for(var i=r[n],o=!i.validEnd,a=[],s=0;s<i.next.length;s++){var c=i.next[s],u=c.type,l=c.next;a.push(u.name),!o||u.isText||u.hasRequiredAttrs()||(o=!1),-1==r.indexOf(l)&&r.push(l)}o&&t.err("Only non-generatable nodes ("+a.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(o,r),o}}])}();fi.empty=new fi(!0);var pi=function(){return S(function e(t,n){x(this,e),this.string=t,this.nodeTypes=n,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()},[{key:"next",get:function(){return this.tokens[this.pos]}},{key:"eat",value:function(e){return this.next==e&&(this.pos++||!0)}},{key:"err",value:function(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}])}();function vi(e){var t=[];do{t.push(mi(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function mi(e){var t=[];do{t.push(gi(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function gi(e){for(var t=function(e){if(e.eat("(")){var t=vi(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){var n=function(e,t){var n=e.nodeTypes,r=n[t];if(r)return[r];var i=[];for(var o in n){var a=n[o];a.isInGroup(t)&&i.push(a)}0==i.length&&e.err("No node type or group '"+t+"' found");return i}(e,e.next).map(function(t){return null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t}});return e.pos++,1==n.length?n[0]:{type:"choice",exprs:n}}e.err("Unexpected token '"+e.next+"'")}(e);;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=ki(e,t)}return t}function yi(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");var t=Number(e.next);return e.pos++,t}function ki(e,t){var n=yi(e),r=n;return e.eat(",")&&(r="}"!=e.next?yi(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}function wi(e,t){return t-e}function bi(e,t){var n=[];return function t(r){var i=e[r];if(1==i.length&&!i[0].term)return t(i[0].to);n.push(r);for(var o=0;o<i.length;o++){var a=i[o],s=a.term,c=a.to;s||-1!=n.indexOf(c)||t(c)}}(t),n.sort(wi)}function xi(e){var t=Object.create(null);return function n(r){var i=[];r.forEach(function(t){e[t].forEach(function(t){var n=t.term,r=t.to;if(n){for(var o,a=0;a<i.length;a++)i[a][0]==n&&(o=i[a][1]);bi(e,r).forEach(function(e){o||i.push([n,o=[]]),-1==o.indexOf(e)&&o.push(e)})}})});for(var o=t[r.join(",")]=new fi(r.indexOf(e.length-1)>-1),a=0;a<i.length;a++){var s=i[a][1].sort(wi);o.next.push({type:i[a][0],next:t[s.join(",")]||n(s)})}return o}(bi(e,0))}function Ci(e){var t=Object.create(null);for(var n in e){var r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function Si(e,t){var n=Object.create(null);for(var r in e){var i=t&&t[r];if(void 0===i){var o=e[r];if(!o.hasDefault)throw new RangeError("No value supplied for attribute "+r);i=o.default}n[r]=i}return n}function _i(e,t,n,r){for(var i in t)if(!(i in e))throw new RangeError("Unsupported attribute ".concat(i," for ").concat(n," of type ").concat(i));for(var o in e){var a=e[o];a.validate&&a.validate(t[o])}}function Mi(e,t){var n=Object.create(null);if(t)for(var r in t)n[r]=new Oi(e,r,t[r]);return n}var Ti=function(){function e(t,n,r){x(this,e),this.name=t,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Mi(t,r.attrs),this.defaultAttrs=Ci(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||"text"==t),this.isText="text"==t}return S(e,[{key:"isInline",get:function(){return!this.isBlock}},{key:"isTextblock",get:function(){return this.isBlock&&this.inlineContent}},{key:"isLeaf",get:function(){return this.contentMatch==fi.empty}},{key:"isAtom",get:function(){return this.isLeaf||!!this.spec.atom}},{key:"isInGroup",value:function(e){return this.groups.indexOf(e)>-1}},{key:"whitespace",get:function(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}},{key:"hasRequiredAttrs",value:function(){for(var e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}},{key:"compatibleContent",value:function(e){return this==e||this.contentMatch.compatible(e.contentMatch)}},{key:"computeAttrs",value:function(e){return!e&&this.defaultAttrs?this.defaultAttrs:Si(this.attrs,e)}},{key:"create",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0;if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new li(this,this.computeAttrs(e),Fr.from(t),Wr.setFrom(n))}},{key:"createChecked",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0;return t=Fr.from(t),this.checkContent(t),new li(this,this.computeAttrs(e),t,Wr.setFrom(n))}},{key:"createAndFill",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0;if(e=this.computeAttrs(e),(t=Fr.from(t)).size){var r=this.contentMatch.fillBefore(t);if(!r)return null;t=r.append(t)}var i=this.contentMatch.matchFragment(t),o=i&&i.fillBefore(Fr.empty,!0);return o?new li(this,e,t.append(o),Wr.setFrom(n)):null}},{key:"validContent",value:function(e){var t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(var n=0;n<e.childCount;n++)if(!this.allowsMarks(e.child(n).marks))return!1;return!0}},{key:"checkContent",value:function(e){if(!this.validContent(e))throw new RangeError("Invalid content for node ".concat(this.name,": ").concat(e.toString().slice(0,50)))}},{key:"checkAttrs",value:function(e){_i(this.attrs,e,"node",this.name)}},{key:"allowsMarkType",value:function(e){return null==this.markSet||this.markSet.indexOf(e)>-1}},{key:"allowsMarks",value:function(e){if(null==this.markSet)return!0;for(var t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}},{key:"allowedMarks",value:function(e){if(null==this.markSet)return e;for(var t,n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:Wr.none:e}}],[{key:"compile",value:function(t,n){var r=Object.create(null);t.forEach(function(t,i){return r[t]=new e(t,n,i)});var i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(var o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}}])}();var Oi=function(){return S(function e(t,n,r){x(this,e),this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate="string"==typeof r.validate?function(e,t,n){var r=n.split("|");return function(n){var i=null===n?"null":T(n);if(r.indexOf(i)<0)throw new RangeError("Expected value of type ".concat(r," for attribute ").concat(t," on type ").concat(e,", got ").concat(i))}}(t,n,r.validate):r.validate},[{key:"isRequired",get:function(){return!this.hasDefault}}])}(),Ni=function(){function e(t,n,r,i){x(this,e),this.name=t,this.rank=n,this.schema=r,this.spec=i,this.attrs=Mi(t,i.attrs),this.excluded=null;var o=Ci(this.attrs);this.instance=o?new Wr(this,o):null}return S(e,[{key:"create",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return!e&&this.instance?this.instance:new Wr(this,Si(this.attrs,e))}},{key:"removeFromSet",value:function(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}},{key:"isInSet",value:function(e){for(var t=0;t<e.length;t++)if(e[t].type==this)return e[t]}},{key:"checkAttrs",value:function(e){_i(this.attrs,e,"mark",this.name)}},{key:"excludes",value:function(e){return this.excluded.indexOf(e)>-1}}],[{key:"compile",value:function(t,n){var r=Object.create(null),i=0;return t.forEach(function(t,o){return r[t]=new e(t,i++,n,o)}),r}}])}(),Ei=function(){return S(function e(t){var n=this;x(this,e),this.linebreakReplacement=null,this.cached=Object.create(null);var r=this.spec={};for(var i in t)r[i]=t[i];r.nodes=Lr.from(t.nodes),r.marks=Lr.from(t.marks||{}),this.nodes=Ti.compile(this.spec.nodes,this),this.marks=Ni.compile(this.spec.marks,this);var o=Object.create(null);for(var a in this.nodes){if(a in this.marks)throw new RangeError(a+" can not be both a node and a mark");var s=this.nodes[a],c=s.spec.content||"",u=s.spec.marks;if(s.contentMatch=o[c]||(o[c]=fi.parse(c,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet="_"==u?null:u?Ai(this,u.split(" ")):""!=u&&s.inlineContent?null:[]}for(var l in this.marks){var d=this.marks[l],h=d.spec.excludes;d.excluded=null==h?[d]:""==h?[]:Ai(this,h.split(" "))}this.nodeFromJSON=function(e){return li.fromJSON(n,e)},this.markFromJSON=function(e){return Wr.fromJSON(n,e)},this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)},[{key:"node",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0;if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof Ti))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,r)}},{key:"text",value:function(e,t){var n=this.nodes.text;return new di(n,n.defaultAttrs,e,Wr.setFrom(t))}},{key:"mark",value:function(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}},{key:"nodeType",value:function(e){var t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}])}();function Ai(e,t){for(var n=[],r=0;r<t.length;r++){var i=t[r],o=e.marks[i],a=o;if(o)n.push(o);else for(var s in e.marks){var c=e.marks[s];("_"==i||c.spec.group&&c.spec.group.split(" ").indexOf(i)>-1)&&n.push(a=c)}if(!a)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}var Di=function(){function e(t,n){var r=this;x(this,e),this.schema=t,this.rules=n,this.tags=[],this.styles=[];var i=this.matchedStyles=[];n.forEach(function(e){if(function(e){return null!=e.tag}(e))r.tags.push(e);else if(function(e){return null!=e.style}(e)){var t=/[^=]*/.exec(e.style)[0];i.indexOf(t)<0&&i.push(t),r.styles.push(e)}}),this.normalizeLists=!this.tags.some(function(e){if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return!1;var n=t.nodes[e.node];return n.contentMatch.matchType(n)})}return S(e,[{key:"parse",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new Bi(this,t,!1);return n.addAll(e,Wr.none,t.from,t.to),n.finish()}},{key:"parseSlice",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new Bi(this,t,!0);return n.addAll(e,Wr.none,t.from,t.to),Ur.maxOpen(n.finish())}},{key:"matchTag",value:function(e,t,n){for(var r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){var i=this.tags[r];if(Vi(e,i.tag)&&(void 0===i.namespace||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs){var o=i.getAttrs(e);if(!1===o)continue;i.attrs=o||void 0}return i}}}},{key:"matchStyle",value:function(e,t,n,r){for(var i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){var o=this.styles[i],a=o.style;if(!(0!=a.indexOf(e)||o.context&&!n.matchesContext(o.context)||a.length>e.length&&(61!=a.charCodeAt(e.length)||a.slice(e.length+1)!=t))){if(o.getAttrs){var s=o.getAttrs(t);if(!1===s)continue;o.attrs=s||void 0}return o}}}}],[{key:"schemaRules",value:function(e){var t=[];function n(e){for(var n=null==e.priority?50:e.priority,r=0;r<t.length;r++){var i=t[r];if((null==i.priority?50:i.priority)<n)break}t.splice(r,0,e)}var r=function(t){var r=e.marks[t].spec.parseDOM;r&&r.forEach(function(e){n(e=Fi(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})};for(var i in e.marks)r(i);var o=function(t){var r=e.nodes[t].spec.parseDOM;r&&r.forEach(function(e){n(e=Fi(e)),e.node||e.ignore||e.mark||(e.node=t)})};for(var a in e.nodes)o(a);return t}},{key:"fromSchema",value:function(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}}])}(),Ii={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},zi={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ri={ol:!0,ul:!0};function Pi(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}var Li=function(){return S(function e(t,n,r,i,o,a){x(this,e),this.type=t,this.attrs=n,this.marks=r,this.solid=i,this.options=a,this.content=[],this.activeMarks=Wr.none,this.match=o||(4&a?null:t.contentMatch)},[{key:"findWrapping",value:function(e){if(!this.match){if(!this.type)return[];var t=this.type.contentMatch.fillBefore(Fr.from(e));if(!t){var n,r=this.type.contentMatch;return(n=r.findWrapping(e.type))?(this.match=r,n):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}},{key:"finish",value:function(e){if(!(1&this.options)){var t,n=this.content[this.content.length-1];if(n&&n.isText&&(t=/[ \t\r\n\u000c]+$/.exec(n.text))){var r=n;n.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=r.withText(r.text.slice(0,r.text.length-t[0].length))}}var i=Fr.from(this.content);return!e&&this.match&&(i=i.append(this.match.fillBefore(Fr.empty,!0))),this.type?this.type.create(this.attrs,i,this.marks):i}},{key:"inlineContext",value:function(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Ii.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}])}(),Bi=function(){return S(function e(t,n,r){x(this,e),this.parser=t,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;var i,o=n.topNode,a=Pi(null,n.preserveWhitespace,0)|(r?4:0);i=o?new Li(o.type,o.attrs,Wr.none,!0,n.topMatch||o.type.contentMatch,a):new Li(r?null:t.schema.topNodeType,null,Wr.none,!0,null,a),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1},[{key:"top",get:function(){return this.nodes[this.open]}},{key:"addDOM",value:function(e,t){3==e.nodeType?this.addTextNode(e,t):1==e.nodeType&&this.addElement(e,t)}},{key:"addTextNode",value:function(e,t){var n=e.nodeValue,r=this.top,i=2&r.options?"full":this.localPreserveWS||(1&r.options)>0,o=this.parser.schema;if("full"===i||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(i)if("full"===i)n=n.replace(/\r\n?/g,"\n");else if(o.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(o.linebreakReplacement.create())){for(var a=n.split(/\r?\n|\r/),s=0;s<a.length;s++)s&&this.insertNode(o.linebreakReplacement.create(),t,!0),a[s]&&this.insertNode(o.text(a[s]),t,!/\S/.test(a[s]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){var c=r.content[r.content.length-1],u=e.previousSibling;(!c||u&&"BR"==u.nodeName||c.isText&&/[ \t\r\n\u000c]$/.test(c.text))&&(n=n.slice(1))}n&&this.insertNode(o.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}},{key:"addElement",value:function(e,t,n){var r=this.localPreserveWS,i=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);var o,a=e.nodeName.toLowerCase();Ri.hasOwnProperty(a)&&this.parser.normalizeLists&&function(e){for(var t=e.firstChild,n=null;t;t=t.nextSibling){var r=1==t.nodeType?t.nodeName.toLowerCase():null;r&&Ri.hasOwnProperty(r)&&n?(n.appendChild(t),t=n):"li"==r?n=t:r&&(n=null)}}(e);var s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));e:if(s?s.ignore:zi.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);var c,u=this.needsBlock;if(Ii.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}var l=s&&s.skip?t:this.readStyles(e,t);l&&this.addAll(e,l),c&&this.sync(i),this.needsBlock=u}else{var d=this.readStyles(e,t);d&&this.addElementByRule(e,s,d,!1===s.consuming?o:void 0)}this.localPreserveWS=r}},{key:"leafFallback",value:function(e,t){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),t)}},{key:"ignoreFallback",value:function(e,t){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),t,!0)}},{key:"readStyles",value:function(e,t){var n=this,r=e.style;if(r&&r.length)for(var i=0;i<this.parser.matchedStyles.length;i++){var o=this.parser.matchedStyles[i],a=r.getPropertyValue(o);if(a)for(var s,c=function(e){var r=n.parser.matchStyle(o,a,n,e);return r?r.ignore?{v:null}:(t=r.clearMark?t.filter(function(e){return!r.clearMark(e)}):t.concat(n.parser.schema.marks[r.mark].create(r.attrs)),!1!==r.consuming?(u=e,0):void(u=e=r)):(u=e,0)},u=void 0;0!==(s=c(u));)if(s)return s.v}return t}},{key:"addElementByRule",value:function(e,t,n,r){var i,o,a=this;if(t.node)if((o=this.parser.schema.nodes[t.node]).isLeaf)this.insertNode(o.create(t.attrs),n,"BR"==e.nodeName)||this.leafFallback(e,n);else{var s=this.enter(o,t.attrs||null,n,t.preserveWhitespace);s&&(i=!0,n=s)}else{var c=this.parser.schema.marks[t.mark];n=n.concat(c.create(t.attrs))}var u=this.top;if(o&&o.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(function(e){return a.insertNode(e,n,!1)});else{var l=e;"string"==typeof t.contentElement?l=e.querySelector(t.contentElement):"function"==typeof t.contentElement?l=t.contentElement(e):t.contentElement&&(l=t.contentElement),this.findAround(e,l,!0),this.addAll(l,n),this.findAround(e,l,!1)}i&&this.sync(u)&&this.open--}},{key:"addAll",value:function(e,t,n,r){for(var i=n||0,o=n?e.childNodes[n]:e.firstChild,a=null==r?null:e.childNodes[r];o!=a;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,t);this.findAtPoint(e,i)}},{key:"findPlace",value:function(e,t,n){for(var r,i,o=this.open,a=0;o>=0;o--){var s=this.nodes[o],c=s.findWrapping(e);if(c&&(!r||r.length>c.length+a)&&(r=c,i=s,!c.length))break;if(s.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(var u=0;u<r.length;u++)t=this.enterInner(r[u],null,t,!1);return t}},{key:"insertNode",value:function(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){var r=this.textblockFromContext();r&&(t=this.enterInner(r,null,t))}var i=this.findPlace(e,t,n);if(i){this.closeExtra();var o=this.top;o.match&&(o.match=o.match.matchType(e.type));var a,s=Wr.none,c=l(i.concat(e.marks));try{for(c.s();!(a=c.n()).done;){var u=a.value;(o.type?o.type.allowsMarkType(u.type):$i(u.type,e.type))&&(s=u.addToSet(s))}}catch(d){c.e(d)}finally{c.f()}return o.content.push(e.mark(s)),!0}return!1}},{key:"enter",value:function(e,t,n,r){var i=this.findPlace(e.create(t),n,!1);return i&&(i=this.enterInner(e,t,n,!0,r)),i}},{key:"enterInner",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4?arguments[4]:void 0;this.closeExtra();var o=this.top;o.match=o.match&&o.match.matchType(e);var a=Pi(e,i,o.options);4&o.options&&0==o.content.length&&(a|=4);var s=Wr.none;return n=n.filter(function(t){return!(o.type?o.type.allowsMarkType(t.type):$i(t.type,e))||(s=t.addToSet(s),!1)}),this.nodes.push(new Li(e,t,s,r,null,a)),this.open++,n}},{key:"closeExtra",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}},{key:"finish",value:function(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!(!this.isOpen&&!this.options.topOpen))}},{key:"sync",value:function(e){for(var t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=1)}return!1}},{key:"currentPos",get:function(){this.closeExtra();for(var e=0,t=this.open;t>=0;t--){for(var n=this.nodes[t].content,r=n.length-1;r>=0;r--)e+=n[r].nodeSize;t&&e++}return e}},{key:"findAtPoint",value:function(e,t){if(this.find)for(var n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}},{key:"findInside",value:function(e){if(this.find)for(var t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}},{key:"findAround",value:function(e,t,n){if(e!=t&&this.find)for(var r=0;r<this.find.length;r++){if(null==this.find[r].pos&&1==e.nodeType&&e.contains(this.find[r].node))t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}}},{key:"findInText",value:function(e){if(this.find)for(var t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}},{key:"matchesContext",value:function(e){var t=this;if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);var n=e.split("/"),r=this.options.context,i=!(this.isOpen||r&&r.parent.type!=this.nodes[0].type),o=-(r?r.depth+1:0)+(i?0:1),a=function(e,s){for(;e>=0;e--){var c=n[e];if(""==c){if(e==n.length-1||0==e)continue;for(;s>=o;s--)if(a(e-1,s))return!0;return!1}var u=s>0||0==s&&i?t.nodes[s].type:r&&s>=o?r.node(s-o).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;s--}return!0};return a(n.length-1,this.open)}},{key:"textblockFromContext",value:function(){var e=this.options.context;if(e)for(var t=e.depth;t>=0;t--){var n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(var r in this.parser.schema.nodes){var i=this.parser.schema.nodes[r];if(i.isTextblock&&i.defaultAttrs)return i}}}])}();function Vi(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Fi(e){var t={};for(var n in e)t[n]=e[n];return t}function $i(e,t){var n,r=t.schema.nodes,i=function(){var n=r[o];if(!n.allowsMarkType(e))return 0;var i=[],a=function(e){i.push(e);for(var n=0;n<e.edgeCount;n++){var r=e.edge(n),o=r.type,s=r.next;if(o==t)return!0;if(i.indexOf(s)<0&&a(s))return!0}};return a(n.contentMatch)?{v:!0}:void 0};for(var o in r)if(0!==(n=i())&&n)return n.v}var ji=function(){function e(t,n){x(this,e),this.nodes=t,this.marks=n}return S(e,[{key:"serializeFragment",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0;r||(r=Wi(n).createDocumentFragment());var i=r,o=[];return e.forEach(function(e){if(o.length||e.marks.length){for(var r=0,a=0;r<o.length&&a<e.marks.length;){var s=e.marks[a];if(t.marks[s.type.name]){if(!s.eq(o[r][0])||!1===s.type.spec.spanning)break;r++,a++}else a++}for(;r<o.length;)i=o.pop()[1];for(;a<e.marks.length;){var c=e.marks[a++],u=t.serializeMark(c,e.isInline,n);u&&(o.push([c,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(t.serializeNodeInner(e,n))}),r}},{key:"serializeNodeInner",value:function(e,t){var n=Ji(Wi(t),this.nodes[e.type.name](e),null,e.attrs),r=n.dom,i=n.contentDOM;if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return r}},{key:"serializeNode",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.serializeNodeInner(e,t),r=e.marks.length-1;r>=0;r--){var i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}},{key:"serializeMark",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=this.marks[e.type.name];return r&&Ji(Wi(n),r(e,t),null,e.attrs)}}],[{key:"renderSpec",value:function(e,t){return Ji(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,arguments.length>3?arguments[3]:void 0)}},{key:"fromSchema",value:function(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}},{key:"nodesFromSchema",value:function(e){var t=Hi(e.nodes);return t.text||(t.text=function(e){return e.text}),t}},{key:"marksFromSchema",value:function(e){return Hi(e.marks)}}])}();function Hi(e){var t={};for(var n in e){var r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function Wi(e){return e.document||window.document}var qi=new WeakMap;function Ui(e){var t=qi.get(e);return void 0===t&&qi.set(e,t=function(e){var t=null;function n(e){if(e&&"object"==T(e))if(Array.isArray(e))if("string"==typeof e[0])t||(t=[]),t.push(e);else for(var r=0;r<e.length;r++)n(e[r]);else for(var i in e)n(e[i])}return n(e),t}(e)),t}function Ji(e,t,n,r){if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;var i,o=t[0];if("string"!=typeof o)throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=Ui(r))&&i.indexOf(t)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");var a,s=o.indexOf(" ");s>0&&(n=o.slice(0,s),o=o.slice(s+1));var c=n?e.createElementNS(n,o):e.createElement(o),u=t[1],l=1;if(u&&"object"==T(u)&&null==u.nodeType&&!Array.isArray(u))for(var d in l=2,u)if(null!=u[d]){var h=d.indexOf(" ");h>0?c.setAttributeNS(d.slice(0,h),d.slice(h+1),u[d]):"style"==d&&c.style?c.style.cssText=u[d]:c.setAttribute(d,u[d])}for(var f=l;f<t.length;f++){var p=t[f];if(0===p){if(f<t.length-1||f>l)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}var v=Ji(e,p,n,r),m=v.dom,g=v.contentDOM;if(c.appendChild(m),g){if(a)throw new RangeError("Multiple content holes");a=g}}return{dom:c,contentDOM:a}}var Ki=Math.pow(2,16);function Yi(e,t){return e+t*Ki}function Gi(e){return 65535&e}var Xi=function(){return S(function e(t,n,r){x(this,e),this.pos=t,this.delInfo=n,this.recover=r},[{key:"deleted",get:function(){return(8&this.delInfo)>0}},{key:"deletedBefore",get:function(){return(5&this.delInfo)>0}},{key:"deletedAfter",get:function(){return(6&this.delInfo)>0}},{key:"deletedAcross",get:function(){return(4&this.delInfo)>0}}])}(),Zi=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(x(this,e),this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}return S(e,[{key:"recover",value:function(e){var t=0,n=Gi(e);if(!this.inverted)for(var r=0;r<n;r++)t+=this.ranges[3*r+2]-this.ranges[3*r+1];return this.ranges[3*n]+t+function(e){return(e-(65535&e))/Ki}(e)}},{key:"mapResult",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this._map(e,t,!1)}},{key:"map",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this._map(e,t,!0)}},{key:"_map",value:function(e,t,n){for(var r=0,i=this.inverted?2:1,o=this.inverted?1:2,a=0;a<this.ranges.length;a+=3){var s=this.ranges[a]-(this.inverted?r:0);if(s>e)break;var c=this.ranges[a+i],u=this.ranges[a+o],l=s+c;if(e<=l){var d=s+r+((c?e==s?-1:e==l?1:t:t)<0?0:u);if(n)return d;var h=e==(t<0?s:l)?null:Yi(a/3,e-s),f=e==s?2:e==l?1:4;return(t<0?e!=s:e!=l)&&(f|=8),new Xi(d,f,h)}r+=u-c}return n?e+r:new Xi(e+r,0,null)}},{key:"touches",value:function(e,t){for(var n=0,r=Gi(t),i=this.inverted?2:1,o=this.inverted?1:2,a=0;a<this.ranges.length;a+=3){var s=this.ranges[a]-(this.inverted?n:0);if(s>e)break;var c=this.ranges[a+i];if(e<=s+c&&a==3*r)return!0;n+=this.ranges[a+o]-c}return!1}},{key:"forEach",value:function(e){for(var t=this.inverted?2:1,n=this.inverted?1:2,r=0,i=0;r<this.ranges.length;r+=3){var o=this.ranges[r],a=o-(this.inverted?i:0),s=o+(this.inverted?0:i),c=this.ranges[r+t],u=this.ranges[r+n];e(a,a+c,s,s+u),i+=u-c}}},{key:"invert",value:function(){return new e(this.ranges,!this.inverted)}},{key:"toString",value:function(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}}],[{key:"offset",value:function(t){return 0==t?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}}])}();Zi.empty=new Zi([]);var Qi=function(){function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t?t.length:0;x(this,e),this.mirror=n,this.from=r,this.to=i,this._maps=t||[],this.ownData=!(t||n)}return S(e,[{key:"maps",get:function(){return this._maps}},{key:"slice",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.maps.length;return new e(this._maps,this.mirror,t,n)}},{key:"appendMap",value:function(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),null!=t&&this.setMirror(this._maps.length-1,t)}},{key:"appendMapping",value:function(e){for(var t=0,n=this._maps.length;t<e._maps.length;t++){var r=e.getMirror(t);this.appendMap(e._maps[t],null!=r&&r<t?n+r:void 0)}}},{key:"getMirror",value:function(e){if(this.mirror)for(var t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}},{key:"setMirror",value:function(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}},{key:"appendMappingInverted",value:function(e){for(var t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){var r=e.getMirror(t);this.appendMap(e._maps[t].invert(),null!=r&&r>t?n-r-1:void 0)}}},{key:"invert",value:function(){var t=new e;return t.appendMappingInverted(this),t}},{key:"map",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(this.mirror)return this._map(e,t,!0);for(var n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}},{key:"mapResult",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this._map(e,t,!1)}},{key:"_map",value:function(e,t,n){for(var r=0,i=this.from;i<this.to;i++){var o=this._maps[i].mapResult(e,t);if(null!=o.recover){var a=this.getMirror(i);if(null!=a&&a>i&&a<this.to){i=a,e=this._maps[a].recover(o.recover);continue}}r|=o.delInfo,e=o.pos}return n?e:new Xi(e,r,null)}}])}(),eo=Object.create(null),to=function(){return S(function e(){x(this,e)},[{key:"getMap",value:function(){return Zi.empty}},{key:"merge",value:function(e){return null}}],[{key:"fromJSON",value:function(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");var n=eo[t.stepType];if(!n)throw new RangeError("No step type ".concat(t.stepType," defined"));return n.fromJSON(e,t)}},{key:"jsonID",value:function(e,t){if(e in eo)throw new RangeError("Duplicate use of step JSON ID "+e);return eo[e]=t,t.prototype.jsonID=e,t}}])}(),no=function(){function e(t,n){x(this,e),this.doc=t,this.failed=n}return S(e,null,[{key:"ok",value:function(t){return new e(t,null)}},{key:"fail",value:function(t){return new e(null,t)}},{key:"fromReplace",value:function(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(pt){if(pt instanceof qr)return e.fail(pt.message);throw pt}}}])}();function ro(e,t,n){for(var r=[],i=0;i<e.childCount;i++){var o=e.child(i);o.content.size&&(o=o.copy(ro(o.content,t,o))),o.isInline&&(o=t(o,n,i)),r.push(o)}return Fr.fromArray(r)}var io=function(e){function t(e,n,i){var o;return x(this,t),(o=r(this,t)).from=e,o.to=n,o.mark=i,o}return a(t,e),S(t,[{key:"apply",value:function(e){var t=this,n=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),o=new Ur(ro(n.content,function(e,n){return e.isAtom&&n.type.allowsMarkType(t.mark.type)?e.mark(t.mark.addToSet(e.marks)):e},i),n.openStart,n.openEnd);return no.fromReplace(e,this.from,this.to,o)}},{key:"invert",value:function(){return new oo(this.from,this.to,this.mark)}},{key:"map",value:function(e){var n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)}},{key:"merge",value:function(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}},{key:"toJSON",value:function(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}}])}(to);to.jsonID("addMark",io);var oo=function(e){function t(e,n,i){var o;return x(this,t),(o=r(this,t)).from=e,o.to=n,o.mark=i,o}return a(t,e),S(t,[{key:"apply",value:function(e){var t=this,n=e.slice(this.from,this.to),r=new Ur(ro(n.content,function(e){return e.mark(t.mark.removeFromSet(e.marks))},e),n.openStart,n.openEnd);return no.fromReplace(e,this.from,this.to,r)}},{key:"invert",value:function(){return new io(this.from,this.to,this.mark)}},{key:"map",value:function(e){var n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)}},{key:"merge",value:function(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}},{key:"toJSON",value:function(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}}])}(to);to.jsonID("removeMark",oo);var ao=function(e){function t(e,n){var i;return x(this,t),(i=r(this,t)).pos=e,i.mark=n,i}return a(t,e),S(t,[{key:"apply",value:function(e){var t=e.nodeAt(this.pos);if(!t)return no.fail("No node at mark step's position");var n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return no.fromReplace(e,this.pos,this.pos+1,new Ur(Fr.from(n),0,t.isLeaf?0:1))}},{key:"invert",value:function(e){var n=e.nodeAt(this.pos);if(n){var r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(var i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new t(this.pos,n.marks[i]);return new t(this.pos,this.mark)}}return new so(this.pos,this.mark)}},{key:"map",value:function(e){var n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.mark)}},{key:"toJSON",value:function(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new t(n.pos,e.markFromJSON(n.mark))}}])}(to);to.jsonID("addNodeMark",ao);var so=function(e){function t(e,n){var i;return x(this,t),(i=r(this,t)).pos=e,i.mark=n,i}return a(t,e),S(t,[{key:"apply",value:function(e){var t=e.nodeAt(this.pos);if(!t)return no.fail("No node at mark step's position");var n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return no.fromReplace(e,this.pos,this.pos+1,new Ur(Fr.from(n),0,t.isLeaf?0:1))}},{key:"invert",value:function(e){var t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new ao(this.pos,this.mark):this}},{key:"map",value:function(e){var n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.mark)}},{key:"toJSON",value:function(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new t(n.pos,e.markFromJSON(n.mark))}}])}(to);to.jsonID("removeNodeMark",so);var co=function(e){function t(e,n,i){var o,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return x(this,t),(o=r(this,t)).from=e,o.to=n,o.slice=i,o.structure=a,o}return a(t,e),S(t,[{key:"apply",value:function(e){return this.structure&&lo(e,this.from,this.to)?no.fail("Structure replace would overwrite content"):no.fromReplace(e,this.from,this.to,this.slice)}},{key:"getMap",value:function(){return new Zi([this.from,this.to-this.from,this.slice.size])}},{key:"invert",value:function(e){return new t(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}},{key:"map",value:function(e){var n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new t(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}},{key:"merge",value:function(e){if(!(e instanceof t)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;var n=this.slice.size+e.slice.size==0?Ur.empty:new Ur(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new t(e.from,this.to,n,this.structure)}var r=this.slice.size+e.slice.size==0?Ur.empty:new Ur(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new t(this.from,this.to+(e.to-e.from),r,this.structure)}},{key:"toJSON",value:function(){var e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new t(n.from,n.to,Ur.fromJSON(e,n.slice),!!n.structure)}}])}(to);to.jsonID("replace",co);var uo=function(e){function t(e,n,i,o,a,s){var c,u=arguments.length>6&&void 0!==arguments[6]&&arguments[6];return x(this,t),(c=r(this,t)).from=e,c.to=n,c.gapFrom=i,c.gapTo=o,c.slice=a,c.insert=s,c.structure=u,c}return a(t,e),S(t,[{key:"apply",value:function(e){if(this.structure&&(lo(e,this.from,this.gapFrom)||lo(e,this.gapTo,this.to)))return no.fail("Structure gap-replace would overwrite content");var t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return no.fail("Gap is not a flat range");var n=this.slice.insertAt(this.insert,t.content);return n?no.fromReplace(e,this.from,this.to,n):no.fail("Content does not fit in gap")}},{key:"getMap",value:function(){return new Zi([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}},{key:"invert",value:function(e){var n=this.gapTo-this.gapFrom;return new t(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}},{key:"map",value:function(e){var n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||o>r.pos?null:new t(n.pos,r.pos,i,o,this.slice,this.insert,this.structure)}},{key:"toJSON",value:function(){var e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.from||"number"!=typeof n.to||"number"!=typeof n.gapFrom||"number"!=typeof n.gapTo||"number"!=typeof n.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new t(n.from,n.to,n.gapFrom,n.gapTo,Ur.fromJSON(e,n.slice),n.insert,!!n.structure)}}])}(to);function lo(e,t,n){for(var r=e.resolve(t),i=n-t,o=r.depth;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0)for(var a=r.node(o).maybeChild(r.indexAfter(o));i>0;){if(!a||a.isLeaf)return!0;a=a.firstChild,i--}return!1}function ho(e,t,n){for(var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:n.contentMatch,i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=e.doc.nodeAt(t),a=[],s=t+1,c=0;c<o.childCount;c++){var u=o.child(c),l=s+u.nodeSize,d=r.matchType(u.type);if(d){r=d;for(var h=0;h<u.marks.length;h++)n.allowsMarkType(u.marks[h].type)||e.step(new oo(s,l,u.marks[h]));if(i&&u.isText&&"pre"!=n.whitespace)for(var f=void 0,p=/\r?\n|\r/g,v=void 0;f=p.exec(u.text);)v||(v=new Ur(Fr.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),a.push(new co(s+f.index,s+f.index+f[0].length,v))}else a.push(new co(s,l,Ur.empty));s=l}if(!r.validEnd){var m=r.fillBefore(Fr.empty,!0);e.replace(s,s,new Ur(m,0,0))}for(var g=a.length-1;g>=0;g--)e.step(a[g])}function fo(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function po(e){for(var t=e.parent.content.cutByIndex(e.startIndex,e.endIndex),n=e.depth,r=0,i=0;;--n){var o=e.$from.node(n),a=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&o.canReplace(a,s,t))return n;if(0==n||o.type.spec.isolating||!fo(o,a,s))break;a&&(r=1),s<o.childCount&&(i=1)}return null}function vo(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e,i=function(e,t){var n=e.parent,r=e.startIndex,i=e.endIndex,o=n.contentMatchAt(r).findWrapping(t);if(!o)return null;var a=o.length?o[0]:t;return n.canReplaceWith(r,i,a)?o:null}(e,t),o=i&&function(e,t){var n=e.parent,r=e.startIndex,i=e.endIndex,o=n.child(r),a=t.contentMatch.findWrapping(o.type);if(!a)return null;for(var s=(a.length?a[a.length-1]:t).contentMatch,c=r;s&&c<i;c++)s=s.matchType(n.child(c).type);return s&&s.validEnd?a:null}(r,t);return o?i.map(mo).concat({type:t,attrs:n}).concat(o.map(mo)):null}function mo(e){return{type:e,attrs:null}}function go(e,t,n,r){t.forEach(function(i,o){if(i.isText)for(var a,s=/\r?\n|\r/g;a=s.exec(i.text);){var c=e.mapping.slice(r).map(n+1+o+a.index);e.replaceWith(c,c+1,t.type.schema.linebreakReplacement.create())}})}function yo(e,t,n,r){t.forEach(function(i,o){if(i.type==i.type.schema.linebreakReplacement){var a=e.mapping.slice(r).map(n+1+o);e.replaceWith(a,a+1,t.type.schema.text("\n"))}})}function ko(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3?arguments[3]:void 0,i=e.resolve(t),o=i.depth-n,a=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!a.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(var s=i.depth-1,c=n-2;s>o;s--,c--){var u=i.node(s),l=i.index(s);if(u.type.spec.isolating)return!1;var d=u.content.cutByIndex(l,u.childCount),h=r&&r[c+1];h&&(d=d.replaceChild(0,h.type.create(h.attrs)));var f=r&&r[c]||u;if(!u.canReplace(l+1,u.childCount)||!f.type.validContent(d))return!1}var p=i.indexAfter(o),v=r&&r[0];return i.node(o).canReplaceWith(p,p,v?v.type:i.node(o+1).type)}function wo(e,t){var n=e.resolve(t),r=n.index();return bo(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function bo(e,t){return!(!e||!t||e.isLeaf||!function(e,t){t.content.size||e.type.compatibleContent(t.type);for(var n=e.contentMatchAt(e.childCount),r=e.type.schema.linebreakReplacement,i=0;i<t.childCount;i++){var o=t.child(i),a=o.type==r?e.type.schema.nodes.text:o.type;if(!(n=n.matchType(a)))return!1;if(!e.type.allowsMarks(o.marks))return!1}return n.validEnd}(e,t))}function xo(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,r=e.resolve(t),i=r.depth;;i--){var o=void 0,a=void 0,s=r.index(i);if(i==r.depth?(o=r.nodeBefore,a=r.nodeAfter):n>0?(o=r.node(i+1),s++,a=r.node(i).maybeChild(s)):(o=r.node(i).maybeChild(s-1),a=r.node(i+1)),o&&!o.isTextblock&&bo(o,a)&&r.node(i).canReplace(s,s+1))return t;if(0==i)break;t=n<0?r.before(i):r.after(i)}}function Co(e,t,n){var r=e.resolve(t);if(!n.content.size)return t;for(var i=n.content,o=0;o<n.openStart;o++)i=i.firstChild.content;for(var a=1;a<=(0==n.openStart&&n.size?2:1);a++)for(var s=r.depth;s>=0;s--){var c=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,u=r.index(s)+(c>0?1:0),l=r.node(s),d=!1;if(1==a)d=l.canReplace(u,u,i);else{var h=l.contentMatchAt(u).findWrapping(i.firstChild.type);d=h&&l.canReplaceWith(u,u,h[0])}if(d)return 0==c?r.pos:c<0?r.before(s+1):r.after(s+1)}return null}function So(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Ur.empty;if(t==n&&!r.size)return null;var i=e.resolve(t),o=e.resolve(n);return _o(i,o,r)?new co(t,n,r):new Mo(i,o,r).fit()}function _o(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}to.jsonID("replaceAround",uo);var Mo=function(){return S(function e(t,n,r){x(this,e),this.$from=t,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=Fr.empty;for(var i=0;i<=t.depth;i++){var o=t.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(t.indexAfter(i))})}for(var a=t.depth;a>0;a--)this.placed=Fr.from(t.node(a).copy(this.placed))},[{key:"depth",get:function(){return this.frontier.length-1}},{key:"fit",value:function(){for(;this.unplaced.size;){var e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}var t=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(t<0?this.$to:r.doc.resolve(t));if(!i)return null;for(var o=this.placed,a=r.depth,s=i.depth;a&&s&&1==o.childCount;)o=o.firstChild.content,a--,s--;var c=new Ur(o,a,s);return t>-1?new uo(r.pos,t,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new co(r.pos,i.pos,c):null}},{key:"findFittable",value:function(){for(var e=this.unplaced.openStart,t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){var i=t.firstChild;if(t.childCount>1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(var o=1;o<=2;o++)for(var a=1==o?e:this.unplaced.openStart;a>=0;a--)for(var s=null,c=(a?(s=No(this.unplaced.content,a-1).firstChild).content:this.unplaced.content).firstChild,u=this.depth;u>=0;u--){var l=this.frontier[u],d=l.type,h=l.match,f=void 0,p=null;if(1==o&&(c?h.matchType(c.type)||(p=h.fillBefore(Fr.from(c),!1)):s&&d.compatibleContent(s.type)))return{sliceDepth:a,frontierDepth:u,parent:s,inject:p};if(2==o&&c&&(f=h.findWrapping(c.type)))return{sliceDepth:a,frontierDepth:u,parent:s,wrap:f};if(s&&h.matchType(s.type))break}}},{key:"openMore",value:function(){var e=this.unplaced,t=e.content,n=e.openStart,r=e.openEnd,i=No(t,n);return!(!i.childCount||i.firstChild.isLeaf)&&(this.unplaced=new Ur(t,n+1,Math.max(r,i.size+n>=t.size-r?n+1:0)),!0)}},{key:"dropNode",value:function(){var e=this.unplaced,t=e.content,n=e.openStart,r=e.openEnd,i=No(t,n);if(i.childCount<=1&&n>0){var o=t.size-n<=n+i.size;this.unplaced=new Ur(To(t,n-1,1),n-1,o?n-1:r)}else this.unplaced=new Ur(To(t,n,1),n,r)}},{key:"placeNodes",value:function(e){for(var t=e.sliceDepth,n=e.frontierDepth,r=e.parent,i=e.inject,o=e.wrap;this.depth>n;)this.closeFrontierNode();if(o)for(var a=0;a<o.length;a++)this.openFrontierNode(o[a]);var s=this.unplaced,c=r?r.content:s.content,u=s.openStart-t,l=0,d=[],h=this.frontier[n],f=h.match,p=h.type;if(i){for(var v=0;v<i.childCount;v++)d.push(i.child(v));f=f.matchFragment(i)}for(var m=c.size+t-(s.content.size-s.openEnd);l<c.childCount;){var g=c.child(l),y=f.matchType(g.type);if(!y)break;(++l>1||0==u||g.content.size)&&(f=y,d.push(Eo(g.mark(p.allowedMarks(g.marks)),1==l?u:0,l==c.childCount?m:-1)))}var k=l==c.childCount;k||(m=-1),this.placed=Oo(this.placed,n,Fr.from(d)),this.frontier[n].match=f,k&&m<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(var w=0,b=c;w<m;w++){var x=b.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),b=x.content}this.unplaced=k?0==t?Ur.empty:new Ur(To(s.content,t-1,1),t-1,m<0?s.openEnd:t-1):new Ur(To(s.content,t,l),s.openStart,s.openEnd)}},{key:"mustMoveInline",value:function(){if(!this.$to.parent.isTextblock)return-1;var e,t=this.frontier[this.depth];if(!t.type.isTextblock||!Ao(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;for(var n=this.$to.depth,r=this.$to.after(n);n>1&&r==this.$to.end(--n);)++r;return r}},{key:"findCloseLevel",value:function(e){e:for(var t=Math.min(this.depth,e.depth);t>=0;t--){var n=this.frontier[t],r=n.match,i=n.type,o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),a=Ao(e,t,i,r,o);if(a){for(var s=t-1;s>=0;s--){var c=this.frontier[s],u=c.match,l=Ao(e,s,c.type,u,!0);if(!l||l.childCount)continue e}return{depth:t,fit:a,move:o?e.doc.resolve(e.after(t+1)):e}}}}},{key:"close",value:function(e){var t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Oo(this.placed,t.depth,t.fit)),e=t.move;for(var n=t.depth+1;n<=e.depth;n++){var r=e.node(n),i=r.type.contentMatch.fillBefore(r.content,!0,e.index(n));this.openFrontierNode(r.type,r.attrs,i)}return e}},{key:"openFrontierNode",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2?arguments[2]:void 0,r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=Oo(this.placed,this.depth,Fr.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}},{key:"closeFrontierNode",value:function(){var e=this.frontier.pop().match.fillBefore(Fr.empty,!0);e.childCount&&(this.placed=Oo(this.placed,this.frontier.length,e))}}])}();function To(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(To(e.firstChild.content,t-1,n)))}function Oo(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Oo(e.lastChild.content,t-1,n)))}function No(e,t){for(var n=0;n<t;n++)e=e.firstChild.content;return e}function Eo(e,t,n){if(t<=0)return e;var r=e.content;return t>1&&(r=r.replaceChild(0,Eo(r.firstChild,t-1,1==r.childCount?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(Fr.empty,!0)))),e.copy(r)}function Ao(e,t,n,r,i){var o=e.node(t),a=i?e.indexAfter(t):e.index(t);if(a==o.childCount&&!n.compatibleContent(o.type))return null;var s=r.fillBefore(o.content,!0,a);return s&&!function(e,t,n){for(var r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}(n,o.content,a)?s:null}function Do(e){return e.spec.defining||e.spec.definingForContent}function Io(e,t,n,r,i){if(t<n){var o=e.firstChild;e=e.replaceChild(0,o.copy(Io(o.content,t+1,n,r,o)))}if(t>r){var a=i.contentMatchAt(0),s=a.fillBefore(e).append(e);e=s.append(a.matchFragment(s).fillBefore(Fr.empty,!0))}return e}function zo(e,t){for(var n=[],r=Math.min(e.depth,t.depth);r>=0;r--){var i=e.start(r);if(i<e.pos-(e.depth-r)||t.end(r)>t.pos+(t.depth-r)||e.node(r).type.spec.isolating||t.node(r).type.spec.isolating)break;(i==t.start(r)||r==e.depth&&r==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&r&&t.start(r-1)==i-1)&&n.push(r)}return n}var Ro=function(e){function t(e,n,i){var o;return x(this,t),(o=r(this,t)).pos=e,o.attr=n,o.value=i,o}return a(t,e),S(t,[{key:"apply",value:function(e){var t=e.nodeAt(this.pos);if(!t)return no.fail("No node at attribute step's position");var n=Object.create(null);for(var r in t.attrs)n[r]=t.attrs[r];n[this.attr]=this.value;var i=t.type.create(n,null,t.marks);return no.fromReplace(e,this.pos,this.pos+1,new Ur(Fr.from(i),0,t.isLeaf?0:1))}},{key:"getMap",value:function(){return Zi.empty}},{key:"invert",value:function(e){return new t(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}},{key:"map",value:function(e){var n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.attr,this.value)}},{key:"toJSON",value:function(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.pos||"string"!=typeof n.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new t(n.pos,n.attr,n.value)}}])}(to);to.jsonID("attr",Ro);var Po=function(e){function t(e,n){var i;return x(this,t),(i=r(this,t)).attr=e,i.value=n,i}return a(t,e),S(t,[{key:"apply",value:function(e){var t=Object.create(null);for(var n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;var r=e.type.create(t,e.content,e.marks);return no.ok(r)}},{key:"getMap",value:function(){return Zi.empty}},{key:"invert",value:function(e){return new t(this.attr,e.attrs[this.attr])}},{key:"map",value:function(e){return this}},{key:"toJSON",value:function(){return{stepType:"docAttr",attr:this.attr,value:this.value}}}],[{key:"fromJSON",value:function(e,n){if("string"!=typeof n.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new t(n.attr,n.value)}}])}(to);to.jsonID("docAttr",Po);var Lo=Error;((Lo=function e(t){var n=Error.call(this,t);return n.__proto__=e.prototype,n}).prototype=Object.create(Error.prototype)).constructor=Lo,Lo.prototype.name="TransformError";var Bo=function(){return S(function e(t){x(this,e),this.doc=t,this.steps=[],this.docs=[],this.mapping=new Qi},[{key:"before",get:function(){return this.docs.length?this.docs[0]:this.doc}},{key:"step",value:function(e){var t=this.maybeStep(e);if(t.failed)throw new Lo(t.failed);return this}},{key:"maybeStep",value:function(e){var t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}},{key:"docChanged",get:function(){return this.steps.length>0}},{key:"addStep",value:function(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}},{key:"replace",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Ur.empty,r=So(this.doc,e,t,n);return r&&this.step(r),this}},{key:"replaceWith",value:function(e,t,n){return this.replace(e,t,new Ur(Fr.from(n),0,0))}},{key:"delete",value:function(e,t){return this.replace(e,t,Ur.empty)}},{key:"insert",value:function(e,t){return this.replaceWith(e,e,t)}},{key:"replaceRange",value:function(e,t,n){return function(e,t,n,r){if(!r.size)return e.deleteRange(t,n);var i=e.doc.resolve(t),o=e.doc.resolve(n);if(_o(i,o,r))return e.step(new co(t,n,r));var a=zo(i,o);0==a[a.length-1]&&a.pop();var s=-(i.depth+1);a.unshift(s);for(var c=i.depth,u=i.pos-1;c>0;c--,u--){var l=i.node(c).type.spec;if(l.defining||l.definingAsContext||l.isolating)break;a.indexOf(c)>-1?s=c:i.before(c)==u&&a.splice(1,0,-c)}for(var d=a.indexOf(s),h=[],f=r.openStart,p=r.content,v=0;;v++){var m=p.firstChild;if(h.push(m),v==r.openStart)break;p=m.content}for(var g=f-1;g>=0;g--){var y=h[g],k=Do(y.type);if(k&&!y.sameMarkup(i.node(Math.abs(s)-1)))f=g;else if(k||!y.type.isTextblock)break}for(var w=r.openStart;w>=0;w--){var b=(w+f+1)%(r.openStart+1),x=h[b];if(x)for(var C=0;C<a.length;C++){var S=a[(C+d)%a.length],_=!0;S<0&&(_=!1,S=-S);var M=i.node(S-1),T=i.index(S-1);if(M.canReplaceWith(T,T,x.type,x.marks))return e.replace(i.before(S),_?o.after(S):n,new Ur(Io(r.content,0,r.openStart,b),b,r.openEnd))}}for(var O=e.steps.length,N=a.length-1;N>=0&&(e.replace(t,n,r),!(e.steps.length>O));N--){var E=a[N];E<0||(t=i.before(E),n=o.after(E))}}(this,e,t,n),this}},{key:"replaceRangeWith",value:function(e,t,n){return function(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){var i=function(e,t,n){var r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(0==r.parentOffset)for(var i=r.depth-1;i>=0;i--){var o=r.index(i);if(r.node(i).canReplaceWith(o,o,n))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(var a=r.depth-1;a>=0;a--){var s=r.indexAfter(a);if(r.node(a).canReplaceWith(s,s,n))return r.after(a+1);if(s<r.node(a).childCount)return null}return null}(e.doc,t,r.type);null!=i&&(t=n=i)}e.replaceRange(t,n,new Ur(Fr.from(r),0,0))}(this,e,t,n),this}},{key:"deleteRange",value:function(e,t){return function(e,t,n){for(var r=e.doc.resolve(t),i=e.doc.resolve(n),o=zo(r,i),a=0;a<o.length;a++){var s=o[a],c=a==o.length-1;if(c&&0==s||r.node(s).type.contentMatch.validEnd)return e.delete(r.start(s),i.end(s));if(s>0&&(c||r.node(s-1).canReplace(r.index(s-1),i.indexAfter(s-1))))return e.delete(r.before(s),i.after(s))}for(var u=1;u<=r.depth&&u<=i.depth;u++)if(t-r.start(u)==r.depth-u&&n>r.end(u)&&i.end(u)-n!=i.depth-u&&r.start(u-1)==i.start(u-1)&&r.node(u-1).canReplace(r.index(u-1),i.index(u-1)))return e.delete(r.before(u),n);e.delete(t,n)}(this,e,t),this}},{key:"lift",value:function(e,t){return function(e,t,n){for(var r=t.$from,i=t.$to,o=t.depth,a=r.before(o+1),s=i.after(o+1),c=a,u=s,l=Fr.empty,d=0,h=o,f=!1;h>n;h--)f||r.index(h)>0?(f=!0,l=Fr.from(r.node(h).copy(l)),d++):c--;for(var p=Fr.empty,v=0,m=o,g=!1;m>n;m--)g||i.after(m+1)<i.end(m)?(g=!0,p=Fr.from(i.node(m).copy(p)),v++):u++;e.step(new uo(c,u,a,s,new Ur(l.append(p),d,v),l.size-d,!0))}(this,e,t),this}},{key:"join",value:function(e){return function(e,t,n){var r=null,i=e.doc.type.schema.linebreakReplacement,o=e.doc.resolve(t-n),a=o.node().type;if(i&&a.inlineContent){var s="pre"==a.whitespace,c=!!a.contentMatch.matchType(i);s&&!c?r=!1:!s&&c&&(r=!0)}var u=e.steps.length;if(!1===r){var l=e.doc.resolve(t+n);yo(e,l.node(),l.before(),u)}a.inlineContent&&ho(e,t+n-1,a,o.node().contentMatchAt(o.index()),null==r);var d=e.mapping.slice(u),h=d.map(t-n);if(e.step(new co(h,d.map(t+n,-1),Ur.empty,!0)),!0===r){var f=e.doc.resolve(h);go(e,f.node(),f.before(),e.steps.length)}}(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:1),this}},{key:"wrap",value:function(e,t){return function(e,t,n){for(var r=Fr.empty,i=n.length-1;i>=0;i--){if(r.size){var o=n[i].type.contentMatch.matchFragment(r);if(!o||!o.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=Fr.from(n[i].type.create(n[i].attrs,r))}var a=t.start,s=t.end;e.step(new uo(a,s,a,s,new Ur(r,0,0),n.length,!0))}(this,e,t),this}},{key:"setBlockType",value:function(e){return function(e,t,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");var o=e.steps.length;e.doc.nodesBetween(t,n,function(t,n){var a="function"==typeof i?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,a)&&function(e,t,n){var r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}(e.doc,e.mapping.slice(o).map(n),r)){var s=null;if(r.schema.linebreakReplacement){var c="pre"==r.whitespace,u=!!r.contentMatch.matchType(r.schema.linebreakReplacement);c&&!u?s=!1:!c&&u&&(s=!0)}!1===s&&yo(e,t,n,o),ho(e,e.mapping.slice(o).map(n,1),r,void 0,null===s);var l=e.mapping.slice(o),d=l.map(n,1),h=l.map(n+t.nodeSize,1);return e.step(new uo(d,h,d+1,h-1,new Ur(Fr.from(r.create(a,null,t.marks)),0,0),1,!0)),!0===s&&go(e,t,n,o),!1}})}(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,arguments.length>2?arguments[2]:void 0,arguments.length>3&&void 0!==arguments[3]?arguments[3]:null),this}},{key:"setNodeMarkup",value:function(e,t){return function(e,t,n,r,i){var o=e.doc.nodeAt(t);if(!o)throw new RangeError("No node at given position");n||(n=o.type);var a=n.create(r,null,i||o.marks);if(o.isLeaf)return e.replaceWith(t,t+o.nodeSize,a);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new uo(t,t+o.nodeSize,t+1,t+o.nodeSize-1,new Ur(Fr.from(a),0,0),1,!0))}(this,e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,arguments.length>3?arguments[3]:void 0),this}},{key:"setNodeAttribute",value:function(e,t,n){return this.step(new Ro(e,t,n)),this}},{key:"setDocAttribute",value:function(e,t){return this.step(new Po(e,t)),this}},{key:"addNodeMark",value:function(e,t){return this.step(new ao(e,t)),this}},{key:"removeNodeMark",value:function(e,t){var n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof Wr)t.isInSet(n.marks)&&this.step(new so(e,t));else{for(var r,i=n.marks,o=[];r=t.isInSet(i);)o.push(new so(e,r)),i=r.removeFromSet(i);for(var a=o.length-1;a>=0;a--)this.step(o[a])}return this}},{key:"split",value:function(e){return function(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3?arguments[3]:void 0,i=e.doc.resolve(t),o=Fr.empty,a=Fr.empty,s=i.depth,c=i.depth-n,u=n-1;s>c;s--,u--){o=Fr.from(i.node(s).copy(o));var l=r&&r[u];a=Fr.from(l?l.type.create(l.attrs,a):i.node(s).copy(a))}e.step(new co(t,t,new Ur(o.append(a),n,n),!0))}(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,arguments.length>2?arguments[2]:void 0),this}},{key:"addMark",value:function(e,t,n){return function(e,t,n,r){var i,o,a=[],s=[];e.doc.nodesBetween(t,n,function(e,c,u){if(e.isInline){var l=e.marks;if(!r.isInSet(l)&&u.type.allowsMarkType(r.type)){for(var d=Math.max(c,t),h=Math.min(c+e.nodeSize,n),f=r.addToSet(l),p=0;p<l.length;p++)l[p].isInSet(f)||(i&&i.to==d&&i.mark.eq(l[p])?i.to=h:a.push(i=new oo(d,h,l[p])));o&&o.to==d?o.to=h:s.push(o=new io(d,h,r))}}}),a.forEach(function(t){return e.step(t)}),s.forEach(function(t){return e.step(t)})}(this,e,t,n),this}},{key:"removeMark",value:function(e,t,n){return function(e,t,n,r){var i=[],o=0;e.doc.nodesBetween(t,n,function(e,a){if(e.isInline){o++;var s=null;if(r instanceof Ni)for(var c,u=e.marks;c=r.isInSet(u);)(s||(s=[])).push(c),u=c.removeFromSet(u);else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length)for(var l=Math.min(a+e.nodeSize,n),d=0;d<s.length;d++){for(var h=s[d],f=void 0,p=0;p<i.length;p++){var v=i[p];v.step==o-1&&h.eq(i[p].style)&&(f=v)}f?(f.to=l,f.step=o):i.push({style:h,from:Math.max(a,t),to:l,step:o})}}}),i.forEach(function(t){return e.step(new oo(t.from,t.to,t.style))})}(this,e,t,n),this}},{key:"clearIncompatible",value:function(e,t,n){return ho(this,e,t,n),this}}])}(),Vo=Object.create(null),Fo=function(){return S(function e(t,n,r){x(this,e),this.$anchor=t,this.$head=n,this.ranges=r||[new $o(t.min(n),t.max(n))]},[{key:"anchor",get:function(){return this.$anchor.pos}},{key:"head",get:function(){return this.$head.pos}},{key:"from",get:function(){return this.$from.pos}},{key:"to",get:function(){return this.$to.pos}},{key:"$from",get:function(){return this.ranges[0].$from}},{key:"$to",get:function(){return this.ranges[0].$to}},{key:"empty",get:function(){for(var e=this.ranges,t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}},{key:"content",value:function(){return this.$from.doc.slice(this.from,this.to,!0)}},{key:"replace",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ur.empty,n=t.content.lastChild,r=null,i=0;i<t.openEnd;i++)r=n,n=n.lastChild;for(var o=e.steps.length,a=this.ranges,s=0;s<a.length;s++){var c=a[s],u=c.$from,l=c.$to,d=e.mapping.slice(o);e.replaceRange(d.map(u.pos),d.map(l.pos),s?Ur.empty:t),0==s&&Xo(e,o,(n?n.isInline:r&&r.isTextblock)?-1:1)}}},{key:"replaceWith",value:function(e,t){for(var n=e.steps.length,r=this.ranges,i=0;i<r.length;i++){var o=r[i],a=o.$from,s=o.$to,c=e.mapping.slice(n),u=c.map(a.pos),l=c.map(s.pos);i?e.deleteRange(u,l):(e.replaceRangeWith(u,l,t),Xo(e,n,t.isInline?-1:1))}}},{key:"getBookmark",value:function(){return Wo.between(this.$anchor,this.$head).getBookmark()}}],[{key:"findFrom",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=e.parent.inlineContent?new Wo(e):Go(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(var i=e.depth-1;i>=0;i--){var o=t<0?Go(e.node(0),e.node(i),e.before(i+1),e.index(i),t,n):Go(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,n);if(o)return o}return null}},{key:"near",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this.findFrom(e,t)||this.findFrom(e,-t)||new Ko(e.node(0))}},{key:"atStart",value:function(e){return Go(e,e,0,0,1)||new Ko(e)}},{key:"atEnd",value:function(e){return Go(e,e,e.content.size,e.childCount,-1)||new Ko(e)}},{key:"fromJSON",value:function(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");var n=Vo[t.type];if(!n)throw new RangeError("No selection type ".concat(t.type," defined"));return n.fromJSON(e,t)}},{key:"jsonID",value:function(e,t){if(e in Vo)throw new RangeError("Duplicate use of selection JSON ID "+e);return Vo[e]=t,t.prototype.jsonID=e,t}}])}();Fo.prototype.visible=!0;var $o=S(function e(t,n){x(this,e),this.$from=t,this.$to=n}),jo=!1;function Ho(e){jo||e.parent.inlineContent||(jo=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}var Wo=function(t){function n(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;return x(this,n),Ho(e),Ho(t),r(this,n,[e,t])}return a(n,t),S(n,[{key:"$cursor",get:function(){return this.$anchor.pos==this.$head.pos?this.$head:null}},{key:"map",value:function(e,t){var r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return Fo.near(r);var i=e.resolve(t.map(this.anchor));return new n(i.parent.inlineContent?i:r,r)}},{key:"replace",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ur.empty;if(e(n,"replace",this,3)([t,r]),r==Ur.empty){var i=this.$from.marksAcross(this.$to);i&&t.ensureMarks(i)}}},{key:"eq",value:function(e){return e instanceof n&&e.anchor==this.anchor&&e.head==this.head}},{key:"getBookmark",value:function(){return new qo(this.anchor,this.head)}},{key:"toJSON",value:function(){return{type:"text",anchor:this.anchor,head:this.head}}}],[{key:"fromJSON",value:function(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new n(e.resolve(t.anchor),e.resolve(t.head))}},{key:"create",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}},{key:"between",value:function(e,t,r){var i=e.pos-t.pos;if(r&&!i||(r=i>=0?1:-1),!t.parent.inlineContent){var o=Fo.findFrom(t,r,!0)||Fo.findFrom(t,-r,!0);if(!o)return Fo.near(t,r);t=o.$head}return e.parent.inlineContent||(0==i||(e=(Fo.findFrom(e,-r,!0)||Fo.findFrom(e,r,!0)).$anchor).pos<t.pos!=i<0)&&(e=t),new n(e,t)}}])}(Fo);Fo.jsonID("text",Wo);var qo=function(){function e(t,n){x(this,e),this.anchor=t,this.head=n}return S(e,[{key:"map",value:function(t){return new e(t.map(this.anchor),t.map(this.head))}},{key:"resolve",value:function(e){return Wo.between(e.resolve(this.anchor),e.resolve(this.head))}}])}(),Uo=function(e){function t(e){var n;x(this,t);var i=e.nodeAfter,o=e.node(0).resolve(e.pos+i.nodeSize);return(n=r(this,t,[e,o])).node=i,n}return a(t,e),S(t,[{key:"map",value:function(e,n){var r=n.mapResult(this.anchor),i=r.deleted,o=r.pos,a=e.resolve(o);return i?Fo.near(a):new t(a)}},{key:"content",value:function(){return new Ur(Fr.from(this.node),0,0)}},{key:"eq",value:function(e){return e instanceof t&&e.anchor==this.anchor}},{key:"toJSON",value:function(){return{type:"node",anchor:this.anchor}}},{key:"getBookmark",value:function(){return new Jo(this.anchor)}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new t(e.resolve(n.anchor))}},{key:"create",value:function(e,n){return new t(e.resolve(n))}},{key:"isSelectable",value:function(e){return!e.isText&&!1!==e.type.spec.selectable}}])}(Fo);Uo.prototype.visible=!1,Fo.jsonID("node",Uo);var Jo=function(){function e(t){x(this,e),this.anchor=t}return S(e,[{key:"map",value:function(t){var n=t.mapResult(this.anchor),r=n.deleted,i=n.pos;return r?new qo(i,i):new e(i)}},{key:"resolve",value:function(e){var t=e.resolve(this.anchor),n=t.nodeAfter;return n&&Uo.isSelectable(n)?new Uo(t):Fo.near(t)}}])}(),Ko=function(t){function n(e){return x(this,n),r(this,n,[e.resolve(0),e.resolve(e.content.size)])}return a(n,t),S(n,[{key:"replace",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ur.empty;if(r==Ur.empty){t.delete(0,t.doc.content.size);var i=Fo.atStart(t.doc);i.eq(t.selection)||t.setSelection(i)}else e(n,"replace",this,3)([t,r])}},{key:"toJSON",value:function(){return{type:"all"}}},{key:"map",value:function(e){return new n(e)}},{key:"eq",value:function(e){return e instanceof n}},{key:"getBookmark",value:function(){return Yo}}],[{key:"fromJSON",value:function(e){return new n(e)}}])}(Fo);Fo.jsonID("all",Ko);var Yo={map:function(){return this},resolve:function(e){return new Ko(e)}};function Go(e,t,n,r,i){var o=arguments.length>5&&void 0!==arguments[5]&&arguments[5];if(t.inlineContent)return Wo.create(e,n);for(var a=r-(i>0?0:1);i>0?a<t.childCount:a>=0;a+=i){var s=t.child(a);if(s.isAtom){if(!o&&Uo.isSelectable(s))return Uo.create(e,n-(i<0?s.nodeSize:0))}else{var c=Go(e,s,n+i,i<0?s.childCount:0,i,o);if(c)return c}n+=s.nodeSize*i}return null}function Xo(e,t,n){var r=e.steps.length-1;if(!(r<t)){var i,o=e.steps[r];if(o instanceof co||o instanceof uo)e.mapping.maps[r].forEach(function(e,t,n,r){null==i&&(i=r)}),e.setSelection(Fo.near(e.doc.resolve(i),n))}}var Zo=function(t){function n(e){var t;return x(this,n),(t=r(this,n,[e.doc])).curSelectionFor=0,t.updated=0,t.meta=Object.create(null),t.time=Date.now(),t.curSelection=e.selection,t.storedMarks=e.storedMarks,t}return a(n,t),S(n,[{key:"selection",get:function(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}},{key:"setSelection",value:function(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=-3&this.updated|1,this.storedMarks=null,this}},{key:"selectionSet",get:function(){return(1&this.updated)>0}},{key:"setStoredMarks",value:function(e){return this.storedMarks=e,this.updated|=2,this}},{key:"ensureMarks",value:function(e){return Wr.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}},{key:"addStoredMark",value:function(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}},{key:"removeStoredMark",value:function(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}},{key:"storedMarksSet",get:function(){return(2&this.updated)>0}},{key:"addStep",value:function(t,r){e(n,"addStep",this,3)([t,r]),this.updated=-3&this.updated,this.storedMarks=null}},{key:"setTime",value:function(e){return this.time=e,this}},{key:"replaceSelection",value:function(e){return this.selection.replace(this,e),this}},{key:"replaceSelectionWith",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||Wr.none))),n.replaceWith(this,e),this}},{key:"deleteSelection",value:function(){return this.selection.replace(this),this}},{key:"insertText",value:function(e,t,n){var r=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();if(null==n&&(n=t),!e)return this.deleteRange(t,n);var i=this.storedMarks;if(!i){var o=this.doc.resolve(t);i=n==t?o.marks():o.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),this.selection.empty||this.selection.to!=t+e.length||this.setSelection(Fo.near(this.selection.$to)),this}},{key:"setMeta",value:function(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}},{key:"getMeta",value:function(e){return this.meta["string"==typeof e?e:e.key]}},{key:"isGeneric",get:function(){for(var e in this.meta)return!1;return!0}},{key:"scrollIntoView",value:function(){return this.updated|=4,this}},{key:"scrolledIntoView",get:function(){return(4&this.updated)>0}}])}(Bo);function Qo(e,t){return t&&e?e.bind(t):e}var ea=S(function e(t,n,r){x(this,e),this.name=t,this.init=Qo(n.init,r),this.apply=Qo(n.apply,r)}),ta=[new ea("doc",{init:function(e){return e.doc||e.schema.topNodeType.createAndFill()},apply:function(e){return e.doc}}),new ea("selection",{init:function(e,t){return e.selection||Fo.atStart(t.doc)},apply:function(e){return e.selection}}),new ea("storedMarks",{init:function(e){return e.storedMarks||null},apply:function(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new ea("scrollToSelection",{init:function(){return 0},apply:function(e,t){return e.scrolledIntoView?t+1:t}})],na=S(function e(t,n){var r=this;x(this,e),this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=ta.slice(),n&&n.forEach(function(e){if(r.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");r.plugins.push(e),r.pluginsByKey[e.key]=e,e.spec.state&&r.fields.push(new ea(e.key,e.spec.state,e))})}),ra=function(){function e(t){x(this,e),this.config=t}return S(e,[{key:"schema",get:function(){return this.config.schema}},{key:"plugins",get:function(){return this.config.plugins}},{key:"apply",value:function(e){return this.applyTransaction(e).state}},{key:"filterTransaction",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1,n=0;n<this.config.plugins.length;n++)if(n!=t){var r=this.config.plugins[n];if(r.spec.filterTransaction&&!r.spec.filterTransaction.call(r,e,this))return!1}return!0}},{key:"applyTransaction",value:function(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};for(var t=[e],n=this.applyInner(e),r=null;;){for(var i=!1,o=0;o<this.config.plugins.length;o++){var a=this.config.plugins[o];if(a.spec.appendTransaction){var s=r?r[o].n:0,c=r?r[o].state:this,u=s<t.length&&a.spec.appendTransaction.call(a,s?t.slice(s):t,c,n);if(u&&n.filterTransaction(u,o)){if(u.setMeta("appendedTransaction",e),!r){r=[];for(var l=0;l<this.config.plugins.length;l++)r.push(l<o?{state:n,n:t.length}:{state:this,n:0})}t.push(u),n=n.applyInner(u),i=!0}r&&(r[o]={state:n,n:t.length})}}if(!i)return{state:n,transactions:t}}}},{key:"applyInner",value:function(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");for(var n=new e(this.config),r=this.config.fields,i=0;i<r.length;i++){var o=r[i];n[o.name]=o.apply(t,this[o.name],this,n)}return n}},{key:"tr",get:function(){return new Zo(this)}},{key:"reconfigure",value:function(t){for(var n=new na(this.schema,t.plugins),r=n.fields,i=new e(n),o=0;o<r.length;o++){var a=r[o].name;i[a]=this.hasOwnProperty(a)?this[a]:r[o].init(t,i)}return i}},{key:"toJSON",value:function(e){var t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(function(e){return e.toJSON()})),e&&"object"==T(e))for(var n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");var r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}}],[{key:"create",value:function(t){for(var n=new na(t.doc?t.doc.type.schema:t.schema,t.plugins),r=new e(n),i=0;i<n.fields.length;i++)r[n.fields[i].name]=n.fields[i].init(t,r);return r}},{key:"fromJSON",value:function(t,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");var i=new na(t.schema,t.plugins),o=new e(i);return i.fields.forEach(function(e){if("doc"==e.name)o.doc=li.fromJSON(t.schema,n.doc);else if("selection"==e.name)o.selection=Fo.fromJSON(o.doc,n.selection);else if("storedMarks"==e.name)n.storedMarks&&(o.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(r)for(var i in r){var a=r[i],s=a.spec.state;if(a.key==e.name&&s&&s.fromJSON&&Object.prototype.hasOwnProperty.call(n,i))return void(o[e.name]=s.fromJSON.call(a,t,n[i],o))}o[e.name]=e.init(t,o)}}),o}}])}();function ia(e,t,n){for(var r in e){var i=e[r];i instanceof Function?i=i.bind(t):"handleDOMEvents"==r&&(i=ia(i,t,{})),n[r]=i}return n}var oa=function(){return S(function e(t){x(this,e),this.spec=t,this.props={},t.props&&ia(t.props,this,this.props),this.key=t.key?t.key.key:sa("plugin")},[{key:"getState",value:function(e){return e[this.key]}}])}(),aa=Object.create(null);function sa(e){return e in aa?e+"$"+ ++aa[e]:(aa[e]=0,e+"$")}var ca=function(){return S(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"key";x(this,e),this.key=sa(t)},[{key:"get",value:function(e){return e.config.pluginsByKey[this.key]}},{key:"getState",value:function(e){return e[this.key]}}])}();function ua(e,t){var n=e.selection.$cursor;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}function la(e,t,n){for(var r=t.nodeBefore,i=t.pos-1;!r.isTextblock;i--){if(r.type.spec.isolating)return!1;var o=r.lastChild;if(!o)return!1;r=o}for(var a=t.nodeAfter,s=t.pos+1;!a.isTextblock;s++){if(a.type.spec.isolating)return!1;var c=a.firstChild;if(!c)return!1;a=c}var u=So(e.doc,i,s,Ur.empty);if(!u||u.from!=i||u instanceof co&&u.slice.size>=s-i)return!1;if(n){var l=e.tr.step(u);l.setSelection(Wo.create(l.doc,i)),n(l.scrollIntoView())}return!0}function da(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=e;r;r="start"==t?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)return!1}return!1}function ha(e){if(!e.parent.type.spec.isolating)for(var t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function fa(e,t){var n=e.selection.$cursor;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}function pa(e){if(!e.parent.type.spec.isolating)for(var t=e.depth-1;t>=0;t--){var n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}function va(e){for(var t=0;t<e.edgeCount;t++){var n=e.edge(t).type;if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function ma(e,t,n,r){var i,o,a=t.nodeBefore,s=t.nodeAfter,c=a.type.spec.isolating||s.type.spec.isolating;if(!c&&function(e,t,n){var r=t.nodeBefore,i=t.nodeAfter,o=t.index();return!(!(r&&i&&r.type.compatibleContent(i.type))||(!r.content.size&&t.parent.canReplace(o-1,o)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(o,o+1)||!i.isTextblock&&!wo(e.doc,t.pos)||(n&&n(e.tr.join(t.pos).scrollIntoView()),0)))}(e,t,n))return!0;var u=!c&&t.parent.canReplace(t.index(),t.index()+1);if(u&&(i=(o=a.contentMatchAt(a.childCount)).findWrapping(s.type))&&o.matchType(i[0]||s.type).validEnd){if(n){for(var l=t.pos+s.nodeSize,d=Fr.empty,h=i.length-1;h>=0;h--)d=Fr.from(i[h].create(null,d));d=Fr.from(a.copy(d));var f=e.tr.step(new uo(t.pos-1,l,t.pos,l,new Ur(d,1,0),i.length,!0)),p=f.doc.resolve(l+2*i.length);p.nodeAfter&&p.nodeAfter.type==a.type&&wo(f.doc,p.pos)&&f.join(p.pos),n(f.scrollIntoView())}return!0}var v=s.type.spec.isolating||r>0&&c?null:Fo.findFrom(t,1),m=v&&v.$from.blockRange(v.$to),g=m&&po(m);if(null!=g&&g>=t.depth)return n&&n(e.tr.lift(m,g).scrollIntoView()),!0;if(u&&da(s,"start",!0)&&da(a,"end")){for(var y=a,k=[];k.push(y),!y.isTextblock;)y=y.lastChild;for(var w=s,b=1;!w.isTextblock;w=w.firstChild)b++;if(y.canReplace(y.childCount,y.childCount,w.content)){if(n){for(var x=Fr.empty,C=k.length-1;C>=0;C--)x=Fr.from(k[C].copy(x));n(e.tr.step(new uo(t.pos-k.length,t.pos+s.nodeSize,t.pos+b,t.pos+s.nodeSize-b,new Ur(x,k.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function ga(e){return function(t,n){for(var r=t.selection,i=e<0?r.$from:r.$to,o=i.depth;i.node(o).isInline;){if(!o)return!1;o--}return!!i.node(o).isTextblock&&(n&&n(t.tr.setSelection(Wo.create(t.doc,e<0?i.start(o):i.end(o)))),!0)}}var ya=ga(-1),ka=ga(1);function wa(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return function(n,r){for(var i=!1,o=0;o<n.selection.ranges.length&&!i;o++){var a=n.selection.ranges[o],s=a.$from.pos,c=a.$to.pos;n.doc.nodesBetween(s,c,function(r,o){if(i)return!1;if(r.isTextblock&&!r.hasMarkup(e,t))if(r.type==e)i=!0;else{var a=n.doc.resolve(o),s=a.index();i=a.parent.canReplaceWith(s,s+1,e)}})}if(!i)return!1;if(r){for(var u=n.tr,l=0;l<n.selection.ranges.length;l++){var d=n.selection.ranges[l],h=d.$from.pos,f=d.$to.pos;u.setBlockType(h,f,e,t)}r(u.scrollIntoView())}return!0}}function ba(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return function(n,r){var i=n.selection,o=i.$from,a=i.$to,s=o.blockRange(a);if(!s)return!1;var c=r?n.tr:null;return!!function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=!1,o=t,a=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&0==t.startIndex){if(0==t.$from.index(t.depth-1))return!1;var s=a.resolve(t.start-2);o=new ci(s,s,t.depth),t.endIndex<t.parent.childCount&&(t=new ci(t.$from,a.resolve(t.$to.end(t.depth)),t.depth)),i=!0}var c=vo(o,n,r,t);if(!c)return!1;e&&function(e,t,n,r,i){for(var o=Fr.empty,a=n.length-1;a>=0;a--)o=Fr.from(n[a].type.create(n[a].attrs,o));e.step(new uo(t.start-(r?2:0),t.end,t.start,t.end,new Ur(o,0,0),n.length,!0));for(var s=0,c=0;c<n.length;c++)n[c].type==i&&(s=c+1);for(var u=n.length-s,l=t.start+n.length-(r?2:0),d=t.parent,h=t.startIndex,f=t.endIndex,p=!0;h<f;h++,p=!1)!p&&ko(e.doc,l,u)&&(e.split(l,u),l+=2*u),l+=d.child(h).nodeSize}(e,t,c,i,n);return!0}(c,s,e,t)&&(r&&r(c.scrollIntoView()),!0)}}function xa(e){return function(t,n){var r=t.selection,i=r.$from,o=r.$to,a=i.blockRange(o,function(t){return t.childCount>0&&t.firstChild.type==e});return!!a&&(!n||(i.node(a.depth-1).type==e?function(e,t,n,r){var i=e.tr,o=r.end,a=r.$to.end(r.depth);o<a&&(i.step(new uo(o-1,a,o,a,new Ur(Fr.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new ci(i.doc.resolve(r.$from.pos),i.doc.resolve(a),r.depth));var s=po(r);if(null==s)return!1;i.lift(r,s);var c=i.doc.resolve(i.mapping.map(o,-1)-1);wo(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos);return t(i.scrollIntoView()),!0}(t,n,e,a):function(e,t,n){for(var r=e.tr,i=n.parent,o=n.end,a=n.endIndex-1,s=n.startIndex;a>s;a--)o-=i.child(a).nodeSize,r.delete(o-1,o+1);var c=r.doc.resolve(n.start),u=c.nodeAfter;if(r.mapping.map(n.end)!=n.start+c.nodeAfter.nodeSize)return!1;var l=0==n.startIndex,d=n.endIndex==i.childCount,h=c.node(-1),f=c.index(-1);if(!h.canReplace(f+(l?0:1),f+1,u.content.append(d?Fr.empty:Fr.from(i))))return!1;var p=c.pos,v=p+u.nodeSize;return r.step(new uo(p-(l?1:0),v+(d?1:0),p+1,v-1,new Ur((l?Fr.empty:Fr.from(i.copy(Fr.empty))).append(d?Fr.empty:Fr.from(i.copy(Fr.empty))),l?0:1,d?0:1),l?0:1)),t(r.scrollIntoView()),!0}(t,n,a)))}}"undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&os.platform();var Ca=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},Sa=function(e){var t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t},_a=null,Ma=function(e,t,n){var r=_a||(_a=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},Ta=function(e,t,n,r){return n&&(Na(e,t,n,r,-1)||Na(e,t,n,r,1))},Oa=/^(img|br|input|textarea|hr)$/i;function Na(e,t,n,r,i){for(var o;;){if(e==n&&t==r)return!0;if(t==(i<0?0:Ea(e))){var a=e.parentNode;if(!a||1!=a.nodeType||Aa(e)||Oa.test(e.nodeName)||"false"==e.contentEditable)return!1;t=Ca(e)+(i<0?0:1),e=a}else{if(1!=e.nodeType)return!1;var s=e.childNodes[t+(i<0?-1:0)];if(1==s.nodeType&&"false"==s.contentEditable){if(!(null===(o=s.pmViewDesc)||void 0===o?void 0:o.ignoreForSelection))return!1;t+=i}else e=s,t=i<0?Ea(e):0}}}function Ea(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Aa(e){for(var t,n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}var Da=function(e){return e.focusNode&&Ta(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function Ia(e,t){var n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}var za="undefined"!=typeof navigator?navigator:null,Ra="undefined"!=typeof document?document:null,Pa=za&&za.userAgent||"",La=/Edge\/(\d+)/.exec(Pa),Ba=/MSIE \d/.exec(Pa),Va=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Pa),Fa=!!(Ba||Va||La),$a=Ba?document.documentMode:Va?+Va[1]:La?+La[1]:0,ja=!Fa&&/gecko\/(\d+)/i.test(Pa);ja&&(/Firefox\/(\d+)/.exec(Pa)||[0,0])[1];var Ha=!Fa&&/Chrome\/(\d+)/.exec(Pa),Wa=!!Ha,qa=Ha?+Ha[1]:0,Ua=!Fa&&!!za&&/Apple Computer/.test(za.vendor),Ja=Ua&&(/Mobile\/\w+/.test(Pa)||!!za&&za.maxTouchPoints>2),Ka=Ja||!!za&&/Mac/.test(za.platform),Ya=!!za&&/Win/.test(za.platform),Ga=/Android \d/.test(Pa),Xa=!!Ra&&"webkitFontSmoothing"in Ra.documentElement.style,Za=Xa?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Qa(e){var t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function es(e,t){return"number"==typeof e?e:e[t]}function ts(e){var t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function ns(e,t,n){for(var r=e.someProp("scrollThreshold")||0,i=e.someProp("scrollMargin")||5,o=e.dom.ownerDocument,a=n||e.dom;a;)if(1==a.nodeType){var s=a,c=s==o.body,u=c?Qa(o):ts(s),l=0,d=0;if(t.top<u.top+es(r,"top")?d=-(u.top-t.top+es(i,"top")):t.bottom>u.bottom-es(r,"bottom")&&(d=t.bottom-t.top>u.bottom-u.top?t.top+es(i,"top")-u.top:t.bottom-u.bottom+es(i,"bottom")),t.left<u.left+es(r,"left")?l=-(u.left-t.left+es(i,"left")):t.right>u.right-es(r,"right")&&(l=t.right-u.right+es(i,"right")),l||d)if(c)o.defaultView.scrollBy(l,d);else{var h=s.scrollLeft,f=s.scrollTop;d&&(s.scrollTop+=d),l&&(s.scrollLeft+=l);var p=s.scrollLeft-h,v=s.scrollTop-f;t={left:t.left-p,top:t.top-v,right:t.right-p,bottom:t.bottom-v}}var m=c?"fixed":getComputedStyle(a).position;if(/^(fixed|sticky)$/.test(m))break;a="absolute"==m?a.offsetParent:Sa(a)}else a=Sa(a)}function rs(e){for(var t=[],n=e.ownerDocument,r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=Sa(r));return t}function is(e,t){for(var n=0;n<e.length;n++){var r=e[n],i=r.dom,o=r.top,a=r.left;i.scrollTop!=o+t&&(i.scrollTop=o+t),i.scrollLeft!=a&&(i.scrollLeft=a)}}var as=null;function ss(e,t){for(var n,r,i,o,a=2e8,s=0,c=t.top,u=t.top,l=e.firstChild,d=0;l;l=l.nextSibling,d++){var h=void 0;if(1==l.nodeType)h=l.getClientRects();else{if(3!=l.nodeType)continue;h=Ma(l).getClientRects()}for(var f=0;f<h.length;f++){var p=h[f];if(p.top<=c&&p.bottom>=u){c=Math.max(p.bottom,c),u=Math.min(p.top,u);var v=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(v<a){n=l,a=v,r=v&&3==n.nodeType?{left:p.right<t.left?p.right:p.left,top:t.top}:t,1==l.nodeType&&v&&(s=d+(t.left>=(p.left+p.right)/2?1:0));continue}}else p.top>t.top&&!i&&p.left<=t.left&&p.right>=t.left&&(i=l,o={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(s=d+1)}}return!n&&i&&(n=i,r=o,a=0),n&&3==n.nodeType?function(e,t){for(var n,r=e.nodeValue.length,i=document.createRange(),o=0;o<r;o++){i.setEnd(e,o+1),i.setStart(e,o);var a=hs(i,1);if(a.top!=a.bottom&&cs(t,a)){n={node:e,offset:o+(t.left>=(a.left+a.right)/2?1:0)};break}}return i.detach(),n||{node:e,offset:0}}(n,r):!n||a&&1==n.nodeType?{node:e,offset:s}:ss(n,r)}function cs(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function us(e,t,n){var r=e.childNodes.length;if(r&&n.top<n.bottom)for(var i=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),o=i;;){var a=e.childNodes[o];if(1==a.nodeType)for(var s=a.getClientRects(),c=0;c<s.length;c++){var u=s[c];if(cs(t,u))return us(a,t,u)}if((o=(o+1)%r)==i)break}return e}function ls(e,t){var n,r=e.dom.ownerDocument,i=0,o=function(e,t,n){if(e.caretPositionFromPoint)try{var r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(Ea(r.offsetNode),r.offset)}}catch(xt){}if(e.caretRangeFromPoint){var i=e.caretRangeFromPoint(t,n);if(i)return{node:i.startContainer,offset:Math.min(Ea(i.startContainer),i.startOffset)}}}(r,t.left,t.top);o&&(n=o.node,i=o.offset);var a,s=(e.root.elementFromPoint?e.root:r).elementFromPoint(t.left,t.top);if(!s||!e.dom.contains(1!=s.nodeType?s.parentNode:s)){var c=e.dom.getBoundingClientRect();if(!cs(t,c))return null;if(!(s=us(e.dom,t,c)))return null}if(Ua)for(var u=s;n&&u;u=Sa(u))u.draggable&&(n=void 0);if(s=function(e,t){var n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(s,t),n){if(ja&&1==n.nodeType&&(i=Math.min(i,n.childNodes.length))<n.childNodes.length){var l,d=n.childNodes[i];"IMG"==d.nodeName&&(l=d.getBoundingClientRect()).right<=t.left&&l.bottom>t.top&&i++}var h;Xa&&i&&1==n.nodeType&&1==(h=n.childNodes[i-1]).nodeType&&"false"==h.contentEditable&&h.getBoundingClientRect().top>=t.top&&i--,n==e.dom&&i==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?a=e.state.doc.content.size:0!=i&&1==n.nodeType&&"BR"==n.childNodes[i-1].nodeName||(a=function(e,t,n,r){for(var i=-1,o=t,a=!1;o!=e.dom;){var s=e.docView.nearestDesc(o,!0),c=void 0;if(!s)return null;if(1==s.dom.nodeType&&(s.node.isBlock&&s.parent||!s.contentDOM)&&((c=s.dom.getBoundingClientRect()).width||c.height)&&(s.node.isBlock&&s.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(s.dom.nodeName)&&(!a&&c.left>r.left||c.top>r.top?i=s.posBefore:(!a&&c.right<r.left||c.bottom<r.top)&&(i=s.posAfter),a=!0),!s.contentDOM&&i<0&&!s.node.isText))return(s.node.isBlock?r.top<(c.top+c.bottom)/2:r.left<(c.left+c.right)/2)?s.posBefore:s.posAfter;o=s.dom.parentNode}return i>-1?i:e.docView.posFromDOM(t,n,-1)}(e,n,i,t))}null==a&&(a=function(e,t,n){var r=ss(t,n),i=r.node,o=r.offset,a=-1;if(1==i.nodeType&&!i.firstChild){var s=i.getBoundingClientRect();a=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return e.docView.posFromDOM(i,o,a)}(e,s,t));var f=e.docView.nearestDesc(s,!0);return{pos:a,inside:f?f.posAtStart-f.border:-1}}function ds(e){return e.top<e.bottom||e.left<e.right}function hs(e,t){var n=e.getClientRects();if(n.length){var r=n[t<0?0:n.length-1];if(ds(r))return r}return Array.prototype.find.call(n,ds)||e.getBoundingClientRect()}var fs=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function ps(e,t,n){var r=e.docView.domFromPos(t,n<0?-1:1),i=r.node,o=r.offset,a=r.atom,s=Xa||ja;if(3==i.nodeType){if(!s||!fs.test(i.nodeValue)&&(n<0?o:o!=i.nodeValue.length)){var c=o,u=o,l=n<0?1:-1;return n<0&&!o?(u++,l=-1):n>=0&&o==i.nodeValue.length?(c--,l=1):n<0?c--:u++,vs(hs(Ma(i,c,u),l),l<0)}var d=hs(Ma(i,o,o),n);if(ja&&o&&/\s/.test(i.nodeValue[o-1])&&o<i.nodeValue.length){var h=hs(Ma(i,o-1,o-1),-1);if(h.top==d.top){var f=hs(Ma(i,o,o+1),-1);if(f.top!=d.top)return vs(f,f.left<h.left)}}return d}if(!e.state.doc.resolve(t-(a||0)).parent.inlineContent){if(null==a&&o&&(n<0||o==Ea(i))){var p=i.childNodes[o-1];if(1==p.nodeType)return ms(p.getBoundingClientRect(),!1)}if(null==a&&o<Ea(i)){var v=i.childNodes[o];if(1==v.nodeType)return ms(v.getBoundingClientRect(),!0)}return ms(i.getBoundingClientRect(),n>=0)}if(null==a&&o&&(n<0||o==Ea(i))){var m=i.childNodes[o-1],g=3==m.nodeType?Ma(m,Ea(m)-(s?0:1)):1!=m.nodeType||"BR"==m.nodeName&&m.nextSibling?null:m;if(g)return vs(hs(g,1),!1)}if(null==a&&o<Ea(i)){for(var y=i.childNodes[o];y.pmViewDesc&&y.pmViewDesc.ignoreForCoords;)y=y.nextSibling;var k=y?3==y.nodeType?Ma(y,0,s?0:1):1==y.nodeType?y:null:null;if(k)return vs(hs(k,-1),!0)}return vs(hs(3==i.nodeType?Ma(i):i,-n),n>=0)}function vs(e,t){if(0==e.width)return e;var n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function ms(e,t){if(0==e.height)return e;var n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function gs(e,t,n){var r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}var ys=/[\u0590-\u08ac]/;var ks=null,ws=null,bs=!1;function xs(e,t,n){return ks==t&&ws==n?bs:(ks=t,ws=n,bs="up"==n||"down"==n?function(e,t,n){var r=t.selection,i="up"==n?r.$from:r.$to;return gs(e,t,function(){for(var t=e.docView.domFromPos(i.pos,"up"==n?-1:1).node;;){var r=e.docView.nearestDesc(t,!0);if(!r)break;if(r.node.isBlock){t=r.contentDOM||r.dom;break}t=r.dom.parentNode}for(var o=ps(e,i.pos,1),a=t.firstChild;a;a=a.nextSibling){var s=void 0;if(1==a.nodeType)s=a.getClientRects();else{if(3!=a.nodeType)continue;s=Ma(a,0,a.nodeValue.length).getClientRects()}for(var c=0;c<s.length;c++){var u=s[c];if(u.bottom>u.top+1&&("up"==n?o.top-u.top>2*(u.bottom-o.top):u.bottom-o.bottom>2*(o.bottom-u.top)))return!1}}return!0})}(e,t,n):function(e,t,n){var r=t.selection.$head;if(!r.parent.isTextblock)return!1;var i=r.parentOffset,o=!i,a=i==r.parent.content.size,s=e.domSelection();return s?ys.test(r.parent.textContent)&&s.modify?gs(e,t,function(){var t=e.domSelectionRange(),i=t.focusNode,o=t.focusOffset,a=t.anchorNode,c=t.anchorOffset,u=s.caretBidiLevel;s.modify("move",n,"character");var l=r.depth?e.docView.domAfterPos(r.before()):e.dom,d=e.domSelectionRange(),h=d.focusNode,f=d.focusOffset,p=h&&!l.contains(1==h.nodeType?h:h.parentNode)||i==h&&o==f;try{s.collapse(a,c),i&&(i!=a||o!=c)&&s.extend&&s.extend(i,o)}catch(xt){}return null!=u&&(s.caretBidiLevel=u),p}):"left"==n||"backward"==n?o:a:r.pos==r.start()||r.pos==r.end()}(e,t,n))}var Cs=function(){return S(function e(t,n,r,i){x(this,e),this.parent=t,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=0,r.pmViewDesc=this},[{key:"matchesWidget",value:function(e){return!1}},{key:"matchesMark",value:function(e){return!1}},{key:"matchesNode",value:function(e,t,n){return!1}},{key:"matchesHack",value:function(e){return!1}},{key:"parseRule",value:function(){return null}},{key:"stopEvent",value:function(e){return!1}},{key:"size",get:function(){for(var e=0,t=0;t<this.children.length;t++)e+=this.children[t].size;return e}},{key:"border",get:function(){return 0}},{key:"destroy",value:function(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(var e=0;e<this.children.length;e++)this.children[e].destroy()}},{key:"posBeforeChild",value:function(e){for(var t=0,n=this.posAtStart;;t++){var r=this.children[t];if(r==e)return n;n+=r.size}}},{key:"posBefore",get:function(){return this.parent.posBeforeChild(this)}},{key:"posAtStart",get:function(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}},{key:"posAfter",get:function(){return this.posBefore+this.size}},{key:"posAtEnd",get:function(){return this.posAtStart+this.size-2*this.border}},{key:"localPosFromDOM",value:function(e,t,n){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(n<0){var r,i;if(e==this.contentDOM)r=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;r=e.previousSibling}for(;r&&(!(i=r.pmViewDesc)||i.parent!=this);)r=r.previousSibling;return r?this.posBeforeChild(i)+i.size:this.posAtStart}var o,a;if(e==this.contentDOM)o=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&(!(a=o.pmViewDesc)||a.parent!=this);)o=o.nextSibling;return o?this.posBeforeChild(a):this.posAtEnd}var s;if(e==this.dom&&this.contentDOM)s=t>Ca(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(var c=e;;c=c.parentNode){if(c==this.dom){s=!1;break}if(c.previousSibling)break}if(null==s&&t==e.childNodes.length)for(var u=e;;u=u.parentNode){if(u==this.dom){s=!0;break}if(u.nextSibling)break}}return(null==s?n>0:s)?this.posAtEnd:this.posAtStart}},{key:"nearestDesc",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=!0,r=e;r;r=r.parentNode){var i=this.getDesc(r),o=void 0;if(i&&(!t||i.node)){if(!n||!(o=i.nodeDOM)||(1==o.nodeType?o.contains(1==e.nodeType?e:e.parentNode):o==e))return i;n=!1}}}},{key:"getDesc",value:function(e){for(var t=e.pmViewDesc,n=t;n;n=n.parent)if(n==this)return t}},{key:"posFromDOM",value:function(e,t,n){for(var r=e;r;r=r.parentNode){var i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return-1}},{key:"descAt",value:function(e){for(var t=0,n=0;t<this.children.length;t++){var r=this.children[t],i=n+r.size;if(n==e&&i!=n){for(;!r.border&&r.children.length;)for(var o=0;o<r.children.length;o++){var a=r.children[o];if(a.size){r=a;break}}return r}if(e<i)return r.descAt(e-n-r.border);n=i}}},{key:"domFromPos",value:function(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};for(var n,r=0,i=0,o=0;r<this.children.length;r++){var a=this.children[r],s=o+a.size;if(s>e||a instanceof Es){i=e-o;break}o=s}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(;r&&!(n=this.children[r-1]).size&&n instanceof Ss&&n.side>=0;r--);if(t<=0){for(var c,u=!0;(c=r?this.children[r-1]:null)&&c.dom.parentNode!=this.contentDOM;r--,u=!1);return c&&t&&u&&!c.border&&!c.domAtom?c.domFromPos(c.size,t):{node:this.contentDOM,offset:c?Ca(c.dom)+1:0}}for(var l,d=!0;(l=r<this.children.length?this.children[r]:null)&&l.dom.parentNode!=this.contentDOM;r++,d=!1);return l&&d&&!l.border&&!l.domAtom?l.domFromPos(0,t):{node:this.contentDOM,offset:l?Ca(l.dom):this.contentDOM.childNodes.length}}},{key:"parseRange",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};for(var r=-1,i=-1,o=n,a=0;;a++){var s=this.children[a],c=o+s.size;if(-1==r&&e<=c){var u=o+s.border;if(e>=u&&t<=c-s.border&&s.node&&s.contentDOM&&this.contentDOM.contains(s.contentDOM))return s.parseRange(e,t,u);e=o;for(var l=a;l>0;l--){var d=this.children[l-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){r=Ca(d.dom)+1;break}e-=d.size}-1==r&&(r=0)}if(r>-1&&(c>t||a==this.children.length-1)){t=c;for(var h=a+1;h<this.children.length;h++){var f=this.children[h];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){i=Ca(f.dom);break}t+=f.size}-1==i&&(i=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:i}}},{key:"emptyChildAt",value:function(e){if(this.border||!this.contentDOM||!this.children.length)return!1;var t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}},{key:"domAfterPos",value:function(e){var t=this.domFromPos(e,0),n=t.node,r=t.offset;if(1!=n.nodeType||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}},{key:"setSelection",value:function(e,t,n){for(var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=Math.min(e,t),o=Math.max(e,t),a=0,s=0;a<this.children.length;a++){var c=this.children[a],u=s+c.size;if(i>s&&o<u)return c.setSelection(e-s-c.border,t-s-c.border,n,r);s=u}var l=this.domFromPos(e,e?-1:1),d=t==e?l:this.domFromPos(t,t?-1:1),h=n.root.getSelection(),f=n.domSelectionRange(),p=!1;if((ja||Ua)&&e==t){var v=l,m=v.node,g=v.offset;if(3==m.nodeType){if((p=!(!g||"\n"!=m.nodeValue[g-1]))&&g==m.nodeValue.length)for(var y,k=m;k;k=k.parentNode){if(y=k.nextSibling){"BR"==y.nodeName&&(l=d={node:y.parentNode,offset:Ca(y)+1});break}var w=k.pmViewDesc;if(w&&w.node&&w.node.isBlock)break}}else{var b=m.childNodes[g-1];p=b&&("BR"==b.nodeName||"false"==b.contentEditable)}}if(ja&&f.focusNode&&f.focusNode!=d.node&&1==f.focusNode.nodeType){var x=f.focusNode.childNodes[f.focusOffset];x&&"false"==x.contentEditable&&(r=!0)}if(r||p&&Ua||!Ta(l.node,l.offset,f.anchorNode,f.anchorOffset)||!Ta(d.node,d.offset,f.focusNode,f.focusOffset)){var C=!1;if((h.extend||e==t)&&(!p||!ja)){h.collapse(l.node,l.offset);try{e!=t&&h.extend(d.node,d.offset),C=!0}catch(xt){}}if(!C){if(e>t){var S=l;l=d,d=S}var _=document.createRange();_.setEnd(d.node,d.offset),_.setStart(l.node,l.offset),h.removeAllRanges(),h.addRange(_)}}}},{key:"ignoreMutation",value:function(e){return!this.contentDOM&&"selection"!=e.type}},{key:"contentLost",get:function(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}},{key:"markDirty",value:function(e,t){for(var n=0,r=0;r<this.children.length;r++){var i=this.children[r],o=n+i.size;if(n==o?e<=o&&t>=n:e<o&&t>n){var a=n+i.border,s=o-i.border;if(e>=a&&t<=s)return this.dirty=e==n||t==o?2:1,void(e!=a||t!=s||!i.contentLost&&i.dom.parentNode==this.contentDOM?i.markDirty(e-a,t-a):i.dirty=3);i.dirty=i.dom!=i.contentDOM||i.dom.parentNode!=this.contentDOM||i.children.length?3:2}n=o}this.dirty=2}},{key:"markParentsDirty",value:function(){for(var e=1,t=this.parent;t;t=t.parent,e++){var n=1==e?2:1;t.dirty<n&&(t.dirty=n)}}},{key:"domAtom",get:function(){return!1}},{key:"ignoreForCoords",get:function(){return!1}},{key:"ignoreForSelection",get:function(){return!1}},{key:"isText",value:function(e){return!1}}])}(),Ss=function(t){function n(e,t,i,o){var a;x(this,n);var s,c=t.type.toDOM;if("function"==typeof c&&(c=c(i,function(){return s?s.parent?s.parent.posBeforeChild(s):void 0:o})),!t.type.spec.raw){if(1!=c.nodeType){var u=document.createElement("span");u.appendChild(c),c=u}c.contentEditable="false",c.classList.add("ProseMirror-widget")}return(a=r(this,n,[e,[],c,null])).widget=t,a.widget=t,s=a,a}return a(n,t),S(n,[{key:"matchesWidget",value:function(e){return 0==this.dirty&&e.type.eq(this.widget.type)}},{key:"parseRule",value:function(){return{ignore:!0}}},{key:"stopEvent",value:function(e){var t=this.widget.spec.stopEvent;return!!t&&t(e)}},{key:"ignoreMutation",value:function(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}},{key:"destroy",value:function(){this.widget.type.destroy(this.dom),e(n,"destroy",this,3)([])}},{key:"domAtom",get:function(){return!0}},{key:"ignoreForSelection",get:function(){return!!this.widget.type.spec.relaxedSide}},{key:"side",get:function(){return this.widget.type.side}}])}(Cs),_s=function(e){function t(e,n,i,o){var a;return x(this,t),(a=r(this,t,[e,[],n,null])).textDOM=i,a.text=o,a}return a(t,e),S(t,[{key:"size",get:function(){return this.text.length}},{key:"localPosFromDOM",value:function(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}},{key:"domFromPos",value:function(e){return{node:this.textDOM,offset:e}}},{key:"ignoreMutation",value:function(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue}}])}(Cs),Ms=function(t){function n(e,t,i,o,a){var s;return x(this,n),(s=r(this,n,[e,[],i,o])).mark=t,s.spec=a,s}return a(n,t),S(n,[{key:"parseRule",value:function(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}},{key:"matchesMark",value:function(e){return 3!=this.dirty&&this.mark.eq(e)}},{key:"markDirty",value:function(t,r){if(e(n,"markDirty",this,3)([t,r]),0!=this.dirty){for(var i=this.parent;!i.node;)i=i.parent;i.dirty<this.dirty&&(i.dirty=this.dirty),this.dirty=0}}},{key:"slice",value:function(e,t,r){var i=n.create(this.parent,this.mark,!0,r),o=this.children,a=this.size;t<a&&(o=Hs(o,t,a,r)),e>0&&(o=Hs(o,0,e,r));for(var s=0;s<o.length;s++)o[s].parent=i;return i.children=o,i}},{key:"ignoreMutation",value:function(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):e(n,"ignoreMutation",this,3)([t])}},{key:"destroy",value:function(){this.spec.destroy&&this.spec.destroy(),e(n,"destroy",this,3)([])}}],[{key:"create",value:function(e,t,r,i){var o=i.nodeViews[t.type.name],a=o&&o(t,i,r);return a&&a.dom||(a=ji.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new n(e,t,a.dom,a.contentDOM||a.dom,a)}}])}(Cs),Ts=function(e){function t(e,n,i,o,a,s,c,u,l){var d;return x(this,t),(d=r(this,t,[e,[],a,s])).node=n,d.outerDeco=i,d.innerDeco=o,d.nodeDOM=c,d}return a(t,e),S(t,[{key:"parseRule",value:function(){var e=this;if(this.node.type.spec.reparseInView)return null;var 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(var n=this.children.length-1;n>=0;n--){var r=this.children[n];if(this.dom.contains(r.dom.parentNode)){t.contentElement=r.dom.parentNode;break}}t.contentElement||(t.getContent=function(){return Fr.empty})}else t.contentElement=this.contentDOM;else t.getContent=function(){return e.node.content};return t}},{key:"matchesNode",value:function(e,t,n){return 0==this.dirty&&e.eq(this.node)&&Vs(t,this.outerDeco)&&n.eq(this.innerDeco)}},{key:"size",get:function(){return this.node.nodeSize}},{key:"border",get:function(){return this.node.isLeaf?0:1}},{key:"updateChildren",value:function(e,t){var n=this,r=this.node.inlineContent,i=t,o=e.composing?this.localCompositionInfo(e,t):null,a=o&&o.pos>-1?o:null,s=o&&o.pos<0,c=new $s(this,a&&a.node,e);!function(e,t,n,r){var i=t.locals(e),o=0;if(0==i.length){for(var a=0;a<e.childCount;a++){var s=e.child(a);r(s,i,t.forChild(o,s),a),o+=s.nodeSize}return}for(var c=0,u=[],l=null,d=0;;){for(var h=void 0,f=void 0;c<i.length&&i[c].to==o;){var p=i[c++];p.widget&&(h?(f||(f=[h])).push(p):h=p)}if(h)if(f){f.sort(js);for(var v=0;v<f.length;v++)n(f[v],d,!!l)}else n(h,d,!!l);var m=void 0,g=void 0;if(l)g=-1,m=l,l=null;else{if(!(d<e.childCount))break;g=d,m=e.child(d++)}for(var y=0;y<u.length;y++)u[y].to<=o&&u.splice(y--,1);for(;c<i.length&&i[c].from<=o&&i[c].to>o;)u.push(i[c++]);var k=o+m.nodeSize;if(m.isText){var w=k;c<i.length&&i[c].from<w&&(w=i[c].from);for(var b=0;b<u.length;b++)u[b].to<w&&(w=u[b].to);w<k&&(l=m.cut(w-o),m=m.cut(0,w-o),k=w,g=-1)}else for(;c<i.length&&i[c].to<k;)c++;var x=m.isInline&&!m.isLeaf?u.filter(function(e){return!e.inline}):u.slice();r(m,x,t.forChild(o,m),g),o=k}}(this.node,this.innerDeco,function(t,o,a){t.spec.marks?c.syncToMarks(t.spec.marks,r,e):t.type.side>=0&&!a&&c.syncToMarks(o==n.node.childCount?Wr.none:n.node.child(o).marks,r,e),c.placeWidget(t,e,i)},function(t,n,a,u){var l;c.syncToMarks(t.marks,r,e),c.findNodeMatch(t,n,a,u)||s&&e.state.selection.from>i&&e.state.selection.to<i+t.nodeSize&&(l=c.findIndexWithChild(o.node))>-1&&c.updateNodeAt(t,n,a,l,e)||c.updateNextNode(t,n,a,e,u,i)||c.addNode(t,n,a,e,i),i+=t.nodeSize}),c.syncToMarks([],r,e),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||2==this.dirty)&&(a&&this.protectLocalComposition(e,a),Ds(this.contentDOM,this.children,e),Ja&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){var t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}},{key:"localCompositionInfo",value:function(e,t){var n=e.state.selection,r=n.from,i=n.to;if(!(e.state.selection instanceof Wo)||r<t||i>t+this.node.content.size)return null;var o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){var a=o.nodeValue,s=function(e,t,n,r){for(var i=0,o=0;i<e.childCount&&o<=r;){var a=e.child(i++),s=o;if(o+=a.nodeSize,a.isText){for(var c=a.text;i<e.childCount;){var u=e.child(i++);if(o+=u.nodeSize,!u.isText)break;c+=u.text}if(o>=n){if(o>=r&&c.slice(r-t.length-s,r-s)==t)return r-t.length;var l=s<r?c.lastIndexOf(t,r-s-1):-1;if(l>=0&&l+t.length+s>=n)return s+l;if(n==r&&c.length>=r+t.length-s&&c.slice(r-s,r-s+t.length)==t)return r}}}return-1}(this.node.content,a,r-t,i-t);return s<0?null:{node:o,pos:s,text:a}}return{node:o,pos:-1,text:""}}},{key:"protectLocalComposition",value:function(e,t){var n=t.node,r=t.pos,i=t.text;if(!this.getDesc(n)){for(var o=n;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}var a=new _s(this,o,n,i);e.input.compositionNodes.push(a),this.children=Hs(this.children,r,r+i.length,e,a)}}},{key:"update",value:function(e,t,n,r){return!(3==this.dirty||!e.sameMarkup(this.node))&&(this.updateInner(e,t,n,r),!0)}},{key:"updateInner",value:function(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}},{key:"updateOuterDeco",value:function(e){if(!Vs(e,this.outerDeco)){var t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=Ps(this.dom,this.nodeDOM,Rs(this.outerDeco,this.node,t),Rs(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}}},{key:"selectNode",value:function(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.nodeDOM.draggable=!0))}},{key:"deselectNode",value:function(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.nodeDOM.removeAttribute("draggable"))}},{key:"domAtom",get:function(){return this.node.isAtom}}],[{key:"create",value:function(e,n,r,i,o,a){var s,c=o.nodeViews[n.type.name],u=c&&c(n,o,function(){return s?s.parent?s.parent.posBeforeChild(s):void 0:a},r,i),l=u&&u.dom,d=u&&u.contentDOM;if(n.isText)if(l){if(3!=l.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else l=document.createTextNode(n.text);else if(!l){var h=ji.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);l=h.dom,d=h.contentDOM}d||n.isText||"BR"==l.nodeName||(l.hasAttribute("contenteditable")||(l.contentEditable="false"),n.type.spec.draggable&&(l.draggable=!0));var f=l;return l=Bs(l,r,n),u?s=new As(e,n,r,i,l,d||null,f,u,o,a+1):n.isText?new Ns(e,n,r,i,l,f,o):new t(e,n,r,i,l,d||null,f,o,a+1)}}])}(Cs);function Os(e,t,n,r,i){Bs(r,t,e);var o=new Ts(void 0,e,t,n,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}var Ns=function(t){function n(e,t,i,o,a,s,c){return x(this,n),r(this,n,[e,t,i,o,a,null,s,c,0])}return a(n,t),S(n,[{key:"parseRule",value:function(){for(var e=this.nodeDOM.parentNode;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}},{key:"update",value:function(e,t,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!e.sameMarkup(this.node))&&(this.updateOuterDeco(t),0==this.dirty&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=0,!0)}},{key:"inParent",value:function(){for(var e=this.parent.contentDOM,t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}},{key:"domFromPos",value:function(e){return{node:this.nodeDOM,offset:e}}},{key:"localPosFromDOM",value:function(t,r,i){return t==this.nodeDOM?this.posAtStart+Math.min(r,this.node.text.length):e(n,"localPosFromDOM",this,3)([t,r,i])}},{key:"ignoreMutation",value:function(e){return"characterData"!=e.type&&"selection"!=e.type}},{key:"slice",value:function(e,t,r){var i=this.node.cut(e,t),o=document.createTextNode(i.text);return new n(this.parent,i,this.outerDeco,this.innerDeco,o,o,r)}},{key:"markDirty",value:function(t,r){e(n,"markDirty",this,3)([t,r]),this.dom==this.nodeDOM||0!=t&&r!=this.nodeDOM.nodeValue.length||(this.dirty=3)}},{key:"domAtom",get:function(){return!1}},{key:"isText",value:function(e){return this.node.text==e}}])}(Ts),Es=function(e){function t(){return x(this,t),r(this,t,arguments)}return a(t,e),S(t,[{key:"parseRule",value:function(){return{ignore:!0}}},{key:"matchesHack",value:function(e){return 0==this.dirty&&this.dom.nodeName==e}},{key:"domAtom",get:function(){return!0}},{key:"ignoreForCoords",get:function(){return"IMG"==this.dom.nodeName}}])}(Cs),As=function(t){function n(e,t,i,o,a,s,c,u,l,d){var h;return x(this,n),(h=r(this,n,[e,t,i,o,a,s,c,l,d])).spec=u,h}return a(n,t),S(n,[{key:"update",value:function(t,r,i,o){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){var a=this.spec.update(t,r,i);return a&&this.updateInner(t,r,i,o),a}return!(!this.contentDOM&&!t.isLeaf)&&e(n,"update",this,3)([t,r,i,o])}},{key:"selectNode",value:function(){this.spec.selectNode?this.spec.selectNode():e(n,"selectNode",this,3)([])}},{key:"deselectNode",value:function(){this.spec.deselectNode?this.spec.deselectNode():e(n,"deselectNode",this,3)([])}},{key:"setSelection",value:function(t,r,i,o){this.spec.setSelection?this.spec.setSelection(t,r,i.root):e(n,"setSelection",this,3)([t,r,i,o])}},{key:"destroy",value:function(){this.spec.destroy&&this.spec.destroy(),e(n,"destroy",this,3)([])}},{key:"stopEvent",value:function(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}},{key:"ignoreMutation",value:function(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):e(n,"ignoreMutation",this,3)([t])}}])}(Ts);function Ds(e,t,n){for(var r=e.firstChild,i=!1,o=0;o<t.length;o++){var a=t[o],s=a.dom;if(s.parentNode==e){for(;s!=r;)r=Fs(r),i=!0;r=r.nextSibling}else i=!0,e.insertBefore(s,r);if(a instanceof Ms){var c=r?r.previousSibling:e.lastChild;Ds(a.contentDOM,a.children,n),r=c?c.nextSibling:e.firstChild}}for(;r;)r=Fs(r),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}var Is=function(e){e&&(this.nodeName=e)};Is.prototype=Object.create(null);var zs=[new Is];function Rs(e,t,n){if(0==e.length)return zs;for(var r=n?zs[0]:new Is,i=[r],o=0;o<e.length;o++){var a=e[o].type.attrs;if(a)for(var s in a.nodeName&&i.push(r=new Is(a.nodeName)),a){var c=a[s];null!=c&&(n&&1==i.length&&i.push(r=new Is(t.isInline?"span":"div")),"class"==s?r.class=(r.class?r.class+" ":"")+c:"style"==s?r.style=(r.style?r.style+";":"")+c:"nodeName"!=s&&(r[s]=c))}}return i}function Ps(e,t,n,r){if(n==zs&&r==zs)return t;for(var i=t,o=0;o<r.length;o++){var a=r[o],s=n[o];if(o){var c=void 0;s&&s.nodeName==a.nodeName&&i!=e&&(c=i.parentNode)&&c.nodeName.toLowerCase()==a.nodeName||((c=document.createElement(a.nodeName)).pmIsDeco=!0,c.appendChild(i),s=zs[0]),i=c}Ls(i,s||zs[0],a)}return i}function Ls(e,t,n){for(var r in t)"class"==r||"style"==r||"nodeName"==r||r in n||e.removeAttribute(r);for(var i in n)"class"!=i&&"style"!=i&&"nodeName"!=i&&n[i]!=t[i]&&e.setAttribute(i,n[i]);if(t.class!=n.class){for(var o=t.class?t.class.split(" ").filter(Boolean):[],a=n.class?n.class.split(" ").filter(Boolean):[],s=0;s<o.length;s++)-1==a.indexOf(o[s])&&e.classList.remove(o[s]);for(var c=0;c<a.length;c++)-1==o.indexOf(a[c])&&e.classList.add(a[c]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style)for(var u,l=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;u=l.exec(t.style);)e.style.removeProperty(u[1]);n.style&&(e.style.cssText+=n.style)}}function Bs(e,t,n){return Ps(e,e,zs,Rs(t,n,1!=e.nodeType))}function Vs(e,t){if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function Fs(e){var t=e.nextSibling;return e.parentNode.removeChild(e),t}var $s=function(){return S(function e(t,n,r){x(this,e),this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=function(e,t){var n=t,r=n.children.length,i=e.childCount,o=new Map,a=[];e:for(;i>0;){for(var s=void 0;;)if(r){var c=n.children[r-1];if(!(c instanceof Ms)){s=c,r--;break}n=c,r=c.children.length}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}var u=s.node;if(u){if(u!=e.child(i-1))break;--i,o.set(s,i),a.push(s)}}return{index:i,matched:o,matches:a.reverse()}}(t.node.content,t)},[{key:"destroyBetween",value:function(e,t){if(e!=t){for(var n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}},{key:"destroyRest",value:function(){this.destroyBetween(this.index,this.top.children.length)}},{key:"syncToMarks",value:function(e,t,n){for(var r=0,i=this.stack.length>>1,o=Math.min(i,e.length);r<o&&(r==i-1?this.top:this.stack[r+1<<1]).matchesMark(e[r])&&!1!==e[r].type.spec.spanning;)r++;for(;r<i;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);for(var a=-1,s=this.index;s<Math.min(this.index+3,this.top.children.length);s++){var c=this.top.children[s];if(c.matchesMark(e[i])&&!this.isLocked(c.dom)){a=s;break}}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{var u=Ms.create(this.top,e[i],t,n);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,i++}}},{key:"findNodeMatch",value:function(e,t,n,r){var i,o=-1;if(r>=this.preMatch.index&&(i=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,n))o=this.top.children.indexOf(i,this.index);else for(var a=this.index,s=Math.min(this.top.children.length,a+5);a<s;a++){var c=this.top.children[a];if(c.matchesNode(e,t,n)&&!this.preMatch.matched.has(c)){o=a;break}}return!(o<0)&&(this.destroyBetween(this.index,o),this.index++,!0)}},{key:"updateNodeAt",value:function(e,t,n,r,i){var o=this.top.children[r];return 3==o.dirty&&o.dom==o.contentDOM&&(o.dirty=2),!!o.update(e,t,n,i)&&(this.destroyBetween(this.index,r),this.index++,!0)}},{key:"findIndexWithChild",value:function(e){for(;;){var t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){var n=e.pmViewDesc;if(n)for(var r=this.index;r<this.top.children.length;r++)if(this.top.children[r]==n)return r;return-1}e=t}}},{key:"updateNextNode",value:function(e,t,n,r,i,o){for(var a=this.index;a<this.top.children.length;a++){var s=this.top.children[a];if(s instanceof Ts){var c=this.preMatch.matched.get(s);if(null!=c&&c!=i)return!1;var u=s.dom,l=void 0,d=this.isLocked(u)&&!(e.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==e.text&&3!=s.dirty&&Vs(t,s.outerDeco));if(!d&&s.update(e,t,n,r))return this.destroyBetween(this.index,a),s.dom!=u&&(this.changed=!0),this.index++,!0;if(!d&&(l=this.recreateWrapper(s,e,t,n,r,o)))return this.destroyBetween(this.index,a),this.top.children[this.index]=l,l.contentDOM&&(l.dirty=2,l.updateChildren(r,o+1),l.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}},{key:"recreateWrapper",value:function(e,t,n,r,i,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Vs(n,e.outerDeco)||!r.eq(e.innerDeco))return null;var a=Ts.create(this.top,t,n,r,i,o);if(a.contentDOM){a.children=e.children,e.children=[];var s,c=l(a.children);try{for(c.s();!(s=c.n()).done;){s.value.parent=a}}catch(u){c.e(u)}finally{c.f()}}return e.destroy(),a}},{key:"addNode",value:function(e,t,n,r,i){var o=Ts.create(this.top,e,t,n,r,i);o.contentDOM&&o.updateChildren(r,i+1),this.top.children.splice(this.index++,0,o),this.changed=!0}},{key:"placeWidget",value:function(e,t,n){var r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(e)||e!=r.widget&&r.widget.type.toDOM.parentNode){var i=new Ss(this.top,e,t,n);this.top.children.splice(this.index++,0,i),this.changed=!0}else this.index++}},{key:"addTextblockHacks",value:function(){for(var e=this.top.children[this.index-1],t=this.top;e instanceof Ms;)e=(t=e).children[t.children.length-1];(!e||!(e instanceof Ns)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ua||Wa)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}},{key:"addHackNode",value:function(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{var n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");var r=new Es(this.top,[],n,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}},{key:"isLocked",value:function(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}}])}();function js(e,t){return e.type.side-t.type.side}function Hs(e,t,n,r,i){for(var o=[],a=0,s=0;a<e.length;a++){var c=e[a],u=s,l=s+=c.size;u>=n||l<=t?o.push(c):(u<t&&o.push(c.slice(0,t-u,r)),i&&(o.push(i),i=void 0),l>n&&o.push(c.slice(n-u,c.size,r)))}return o}function Ws(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;var i=e.docView.nearestDesc(n.focusNode),o=i&&0==i.size,a=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(a<0)return null;var s,c,u=r.resolve(a);if(Da(n)){for(s=a;i&&!i.node;)i=i.parent;var l=i.node;if(i&&l.isAtom&&Uo.isSelectable(l)&&i.parent&&(!l.isInline||!function(e,t,n){for(var r=0==t,i=t==Ea(e);r||i;){if(e==n)return!0;var o=Ca(e);if(!(e=e.parentNode))return!1;r=r&&0==o,i=i&&o==Ea(e)}}(n.focusNode,n.focusOffset,i.dom))){var h=i.posBefore;c=new Uo(a==h?u:r.resolve(h))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){for(var f=a,p=a,v=0;v<n.rangeCount;v++){var m=n.getRangeAt(v);f=Math.min(f,e.docView.posFromDOM(m.startContainer,m.startOffset,1)),p=Math.max(p,e.docView.posFromDOM(m.endContainer,m.endOffset,-1))}if(f<0)return null;var g=d(p==e.state.selection.anchor?[p,f]:[f,p],2);s=g[0],a=g[1],u=r.resolve(a)}else s=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(s<0)return null}var y=r.resolve(s);c||(c=Qs(e,y,u,"pointer"==t||e.state.selection.head<u.pos&&!o?1:-1));return c}function qs(e){return e.editable?e.hasFocus():tc(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function Us(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=e.state.selection;if(Xs(e,n),qs(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&Wa){var r=e.domSelectionRange(),i=e.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Ta(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset))return e.input.mouseDown.delayedSelectionSync=!0,void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){var t=e.domSelection();if(!t)return;var n=e.cursorWrapper.dom,r="IMG"==n.nodeName;r?t.collapse(n.parentNode,Ca(n)+1):t.collapse(n,0);!r&&!e.state.selection.visible&&Fa&&$a<=11&&(n.disabled=!0,n.disabled=!1)}(e);else{var o,a,s=n.anchor,c=n.head;!Js||n instanceof Wo||(n.$from.parent.inlineContent||(o=Ks(e,n.from)),n.empty||n.$from.parent.inlineContent||(a=Ks(e,n.to))),e.docView.setSelection(s,c,e,t),Js&&(o&&Gs(o),a&&Gs(a)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){var t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);var n=e.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=function(){n.anchorNode==r&&n.anchorOffset==i||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(function(){qs(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")},20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}var Js=Ua||Wa&&qa<63;function Ks(e,t){var n=e.docView.domFromPos(t,0),r=n.node,i=n.offset,o=i<r.childNodes.length?r.childNodes[i]:null,a=i?r.childNodes[i-1]:null;if(Ua&&o&&"false"==o.contentEditable)return Ys(o);if(!(o&&"false"!=o.contentEditable||a&&"false"!=a.contentEditable)){if(o)return Ys(o);if(a)return Ys(a)}}function Ys(e){return e.contentEditable="true",Ua&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function Gs(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function Xs(e,t){if(t instanceof Uo){var n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(Zs(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else Zs(e)}function Zs(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Qs(e,t,n,r){return e.someProp("createSelectionBetween",function(r){return r(e,t,n)})||Wo.between(t,n,r)}function ec(e){return!(e.editable&&!e.hasFocus())&&tc(e)}function tc(e){var t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(xt){return!1}}function nc(e,t){var n=e.selection,r=n.$anchor,i=n.$head,o=t>0?r.max(i):r.min(i),a=o.parent.inlineContent?o.depth?e.doc.resolve(t>0?o.after():o.before()):null:o;return a&&Fo.findFrom(a,t)}function rc(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function ic(e,t,n){var r=e.state.selection;if(!(r instanceof Wo)){if(r instanceof Uo&&r.node.isInline)return rc(e,new Wo(t>0?r.$to:r.$from));var i=nc(e.state,t);return!!i&&rc(e,i)}if(n.indexOf("s")>-1){var o=r.$head,a=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter;if(!a||a.isText||!a.isLeaf)return!1;var s=e.state.doc.resolve(o.pos+a.nodeSize*(t<0?-1:1));return rc(e,new Wo(r.$anchor,s))}if(!r.empty)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){var c=nc(e.state,t);return!!(c&&c instanceof Uo)&&rc(e,c)}if(!(Ka&&n.indexOf("m")>-1)){var u,l=r.$head,d=l.textOffset?null:t<0?l.nodeBefore:l.nodeAfter;if(!d||d.isText)return!1;var h=t<0?l.pos-d.nodeSize:l.pos;return!!(d.isAtom||(u=e.docView.descAt(h))&&!u.contentDOM)&&(Uo.isSelectable(d)?rc(e,new Uo(t<0?e.state.doc.resolve(l.pos-d.nodeSize):l)):!!Xa&&rc(e,new Wo(e.state.doc.resolve(t<0?h:h+d.nodeSize))))}}function oc(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function ac(e,t){var n=e.pmViewDesc;return n&&0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function sc(e,t){return t<0?function(e){var t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;var i,o,a=!1;ja&&1==n.nodeType&&r<oc(n)&&ac(n.childNodes[r],-1)&&(a=!0);for(;;)if(r>0){if(1!=n.nodeType)break;var s=n.childNodes[r-1];if(ac(s,-1))i=n,o=--r;else{if(3!=s.nodeType)break;r=(n=s).nodeValue.length}}else{if(cc(n))break;for(var c=n.previousSibling;c&&ac(c,-1);)i=n.parentNode,o=Ca(c),c=c.previousSibling;if(c)r=oc(n=c);else{if((n=n.parentNode)==e.dom)break;r=0}}a?uc(e,n,r):i&&uc(e,i,o)}(e):function(e){var t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;for(var i,o,a=oc(n);;)if(r<a){if(1!=n.nodeType)break;if(!ac(n.childNodes[r],1))break;i=n,o=++r}else{if(cc(n))break;for(var s=n.nextSibling;s&&ac(s,1);)i=s.parentNode,o=Ca(s)+1,s=s.nextSibling;if(s)r=0,a=oc(n=s);else{if((n=n.parentNode)==e.dom)break;r=a=0}}i&&uc(e,i,o)}(e)}function cc(e){var t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function uc(e,t,n){var r,i;3!=t.nodeType&&((i=function(e,t){for(;e&&t==e.childNodes.length&&!Aa(e);)t=Ca(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){var n=e.childNodes[t];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=n,t=0}}(t,n))?(t=i,n=0):(r=function(e,t){for(;e&&!t&&!Aa(e);)t=Ca(e),e=e.parentNode;for(;e&&t;){var n=e.childNodes[t-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=(e=n).childNodes.length}}(t,n))&&(t=r,n=r.nodeValue.length));var o=e.domSelection();if(o){if(Da(o)){var a=document.createRange();a.setEnd(t,n),a.setStart(t,n),o.removeAllRanges(),o.addRange(a)}else o.extend&&o.extend(t,n);e.domObserver.setCurSelection();var s=e.state;setTimeout(function(){e.state==s&&Us(e)},50)}}function lc(e,t){var n=e.state.doc.resolve(t);if(!Wa&&!Ya&&n.parent.inlineContent){var r=e.coordsAtPos(t);if(t>n.start()){var i=e.coordsAtPos(t-1),o=(i.top+i.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(i.left-r.left)>1)return i.left<r.left?"ltr":"rtl"}if(t<n.end()){var a=e.coordsAtPos(t+1),s=(a.top+a.bottom)/2;if(s>r.top&&s<r.bottom&&Math.abs(a.left-r.left)>1)return a.left>r.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function dc(e,t,n){var r=e.state.selection;if(r instanceof Wo&&!r.empty||n.indexOf("s")>-1)return!1;if(Ka&&n.indexOf("m")>-1)return!1;var i=r.$from,o=r.$to;if(!i.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){var a=nc(e.state,t);if(a&&a instanceof Uo)return rc(e,a)}if(!i.parent.inlineContent){var s=t<0?i:o,c=r instanceof Ko?Fo.near(s,t):Fo.findFrom(s,t);return!!c&&rc(e,c)}return!1}function hc(e,t){if(!(e.state.selection instanceof Wo))return!0;var n=e.state.selection,r=n.$head,i=n.$anchor,o=n.empty;if(!r.sameParent(i))return!0;if(!o)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;var a=!r.textOffset&&(t<0?r.nodeBefore:r.nodeAfter);if(a&&!a.isText){var s=e.state.tr;return t<0?s.delete(r.pos-a.nodeSize,r.pos):s.delete(r.pos,r.pos+a.nodeSize),e.dispatch(s),!0}return!1}function fc(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function pc(e,t){var n=t.keyCode,r=function(e){var t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);if(8==n||Ka&&72==n&&"c"==r)return hc(e,-1)||sc(e,-1);if(46==n&&!t.shiftKey||Ka&&68==n&&"c"==r)return hc(e,1)||sc(e,1);if(13==n||27==n)return!0;if(37==n||Ka&&66==n&&"c"==r){var i=37==n?"ltr"==lc(e,e.state.selection.from)?-1:1:-1;return ic(e,i,r)||sc(e,i)}if(39==n||Ka&&70==n&&"c"==r){var o=39==n?"ltr"==lc(e,e.state.selection.from)?1:-1:1;return ic(e,o,r)||sc(e,o)}return 38==n||Ka&&80==n&&"c"==r?dc(e,-1,r)||sc(e,-1):40==n||Ka&&78==n&&"c"==r?function(e){if(!Ua||e.state.selection.$head.parentOffset>0)return!1;var t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(n&&1==n.nodeType&&0==r&&n.firstChild&&"false"==n.firstChild.contentEditable){var i=n.firstChild;fc(e,i,"true"),setTimeout(function(){return fc(e,i,"false")},20)}return!1}(e)||dc(e,1,r)||sc(e,1):r==(Ka?"m":"c")&&(66==n||73==n||89==n||90==n)}function vc(e,t){e.someProp("transformCopied",function(n){t=n(t,e)});for(var n=[],r=t,i=r.content,o=r.openStart,a=r.openEnd;o>1&&a>1&&1==i.childCount&&1==i.firstChild.childCount;){o--,a--;var s=i.firstChild;n.push(s.type.name,s.attrs!=s.type.defaultAttrs?s.attrs:null),i=s.content}var c=e.someProp("clipboardSerializer")||ji.fromSchema(e.state.schema),u=_c(),l=u.createElement("div");l.appendChild(c.serializeFragment(i,{document:u}));for(var d,h=l.firstChild,f=0;h&&1==h.nodeType&&(d=Cc[h.nodeName.toLowerCase()]);){for(var p=d.length-1;p>=0;p--){for(var v=u.createElement(d[p]);l.firstChild;)v.appendChild(l.firstChild);l.appendChild(v),f++}h=l.firstChild}h&&1==h.nodeType&&h.setAttribute("data-pm-slice","".concat(o," ").concat(a).concat(f?" -".concat(f):""," ").concat(JSON.stringify(n)));var m=e.someProp("clipboardTextSerializer",function(n){return n(t,e)})||t.content.textBetween(0,t.content.size,"\n\n");return{dom:l,text:m,slice:t}}function mc(e,t,n,r,i){var o,a,s=i.parent.type.spec.code;if(!n&&!t)return null;var c=!!t&&(r||s||!n);if(c){if(e.someProp("transformPastedText",function(n){t=n(t,s||r,e)}),s)return a=new Ur(Fr.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0),e.someProp("transformPasted",function(t){a=t(a,e,!0)}),a;var u=e.someProp("clipboardTextParser",function(n){return n(t,i,r,e)});if(u)a=u;else{var l=i.marks(),d=e.state.schema,h=ji.fromSchema(d);o=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(function(e){var t=o.appendChild(document.createElement("p"));e&&t.appendChild(h.serializeNode(d.text(e,l)))})}}else e.someProp("transformPastedHTML",function(t){n=t(n,e)}),o=function(e){var t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));var n,r=_c().createElement("div"),i=/<([a-z][^>\s]+)/i.exec(e);(n=i&&Cc[i[1].toLowerCase()])&&(e=n.map(function(e){return"<"+e+">"}).join("")+e+n.map(function(e){return"</"+e+">"}).reverse().join(""));if(r.innerHTML=function(e){var t=window.trustedTypes;if(!t)return e;Mc||(Mc=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:function(e){return e}}));return Mc.createHTML(e)}(e),n)for(var o=0;o<n.length;o++)r=r.querySelector(n[o])||r;return r}(n),Xa&&function(e){for(var t=e.querySelectorAll(Wa?"span:not([class]):not([style])":"span.Apple-converted-space"),n=0;n<t.length;n++){var r=t[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}(o);var f=o&&o.querySelector("[data-pm-slice]"),p=f&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(f.getAttribute("data-pm-slice")||"");if(p&&p[3])for(var v=+p[3];v>0;v--){for(var m=o.firstChild;m&&1!=m.nodeType;)m=m.nextSibling;if(!m)break;o=m}if(!a){var g=e.someProp("clipboardParser")||e.someProp("domParser")||Di.fromSchema(e.state.schema);a=g.parseSlice(o,{preserveWhitespace:!(!c&&!p),context:i,ruleFromNode:function(e){return"BR"!=e.nodeName||e.nextSibling||!e.parentNode||gc.test(e.parentNode.nodeName)?null:{ignore:!0}}})}if(p)a=function(e,t){if(!e.size)return e;var n,r=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(pt){return e}for(var i=e.content,o=e.openStart,a=e.openEnd,s=n.length-2;s>=0;s-=2){var c=r.nodes[n[s]];if(!c||c.hasRequiredAttrs())break;i=Fr.from(c.create(n[s+1],i)),o++,a++}return new Ur(i,o,a)}(xc(a,+p[1],+p[2]),p[4]);else if(a=Ur.maxOpen(function(e,t){if(e.childCount<2)return e;for(var n,r=function(){var n,r=t.node(i).contentMatchAt(t.index(i)),o=[];if(e.forEach(function(e){if(o){var t,i=r.findWrapping(e.type);if(!i)return o=null;if(t=o.length&&n.length&&kc(i,n,e,o[o.length-1],0))o[o.length-1]=t;else{o.length&&(o[o.length-1]=wc(o[o.length-1],n.length));var a=yc(e,i);o.push(a),r=r.matchType(a.type),n=i}}}),o)return{v:Fr.from(o)}},i=t.depth;i>=0;i--)if(n=r())return n.v;return e}(a.content,i),!0),a.openStart||a.openEnd){for(var y=0,k=0,w=a.content.firstChild;y<a.openStart&&!w.type.spec.isolating;y++,w=w.firstChild);for(var b=a.content.lastChild;k<a.openEnd&&!b.type.spec.isolating;k++,b=b.lastChild);a=xc(a,y,k)}return e.someProp("transformPasted",function(t){a=t(a,e,c)}),a}var gc=/^(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 yc(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=t.length-1;r>=n;r--)e=t[r].create(null,Fr.from(e));return e}function kc(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){var o=kc(e,t,n,r.lastChild,i+1);if(o)return r.copy(r.content.replaceChild(r.childCount-1,o));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(Fr.from(yc(n,e,i+1))))}}function wc(e,t){if(0==t)return e;var n=e.content.replaceChild(e.childCount-1,wc(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(Fr.empty,!0);return e.copy(n.append(r))}function bc(e,t,n,r,i,o){var a=t<0?e.firstChild:e.lastChild,s=a.content;return e.childCount>1&&(o=0),i<r-1&&(s=bc(s,t,n,r,i+1,o)),i>=n&&(s=t<0?a.contentMatchAt(0).fillBefore(s,o<=i).append(s):s.append(a.contentMatchAt(a.childCount).fillBefore(Fr.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,a.copy(s))}function xc(e,t,n){return t<e.openStart&&(e=new Ur(bc(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new Ur(bc(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var Cc={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},Sc=null;function _c(){return Sc||(Sc=document.implementation.createHTMLDocument("title"))}var Mc=null;var Tc={},Oc={},Nc={touchstart:!0,touchmove:!0},Ec=S(function e(){x(this,e),this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null});function Ac(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Dc(e){e.someProp("handleDOMEvents",function(t){for(var n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=function(t){return Ic(e,t)})})}function Ic(e,t){return e.someProp("handleDOMEvents",function(n){var r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)})}function zc(e){return{left:e.clientX,top:e.clientY}}function Rc(e,t,n,r,i){if(-1==r)return!1;for(var o,a=e.state.doc.resolve(r),s=function(r){if(e.someProp(t,function(t){return r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)}))return{v:!0}},c=a.depth+1;c>0;c--)if(o=s(c))return o.v;return!1}function Pc(e,t,n){if(e.focused||e.focus(),!e.state.selection.eq(t)){var r=e.state.tr.setSelection(t);"pointer"==n&&r.setMeta("pointer",!0),e.dispatch(r)}}function Lc(e,t,n,r,i){return Rc(e,"handleClickOn",t,n,r)||e.someProp("handleClick",function(n){return n(e,t,r)})||(i?function(e,t){if(-1==t)return!1;var n,r,i=e.state.selection;i instanceof Uo&&(n=i.node);for(var o=e.state.doc.resolve(t),a=o.depth+1;a>0;a--){var s=a>o.depth?o.nodeAfter:o.node(a);if(Uo.isSelectable(s)){r=n&&i.$from.depth>0&&a>=i.$from.depth&&o.before(i.$from.depth+1)==i.$from.pos?o.before(i.$from.depth):o.before(a);break}}return null!=r&&(Pc(e,Uo.create(e.state.doc,r),"pointer"),!0)}(e,n):function(e,t){if(-1==t)return!1;var n=e.state.doc.resolve(t),r=n.nodeAfter;return!!(r&&r.isAtom&&Uo.isSelectable(r))&&(Pc(e,new Uo(n),"pointer"),!0)}(e,n))}function Bc(e,t,n,r){return Rc(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",function(n){return n(e,t,r)})}function Vc(e,t,n,r){return Rc(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",function(n){return n(e,t,r)})||function(e,t,n){if(0!=n.button)return!1;var r=e.state.doc;if(-1==t)return!!r.inlineContent&&(Pc(e,Wo.create(r,0,r.content.size),"pointer"),!0);for(var i=r.resolve(t),o=i.depth+1;o>0;o--){var a=o>i.depth?i.nodeAfter:i.node(o),s=i.before(o);if(a.inlineContent)Pc(e,Wo.create(r,s+1,s+1+a.content.size),"pointer");else{if(!Uo.isSelectable(a))continue;Pc(e,Uo.create(r,s),"pointer")}return!0}}(e,n,r)}function Fc(e){return Kc(e)}Oc.keydown=function(e,t){var n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!Hc(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!Ga||!Wa||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!Ja||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",function(t){return t(e,n)})||pc(e,n)?n.preventDefault():Ac(e,"key");else{var r=Date.now();e.input.lastIOSEnter=r,e.input.lastIOSEnterFallbackTimeout=setTimeout(function(){e.input.lastIOSEnter==r&&(e.someProp("handleKeyDown",function(t){return t(e,Ia(13,"Enter"))}),e.input.lastIOSEnter=0)},200)}},Oc.keyup=function(e,t){16==t.keyCode&&(e.input.shiftKey=!1)},Oc.keypress=function(e,t){var n=t;if(!(Hc(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||Ka&&n.metaKey))if(e.someProp("handleKeyPress",function(t){return t(e,n)}))n.preventDefault();else{var r=e.state.selection;if(!(r instanceof Wo&&r.$from.sameParent(r.$to))){var i=String.fromCharCode(n.charCode),o=function(){return e.state.tr.insertText(i).scrollIntoView()};/[\r\n]/.test(i)||e.someProp("handleTextInput",function(t){return t(e,r.$from.pos,r.$to.pos,i,o)})||e.dispatch(o()),n.preventDefault()}}};var $c=Ka?"metaKey":"ctrlKey";Tc.mousedown=function(e,t){var n=t;e.input.shiftKey=n.shiftKey;var r=Fc(e),i=Date.now(),o="singleClick";i-e.input.lastClick.time<500&&function(e,t){var n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}(n,e.input.lastClick)&&!n[$c]&&e.input.lastClick.button==n.button&&("singleClick"==e.input.lastClick.type?o="doubleClick":"doubleClick"==e.input.lastClick.type&&(o="tripleClick")),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:o,button:n.button};var a=e.posAtCoords(zc(n));a&&("singleClick"==o?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new jc(e,a,n,!!r)):("doubleClick"==o?Bc:Vc)(e,a.pos,a.inside,n)?n.preventDefault():Ac(e,"pointer"))};var jc=function(){return S(function e(t,n,r,i){var o,a,s=this;if(x(this,e),this.view=t,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!r[$c],this.allowDefault=r.shiftKey,n.inside>-1)o=t.state.doc.nodeAt(n.inside),a=n.inside;else{var c=t.state.doc.resolve(n.pos);o=c.parent,a=c.depth?c.before():0}var u=i?null:r.target,l=u?t.docView.nearestDesc(u,!0):null;this.target=l&&1==l.nodeDOM.nodeType?l.nodeDOM:null;var d=t.state.selection;(0==r.button&&o.type.spec.draggable&&!1!==o.type.spec.selectable||d instanceof Uo&&d.from<=a&&d.to>a)&&(this.mightDrag={node:o,pos:a,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!ja||this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(function(){s.view.input.mouseDown==s&&s.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)),Ac(t,"pointer")},[{key:"done",value:function(){var e=this;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(function(){return Us(e.view)}),this.view.input.mouseDown=null}},{key:"up",value:function(e){if(this.done(),this.view.dom.contains(e.target)){var t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(zc(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ac(this.view,"pointer"):Lc(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||Ua&&this.mightDrag&&!this.mightDrag.node.isAtom||Wa&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Pc(this.view,Fo.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Ac(this.view,"pointer")}}},{key:"move",value:function(e){this.updateAllowDefault(e),Ac(this.view,"pointer"),0==e.buttons&&this.done()}},{key:"updateAllowDefault",value:function(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}])}();function Hc(e,t){return!!e.composing||!!(Ua&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}Tc.touchstart=function(e){e.input.lastTouch=Date.now(),Fc(e),Ac(e,"pointer")},Tc.touchmove=function(e){e.input.lastTouch=Date.now(),Ac(e,"pointer")},Tc.contextmenu=function(e){return Fc(e)};var Wc=Ga?5e3:-1;function qc(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(function(){return Kc(e)},t))}function Uc(e){var t;for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=((t=document.createEvent("Event")).initEvent("event",!0,!0),t.timeStamp));e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function Jc(e){var t=e.domSelectionRange();if(!t.focusNode)return null;var n=function(e,t){for(;;){if(3==e.nodeType&&t)return e;if(1==e.nodeType&&t>0){if("false"==e.contentEditable)return null;t=Ea(e=e.childNodes[t-1])}else{if(!e.parentNode||Aa(e))return null;t=Ca(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),r=function(e,t){for(;;){if(3==e.nodeType&&t<e.nodeValue.length)return e;if(1==e.nodeType&&t<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[t],t=0}else{if(!e.parentNode||Aa(e))return null;t=Ca(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(n&&r&&n!=r){var i=r.pmViewDesc,o=e.domObserver.lastChangedTextNode;if(n==o||r==o)return o;if(!i||!i.isText(r.nodeValue))return r;if(e.input.compositionNode==r){var a=n.pmViewDesc;if(a&&a.isText(n.nodeValue))return r}}return n||r}function Kc(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!(Ga&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),Uc(e),t||e.docView&&e.docView.dirty){var n=Ws(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):!e.markCursor&&!t||r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.updateState(e.state):e.dispatch(e.state.tr.deleteSelection()),!0}return!1}}Oc.compositionstart=Oc.compositionupdate=function(e){if(!e.composing){e.domObserver.flush();var t=e.state,n=t.selection.$to;if(t.selection instanceof Wo&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(function(e){return!1===e.type.spec.inclusive})||Wa&&Ya&&function(e){var t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n||1!=n.nodeType||r>=n.childNodes.length)return!1;var i=n.childNodes[r];return 1==i.nodeType&&"false"==i.contentEditable}(e)))e.markCursor=e.state.storedMarks||n.marks(),Kc(e,!0),e.markCursor=null;else if(Kc(e,!t.selection.empty),ja&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length)for(var r=e.domSelectionRange(),i=r.focusNode,o=r.focusOffset;i&&1==i.nodeType&&0!=o;){var a=o<0?i.lastChild:i.childNodes[o-1];if(!a)break;if(3==a.nodeType){var s=e.domSelection();s&&s.collapse(a,a.nodeValue.length);break}i=a,o=-1}e.input.composing=!0}qc(e,Wc)},Oc.compositionend=function(e,t){e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.compositionPendingChanges&&Promise.resolve().then(function(){return e.domObserver.flush()}),e.input.compositionID++,qc(e,20))};var Yc=Fa&&$a<15||Ja&&Za<604;function Gc(e,t,n,r,i){var o=mc(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",function(t){return t(e,i,o||Ur.empty)}))return!0;if(!o)return!1;var a=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(o),s=a?e.state.tr.replaceSelectionWith(a,r):e.state.tr.replaceSelection(o);return e.dispatch(s.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Xc(e){var t=e.getData("text/plain")||e.getData("Text");if(t)return t;var n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Tc.copy=Oc.cut=function(e,t){var n=t,r=e.state.selection,i="cut"==n.type;if(!r.empty){var o=Yc?null:n.clipboardData,a=vc(e,r.content()),s=a.dom,c=a.text;o?(n.preventDefault(),o.clearData(),o.setData("text/html",s.innerHTML),o.setData("text/plain",c)):function(e,t){if(e.dom.parentNode){var n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";var r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(function(){n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}}(e,s),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))}},Oc.paste=function(e,t){var n=t;if(!e.composing||Ga){var r=Yc?null:n.clipboardData,i=e.input.shiftKey&&45!=e.input.lastKeyCode;r&&Gc(e,Xc(r),r.getData("text/html"),i,n)?n.preventDefault():function(e,t){if(e.dom.parentNode){var n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();var i=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout(function(){e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Gc(e,r.value,null,i,t):Gc(e,r.textContent,r.innerHTML,i,t)},50)}}(e,n)}};var Zc=S(function e(t,n,r){x(this,e),this.slice=t,this.move=n,this.node=r}),Qc=Ka?"altKey":"ctrlKey";function eu(e,t){var n=e.someProp("dragCopies",function(e){return!e(t)});return null!=n?n:!t[Qc]}for(var tu in Tc.dragstart=function(e,t){var n=t,r=e.input.mouseDown;if(r&&r.done(),n.dataTransfer){var i,o=e.state.selection,a=o.empty?null:e.posAtCoords(zc(n));if(a&&a.pos>=o.from&&a.pos<=(o instanceof Uo?o.to-1:o.to));else if(r&&r.mightDrag)i=Uo.create(e.state.doc,r.mightDrag.pos);else if(n.target&&1==n.target.nodeType){var s=e.docView.nearestDesc(n.target,!0);s&&s.node.type.spec.draggable&&s!=e.docView&&(i=Uo.create(e.state.doc,s.posBefore))}var c=vc(e,(i||e.state.selection).content()),u=c.dom,l=c.text,d=c.slice;(!n.dataTransfer.files.length||!Wa||qa>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Yc?"Text":"text/html",u.innerHTML),n.dataTransfer.effectAllowed="copyMove",Yc||n.dataTransfer.setData("text/plain",l),e.dragging=new Zc(d,eu(e,n),i)}},Tc.dragend=function(e){var t=e.dragging;window.setTimeout(function(){e.dragging==t&&(e.dragging=null)},50)},Oc.dragover=Oc.dragenter=function(e,t){return t.preventDefault()},Oc.drop=function(e,t){try{!function(e,t,n){if(!t.dataTransfer)return;var r=e.posAtCoords(zc(t));if(!r)return;var i=e.state.doc.resolve(r.pos),o=n&&n.slice;o?e.someProp("transformPasted",function(t){o=t(o,e,!1)}):o=mc(e,Xc(t.dataTransfer),Yc?null:t.dataTransfer.getData("text/html"),!1,i);var a=!(!n||!eu(e,t));if(e.someProp("handleDrop",function(n){return n(e,t,o||Ur.empty,a)}))return void t.preventDefault();if(!o)return;t.preventDefault();var s=o?Co(e.state.doc,i.pos,o):i.pos;null==s&&(s=i.pos);var c=e.state.tr;if(a){var u=n.node;u?u.replace(c):c.deleteSelection()}var l=c.mapping.map(s),d=0==o.openStart&&0==o.openEnd&&1==o.content.childCount,h=c.doc;d?c.replaceRangeWith(l,l,o.content.firstChild):c.replaceRange(l,l,o);if(c.doc.eq(h))return;var f=c.doc.resolve(l);if(d&&Uo.isSelectable(o.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new Uo(f));else{var p=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach(function(e,t,n,r){return p=r}),c.setSelection(Qs(e,f,c.doc.resolve(p)))}e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))}(e,t,e.dragging)}finally{e.dragging=null}},Tc.focus=function(e){e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(function(){e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&Us(e)},20))},Tc.blur=function(e,t){var n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},Tc.beforeinput=function(e,t){if(Wa&&Ga&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();var n=e.input.domChangeCount;setTimeout(function(){if(e.input.domChangeCount==n&&(e.dom.blur(),e.focus(),!e.someProp("handleKeyDown",function(t){return t(e,Ia(8,"Backspace"))}))){var t=e.state.selection.$cursor;t&&t.pos>0&&e.dispatch(e.state.tr.delete(t.pos-1,t.pos).scrollIntoView())}},50)}},Oc)Tc[tu]=Oc[tu];function nu(e,t){if(e==t)return!0;for(var n in e)if(e[n]!==t[n])return!1;for(var r in t)if(!(r in e))return!1;return!0}var ru=function(){function e(t,n){x(this,e),this.toDOM=t,this.spec=n||cu,this.side=this.spec.side||0}return S(e,[{key:"map",value:function(e,t,n,r){var i=e.mapResult(t.from+r,this.side<0?-1:1),o=i.pos;return i.deleted?null:new au(o-n,o-n,this)}},{key:"valid",value:function(){return!0}},{key:"eq",value:function(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&nu(this.spec,t.spec))}},{key:"destroy",value:function(e){this.spec.destroy&&this.spec.destroy(e)}}])}(),iu=function(){function e(t,n){x(this,e),this.attrs=t,this.spec=n||cu}return S(e,[{key:"map",value:function(e,t,n,r){var i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,o=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=o?null:new au(i,o,this)}},{key:"valid",value:function(e,t){return t.from<t.to}},{key:"eq",value:function(t){return this==t||t instanceof e&&nu(this.attrs,t.attrs)&&nu(this.spec,t.spec)}},{key:"destroy",value:function(){}}],[{key:"is",value:function(t){return t.type instanceof e}}])}(),ou=function(){function e(t,n){x(this,e),this.attrs=t,this.spec=n||cu}return S(e,[{key:"map",value:function(e,t,n,r){var i=e.mapResult(t.from+r,1);if(i.deleted)return null;var o=e.mapResult(t.to+r,-1);return o.deleted||o.pos<=i.pos?null:new au(i.pos-n,o.pos-n,this)}},{key:"valid",value:function(e,t){var n,r=e.content.findIndex(t.from),i=r.index,o=r.offset;return o==t.from&&!(n=e.child(i)).isText&&o+n.nodeSize==t.to}},{key:"eq",value:function(t){return this==t||t instanceof e&&nu(this.attrs,t.attrs)&&nu(this.spec,t.spec)}},{key:"destroy",value:function(){}}])}(),au=function(){function e(t,n,r){x(this,e),this.from=t,this.to=n,this.type=r}return S(e,[{key:"copy",value:function(t,n){return new e(t,n,this.type)}},{key:"eq",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}},{key:"map",value:function(e,t,n){return this.type.map(e,this,t,n)}},{key:"spec",get:function(){return this.type.spec}},{key:"inline",get:function(){return this.type instanceof iu}},{key:"widget",get:function(){return this.type instanceof ru}}],[{key:"widget",value:function(t,n,r){return new e(t,t,new ru(n,r))}},{key:"inline",value:function(t,n,r,i){return new e(t,n,new iu(r,i))}},{key:"node",value:function(t,n,r,i){return new e(t,n,new ou(r,i))}}])}(),su=[],cu={},uu=function(){function e(t,n){x(this,e),this.local=t.length?t:su,this.children=n.length?n:su}return S(e,[{key:"find",value:function(e,t,n){var r=[];return this.findInner(null==e?0:e,null==t?1e9:t,r,0,n),r}},{key:"findInner",value:function(e,t,n,r,i){for(var o=0;o<this.local.length;o++){var a=this.local[o];a.from<=t&&a.to>=e&&(!i||i(a.spec))&&n.push(a.copy(a.from+r,a.to+r))}for(var s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){var c=this.children[s]+1;this.children[s+2].findInner(e-c,t-c,n,r+c,i)}}},{key:"map",value:function(e,t,n){return this==lu||0==e.maps.length?this:this.mapInner(e,t,0,0,n||cu)}},{key:"mapInner",value:function(t,n,r,i,o){for(var a,s=0;s<this.local.length;s++){var c=this.local[s].map(t,r,i);c&&c.type.valid(n,c)?(a||(a=[])).push(c):o.onRemove&&o.onRemove(this.local[s].spec)}return this.children.length?hu(this.children,a||[],t,n,r,i,o):a?new e(a.sort(gu),su):lu}},{key:"add",value:function(t,n){return n.length?this==lu?e.create(t,n):this.addInner(t,n,0):this}},{key:"addInner",value:function(t,n,r){var i,o=this,a=0;t.forEach(function(e,t){var s,c=t+r;if(s=pu(n,e,c)){for(i||(i=o.children.slice());a<i.length&&i[a]<t;)a+=3;i[a]==t?i[a+2]=i[a+2].addInner(e,s,c+1):i.splice(a,0,t,t+e.nodeSize,mu(s,e,c+1,cu)),a+=3}});for(var s=fu(a?vu(n):n,-r),c=0;c<s.length;c++)s[c].type.valid(t,s[c])||s.splice(c--,1);return new e(s.length?this.local.concat(s).sort(gu):this.local,i||this.children)}},{key:"remove",value:function(e){return 0==e.length||this==lu?this:this.removeInner(e,0)}},{key:"removeInner",value:function(t,n){for(var r=this.children,i=this.local,o=0;o<r.length;o+=3){for(var a,s=void 0,c=r[o]+n,u=r[o+1]+n,l=0;l<t.length;l++)(a=t[l])&&a.from>c&&a.to<u&&(t[l]=null,(s||(s=[])).push(a));if(s){r==this.children&&(r=this.children.slice());var d=r[o+2].removeInner(s,c+1);d!=lu?r[o+2]=d:(r.splice(o,3),o-=3)}}if(i.length)for(var h,f=0;f<t.length;f++)if(h=t[f])for(var p=0;p<i.length;p++)i[p].eq(h,n)&&(i==this.local&&(i=this.local.slice()),i.splice(p--,1));return r==this.children&&i==this.local?this:i.length||r.length?new e(i,r):lu}},{key:"forChild",value:function(t,n){if(this==lu)return this;if(n.isLeaf)return e.empty;for(var r,i,o=0;o<this.children.length;o+=3)if(this.children[o]>=t){this.children[o]==t&&(r=this.children[o+2]);break}for(var a=t+1,s=a+n.content.size,c=0;c<this.local.length;c++){var u=this.local[c];if(u.from<s&&u.to>a&&u.type instanceof iu){var l=Math.max(a,u.from)-a,d=Math.min(s,u.to)-a;l<d&&(i||(i=[])).push(u.copy(l,d))}}if(i){var h=new e(i.sort(gu),su);return r?new du([h,r]):h}return r||lu}},{key:"eq",value:function(t){if(this==t)return!0;if(!(t instanceof e)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(var n=0;n<this.local.length;n++)if(!this.local[n].eq(t.local[n]))return!1;for(var r=0;r<this.children.length;r+=3)if(this.children[r]!=t.children[r]||this.children[r+1]!=t.children[r+1]||!this.children[r+2].eq(t.children[r+2]))return!1;return!0}},{key:"locals",value:function(e){return yu(this.localsInner(e))}},{key:"localsInner",value:function(e){if(this==lu)return su;if(e.inlineContent||!this.local.some(iu.is))return this.local;for(var t=[],n=0;n<this.local.length;n++)this.local[n].type instanceof iu||t.push(this.local[n]);return t}},{key:"forEachSet",value:function(e){e(this)}}],[{key:"create",value:function(e,t){return t.length?mu(t,e,0,cu):lu}}])}();uu.empty=new uu([],[]),uu.removeOverlap=yu;var lu=uu.empty,du=function(){function e(t){x(this,e),this.members=t}return S(e,[{key:"map",value:function(t,n){var r=this.members.map(function(e){return e.map(t,n,cu)});return e.from(r)}},{key:"forChild",value:function(t,n){if(n.isLeaf)return uu.empty;for(var r=[],i=0;i<this.members.length;i++){var o=this.members[i].forChild(t,n);o!=lu&&(o instanceof e?r=r.concat(o.members):r.push(o))}return e.from(r)}},{key:"eq",value:function(t){if(!(t instanceof e)||t.members.length!=this.members.length)return!1;for(var n=0;n<this.members.length;n++)if(!this.members[n].eq(t.members[n]))return!1;return!0}},{key:"locals",value:function(e){for(var t,n=!0,r=0;r<this.members.length;r++){var i=this.members[r].localsInner(e);if(i.length)if(t){n&&(t=t.slice(),n=!1);for(var o=0;o<i.length;o++)t.push(i[o])}else t=i}return t?yu(n?t:t.sort(gu)):su}},{key:"forEachSet",value:function(e){for(var t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}],[{key:"from",value:function(t){switch(t.length){case 0:return lu;case 1:return t[0];default:return new e(t.every(function(e){return e instanceof uu})?t:t.reduce(function(e,t){return e.concat(t instanceof uu?t:t.members)},[]))}}}])}();function hu(e,t,n,r,i,o,a){for(var s=e.slice(),c=function(e){var t=0;n.maps[u].forEach(function(n,r,i,o){for(var a=o-i-(r-n),c=0;c<s.length;c+=3){var u=s[c+1];if(!(u<0||n>u+e-t)){var l=s[c]+e-t;r>=l?s[c+1]=n<=l?-2:-1:n>=e&&a&&(s[c]+=a,s[c+1]+=a)}}t+=a}),e=n.maps[u].map(e,-1),l=e},u=0,l=o;u<n.maps.length;u++)c(l);for(var d=!1,h=0;h<s.length;h+=3)if(s[h+1]<0){if(-2==s[h+1]){d=!0,s[h+1]=-1;continue}var f=n.map(e[h]+o),p=f-i;if(p<0||p>=r.content.size){d=!0;continue}var v=n.map(e[h+1]+o,-1)-i,m=r.content.findIndex(p),g=m.index,y=m.offset,k=r.maybeChild(g);if(k&&y==p&&y+k.nodeSize==v){var w=s[h+2].mapInner(n,k,f+1,e[h]+o+1,a);w!=lu?(s[h]=p,s[h+1]=v,s[h+2]=w):(s[h+1]=-2,d=!0)}else d=!0}if(d){var b=function(e,t,n,r,i,o,a){function s(e,t){for(var o=0;o<e.local.length;o++){var c=e.local[o].map(r,i,t);c?n.push(c):a.onRemove&&a.onRemove(e.local[o].spec)}for(var u=0;u<e.children.length;u+=3)s(e.children[u+2],e.children[u]+t+1)}for(var c=0;c<e.length;c+=3)-1==e[c+1]&&s(e[c+2],t[c]+o+1);return n}(s,e,t,n,i,o,a),x=mu(b,r,0,a);t=x.local;for(var C=0;C<s.length;C+=3)s[C+1]<0&&(s.splice(C,3),C-=3);for(var S=0,_=0;S<x.children.length;S+=3){for(var M=x.children[S];_<s.length&&s[_]<M;)_+=3;s.splice(_,0,x.children[S],x.children[S+1],x.children[S+2])}}return new uu(t.sort(gu),s)}function fu(e,t){if(!t||!e.length)return e;for(var n=[],r=0;r<e.length;r++){var i=e[r];n.push(new au(i.from+t,i.to+t,i.type))}return n}function pu(e,t,n){if(t.isLeaf)return null;for(var r,i=n+t.nodeSize,o=null,a=0;a<e.length;a++)(r=e[a])&&r.from>n&&r.to<i&&((o||(o=[])).push(r),e[a]=null);return o}function vu(e){for(var t=[],n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function mu(e,t,n,r){var i=[],o=!1;t.forEach(function(t,a){var s=pu(e,t,a+n);if(s){o=!0;var c=mu(s,t,n+a+1,r);c!=lu&&i.push(a,a+t.nodeSize,c)}});for(var a=fu(o?vu(e):e,-n).sort(gu),s=0;s<a.length;s++)a[s].type.valid(t,a[s])||(r.onRemove&&r.onRemove(a[s].spec),a.splice(s--,1));return a.length||i.length?new uu(a,i):lu}function gu(e,t){return e.from-t.from||e.to-t.to}function yu(e){for(var t=e,n=0;n<t.length-1;n++){var r=t[n];if(r.from!=r.to)for(var i=n+1;i<t.length;i++){var o=t[i];if(o.from!=r.from){o.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,o.from),ku(t,i,r.copy(o.from,r.to)));break}o.to!=r.to&&(t==e&&(t=e.slice()),t[i]=o.copy(o.from,r.to),ku(t,i+1,o.copy(r.to,o.to)))}}return t}function ku(e,t,n){for(;t<e.length&&gu(n,e[t])>0;)t++;e.splice(t,0,n)}function wu(e){var t=[];return e.someProp("decorations",function(n){var r=n(e.state);r&&r!=lu&&t.push(r)}),e.cursorWrapper&&t.push(uu.create(e.state.doc,[e.cursorWrapper.deco])),du.from(t)}var bu={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},xu=Fa&&$a<=11,Cu=function(){return S(function e(){x(this,e),this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0},[{key:"set",value:function(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}},{key:"clear",value:function(){this.anchorNode=this.focusNode=null}},{key:"eq",value:function(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}])}(),Su=function(){return S(function e(t,n){var r=this;x(this,e),this.view=t,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Cu,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(function(e){for(var t=0;t<e.length;t++)r.queue.push(e[t]);Fa&&$a<=11&&e.some(function(e){return"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length})?r.flushSoon():r.flush()}),xu&&(this.onCharData=function(e){r.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),r.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)},[{key:"flushSoon",value:function(){var e=this;this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(function(){e.flushingSoon=-1,e.flush()},20))}},{key:"forceFlush",value:function(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}},{key:"start",value:function(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,bu)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}},{key:"stop",value:function(){var e=this;if(this.observer){var t=this.observer.takeRecords();if(t.length){for(var n=0;n<t.length;n++)this.queue.push(t[n]);window.setTimeout(function(){return e.flush()},20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}},{key:"connectSelection",value:function(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}},{key:"disconnectSelection",value:function(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}},{key:"suppressSelectionUpdates",value:function(){var e=this;this.suppressingSelectionUpdates=!0,setTimeout(function(){return e.suppressingSelectionUpdates=!1},50)}},{key:"onSelectionChange",value:function(){if(ec(this.view)){if(this.suppressingSelectionUpdates)return Us(this.view);if(Fa&&$a<=11&&!this.view.state.selection.empty){var e=this.view.domSelectionRange();if(e.focusNode&&Ta(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}},{key:"setCurSelection",value:function(){this.currentSelection.set(this.view.domSelectionRange())}},{key:"ignoreSelectionChange",value:function(e){if(!e.focusNode)return!0;for(var t,n=new Set,r=e.focusNode;r;r=Sa(r))n.add(r);for(var i=e.anchorNode;i;i=Sa(i))if(n.has(i)){t=i;break}var o=t&&this.view.docView.nearestDesc(t);return o&&o.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0}},{key:"pendingRecords",value:function(){if(this.observer){var e,t=l(this.observer.takeRecords());try{for(t.s();!(e=t.n()).done;){var n=e.value;this.queue.push(n)}}catch(r){t.e(r)}finally{t.f()}}return this.queue}},{key:"flush",value:function(){var e=this.view;if(e.docView&&!(this.flushingSoon>-1)){var t=this.pendingRecords();t.length&&(this.queue=[]);var n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&ec(e)&&!this.ignoreSelectionChange(n),i=-1,o=-1,a=!1,s=[];if(e.editable)for(var c=0;c<t.length;c++){var u=this.registerMutation(t[c],s);u&&(i=i<0?u.from:Math.min(u.from,i),o=o<0?u.to:Math.max(u.to,o),u.typeOver&&(a=!0))}if(ja&&s.length){var h=s.filter(function(e){return"BR"==e.nodeName});if(2==h.length){var f=d(h,2),p=f[0],v=f[1];p.parentNode&&p.parentNode.parentNode==v.parentNode?v.remove():p.remove()}else{var m,g=this.currentSelection.focusNode,y=l(h);try{for(y.s();!(m=y.n()).done;){var k=m.value,w=k.parentNode;!w||"LI"!=w.nodeName||g&&Ou(e,g)==w||k.remove()}}catch(M){y.e(M)}finally{y.f()}}}else if((Wa||Ua)&&s.some(function(e){return"BR"==e.nodeName})&&(8==e.input.lastKeyCode||46==e.input.lastKeyCode)){var b,x=l(s);try{for(x.s();!(b=x.n()).done;){var C=b.value;if("BR"==C.nodeName&&C.parentNode){var S=C.nextSibling;S&&1==S.nodeType&&"false"==S.contentEditable&&C.parentNode.removeChild(C)}}}catch(M){x.e(M)}finally{x.f()}}var _=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Da(n)&&(_=Ws(e))&&_.eq(Fo.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Us(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,o),function(e){if(_u.has(e))return;if(_u.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)){if(e.requiresGeckoHackNode=ja,Mu)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Mu=!0}}(e)),this.handleDOMChange(i,o,a,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||Us(e),this.currentSelection.set(n))}}},{key:"registerMutation",value:function(e,t){if(t.indexOf(e.target)>-1)return null;var n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(var r=0;r<e.addedNodes.length;r++){var i=e.addedNodes[r];t.push(i),3==i.nodeType&&(this.lastChangedTextNode=i)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};var o=e.previousSibling,a=e.nextSibling;if(Fa&&$a<=11&&e.addedNodes.length)for(var s=0;s<e.addedNodes.length;s++){var c=e.addedNodes[s],u=c.previousSibling,l=c.nextSibling;(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(o=u),(!l||Array.prototype.indexOf.call(e.addedNodes,l)<0)&&(a=l)}var d=o&&o.parentNode==e.target?Ca(o)+1:0,h=n.localPosFromDOM(e.target,d,-1),f=a&&a.parentNode==e.target?Ca(a):e.target.childNodes.length;return{from:h,to:n.localPosFromDOM(e.target,f,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}])}(),_u=new WeakMap,Mu=!1;function Tu(e,t){var n=t.startContainer,r=t.startOffset,i=t.endContainer,o=t.endOffset,a=e.domAtPos(e.state.selection.anchor);if(Ta(a.node,a.offset,i,o)){var s=[i,o,n,r];n=s[0],r=s[1],i=s[2],o=s[3]}return{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}}function Ou(e,t){for(var n=t.parentNode;n&&n!=e.dom;n=n.parentNode){var r=e.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function Nu(e){var t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(Ua&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){var n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}if(e.parentNode.lastChild==e||Ua&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}var Eu=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Au(e,t,n,r,i){var o=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){var a=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,s=Ws(e,a);if(s&&!e.state.selection.eq(s)){if(Wa&&Ga&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",function(t){return t(e,Ia(13,"Enter"))}))return;var c=e.state.tr.setSelection(s);"pointer"==a?c.setMeta("pointer",!0):"key"==a&&c.scrollIntoView(),o&&c.setMeta("composition",o),e.dispatch(c)}}else{var u=e.state.doc.resolve(t),l=u.sharedDepth(n);t=u.before(l+1),n=e.state.doc.resolve(n).after(l+1);var d,h,f=e.state.selection,p=function(e,t,n){var r,i=e.docView.parseRange(t,n),o=i.node,a=i.fromOffset,s=i.toOffset,c=i.from,u=i.to,l=e.domSelectionRange(),d=l.anchorNode;if(d&&e.dom.contains(1==d.nodeType?d:d.parentNode)&&(r=[{node:d,offset:l.anchorOffset}],Da(l)||r.push({node:l.focusNode,offset:l.focusOffset})),Wa&&8===e.input.lastKeyCode)for(var h=s;h>a;h--){var f=o.childNodes[h-1],p=f.pmViewDesc;if("BR"==f.nodeName&&!p){s=h;break}if(!p||p.size)break}var v=e.state.doc,m=e.someProp("domParser")||Di.fromSchema(e.state.schema),g=v.resolve(c),y=null,k=m.parse(o,{topNode:g.parent,topMatch:g.parent.contentMatchAt(g.index()),topOpen:!0,from:a,to:s,preserveWhitespace:"pre"!=g.parent.type.whitespace||"full",findPositions:r,ruleFromNode:Nu,context:g});if(r&&null!=r[0].pos){var w=r[0].pos,b=r[1]&&r[1].pos;null==b&&(b=w),y={anchor:w+c,head:b+c}}return{doc:k,sel:y,from:c,to:u}}(e,t,n),v=e.state.doc,m=v.slice(p.from,p.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(d=e.state.selection.to,h="end"):(d=e.state.selection.from,h="start"),e.input.lastKeyCode=null;var g=function(e,t,n,r,i){var o=e.findDiffStart(t,n);if(null==o)return null;var a=e.findDiffEnd(t,n+e.size,n+t.size),s=a.a,c=a.b;if("end"==i){r-=s+Math.max(0,o-Math.min(s,c))-o}if(s<o&&e.size<t.size){var u=r<=o&&r>=s?o-r:0;(o-=u)&&o<t.size&&zu(t.textBetween(o-1,o+1))&&(o+=u?1:-1),c=o+(c-s),s=o}else if(c<o){var l=r<=o&&r>=c?o-r:0;(o-=l)&&o<e.size&&zu(e.textBetween(o-1,o+1))&&(o+=l?1:-1),s=o+(s-c),c=o}return{start:o,endA:s,endB:c}}(m.content,p.doc.content,p.from,d,h);if(g&&e.input.domChangeCount++,(Ja&&e.input.lastIOSEnter>Date.now()-225||Ga)&&i.some(function(e){return 1==e.nodeType&&!Eu.test(e.nodeName)})&&(!g||g.endA>=g.endB)&&e.someProp("handleKeyDown",function(t){return t(e,Ia(13,"Enter"))}))e.input.lastIOSEnter=0;else{if(!g){if(!(r&&f instanceof Wo&&!f.empty&&f.$head.sameParent(f.$anchor))||e.composing||p.sel&&p.sel.anchor!=p.sel.head){if(p.sel){var y=Du(e,e.state.doc,p.sel);if(y&&!y.eq(e.state.selection)){var k=e.state.tr.setSelection(y);o&&k.setMeta("composition",o),e.dispatch(k)}}return}g={start:f.from,endA:f.to,endB:f.to}}e.state.selection.from<e.state.selection.to&&g.start==g.endB&&e.state.selection instanceof Wo&&(g.start>e.state.selection.from&&g.start<=e.state.selection.from+2&&e.state.selection.from>=p.from?g.start=e.state.selection.from:g.endA<e.state.selection.to&&g.endA>=e.state.selection.to-2&&e.state.selection.to<=p.to&&(g.endB+=e.state.selection.to-g.endA,g.endA=e.state.selection.to)),Fa&&$a<=11&&g.endB==g.start+1&&g.endA==g.start&&g.start>p.from&&"  "==p.doc.textBetween(g.start-p.from-1,g.start-p.from+1)&&(g.start--,g.endA--,g.endB--);var w=p.doc.resolveNoCache(g.start-p.from),b=p.doc.resolveNoCache(g.endB-p.from),x=v.resolve(g.start),C=w.sameParent(b)&&w.parent.inlineContent&&x.end()>=g.endA;if((Ja&&e.input.lastIOSEnter>Date.now()-225&&(!C||i.some(function(e){return"DIV"==e.nodeName||"P"==e.nodeName}))||!C&&w.pos<p.doc.content.size&&(!w.sameParent(b)||!w.parent.inlineContent)&&w.pos<b.pos&&!/\S/.test(p.doc.textBetween(w.pos,b.pos,"","")))&&e.someProp("handleKeyDown",function(t){return t(e,Ia(13,"Enter"))}))e.input.lastIOSEnter=0;else if(e.state.selection.anchor>g.start&&function(e,t,n,r,i){if(n-t<=i.pos-r.pos||Iu(r,!0,!1)<i.pos)return!1;var o=e.resolve(t);if(!r.parent.isTextblock){var a=o.nodeAfter;return null!=a&&n==t+a.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;var s=e.resolve(Iu(o,!0,!0));return!(!s.parent.isTextblock||s.pos>n||Iu(s,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(s.parent.content)}(v,g.start,g.endA,w,b)&&e.someProp("handleKeyDown",function(t){return t(e,Ia(8,"Backspace"))}))Ga&&Wa&&e.domObserver.suppressSelectionUpdates();else{Wa&&g.endB==g.start&&(e.input.lastChromeDelete=Date.now()),Ga&&!C&&w.start()!=b.start()&&0==b.parentOffset&&w.depth==b.depth&&p.sel&&p.sel.anchor==p.sel.head&&p.sel.head==g.endA&&(g.endB-=2,b=p.doc.resolveNoCache(g.endB-p.from),setTimeout(function(){e.someProp("handleKeyDown",function(t){return t(e,Ia(13,"Enter"))})},20));var S,_=g.start,M=g.endA,T=function(t){var n=t||e.state.tr.replace(_,M,p.doc.slice(g.start-p.from,g.endB-p.from));if(p.sel){var r=Du(e,n.doc,p.sel);r&&!(Wa&&e.composing&&r.empty&&(g.start!=g.endB||e.input.lastChromeDelete<Date.now()-100)&&(r.head==_||r.head==n.mapping.map(M)-1)||Fa&&r.empty&&r.head==_)&&n.setSelection(r)}return o&&n.setMeta("composition",o),n.scrollIntoView()};if(C)if(w.pos==b.pos){Fa&&$a<=11&&0==w.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout(function(){return Us(e)},20));var O=T(e.state.tr.delete(_,M)),N=v.resolve(g.start).marksAcross(v.resolve(g.endA));N&&O.ensureMarks(N),e.dispatch(O)}else if(g.endA==g.endB&&(S=function(e,t){for(var n,r,i,o=e.firstChild.marks,a=t.firstChild.marks,s=o,c=a,u=0;u<a.length;u++)s=a[u].removeFromSet(s);for(var l=0;l<o.length;l++)c=o[l].removeFromSet(c);if(1==s.length&&0==c.length)r=s[0],n="add",i=function(e){return e.mark(r.addToSet(e.marks))};else{if(0!=s.length||1!=c.length)return null;r=c[0],n="remove",i=function(e){return e.mark(r.removeFromSet(e.marks))}}for(var d=[],h=0;h<t.childCount;h++)d.push(i(t.child(h)));if(Fr.from(d).eq(e))return{mark:r,type:n}}(w.parent.content.cut(w.parentOffset,b.parentOffset),x.parent.content.cut(x.parentOffset,g.endA-x.start())))){var E=T(e.state.tr);"add"==S.type?E.addMark(_,M,S.mark):E.removeMark(_,M,S.mark),e.dispatch(E)}else if(w.parent.child(w.index()).isText&&w.index()==b.index()-(b.textOffset?0:1)){var A=w.parent.textBetween(w.parentOffset,b.parentOffset),D=function(){return T(e.state.tr.insertText(A,_,M))};e.someProp("handleTextInput",function(t){return t(e,_,M,A,D)})||e.dispatch(D())}else e.dispatch(T());else e.dispatch(T())}}}}function Du(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Qs(e,t.resolve(n.anchor),t.resolve(n.head))}function Iu(e,t,n){for(var r=e.depth,i=t?e.end():e.pos;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n)for(var o=e.node(r).maybeChild(e.indexAfter(r));o&&!o.isLeaf;)o=o.firstChild,i++;return i}function zu(e){if(2!=e.length)return!1;var t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}var Ru=function(){return S(function e(t,n){var r=this;x(this,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 Ec,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Fu),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=Bu(this),Lu(this),this.nodeViews=Vu(this),this.docView=Os(this.state.doc,Pu(this),wu(this),this.dom,this),this.domObserver=new Su(this,function(e,t,n,i){return Au(r,e,t,n,i)}),this.domObserver.start(),function(e){var t=function(){var t=Tc[n];e.dom.addEventListener(n,e.input.eventHandlers[n]=function(n){!function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(var n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}(e,n)||Ic(e,n)||!e.editable&&n.type in Oc||t(e,n)},Nc[n]?{passive:!0}:void 0)};for(var n in Tc)t();Ua&&e.dom.addEventListener("input",function(){return null}),Dc(e)}(this),this.updatePluginViews()},[{key:"composing",get:function(){return this.input.composing}},{key:"props",get:function(){if(this._props.state!=this.state){var e=this._props;for(var t in this._props={},e)this._props[t]=e[t];this._props.state=this.state}return this._props}},{key:"update",value:function(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Dc(this);var t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Fu),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}},{key:"setProps",value:function(e){var t={};for(var n in this._props)t[n]=this._props[n];for(var r in t.state=this.state,e)t[r]=e[r];this.update(t)}},{key:"updateState",value:function(e){this.updateStateInner(e,this._props)}},{key:"updateStateInner",value:function(e,t){var n,r=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(Uc(this),o=!0),this.state=e;var a=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){var s=Vu(this);(function(e,t){var n=0,r=0;for(var i in e){if(e[i]!=t[i])return!0;n++}for(var o in t)r++;return n!=r})(s,this.nodeViews)&&(this.nodeViews=s,i=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&Dc(this),this.editable=Bu(this),Lu(this);var c=wu(this),u=Pu(this),l=r.plugins==e.plugins||r.doc.eq(e.doc)?e.scrollToSelection>r.scrollToSelection?"to selection":"preserve":"reset",d=i||!this.docView.matchesNode(e.doc,u,c);!d&&e.selection.eq(r.selection)||(o=!0);var h,f,p,v,m,g,y,k,w,b,x,C="preserve"==l&&o&&null==this.dom.style.overflowAnchor&&function(e){for(var t,n,r=e.dom.getBoundingClientRect(),i=Math.max(0,r.top),o=(r.left+r.right)/2,a=i+1;a<Math.min(innerHeight,r.bottom);a+=5){var s=e.root.elementFromPoint(o,a);if(s&&s!=e.dom&&e.dom.contains(s)){var c=s.getBoundingClientRect();if(c.top>=i-20){t=s,n=c.top;break}}}return{refDOM:t,refTop:n,stack:rs(e.dom)}}(this);if(o){this.domObserver.stop();var S=d&&(Fa||Wa)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&(v=r.selection,m=e.selection,g=Math.min(v.$anchor.sharedDepth(v.head),m.$anchor.sharedDepth(m.head)),v.$anchor.start(g)!=m.$anchor.start(g));if(d){var _=Wa?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Jc(this)),!i&&this.docView.update(e.doc,u,c,this)||(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=Os(e.doc,u,c,this.dom,this)),_&&!this.trackWrites&&(S=!0)}S||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&(h=this,f=h.docView.domFromPos(h.state.selection.anchor,0),p=h.domSelectionRange(),Ta(f.node,f.offset,p.anchorNode,p.anchorOffset)))?Us(this,S):(Xs(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!r.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,r),"reset"==l?this.dom.scrollTop=0:"to selection"==l?this.scrollToSelection():C&&(k=(y=C).refDOM,w=y.refTop,b=y.stack,x=k?k.getBoundingClientRect().top:0,is(b,0==x?0:x-w))}},{key:"scrollToSelection",value:function(){var e=this,t=this.domSelectionRange().focusNode;if(t&&this.dom.contains(1==t.nodeType?t:t.parentNode))if(this.someProp("handleScrollToSelection",function(t){return t(e)}));else if(this.state.selection instanceof Uo){var n=this.docView.domAfterPos(this.state.selection.from);1==n.nodeType&&ns(this,n.getBoundingClientRect(),t)}else ns(this,this.coordsAtPos(this.state.selection.head,1),t);else;}},{key:"destroyPluginViews",value:function(){for(var e;e=this.pluginViews.pop();)e.destroy&&e.destroy()}},{key:"updatePluginViews",value:function(e){if(e&&e.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(var t=0;t<this.pluginViews.length;t++){var n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(var r=0;r<this.directPlugins.length;r++){var i=this.directPlugins[r];i.spec.view&&this.pluginViews.push(i.spec.view(this))}for(var o=0;o<this.state.plugins.length;o++){var a=this.state.plugins[o];a.spec.view&&this.pluginViews.push(a.spec.view(this))}}}},{key:"updateDraggedNode",value:function(e,t){var n=e.node,r=-1;if(this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{var i=n.from+(this.state.doc.content.size-t.doc.content.size);(i>0&&this.state.doc.nodeAt(i))==n.node&&(r=i)}this.dragging=new Zc(e.slice,e.move,r<0?void 0:Uo.create(this.state.doc,r))}},{key:"someProp",value:function(e,t){var n,r=this._props&&this._props[e];if(null!=r&&(n=t?t(r):r))return n;for(var i=0;i<this.directPlugins.length;i++){var o=this.directPlugins[i].props[e];if(null!=o&&(n=t?t(o):o))return n}var a=this.state.plugins;if(a)for(var s=0;s<a.length;s++){var c=a[s].props[e];if(null!=c&&(n=t?t(c):c))return n}}},{key:"hasFocus",value:function(){if(Fa){var e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}},{key:"focus",value:function(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(as)return e.focus(as);var t=rs(e);e.focus(null==as?{get preventScroll(){return as={preventScroll:!0},!0}}:void 0),as||(as=!1,is(t,0))}(this.dom),Us(this),this.domObserver.start()}},{key:"root",get:function(){var e=this,t=this._root;if(null==t)for(var n,r=function(t){if(9==t.nodeType||11==t.nodeType&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=function(){return t.ownerDocument.getSelection()}),{v:e._root=t}},i=this.dom.parentNode;i;i=i.parentNode)if(n=r(i))return n.v;return t||document}},{key:"updateRoot",value:function(){this._root=null}},{key:"posAtCoords",value:function(e){return ls(this,e)}},{key:"coordsAtPos",value:function(e){return ps(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:1)}},{key:"domAtPos",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.docView.domFromPos(e,t)}},{key:"nodeDOM",value:function(e){var t=this.docView.descAt(e);return t?t.nodeDOM:null}},{key:"posAtDOM",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,r=this.docView.posFromDOM(e,t,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r}},{key:"endOfTextblock",value:function(e,t){return xs(this,t||this.state,e)}},{key:"pasteHTML",value:function(e,t){return Gc(this,"",e,!1,t||new ClipboardEvent("paste"))}},{key:"pasteText",value:function(e,t){return Gc(this,e,null,!0,t||new ClipboardEvent("paste"))}},{key:"serializeForClipboard",value:function(e){return vc(this,e)}},{key:"destroy",value:function(){this.docView&&(!function(e){for(var t in e.domObserver.stop(),e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],wu(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,_a=null)}},{key:"isDestroyed",get:function(){return null==this.docView}},{key:"dispatchEvent",value:function(e){return function(e,t){Ic(e,t)||!Tc[t.type]||!e.editable&&t.type in Oc||Tc[t.type](e,t)}(this,e)}},{key:"domSelectionRange",value:function(){var e=this.domSelection();return e?Ua&&11===this.root.nodeType&&function(e){for(var t=e.activeElement;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom&&function(e,t){if(t.getComposedRanges){var n=t.getComposedRanges(e.root)[0];if(n)return Tu(e,n)}var r;function i(e){e.preventDefault(),e.stopImmediatePropagation(),r=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",i,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",i,!0),r?Tu(e,r):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}},{key:"domSelection",value:function(){return this.root.getSelection()}}])}();function Pu(e){var t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",function(n){if("function"==typeof n&&(n=n(e.state)),n)for(var r in n)"class"==r?t.class+=" "+n[r]:"style"==r?t.style=(t.style?t.style+";":"")+n[r]:t[r]||"contenteditable"==r||"nodeName"==r||(t[r]=String(n[r]))}),t.translate||(t.translate="no"),[au.node(0,e.state.doc.content.size,t)]}function Lu(e){if(e.markCursor){var t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:au.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Bu(e){return!e.someProp("editable",function(t){return!1===t(e.state)})}function Vu(e){var t=Object.create(null);function n(e){for(var n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function Fu(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}Ru.prototype.dispatch=function(e){var t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};for(var $u={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:"'"},ju={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Hu="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Wu="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),qu=0;qu<10;qu++)$u[48+qu]=$u[96+qu]=String(qu);for(qu=1;qu<=24;qu++)$u[qu+111]="F"+qu;for(qu=65;qu<=90;qu++)$u[qu]=String.fromCharCode(qu+32),ju[qu]=String.fromCharCode(qu);for(var Uu in $u)ju.hasOwnProperty(Uu)||(ju[Uu]=$u[Uu]);var Ju="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Ku="undefined"!=typeof navigator&&/Win/.test(navigator.platform);function Yu(e){var t,n,r,i,o=e.split(/-(?!$)/),a=o[o.length-1];"Space"==a&&(a=" ");for(var s=0;s<o.length-1;s++){var c=o[s];if(/^(cmd|meta|m)$/i.test(c))i=!0;else if(/^a(lt)?$/i.test(c))t=!0;else if(/^(c|ctrl|control)$/i.test(c))n=!0;else if(/^s(hift)?$/i.test(c))r=!0;else{if(!/^mod$/i.test(c))throw new Error("Unrecognized modifier name: "+c);Ju?i=!0:n=!0}}return t&&(a="Alt-"+a),n&&(a="Ctrl-"+a),i&&(a="Meta-"+a),r&&(a="Shift-"+a),a}function Gu(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function Xu(e){var t=function(e){var t=Object.create(null);for(var n in e)t[Yu(n)]=e[n];return t}(e);return function(e,n){var r,i=function(e){var t=!(Hu&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Wu&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?ju:$u)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(n),o=t[Gu(i,n)];if(o&&o(e.state,e.dispatch,e))return!0;if(1==i.length&&" "!=i){if(n.shiftKey){var a=t[Gu(i,n,!1)];if(a&&a(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(Ku&&n.ctrlKey&&n.altKey)&&(r=$u[n.keyCode])&&r!=i){var s=t[Gu(r,n)];if(s&&s(e.state,e.dispatch,e))return!0}}return!1}}var Zu=Object.defineProperty,Qu=function(e,t){for(var n in t)Zu(e,n,{get:t[n],enumerable:!0})};function el(e){var t=e.state,n=e.transaction,r=n.selection,i=n.doc,o=n.storedMarks;return g(g({},t),{},{apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return o},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,o=n.storedMarks,n}})}var tl=function(){return S(function e(t){x(this,e),this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state},[{key:"hasCustomState",get:function(){return!!this.customState}},{key:"state",get:function(){return this.customState||this.editor.state}},{key:"commands",get:function(){var e=this,t=this.rawCommands,n=this.editor,r=this.state,i=n.view,o=r.tr,a=this.buildProps(o);return Object.fromEntries(Object.entries(t).map(function(t){var n=d(t,2),r=n[0],s=n[1];return[r,function(){var t=s.apply(void 0,arguments)(a);return o.getMeta("preventDispatch")||e.hasCustomState||i.dispatch(o),t}]}))}},{key:"chain",get:function(){var e=this;return function(){return e.createChain()}}},{key:"can",get:function(){var e=this;return function(){return e.createCan()}}},{key:"createChain",value:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=this.rawCommands,i=this.editor,o=this.state,a=i.view,s=[],c=!!e,u=e||o.tr,l=g(g({},Object.fromEntries(Object.entries(r).map(function(e){var r=d(e,2),i=r[0],o=r[1];return[i,function(){var e=t.buildProps(u,n),r=o.apply(void 0,arguments)(e);return s.push(r),l}]}))),{},{run:function(){return c||!n||u.getMeta("preventDispatch")||t.hasCustomState||a.dispatch(u),s.every(function(e){return!0===e})}});return l}},{key:"createCan",value:function(e){var t=this,n=this.rawCommands,r=this.state,i=!1,o=e||r.tr,a=this.buildProps(o,i),s=Object.fromEntries(Object.entries(n).map(function(e){var t=d(e,2),n=t[0],r=t[1];return[n,function(){return r.apply(void 0,arguments)(g(g({},a),{},{dispatch:void 0}))}]}));return g(g({},s),{},{chain:function(){return t.createChain(o,i)}})}},{key:"buildProps",value:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=this.rawCommands,i=this.editor,o=this.state,a=i.view,s={tr:e,editor:i,view:a,state:el({state:o,transaction:e}),dispatch:n?function(){}:void 0,chain:function(){return t.createChain(e,n)},can:function(){return t.createCan(e)},get commands(){return Object.fromEntries(Object.entries(r).map(function(e){var t=d(e,2),n=t[0],r=t[1];return[n,function(){return r.apply(void 0,arguments)(s)}]}))}};return s}}])}(),nl={};Qu(nl,{blur:function(){return rl},clearContent:function(){return il},clearNodes:function(){return ol},command:function(){return al},createParagraphNear:function(){return sl},cut:function(){return cl},deleteCurrentNode:function(){return ul},deleteNode:function(){return dl},deleteRange:function(){return hl},deleteSelection:function(){return fl},enter:function(){return pl},exitCode:function(){return vl},extendMarkRange:function(){return xl},first:function(){return Cl},focus:function(){return Ol},forEach:function(){return Nl},insertContent:function(){return El},insertContentAt:function(){return zl},joinBackward:function(){return Ll},joinDown:function(){return Pl},joinForward:function(){return Bl},joinItemBackward:function(){return Vl},joinItemForward:function(){return Fl},joinTextblockBackward:function(){return $l},joinTextblockForward:function(){return jl},joinUp:function(){return Rl},keyboardShortcut:function(){return Wl},lift:function(){return Ul},liftEmptyBlock:function(){return Jl},liftListItem:function(){return Kl},newlineInCode:function(){return Yl},resetAttributes:function(){return Zl},scrollIntoView:function(){return Ql},selectAll:function(){return ed},selectNodeBackward:function(){return td},selectNodeForward:function(){return nd},selectParentNode:function(){return rd},selectTextblockEnd:function(){return id},selectTextblockStart:function(){return od},setContent:function(){return sd},setMark:function(){return Ld},setMeta:function(){return Bd},setNode:function(){return Vd},setNodeSelection:function(){return Fd},setTextDirection:function(){return $d},setTextSelection:function(){return jd},sinkListItem:function(){return Hd},splitBlock:function(){return qd},splitListItem:function(){return Ud},toggleList:function(){return Yd},toggleMark:function(){return Gd},toggleNode:function(){return Xd},toggleWrap:function(){return Zd},undoInputRule:function(){return Qd},unsetAllMarks:function(){return eh},unsetMark:function(){return th},unsetTextDirection:function(){return nh},updateAttributes:function(){return rh},wrapIn:function(){return ih},wrapInList:function(){return oh}});var rl=function(){return function(e){var t=e.editor,n=e.view;return requestAnimationFrame(function(){var e;t.isDestroyed||(n.dom.blur(),null==(e=null==window?void 0:window.getSelection())||e.removeAllRanges())}),!0}},il=function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return function(t){return t.commands.setContent("",{emitUpdate:e})}},ol=function(){return function(e){var t=e.state,n=e.tr,r=e.dispatch,i=n.selection.ranges;return!r||(i.forEach(function(e){var r=e.$from,i=e.$to;t.doc.nodesBetween(r.pos,i.pos,function(e,t){if(!e.type.isText){var r=n.doc,i=n.mapping,o=r.resolve(i.map(t)),a=r.resolve(i.map(t+e.nodeSize)),s=o.blockRange(a);if(s){var c=po(s);if(e.type.isTextblock){var u=o.parent.contentMatchAt(o.index()).defaultType;n.setNodeMarkup(s.start,u)}(c||0===c)&&n.lift(s,c)}}})}),!0)}},al=function(e){return function(t){return e(t)}},sl=function(){return function(e){return function(e,t){var n=e.selection,r=n.$from,i=n.$to;if(n instanceof Ko||r.parent.inlineContent||i.parent.inlineContent)return!1;var o=va(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(t){var a=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,s=e.tr.insert(a,o.createAndFill());s.setSelection(Wo.create(s.doc,a+1)),t(s.scrollIntoView())}return!0}(e.state,e.dispatch)}},cl=function(e,t){return function(n){var r=n.editor,i=n.tr,o=r.state.doc.slice(e.from,e.to);i.deleteRange(e.from,e.to);var a=i.mapping.map(t);return i.insert(a,o.content),i.setSelection(new Wo(i.doc.resolve(Math.max(a-1,0)))),!0}},ul=function(){return function(e){var t=e.tr,n=e.dispatch,r=t.selection.$anchor.node();if(r.content.size>0)return!1;for(var i=t.selection.$anchor,o=i.depth;o>0;o-=1){if(i.node(o).type===r.type){if(n){var a=i.before(o),s=i.after(o);t.delete(a,s).scrollIntoView()}return!0}}return!1}};function ll(e,t){if("string"==typeof e){if(!t.nodes[e])throw Error("There is no node type named '".concat(e,"'. Maybe you forgot to add the extension?"));return t.nodes[e]}return e}var dl=function(e){return function(t){for(var n=t.tr,r=t.state,i=t.dispatch,o=ll(e,r.schema),a=n.selection.$anchor,s=a.depth;s>0;s-=1){if(a.node(s).type===o){if(i){var c=a.before(s),u=a.after(s);n.delete(c,u).scrollIntoView()}return!0}}return!1}},hl=function(e){return function(t){var n=t.tr,r=t.dispatch,i=e.from,o=e.to;return r&&n.delete(i,o),!0}},fl=function(){return function(e){return function(e,t){return!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0)}(e.state,e.dispatch)}},pl=function(){return function(e){return e.commands.keyboardShortcut("Enter")}},vl=function(){return function(e){return function(e,t){var n=e.selection,r=n.$head,i=n.$anchor;if(!r.parent.type.spec.code||!r.sameParent(i))return!1;var o=r.node(-1),a=r.indexAfter(-1),s=va(o.contentMatchAt(a));if(!s||!o.canReplaceWith(a,a,s))return!1;if(t){var c=r.after(),u=e.tr.replaceWith(c,c,s.createAndFill());u.setSelection(Fo.near(u.doc.resolve(c),1)),t(u.scrollIntoView())}return!0}(e.state,e.dispatch)}};function ml(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function gl(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{strict:!0},r=Object.keys(t);return!r.length||r.every(function(r){return n.strict?t[r]===e[r]:ml(t[r])?t[r].test(e[r]):t[r]===e[r]})}function yl(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return e.find(function(e){return e.type===t&&gl(Object.fromEntries(Object.keys(n).map(function(t){return[t,e.attrs[t]]})),n)})}function kl(e,t){return!!yl(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:{})}function wl(e,t,n){var r;if(e&&t){var i=e.parent.childAfter(e.parentOffset);if(i.node&&i.node.marks.some(function(e){return e.type===t})||(i=e.parent.childBefore(e.parentOffset)),i.node&&i.node.marks.some(function(e){return e.type===t}))if(n=n||(null==(r=i.node.marks[0])?void 0:r.attrs),yl(c(i.node.marks),t,n)){for(var o=i.index,a=e.start()+i.offset,s=o+1,u=a+i.node.nodeSize;o>0&&kl(c(e.parent.child(o-1).marks),t,n);)o-=1,a-=e.parent.child(o).nodeSize;for(;s<e.parent.childCount&&kl(c(e.parent.child(s).marks),t,n);)u+=e.parent.child(s).nodeSize,s+=1;return{from:a,to:u}}}}function bl(e,t){if("string"==typeof e){if(!t.marks[e])throw Error("There is no mark type named '".concat(e,"'. Maybe you forgot to add the extension?"));return t.marks[e]}return e}var xl=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.tr,i=n.state,o=n.dispatch,a=bl(e,i.schema),s=r.doc,c=r.selection,u=c.$from,l=c.from,d=c.to;if(o){var h=wl(u,a,t);if(h&&h.from<=l&&h.to>=d){var f=Wo.create(s,h.from,h.to);r.setSelection(f)}}return!0}},Cl=function(e){return function(t){for(var n="function"==typeof e?e(t):e,r=0;r<n.length;r+=1)if(n[r](t))return!0;return!1}};function Sl(e){return e instanceof Wo}function _l(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Math.min(Math.max(e,t),n)}function Ml(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!t)return null;var n=Fo.atStart(e),r=Fo.atEnd(e);if("start"===t||!0===t)return n;if("end"===t)return r;var i=n.from,o=r.to;return"all"===t?Wo.create(e,_l(0,i,o),_l(e.content.size,i,o)):Wo.create(e,_l(t,i,o),_l(t,i,o))}function Tl(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var Ol=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.editor,i=n.view,o=n.tr,a=n.dispatch;t=g({scrollIntoView:!0},t);var s=function(){(Tl()||"Android"===navigator.platform||/android/i.test(navigator.userAgent))&&i.dom.focus(),requestAnimationFrame(function(){r.isDestroyed||(i.focus(),(null==t?void 0:t.scrollIntoView)&&r.commands.scrollIntoView())})};if(i.hasFocus()&&null===e||!1===e)return!0;if(a&&null===e&&!Sl(r.state.selection))return s(),!0;var c=Ml(o.doc,e)||r.state.selection,u=r.state.selection.eq(c);return a&&(u||o.setSelection(c),u&&o.storedMarks&&o.setStoredMarks(o.storedMarks),s()),!0}},Nl=function(e,t){return function(n){return e.every(function(e,r){return t(e,g(g({},n),{},{index:r}))})}},El=function(e,t){return function(n){var r=n.tr;return n.commands.insertContentAt({from:r.selection.from,to:r.selection.to},e,t)}},Al=function(e){for(var t=e.childNodes,n=t.length-1;n>=0;n-=1){var r=t[n];3===r.nodeType&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):1===r.nodeType&&Al(r)}return e};function Dl(e){if("undefined"==typeof window)throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");var t="<body>".concat(e,"</body>"),n=(new window.DOMParser).parseFromString(t,"text/html").body;return Al(n)}function Il(e,t,n){if(e instanceof li||e instanceof Fr)return e;n=g({slice:!0,parseOptions:{}},n);var r="string"==typeof e;if("object"===T(e)&&null!==e)try{if(Array.isArray(e)&&e.length>0)return Fr.fromArray(e.map(function(e){return t.nodeFromJSON(e)}));var i=t.nodeFromJSON(e);return n.errorOnInvalidContent&&i.check(),i}catch(u){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:u});return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",u),Il("",t,n)}if(r){if(n.errorOnInvalidContent){var o=!1,a="",s=new Ei({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:function(e){return o=!0,a="string"==typeof e?e:e.outerHTML,null}}]}})});if(n.slice?Di.fromSchema(s).parseSlice(Dl(e),n.parseOptions):Di.fromSchema(s).parse(Dl(e),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error("Invalid element found: ".concat(a))})}var c=Di.fromSchema(t);return n.slice?c.parseSlice(Dl(e),n.parseOptions).content:c.parse(Dl(e),n.parseOptions)}return Il("",t,n)}var zl=function(e,t,n){return function(r){var i,o=r.tr,a=r.dispatch,s=r.editor;if(a){var c;n=g({parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1},n);var u=function(e){s.emit("contentError",{editor:s,error:e,disableCollaboration:function(){"collaboration"in s.storage&&"object"===T(s.storage.collaboration)&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},l=g({preserveWhitespace:"full"},n.parseOptions);if(!n.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{Il(t,s.schema,{parseOptions:l,errorOnInvalidContent:!0})}catch(pt){u(pt)}try{c=Il(t,s.schema,{parseOptions:l,errorOnInvalidContent:null!=(i=n.errorOnInvalidContent)?i:s.options.enableContentCheck})}catch(pt){return u(pt),!1}var d,h="number"==typeof e?{from:e,to:e}:{from:e.from,to:e.to},f=h.from,p=h.to,v=!0,m=!0;if(("type"in c?[c]:c).forEach(function(e){e.check(),v=!!v&&(e.isText&&0===e.marks.length),m=!!m&&e.isBlock}),f===p&&m){var y=o.doc.resolve(f).parent;y.isTextblock&&!y.type.spec.code&&!y.childCount&&(f-=1,p+=1)}if(v){if(Array.isArray(t))d=t.map(function(e){return e.text||""}).join("");else if(t instanceof Fr){var k="";t.forEach(function(e){e.text&&(k+=e.text)}),d=k}else d="object"===T(t)&&t&&t.text?t.text:t;o.insertText(d,f,p)}else{d=c;var w=o.doc.resolve(f),b=w.node(),x=0===w.parentOffset,C=b.isText||b.isTextblock,S=b.content.size>0;x&&C&&S&&(f=Math.max(0,f-1)),o.replaceWith(f,p,d)}n.updateSelection&&function(e,t,n){var r=e.steps.length-1;if(!(r<t)){var i=e.steps[r];if(i instanceof co||i instanceof uo){var o=e.mapping.maps[r],a=0;o.forEach(function(e,t,n,r){0===a&&(a=r)}),e.setSelection(Fo.near(e.doc.resolve(a),n))}}}(o,o.steps.length-1,-1),n.applyInputRules&&o.setMeta("applyInputRules",{from:f,text:d}),n.applyPasteRules&&o.setMeta("applyPasteRules",{from:f,text:d})}return!0}},Rl=function(){return function(e){return function(e,t){var n,r=e.selection,i=r instanceof Uo;if(i){if(r.node.isTextblock||!wo(e.doc,r.from))return!1;n=r.from}else if(null==(n=xo(e.doc,r.from,-1)))return!1;if(t){var o=e.tr.join(n);i&&o.setSelection(Uo.create(o.doc,n-e.doc.resolve(n).nodeBefore.nodeSize)),t(o.scrollIntoView())}return!0}(e.state,e.dispatch)}},Pl=function(){return function(e){return function(e,t){var n,r=e.selection;if(r instanceof Uo){if(r.node.isTextblock||!wo(e.doc,r.to))return!1;n=r.to}else if(null==(n=xo(e.doc,r.to,1)))return!1;return t&&t(e.tr.join(n).scrollIntoView()),!0}(e.state,e.dispatch)}},Ll=function(){return function(e){return function(e,t,n){var r=ua(e,n);if(!r)return!1;var i=ha(r);if(!i){var o=r.blockRange(),a=o&&po(o);return null!=a&&(t&&t(e.tr.lift(o,a).scrollIntoView()),!0)}var s=i.nodeBefore;if(ma(e,i,t,-1))return!0;if(0==r.parent.content.size&&(da(s,"end")||Uo.isSelectable(s)))for(var c=r.depth;;c--){var u=So(e.doc,r.before(c),r.after(c),Ur.empty);if(u&&u.slice.size<u.to-u.from){if(t){var l=e.tr.step(u);l.setSelection(da(s,"end")?Fo.findFrom(l.doc.resolve(l.mapping.map(i.pos,-1)),-1):Uo.create(l.doc,i.pos-s.nodeSize)),t(l.scrollIntoView())}return!0}if(1==c||r.node(c-1).childCount>1)break}return!(!s.isAtom||i.depth!=r.depth-1||(t&&t(e.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),0))}(e.state,e.dispatch)}},Bl=function(){return function(e){return function(e,t,n){var r=fa(e,n);if(!r)return!1;var i=pa(r);if(!i)return!1;var o=i.nodeAfter;if(ma(e,i,t,1))return!0;if(0==r.parent.content.size&&(da(o,"start")||Uo.isSelectable(o))){var a=So(e.doc,r.before(),r.after(),Ur.empty);if(a&&a.slice.size<a.to-a.from){if(t){var s=e.tr.step(a);s.setSelection(da(o,"start")?Fo.findFrom(s.doc.resolve(s.mapping.map(i.pos)),1):Uo.create(s.doc,s.mapping.map(i.pos))),t(s.scrollIntoView())}return!0}}return!(!o.isAtom||i.depth!=r.depth-1||(t&&t(e.tr.delete(i.pos,i.pos+o.nodeSize).scrollIntoView()),0))}(e.state,e.dispatch)}},Vl=function(){return function(e){var t=e.state,n=e.dispatch,r=e.tr;try{var i=xo(t.doc,t.selection.$from.pos,-1);return null!=i&&(r.join(i,2),n&&n(r),!0)}catch(o){return!1}}},Fl=function(){return function(e){var t=e.state,n=e.dispatch,r=e.tr;try{var i=xo(t.doc,t.selection.$from.pos,1);return null!=i&&(r.join(i,2),n&&n(r),!0)}catch(o){return!1}}},$l=function(){return function(e){return function(e,t,n){var r=ua(e,n);if(!r)return!1;var i=ha(r);return!!i&&la(e,i,t)}(e.state,e.dispatch)}},jl=function(){return function(e){return function(e,t,n){var r=fa(e,n);if(!r)return!1;var i=pa(r);return!!i&&la(e,i,t)}(e.state,e.dispatch)}};function Hl(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}var Wl=function(e){return function(t){var n=t.editor,r=t.view,i=t.tr,o=t.dispatch,a=function(e){var t,n,r,i,o=e.split(/-(?!$)/),a=o[o.length-1];"Space"===a&&(a=" ");for(var s=0;s<o.length-1;s+=1){var c=o[s];if(/^(cmd|meta|m)$/i.test(c))i=!0;else if(/^a(lt)?$/i.test(c))t=!0;else if(/^(c|ctrl|control)$/i.test(c))n=!0;else if(/^s(hift)?$/i.test(c))r=!0;else{if(!/^mod$/i.test(c))throw new Error("Unrecognized modifier name: ".concat(c));Tl()||Hl()?i=!0:n=!0}}return t&&(a="Alt-".concat(a)),n&&(a="Ctrl-".concat(a)),i&&(a="Meta-".concat(a)),r&&(a="Shift-".concat(a)),a}(e).split(/-(?!$)/),s=a.find(function(e){return!["Alt","Ctrl","Meta","Shift"].includes(e)}),c=new KeyboardEvent("keydown",{key:"Space"===s?" ":s,altKey:a.includes("Alt"),ctrlKey:a.includes("Ctrl"),metaKey:a.includes("Meta"),shiftKey:a.includes("Shift"),bubbles:!0,cancelable:!0}),u=n.captureTransaction(function(){r.someProp("handleKeyDown",function(e){return e(r,c)})});return null==u||u.steps.forEach(function(e){var t=e.map(i.mapping);t&&o&&i.maybeStep(t)}),!0}};function ql(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=e.selection,i=r.from,o=r.to,a=r.empty,s=t?ll(t,e.schema):null,c=[];e.doc.nodesBetween(i,o,function(e,t){if(!e.isText){var n=Math.max(i,t),r=Math.min(o,t+e.nodeSize);c.push({node:e,from:n,to:r})}});var u=o-i,l=c.filter(function(e){return!s||s.name===e.node.type.name}).filter(function(e){return gl(e.node.attrs,n,{strict:!1})});return a?!!l.length:l.reduce(function(e,t){return e+t.to-t.from},0)>=u}var Ul=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.state,i=n.dispatch;return!!ql(r,ll(e,r.schema),t)&&function(e,t){var n=e.selection,r=n.$from,i=n.$to,o=r.blockRange(i),a=o&&po(o);return null!=a&&(t&&t(e.tr.lift(o,a).scrollIntoView()),!0)}(r,i)}},Jl=function(){return function(e){return function(e,t){var n=e.selection.$cursor;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){var r=n.before();if(ko(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}var i=n.blockRange(),o=i&&po(i);return null!=o&&(t&&t(e.tr.lift(i,o).scrollIntoView()),!0)}(e.state,e.dispatch)}},Kl=function(e){return function(t){var n=t.state,r=t.dispatch;return xa(ll(e,n.schema))(n,r)}},Yl=function(){return function(e){return function(e,t){var n=e.selection,r=n.$head,i=n.$anchor;return!(!r.parent.type.spec.code||!r.sameParent(i)||(t&&t(e.tr.insertText("\n").scrollIntoView()),0))}(e.state,e.dispatch)}};function Gl(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function Xl(e,t){var n="string"==typeof t?[t]:t;return Object.keys(e).reduce(function(t,r){return n.includes(r)||(t[r]=e[r]),t},{})}var Zl=function(e,t){return function(n){var r=n.tr,i=n.state,o=n.dispatch,a=null,s=null,c=Gl("string"==typeof e?e:e.name,i.schema);if(!c)return!1;"node"===c&&(a=ll(e,i.schema)),"mark"===c&&(s=bl(e,i.schema));var u=!1;return r.selection.ranges.forEach(function(e){i.doc.nodesBetween(e.$from.pos,e.$to.pos,function(e,n){a&&a===e.type&&(u=!0,o&&r.setNodeMarkup(n,void 0,Xl(e.attrs,t))),s&&e.marks.length&&e.marks.forEach(function(i){s===i.type&&(u=!0,o&&r.addMark(n,n+e.nodeSize,s.create(Xl(i.attrs,t))))})})}),u}},Ql=function(){return function(e){var t=e.tr;return e.dispatch&&t.scrollIntoView(),!0}},ed=function(){return function(e){var t=e.tr;if(e.dispatch){var n=new Ko(t.doc);t.setSelection(n)}return!0}},td=function(){return function(e){return function(e,t,n){var r=e.selection,i=r.$head,o=i;if(!r.empty)return!1;if(i.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):i.parentOffset>0)return!1;o=ha(i)}var a=o&&o.nodeBefore;return!(!a||!Uo.isSelectable(a)||(t&&t(e.tr.setSelection(Uo.create(e.doc,o.pos-a.nodeSize)).scrollIntoView()),0))}(e.state,e.dispatch)}},nd=function(){return function(e){return function(e,t,n){var r=e.selection,i=r.$head,o=i;if(!r.empty)return!1;if(i.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):i.parentOffset<i.parent.content.size)return!1;o=pa(i)}var a=o&&o.nodeAfter;return!(!a||!Uo.isSelectable(a)||(t&&t(e.tr.setSelection(Uo.create(e.doc,o.pos)).scrollIntoView()),0))}(e.state,e.dispatch)}},rd=function(){return function(e){return function(e,t){var n,r=e.selection,i=r.$from,o=r.to,a=i.sharedDepth(o);return 0!=a&&(n=i.before(a),t&&t(e.tr.setSelection(Uo.create(e.doc,n))),!0)}(e.state,e.dispatch)}},id=function(){return function(e){var t=e.state,n=e.dispatch;return ka(t,n)}},od=function(){return function(e){var t=e.state,n=e.dispatch;return ya(t,n)}};function ad(e,t){return Il(e,t,{slice:!1,parseOptions:arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},errorOnInvalidContent:(arguments.length>3&&void 0!==arguments[3]?arguments[3]:{}).errorOnInvalidContent})}var sd=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.errorOnInvalidContent,r=t.emitUpdate,i=void 0===r||r,o=t.parseOptions,a=void 0===o?{}:o;return function(t){var r=t.editor,o=t.tr,s=t.dispatch,c=t.commands,u=o.doc;if("full"!==a.preserveWhitespace){var l=ad(e,r.schema,a,{errorOnInvalidContent:null!=n?n:r.options.enableContentCheck});return s&&o.replaceWith(0,u.content.size,l).setMeta("preventUpdate",!i),!0}return s&&o.setMeta("preventUpdate",!i),c.insertContentAt({from:0,to:u.content.size},e,{parseOptions:a,errorOnInvalidContent:null!=n?n:r.options.enableContentCheck})}};function cd(e,t){var n=bl(t,e.schema),r=e.selection,i=r.from,o=r.to,a=r.empty,s=[];a?(e.storedMarks&&s.push.apply(s,c(e.storedMarks)),s.push.apply(s,c(e.selection.$head.marks()))):e.doc.nodesBetween(i,o,function(e){s.push.apply(s,c(e.marks))});var u=s.find(function(e){return e.type.name===n.name});return u?g({},u.attrs):{}}function ud(e){return function(t){return function(e,t){for(var n=e.depth;n>0;n-=1){var r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}(t.$from,e)}}function ld(e,t,n){return void 0===e.config[t]&&e.parent?ld(e.parent,t,n):"function"==typeof e.config[t]?e.config[t].bind(g(g({},n),{},{parent:e.parent?ld(e.parent,t,n):null})):e.config[t]}function dd(e){return e.map(function(e){var t=ld(e,"addExtensions",{name:e.name,options:e.options,storage:e.storage});return t?[e].concat(c(dd(t()))):e}).flat(10)}function hd(e,t){var n=ji.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function fd(e){return"function"==typeof e}function pd(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;if(fd(e)){for(var n=arguments.length,r=new Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return t?e.bind(t).apply(void 0,r):e.apply(void 0,r)}return e}function vd(e){return{baseExtensions:e.filter(function(e){return"extension"===e.type}),nodeExtensions:e.filter(function(e){return"node"===e.type}),markExtensions:e.filter(function(e){return"mark"===e.type})}}function md(e){var t=[],n=vd(e),r=n.nodeExtensions,i=n.markExtensions,o=[].concat(c(r),c(i)),a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return e.forEach(function(e){var n=ld(e,"addGlobalAttributes",{name:e.name,options:e.options,storage:e.storage,extensions:o});n&&n().forEach(function(e){e.types.forEach(function(n){Object.entries(e.attributes).forEach(function(e){var r=d(e,2),i=r[0],o=r[1];t.push({type:n,name:i,attribute:g(g({},a),o)})})})})}),o.forEach(function(e){var n={name:e.name,options:e.options,storage:e.storage},r=ld(e,"addAttributes",n);if(r){var i=r();Object.entries(i).forEach(function(n){var r=d(n,2),i=r[0],o=r[1],s=g(g({},a),o);"function"==typeof(null==s?void 0:s.default)&&(s.default=s.default()),(null==s?void 0:s.isRequired)&&void 0===(null==s?void 0:s.default)&&delete s.default,t.push({type:e.name,name:i,attribute:s})})}}),t}function gd(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter(function(e){return!!e}).reduce(function(e,t){var n=g({},e);return Object.entries(t).forEach(function(e){var t=d(e,2),r=t[0],i=t[1];if(n[r])if("class"===r){var o=i?String(i).split(" "):[],a=n[r]?n[r].split(" "):[],s=o.filter(function(e){return!a.includes(e)});n[r]=[].concat(c(a),c(s)).join(" ")}else if("style"===r){var u=i?i.split(";").map(function(e){return e.trim()}).filter(Boolean):[],l=n[r]?n[r].split(";").map(function(e){return e.trim()}).filter(Boolean):[],h=new Map;l.forEach(function(e){var t=d(e.split(":").map(function(e){return e.trim()}),2),n=t[0],r=t[1];h.set(n,r)}),u.forEach(function(e){var t=d(e.split(":").map(function(e){return e.trim()}),2),n=t[0],r=t[1];h.set(n,r)}),n[r]=Array.from(h.entries()).map(function(e){var t=d(e,2),n=t[0],r=t[1];return"".concat(n,": ").concat(r)}).join("; ")}else n[r]=i;else n[r]=i}),n},{})}function yd(e,t){return t.filter(function(t){return t.type===e.type.name}).filter(function(e){return e.attribute.rendered}).map(function(t){return t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:_({},t.name,e.attrs[t.name])}).reduce(function(e,t){return gd(e,t)},{})}function kd(e,t){return"style"in e?e:g(g({},e),{},{getAttrs:function(n){var r=e.getAttrs?e.getAttrs(n):e.attrs;if(!1===r)return!1;var i=t.reduce(function(e,t){var r=t.attribute.parseHTML?t.attribute.parseHTML(n):function(e){return"string"!=typeof e?e:e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):"true"===e||"false"!==e&&e}(n.getAttribute(t.name));return null==r?e:g(g({},e),{},_({},t.name,r))},{});return g(g({},r),i)}})}function wd(e){return Object.fromEntries(Object.entries(e).filter(function(e){var t=d(e,2),n=t[0],r=t[1];return("attrs"!==n||!function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return 0===Object.keys(e).length&&e.constructor===Object}(r))&&null!=r}))}function bd(e){var t,n,r={};return!(null==(t=null==e?void 0:e.attribute)?void 0:t.isRequired)&&"default"in((null==e?void 0:e.attribute)||{})&&(r.default=e.attribute.default),void 0!==(null==(n=null==e?void 0:e.attribute)?void 0:n.validate)&&(r.validate=e.attribute.validate),[e.name,r]}function xd(e){return e.sort(function(e,t){var n=ld(e,"priority")||100,r=ld(t,"priority")||100;return n>r?-1:n<r?1:0})}function Cd(e){var t,n,r=xd(dd(e)),i=(t=r.map(function(e){return e.name}),n=t.filter(function(e,n){return t.indexOf(e)!==n}),Array.from(new Set(n)));return i.length&&console.warn("[tiptap warn]: Duplicate extension names found: [".concat(i.map(function(e){return"'".concat(e,"'")}).join(", "),"]. This can lead to issues.")),r}function Sd(e,t,n){var r=t.from,i=t.to,o=n||{},a=o.blockSeparator,s=void 0===a?"\n\n":a,c=o.textSerializers,u=void 0===c?{}:c,l="";return e.nodesBetween(r,i,function(e,n,o,a){var c;e.isBlock&&n>r&&(l+=s);var d=null==u?void 0:u[e.type.name];if(d)return o&&(l+=d({node:e,pos:n,parent:o,index:a,range:t})),!1;e.isText&&(l+=null==(c=null==e?void 0:e.text)?void 0:c.slice(Math.max(r,n)-n,i-n))}),l}function _d(e){return Object.fromEntries(Object.entries(e.nodes).filter(function(e){return d(e,2)[1].spec.toText}).map(function(e){var t=d(e,2);return[t[0],t[1].spec.toText]}))}function Md(e,t){var n=Gl("string"==typeof t?t:t.name,e.schema);return"node"===n?function(e,t){var n=ll(t,e.schema),r=e.selection,i=r.from,o=r.to,a=[];e.doc.nodesBetween(i,o,function(e){a.push(e)});var s=a.reverse().find(function(e){return e.type.name===n.name});return s?g({},s.attrs):{}}(e,t):"mark"===n?cd(e,t):{}}function Td(e){var t=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:JSON.stringify,n={};return e.filter(function(e){var r=t(e);return!Object.prototype.hasOwnProperty.call(n,r)&&(n[r]=!0)})}(e);return 1===t.length?t:t.filter(function(e,n){var r=t.filter(function(e,t){return t!==n});return!r.some(function(t){return e.oldRange.from>=t.oldRange.from&&e.oldRange.to<=t.oldRange.to&&e.newRange.from>=t.newRange.from&&e.newRange.to<=t.newRange.to})})}function Od(e,t){return t.nodes[e]||t.marks[e]||null}function Nd(e,t,n){return Object.fromEntries(Object.entries(n).filter(function(n){var r=d(n,1)[0],i=e.find(function(e){return e.type===t&&e.name===r});return!!i&&i.attribute.keepOnSplit}))}function Ed(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=e.selection,i=r.empty,o=r.ranges,a=t?bl(t,e.schema):null;if(i)return!!(e.storedMarks||e.selection.$from.marks()).filter(function(e){return!a||a.name===e.type.name}).find(function(e){return gl(e.attrs,n,{strict:!1})});var s=0,u=[];if(o.forEach(function(t){var n=t.$from,r=t.$to,i=n.pos,o=r.pos;e.doc.nodesBetween(i,o,function(e,t){if(e.isText||e.marks.length){var n=Math.max(i,t),r=Math.min(o,t+e.nodeSize);s+=r-n,u.push.apply(u,c(e.marks.map(function(e){return{mark:e,from:n,to:r}})))}})}),0===s)return!1;var l=u.filter(function(e){return!a||a.name===e.mark.type.name}).filter(function(e){return gl(e.mark.attrs,n,{strict:!1})}).reduce(function(e,t){return e+t.to-t.from},0),d=u.filter(function(e){return!a||e.mark.type!==a&&e.mark.type.excludes(a)}).reduce(function(e,t){return e+t.to-t.from},0);return(l>0?l+d:l)>=s}function Ad(e,t){return Array.isArray(t)?t.some(function(t){return("string"==typeof t?t:t.name)===e.name}):t}function Dd(e,t){var n=vd(t).nodeExtensions.find(function(t){return t.name===e});if(!n)return!1;var r=pd(ld(n,"group",{name:n.name,options:n.options,storage:n.storage}));return"string"==typeof r&&r.split(" ").includes("list")}function Id(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.checkChildren,i=void 0===r||r,o=n.ignoreWhitespace,a=void 0!==o&&o;if(a){if("hardBreak"===e.type.name)return!0;if(e.isText)return/^\s*$/m.test(null!=(t=e.text)?t:"")}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(0===e.content.childCount)return!0;if(i){var s=!0;return e.content.forEach(function(e){!1!==s&&(Id(e,{ignoreWhitespace:a,checkChildren:i})||(s=!1))}),s}return!1}var zd=function(){function e(t){x(this,e),this.position=t}return S(e,[{key:"toJSON",value:function(){return{position:this.position}}}],[{key:"fromJSON",value:function(t){return new e(t.position)}}])}();function Rd(e,t){var n=t.mapping.mapResult(e.position);return{position:new zd(n.pos),mapResult:n}}function Pd(e){return new zd(e)}var Ld=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.tr,i=n.state,o=n.dispatch,a=r.selection,s=a.empty,c=a.ranges,u=bl(e,i.schema);if(o)if(s){var l=cd(i,u);r.addStoredMark(u.create(g(g({},l),t)))}else c.forEach(function(e){var n=e.$from.pos,o=e.$to.pos;i.doc.nodesBetween(n,o,function(e,i){var a=Math.max(i,n),s=Math.min(i+e.nodeSize,o);e.marks.find(function(e){return e.type===u})?e.marks.forEach(function(e){u===e.type&&r.addMark(a,s,u.create(g(g({},e.attrs),t)))}):r.addMark(a,s,u.create(t))})});return function(e,t,n){var r,i=t.selection,o=null;if(Sl(i)&&(o=i.$cursor),o){var a=null!=(r=e.storedMarks)?r:o.marks();return o.parent.type.allowsMarkType(n)&&(!!n.isInSet(a)||!a.some(function(e){return e.type.excludes(n)}))}return i.ranges.some(function(t){var r=t.$from,i=t.$to,o=0===r.depth&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(r.pos,i.pos,function(e,t,r){if(o)return!1;if(e.isInline){var i=!r||r.type.allowsMarkType(n),a=!!n.isInSet(e.marks)||!e.marks.some(function(e){return e.type.excludes(n)});o=i&&a}return!o}),o})}(i,r,u)}},Bd=function(e,t){return function(n){return n.tr.setMeta(e,t),!0}},Vd=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r,i=n.state,o=n.dispatch,a=n.chain,s=ll(e,i.schema);return i.selection.$anchor.sameParent(i.selection.$head)&&(r=i.selection.$anchor.parent.attrs),s.isTextblock?a().command(function(e){var n=e.commands;return!!wa(s,g(g({},r),t))(i)||n.clearNodes()}).command(function(e){var n=e.state;return wa(s,g(g({},r),t))(n,o)}).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)}},Fd=function(e){return function(t){var n=t.tr;if(t.dispatch){var r=n.doc,i=_l(e,0,r.content.size),o=Uo.create(r,i);n.setSelection(o)}return!0}},$d=function(e,t){return function(n){var r,i,o=n.tr,a=n.state,s=n.dispatch,c=a.selection;return"number"==typeof t?(r=t,i=t):t&&"from"in t&&"to"in t?(r=t.from,i=t.to):(r=c.from,i=c.to),s&&o.doc.nodesBetween(r,i,function(t,n){t.isText||o.setNodeMarkup(n,void 0,g(g({},t.attrs),{},{dir:e}))}),!0}},jd=function(e){return function(t){var n=t.tr;if(t.dispatch){var r=n.doc,i="number"==typeof e?{from:e,to:e}:e,o=i.from,a=i.to,s=Wo.atStart(r).from,c=Wo.atEnd(r).to,u=_l(o,s,c),l=_l(a,s,c),d=Wo.create(r,u,l);n.setSelection(d)}return!0}},Hd=function(e){return function(t){var n,r=t.state,i=t.dispatch,o=ll(e,r.schema);return(n=o,function(e,t){var r=e.selection,i=r.$from,o=r.$to,a=i.blockRange(o,function(e){return e.childCount>0&&e.firstChild.type==n});if(!a)return!1;var s=a.startIndex;if(0==s)return!1;var c=a.parent,u=c.child(s-1);if(u.type!=n)return!1;if(t){var l=u.lastChild&&u.lastChild.type==c.type,d=Fr.from(l?n.create():null),h=new Ur(Fr.from(n.create(null,Fr.from(c.type.create(null,d)))),l?3:1,0),f=a.start,p=a.end;t(e.tr.step(new uo(f-(l?3:1),p,f,p,h,1,!0)).scrollIntoView())}return!0})(r,i)}};function Wd(e,t){var n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){var r=n.filter(function(e){return null==t?void 0:t.includes(e.type.name)});e.tr.ensureMarks(r)}}var qd=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).keepMarks,t=void 0===e||e;return function(e){var n=e.tr,r=e.state,i=e.dispatch,o=e.editor,a=n.selection,s=n.doc,c=a.$from,u=a.$to,l=Nd(o.extensionManager.attributes,c.node().type.name,c.node().attrs);if(a instanceof Uo&&a.node.isBlock)return!(!c.parentOffset||!ko(s,c.pos))&&(i&&(t&&Wd(r,o.extensionManager.splittableMarks),n.split(c.pos).scrollIntoView()),!0);if(!c.parent.isBlock)return!1;var d=u.parentOffset===u.parent.content.size,h=0===c.depth?void 0:function(e){for(var t=0;t<e.edgeCount;t+=1){var n=e.edge(t).type;if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}(c.node(-1).contentMatchAt(c.indexAfter(-1))),f=d&&h?[{type:h,attrs:l}]:void 0,p=ko(n.doc,n.mapping.map(c.pos),1,f);if(f||p||!ko(n.doc,n.mapping.map(c.pos),1,h?[{type:h}]:void 0)||(p=!0,f=h?[{type:h,attrs:l}]:void 0),i){if(p&&(a instanceof Wo&&n.deleteSelection(),n.split(n.mapping.map(c.pos),1,f),h&&!d&&!c.parentOffset&&c.parent.type!==h)){var v=n.mapping.map(c.before()),m=n.doc.resolve(v);c.node(-1).canReplaceWith(m.index(),m.index()+1,h)&&n.setNodeMarkup(n.mapping.map(c.before()),h)}t&&Wd(r,o.extensionManager.splittableMarks),n.scrollIntoView()}return p}},Ud=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r,i=n.tr,o=n.state,a=n.dispatch,s=n.editor,c=ll(e,o.schema),u=o.selection,l=u.$from,d=u.$to,h=o.selection.node;if(h&&h.isBlock||l.depth<2||!l.sameParent(d))return!1;var f=l.node(-1);if(f.type!==c)return!1;var p=s.extensionManager.attributes;if(0===l.parent.content.size&&l.node(-1).childCount===l.indexAfter(-1)){if(2===l.depth||l.node(-3).type!==c||l.index(-2)!==l.node(-2).childCount-1)return!1;if(a){for(var v=Fr.empty,m=l.index(-1)?1:l.index(-2)?2:3,y=l.depth-m;y>=l.depth-3;y-=1)v=Fr.from(l.node(y).copy(v));var k=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,w=g(g({},Nd(p,l.node().type.name,l.node().attrs)),t),b=(null==(r=c.contentMatch.defaultType)?void 0:r.createAndFill(w))||void 0;v=v.append(Fr.from(c.createAndFill(null,b)||void 0));var x=l.before(l.depth-(m-1));i.replace(x,l.after(-k),new Ur(v,4-m,0));var C=-1;i.doc.nodesBetween(x,i.doc.content.size,function(e,t){if(C>-1)return!1;e.isTextblock&&0===e.content.size&&(C=t+1)}),C>-1&&i.setSelection(Wo.near(i.doc.resolve(C))),i.scrollIntoView()}return!0}var S=d.pos===l.end()?f.contentMatchAt(0).defaultType:null,_=g(g({},Nd(p,f.type.name,f.attrs)),t),M=g(g({},Nd(p,l.node().type.name,l.node().attrs)),t);i.delete(l.pos,d.pos);var T=S?[{type:c,attrs:_},{type:S,attrs:M}]:[{type:c,attrs:_}];if(!ko(i.doc,l.pos,2))return!1;if(a){var O=o.selection,N=o.storedMarks,E=s.extensionManager.splittableMarks,A=N||O.$to.parentOffset&&O.$from.marks();if(i.split(l.pos,2,T).scrollIntoView(),!A||!a)return!0;var D=A.filter(function(e){return E.includes(e.type.name)});i.ensureMarks(D)}return!0}},Jd=function(e,t){var n=ud(function(e){return e.type===t})(e.selection);if(!n)return!0;var r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===r)return!0;var i=e.doc.nodeAt(r);return n.node.type!==(null==i?void 0:i.type)||!wo(e.doc,n.pos)||(e.join(n.pos),!0)},Kd=function(e,t){var n=ud(function(e){return e.type===t})(e.selection);if(!n)return!0;var r=e.doc.resolve(n.start).after(n.depth);if(void 0===r)return!0;var i=e.doc.nodeAt(r);return n.node.type!==(null==i?void 0:i.type)||!wo(e.doc,r)||(e.join(r),!0)},Yd=function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return function(i){var o=i.editor,a=i.tr,s=i.state,c=i.dispatch,u=i.chain,l=i.commands,d=i.can,h=o.extensionManager,f=h.extensions,p=h.splittableMarks,v=ll(e,s.schema),m=ll(t,s.schema),g=s.selection,y=s.storedMarks,k=g.$from,w=g.$to,b=k.blockRange(w),x=y||g.$to.parentOffset&&g.$from.marks();if(!b)return!1;var C=ud(function(e){return Dd(e.type.name,f)})(g);if(b.depth>=1&&C&&b.depth-C.depth<=1){if(C.node.type===v)return l.liftListItem(m);if(Dd(C.node.type.name,f)&&v.validContent(C.node.content)&&c)return u().command(function(){return a.setNodeMarkup(C.pos,v),!0}).command(function(){return Jd(a,v)}).command(function(){return Kd(a,v)}).run()}return n&&x&&c?u().command(function(){var e=d().wrapInList(v,r),t=x.filter(function(e){return p.includes(e.type.name)});return a.ensureMarks(t),!!e||l.clearNodes()}).wrapInList(v,r).command(function(){return Jd(a,v)}).command(function(){return Kd(a,v)}).run():u().command(function(){return!!d().wrapInList(v,r)||l.clearNodes()}).wrapInList(v,r).command(function(){return Jd(a,v)}).command(function(){return Kd(a,v)}).run()}},Gd=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(r){var i=r.state,o=r.commands,a=n.extendEmptyMarkRange,s=void 0!==a&&a,c=bl(e,i.schema);return Ed(i,c,t)?o.unsetMark(c,{extendEmptyMarkRange:s}):o.setMark(c,t)}},Xd=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(r){var i,o=r.state,a=r.commands,s=ll(e,o.schema),c=ll(t,o.schema),u=ql(o,s,n);return o.selection.$anchor.sameParent(o.selection.$head)&&(i=o.selection.$anchor.parent.attrs),u?a.setNode(c,i):a.setNode(s,g(g({},i),n))}},Zd=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.state,i=n.commands,o=ll(e,r.schema);return ql(r,o,t)?i.lift(o):i.wrapIn(o,t)}},Qd=function(){return function(e){for(var t=e.state,n=e.dispatch,r=t.plugins,i=0;i<r.length;i+=1){var o=r[i],a=void 0;if(o.spec.isInputRules&&(a=o.getState(t))){if(n){for(var s=t.tr,c=a.transform,u=c.steps.length-1;u>=0;u-=1)s.step(c.steps[u].invert(c.docs[u]));if(a.text){var l=s.doc.resolve(a.from).marks();s.replaceWith(a.from,a.to,t.schema.text(a.text,l))}else s.delete(a.from,a.to)}return!0}}return!1}},eh=function(){return function(e){var t=e.tr,n=e.dispatch,r=t.selection,i=r.empty,o=r.ranges;return i||n&&o.forEach(function(e){t.removeMark(e.$from.pos,e.$to.pos)}),!0}},th=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r,i=n.tr,o=n.state,a=n.dispatch,s=t.extendEmptyMarkRange,c=void 0!==s&&s,u=i.selection,l=bl(e,o.schema),d=u.$from,h=u.empty,f=u.ranges;if(!a)return!0;if(h&&c){var p=u.from,v=u.to,m=null==(r=d.marks().find(function(e){return e.type===l}))?void 0:r.attrs,g=wl(d,l,m);g&&(p=g.from,v=g.to),i.removeMark(p,v,l)}else f.forEach(function(e){i.removeMark(e.$from.pos,e.$to.pos,l)});return i.removeStoredMark(l),!0}},nh=function(e){return function(t){var n,r,i=t.tr,o=t.state,a=t.dispatch,s=o.selection;return"number"==typeof e?(n=e,r=e):e&&"from"in e&&"to"in e?(n=e.from,r=e.to):(n=s.from,r=s.to),a&&i.doc.nodesBetween(n,r,function(e,t){if(!e.isText){var n=g({},e.attrs);delete n.dir,i.setNodeMarkup(t,void 0,n)}}),!0}},rh=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.tr,i=n.state,o=n.dispatch,a=null,s=null,c=Gl("string"==typeof e?e:e.name,i.schema);if(!c)return!1;"node"===c&&(a=ll(e,i.schema)),"mark"===c&&(s=bl(e,i.schema));var u=!1;return r.selection.ranges.forEach(function(e){var n,c,l,d,h=e.$from.pos,f=e.$to.pos;r.selection.empty?i.doc.nodesBetween(h,f,function(e,t){a&&a===e.type&&(u=!0,l=Math.max(t,h),d=Math.min(t+e.nodeSize,f),n=t,c=e)}):i.doc.nodesBetween(h,f,function(e,i){i<h&&a&&a===e.type&&(u=!0,l=Math.max(i,h),d=Math.min(i+e.nodeSize,f),n=i,c=e),i>=h&&i<=f&&(a&&a===e.type&&(u=!0,o&&r.setNodeMarkup(i,void 0,g(g({},e.attrs),t))),s&&e.marks.length&&e.marks.forEach(function(n){if(s===n.type&&(u=!0,o)){var a=Math.max(i,h),c=Math.min(i+e.nodeSize,f);r.addMark(a,c,s.create(g(g({},n.attrs),t)))}}))}),c&&(void 0!==n&&o&&r.setNodeMarkup(n,void 0,g(g({},c.attrs),t)),s&&c.marks.length&&c.marks.forEach(function(e){s===e.type&&o&&r.addMark(l,d,s.create(g(g({},e.attrs),t)))}))}),u}},ih=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.state,i=n.dispatch;return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return function(n,r){var i=n.selection,o=i.$from,a=i.$to,s=o.blockRange(a),c=s&&vo(s,e,t);return!!c&&(r&&r(n.tr.wrap(s,c).scrollIntoView()),!0)}}(ll(e,r.schema),t)(r,i)}},oh=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.state,i=n.dispatch;return ba(ll(e,r.schema),t)(r,i)}},ah=function(){return S(function e(){x(this,e),this.callbacks={}},[{key:"on",value:function(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}},{key:"emit",value:function(e){for(var t=this,n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];var o=this.callbacks[e];return o&&o.forEach(function(e){return e.apply(t,r)}),this}},{key:"off",value:function(e,t){var n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(function(e){return e!==t}):delete this.callbacks[e]),this}},{key:"once",value:function(e,t){var n=this,r=function(){n.off(e,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];t.apply(n,o)};return this.on(e,r)}},{key:"removeAllListeners",value:function(){this.callbacks={}}}])}(),sh=S(function e(t){var n;x(this,e),this.find=t.find,this.handler=t.handler,this.undoable=null==(n=t.undoable)||n});function ch(e){var t,n=e.editor,r=e.from,i=e.to,o=e.text,a=e.rules,s=e.plugin,c=n.view;if(c.composing)return!1;var u=c.state.doc.resolve(r);if(u.parent.type.spec.code||(null==(t=u.nodeBefore||u.nodeAfter)?void 0:t.marks.find(function(e){return e.type.spec.code})))return!1;var l=!1,d=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,n="",r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,function(e,t,i,o){var a,s,c=(null==(s=(a=e.type.spec).toText)?void 0:s.call(a,{node:e,pos:t,parent:i,index:o}))||e.textContent||"%leaf%";n+=e.isAtom&&!e.isText?c:c.slice(0,Math.max(0,r-t))}),n}(u)+o;return a.forEach(function(e){if(!l){var t=function(e,t){if(ml(t))return t.exec(e);var n=t(e);if(!n)return null;var r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r}(d,e.find);if(t){var a=c.state.tr,u=el({state:c.state,transaction:a}),h={from:r-(t[0].length-o.length),to:i},f=new tl({editor:n,state:u}),p=f.commands,v=f.chain,m=f.can;null!==e.handler({state:u,range:h,match:t,commands:p,chain:v,can:m})&&a.steps.length&&(e.undoable&&a.setMeta(s,{transform:a,from:r,to:i,text:o}),c.dispatch(a),l=!0)}}}),l}function uh(e){return"Object"===function(e){return Object.prototype.toString.call(e).slice(8,-1)}(e)&&(e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype)}function lh(e,t){var n=g({},e);return uh(e)&&uh(t)&&Object.keys(t).forEach(function(r){uh(t[r])&&uh(e[r])?n[r]=lh(e[r],t[r]):n[r]=t[r]}),n}var dh=function(){return S(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};x(this,e),this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config=g(g({},this.config),t),this.name=this.config.name},[{key:"options",get:function(){return g({},pd(ld(this,"addOptions",{name:this.name}))||{})}},{key:"storage",get:function(){return g({},pd(ld(this,"addStorage",{name:this.name,options:this.options}))||{})}},{key:"configure",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=this.extend(g(g({},this.config),{},{addOptions:function(){return lh(e.options,t)}}));return n.name=this.name,n.parent=this.parent,n}},{key:"extend",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=new this.constructor(g(g({},this.config),e));return t.parent=this,this.child=t,t.name="name"in e?e.name:t.parent.name,t}}])}(),hh=function(t){function n(){var e;return x(this,n),(e=r(this,n,arguments)).type="mark",e}return a(n,t),S(n,[{key:"configure",value:function(t){return e(n,"configure",this,3)([t])}},{key:"extend",value:function(t){var r="function"==typeof t?t():t;return e(n,"extend",this,3)([r])}}],[{key:"create",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new n("function"==typeof e?e():e)}},{key:"handleExit",value:function(e){var t=e.editor,n=e.mark,r=t.state.tr,i=t.state.selection.$from;if(i.pos===i.end()){var o=i.marks(),a=!!o.find(function(e){return(null==e?void 0:e.type.name)===n.name});if(!a)return!1;var s=o.find(function(e){return(null==e?void 0:e.type.name)===n.name});return s&&r.removeStoredMark(s),r.insertText(" ",i.pos),t.view.dispatch(r),!0}return!1}}])}(dh);function fh(e){var t=e.editor,n=e.state,r=e.from,i=e.to,o=e.rule,a=e.pasteEvent,s=e.dropEvent,u=new tl({editor:t,state:n}),l=u.commands,d=u.chain,h=u.can,f=[];return n.doc.nodesBetween(r,i,function(e,t){var u,p,v,m,g;if(!(null==(p=null==(u=e.type)?void 0:u.spec)?void 0:p.code)&&(e.isText||e.isTextblock||e.isInline)){var y=null!=(g=null!=(m=null==(v=e.content)?void 0:v.size)?m:e.nodeSize)?g:0,k=Math.max(r,t),w=Math.min(i,t+y);if(!(k>=w))(function(e,t,n){if(ml(t))return c(e.matchAll(t));var r=t(e,n);return r?r.map(function(t){var n=[t.text];return n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),n.push(t.replaceWith)),n}):[]})(e.isText?e.text||"":e.textBetween(k-t,w-t,void 0,""),o.find,a).forEach(function(e){if(void 0!==e.index){var t=k+e.index+1,r=t+e[0].length,i={from:n.tr.mapping.map(t),to:n.tr.mapping.map(r)},c=o.handler({state:n,range:i,match:e,commands:l,chain:d,can:h,pasteEvent:a,dropEvent:s});f.push(c)}})}}),f.every(function(e){return null!==e})}var ph=null;function vh(e){var t,n=e.editor,r=e.rules,i=null,o=!1,a=!1,s="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null;try{t="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch(u){t=null}var c=function(e){var r=e.state,i=e.from,o=e.to,a=e.rule,c=e.pasteEvt,u=r.tr,l=el({state:r,transaction:u});if(fh({editor:n,state:l,from:Math.max(i-1,0),to:o.b-1,rule:a,pasteEvent:c,dropEvent:t})&&u.steps.length){try{t="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch(d){t=null}return s="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null,u}};return r.map(function(e){return new oa({view:function(e){var t=function(t){var r;(i=(null==(r=e.dom.parentElement)?void 0:r.contains(t.target))?e.dom.parentElement:null)&&(ph=n)},r=function(){ph&&(ph=null)};return window.addEventListener("dragstart",t),window.addEventListener("dragend",r),{destroy:function(){window.removeEventListener("dragstart",t),window.removeEventListener("dragend",r)}}},props:{handleDOMEvents:{drop:function(e,n){if(a=i===e.dom.parentElement,t=n,!a){var r=ph;(null==r?void 0:r.isEditable)&&setTimeout(function(){var e=r.state.selection;e&&r.commands.deleteRange({from:e.from,to:e.to})},10)}return!1},paste:function(e,t){var n,r=null==(n=t.clipboardData)?void 0:n.getData("text/html");return s=t,o=!!(null==r?void 0:r.includes("data-pm-slice")),!1}}},appendTransaction:function(t,n,r){var i=t[0],u="paste"===i.getMeta("uiEvent")&&!o,l="drop"===i.getMeta("uiEvent")&&!a,d=i.getMeta("applyPasteRules"),h=!!d;if(u||l||h){if(h){var f=d.text;"string"==typeof f||(f=hd(Fr.from(f),r.schema));var p=d.from,v=p+f.length,m=function(e){var t,n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return null==(t=n.clipboardData)||t.setData("text/html",e),n}(f);return c({rule:e,state:r,from:p,to:{b:v},pasteEvt:m})}var g=n.doc.content.findDiffStart(r.doc.content),y=n.doc.content.findDiffEnd(r.doc.content);if("number"==typeof g&&y&&g!==y.b)return c({rule:e,state:r,from:g,to:y,pasteEvt:s})}}})})}var mh=function(){return S(function e(t,n){x(this,e),this.splittableMarks=[],this.editor=n,this.baseExtensions=t,this.extensions=Cd(t),this.schema=function(e,t){var n,r=md(e),i=vd(e),o=i.nodeExtensions,a=i.markExtensions,s=null==(n=o.find(function(e){return ld(e,"topNode")}))?void 0:n.name,c=Object.fromEntries(o.map(function(n){var i=r.filter(function(e){return e.type===n.name}),o={name:n.name,options:n.options,storage:n.storage,editor:t},a=e.reduce(function(e,t){var r=ld(t,"extendNodeSchema",o);return g(g({},e),r?r(n):{})},{}),s=wd(g(g({},a),{},{content:pd(ld(n,"content",o)),marks:pd(ld(n,"marks",o)),group:pd(ld(n,"group",o)),inline:pd(ld(n,"inline",o)),atom:pd(ld(n,"atom",o)),selectable:pd(ld(n,"selectable",o)),draggable:pd(ld(n,"draggable",o)),code:pd(ld(n,"code",o)),whitespace:pd(ld(n,"whitespace",o)),linebreakReplacement:pd(ld(n,"linebreakReplacement",o)),defining:pd(ld(n,"defining",o)),isolating:pd(ld(n,"isolating",o)),attrs:Object.fromEntries(i.map(bd))})),c=pd(ld(n,"parseHTML",o));c&&(s.parseDOM=c.map(function(e){return kd(e,i)}));var u=ld(n,"renderHTML",o);u&&(s.toDOM=function(e){return u({node:e,HTMLAttributes:yd(e,i)})});var l=ld(n,"renderText",o);return l&&(s.toText=l),[n.name,s]})),u=Object.fromEntries(a.map(function(n){var i=r.filter(function(e){return e.type===n.name}),o={name:n.name,options:n.options,storage:n.storage,editor:t},a=e.reduce(function(e,t){var r=ld(t,"extendMarkSchema",o);return g(g({},e),r?r(n):{})},{}),s=wd(g(g({},a),{},{inclusive:pd(ld(n,"inclusive",o)),excludes:pd(ld(n,"excludes",o)),group:pd(ld(n,"group",o)),spanning:pd(ld(n,"spanning",o)),code:pd(ld(n,"code",o)),attrs:Object.fromEntries(i.map(bd))})),c=pd(ld(n,"parseHTML",o));c&&(s.parseDOM=c.map(function(e){return kd(e,i)}));var u=ld(n,"renderHTML",o);return u&&(s.toDOM=function(e){return u({mark:e,HTMLAttributes:yd(e,i)})}),[n.name,s]}));return new Ei({topNode:s,nodes:c,marks:u})}(this.extensions,n),this.setupExtensions()},[{key:"commands",get:function(){var e=this;return this.extensions.reduce(function(t,n){var r=ld(n,"addCommands",{name:n.name,options:n.options,storage:e.editor.extensionStorage[n.name],editor:e.editor,type:Od(n.name,e.schema)});return r?g(g({},t),r()):t},{})}},{key:"plugins",get:function(){var e=this,t=this.editor;return xd(c(this.extensions).reverse()).flatMap(function(n){var r={name:n.name,options:n.options,storage:e.editor.extensionStorage[n.name],editor:t,type:Od(n.name,e.schema)},i=[],o=ld(n,"addKeyboardShortcuts",r),a={};if("mark"===n.type&&ld(n,"exitable",r)&&(a.ArrowRight=function(){return hh.handleExit({editor:t,mark:n})}),o){var s=Object.fromEntries(Object.entries(o()).map(function(e){var n=d(e,2),r=n[0],i=n[1];return[r,function(){return i({editor:t})}]}));a=g(g({},a),s)}var u=function(e){return new oa({props:{handleKeyDown:Xu(e)}})}(a);i.push(u);var l=ld(n,"addInputRules",r);if(Ad(n,t.options.enableInputRules)&&l){var h=l();if(h&&h.length){var f=function(e){var t=e.editor,n=e.rules,r=new oa({state:{init:function(){return null},apply:function(e,i,o){var a=e.getMeta(r);if(a)return a;var s=e.getMeta("applyInputRules");return!!s&&setTimeout(function(){var e=s.text;"string"==typeof e||(e=hd(Fr.from(e),o.schema));var i=s.from,a=i+e.length;ch({editor:t,from:i,to:a,text:e,rules:n,plugin:r})}),e.selectionSet||e.docChanged?null:i}},props:{handleTextInput:function(e,i,o,a){return ch({editor:t,from:i,to:o,text:a,rules:n,plugin:r})},handleDOMEvents:{compositionend:function(e){return setTimeout(function(){var i=e.state.selection.$cursor;i&&ch({editor:t,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1}},handleKeyDown:function(e,i){if("Enter"!==i.key)return!1;var o=e.state.selection.$cursor;return!!o&&ch({editor:t,from:o.pos,to:o.pos,text:"\n",rules:n,plugin:r})}},isInputRules:!0});return r}({editor:t,rules:h}),p=Array.isArray(f)?f:[f];i.push.apply(i,c(p))}}var v=ld(n,"addPasteRules",r);if(Ad(n,t.options.enablePasteRules)&&v){var m=v();if(m&&m.length){var y=vh({editor:t,rules:m});i.push.apply(i,c(y))}}var k=ld(n,"addProseMirrorPlugins",r);if(k){var w=k();i.push.apply(i,c(w))}return i})}},{key:"attributes",get:function(){return md(this.extensions)}},{key:"nodeViews",get:function(){var e=this,t=this.editor,n=vd(this.extensions).nodeExtensions;return Object.fromEntries(n.filter(function(e){return!!ld(e,"addNodeView")}).map(function(n){var r=e.attributes.filter(function(e){return e.type===n.name}),i={name:n.name,options:n.options,storage:e.editor.extensionStorage[n.name],editor:t,type:ll(n.name,e.schema)},o=ld(n,"addNodeView",i);if(!o)return[];var a=o();if(!a)return[];return[n.name,function(e,i,o,s,c){var u=yd(e,r);return a({node:e,view:i,getPos:o,decorations:s,innerDecorations:c,editor:t,extension:n,HTMLAttributes:u})}]}))}},{key:"markViews",get:function(){var e=this,t=this.editor,n=vd(this.extensions).markExtensions;return Object.fromEntries(n.filter(function(e){return!!ld(e,"addMarkView")}).map(function(n){var r=e.attributes.filter(function(e){return e.type===n.name}),i={name:n.name,options:n.options,storage:e.editor.extensionStorage[n.name],editor:t,type:bl(n.name,e.schema)},o=ld(n,"addMarkView",i);if(!o)return[];return[n.name,function(e,i,a){var s=yd(e,r);return o()({mark:e,view:i,inline:a,editor:t,extension:n,HTMLAttributes:s,updateAttributes:function(n){!function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=t.state,i=r.doc,o=r.tr,a=e;i.descendants(function(t,r){var i=o.mapping.map(r),s=o.mapping.map(r)+t.nodeSize,c=null;if(t.marks.forEach(function(e){if(e!==a)return!1;c=e}),c){var u=!1;if(Object.keys(n).forEach(function(e){n[e]!==c.attrs[e]&&(u=!0)}),u){var l=e.type.create(g(g({},e.attrs),n));o.removeMark(i,s,e.type),o.addMark(i,s,l)}}}),o.docChanged&&t.view.dispatch(o)}(e,t,n)}})}]}))}},{key:"setupExtensions",value:function(){var e=this,t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(function(e){return[e.name,e.storage]})),t.forEach(function(t){var n,r={name:t.name,options:t.options,storage:e.editor.extensionStorage[t.name],editor:e.editor,type:Od(t.name,e.schema)};"mark"===t.type&&((null==(n=pd(ld(t,"keepOnSplit",r)))||n)&&e.splittableMarks.push(t.name));var i=ld(t,"onBeforeCreate",r),o=ld(t,"onCreate",r),a=ld(t,"onUpdate",r),s=ld(t,"onSelectionUpdate",r),c=ld(t,"onTransaction",r),u=ld(t,"onFocus",r),l=ld(t,"onBlur",r),d=ld(t,"onDestroy",r);i&&e.editor.on("beforeCreate",i),o&&e.editor.on("create",o),a&&e.editor.on("update",a),s&&e.editor.on("selectionUpdate",s),c&&e.editor.on("transaction",c),u&&e.editor.on("focus",u),l&&e.editor.on("blur",l),d&&e.editor.on("destroy",d)})}}])}();mh.resolve=Cd,mh.sort=xd,mh.flatten=dd;Qu({},{ClipboardTextSerializer:function(){return yh},Commands:function(){return kh},Delete:function(){return wh},Drop:function(){return bh},Editable:function(){return xh},FocusEvents:function(){return Sh},Keymap:function(){return _h},Paste:function(){return Mh},Tabindex:function(){return Th},TextDirection:function(){return Oh},focusEventsPluginKey:function(){return Ch}});var gh=function(t){function n(){var e;return x(this,n),(e=r(this,n,arguments)).type="extension",e}return a(n,t),S(n,[{key:"configure",value:function(t){return e(n,"configure",this,3)([t])}},{key:"extend",value:function(t){var r="function"==typeof t?t():t;return e(n,"extend",this,3)([r])}}],[{key:"create",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new n("function"==typeof e?e():e)}}])}(dh),yh=gh.create({name:"clipboardTextSerializer",addOptions:function(){return{blockSeparator:void 0}},addProseMirrorPlugins:function(){var e=this;return[new oa({key:new ca("clipboardTextSerializer"),props:{clipboardTextSerializer:function(){var t=e.editor,n=t.state,r=t.schema,i=n.doc,o=n.selection.ranges,a=Math.min.apply(Math,c(o.map(function(e){return e.$from.pos}))),s=Math.max.apply(Math,c(o.map(function(e){return e.$to.pos}))),u=_d(r);return Sd(i,{from:a,to:s},g(g({},void 0!==e.options.blockSeparator?{blockSeparator:e.options.blockSeparator}:{}),{},{textSerializers:u}))}}})]}}),kh=gh.create({name:"commands",addCommands:function(){return g({},nl)}}),wh=gh.create({name:"delete",onUpdate:function(e){var t,n,r,i=this,o=e.transaction,a=e.appendedTransactions,s=function(){var e,t,n,r;if(!(null!=(r=null==(n=null==(t=null==(e=i.editor.options.coreExtensionOptions)?void 0:e.delete)?void 0:t.filterTransaction)?void 0:n.call(t,o))?r:o.getMeta("y-sync$"))){var s,u,l,d=(s=o.before,u=[o].concat(c(a)),l=new Bo(s),u.forEach(function(e){e.steps.forEach(function(e){l.step(e)})}),l),h=function(e){var t=e.mapping,n=e.steps,r=[];return t.maps.forEach(function(e,i){var o=[];if(e.ranges.length)e.forEach(function(e,t){o.push({from:e,to:t})});else{var a=n[i],s=a.from,c=a.to;if(void 0===s||void 0===c)return;o.push({from:s,to:c})}o.forEach(function(e){var n=e.from,o=e.to,a=t.slice(i).map(n,-1),s=t.slice(i).map(o),c=t.invert().map(a,-1),u=t.invert().map(s);r.push({oldRange:{from:c,to:u},newRange:{from:a,to:s}})})}),Td(r)}(d);h.forEach(function(e){d.mapping.mapResult(e.oldRange.from).deletedAfter&&d.mapping.mapResult(e.oldRange.to).deletedBefore&&d.before.nodesBetween(e.oldRange.from,e.oldRange.to,function(t,n){var r=n+t.nodeSize-2,a=e.oldRange.from<=n&&r<=e.oldRange.to;i.editor.emit("delete",{type:"node",node:t,from:n,to:r,newFrom:d.mapping.map(n),newTo:d.mapping.map(r),deletedRange:e.oldRange,newRange:e.newRange,partial:!a,editor:i.editor,transaction:o,combinedTransform:d})})});var f=d.mapping;d.steps.forEach(function(e,t){var n,r;if(e instanceof oo){var a=f.slice(t).map(e.from,-1),s=f.slice(t).map(e.to),c=f.invert().map(a,-1),u=f.invert().map(s),l=null==(n=d.doc.nodeAt(a-1))?void 0:n.marks.some(function(t){return t.eq(e.mark)}),h=null==(r=d.doc.nodeAt(s))?void 0:r.marks.some(function(t){return t.eq(e.mark)});i.editor.emit("delete",{type:"mark",mark:e.mark,from:e.from,to:e.to,deletedRange:{from:c,to:u},newRange:{from:a,to:s},partial:Boolean(h||l),editor:i.editor,transaction:o,combinedTransform:d})}})}};null==(r=null==(n=null==(t=this.editor.options.coreExtensionOptions)?void 0:t.delete)?void 0:n.async)||r?setTimeout(s,0):s()}}),bh=gh.create({name:"drop",addProseMirrorPlugins:function(){var e=this;return[new oa({key:new ca("tiptapDrop"),props:{handleDrop:function(t,n,r,i){e.editor.emit("drop",{editor:e.editor,event:n,slice:r,moved:i})}}})]}}),xh=gh.create({name:"editable",addProseMirrorPlugins:function(){var e=this;return[new oa({key:new ca("editable"),props:{editable:function(){return e.editor.options.editable}}})]}}),Ch=new ca("focusEvents"),Sh=gh.create({name:"focusEvents",addProseMirrorPlugins:function(){var e=this.editor;return[new oa({key:Ch,props:{handleDOMEvents:{focus:function(t,n){e.isFocused=!0;var r=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1},blur:function(t,n){e.isFocused=!1;var r=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1}}}})]}}),_h=gh.create({name:"keymap",addKeyboardShortcuts:function(){var e=this,t=function(){return e.editor.commands.first(function(e){var t=e.commands;return[function(){return t.undoInputRule()},function(){return t.command(function(e){var n=e.tr,r=n.selection,i=n.doc,o=r.empty,a=r.$anchor,s=a.pos,c=a.parent,u=a.parent.isTextblock&&s>0?n.doc.resolve(s-1):a,l=u.parent.type.spec.isolating,d=a.pos-a.parentOffset,h=l&&1===u.parent.childCount?d===a.pos:Fo.atStart(i).from===s;return!(!o||!c.type.isTextblock||c.textContent.length||!h||h&&"paragraph"===a.parent.type.name)&&t.clearNodes()})},function(){return t.deleteSelection()},function(){return t.joinBackward()},function(){return t.selectNodeBackward()}]})},n=function(){return e.editor.commands.first(function(e){var t=e.commands;return[function(){return t.deleteSelection()},function(){return t.deleteCurrentNode()},function(){return t.joinForward()},function(){return t.selectNodeForward()}]})},r={Enter:function(){return e.editor.commands.first(function(e){var t=e.commands;return[function(){return t.newlineInCode()},function(){return t.createParagraphNear()},function(){return t.liftEmptyBlock()},function(){return t.splitBlock()}]})},"Mod-Enter":function(){return e.editor.commands.exitCode()},Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:n,"Mod-Delete":n,"Mod-a":function(){return e.editor.commands.selectAll()}},i=g({},r),o=g(g({},r),{},{"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":n,"Ctrl-Alt-Backspace":n,"Alt-Delete":n,"Alt-d":n,"Ctrl-a":function(){return e.editor.commands.selectTextblockStart()},"Ctrl-e":function(){return e.editor.commands.selectTextblockEnd()}});return Tl()||Hl()?o:i},addProseMirrorPlugins:function(){var e=this;return[new oa({key:new ca("clearDocument"),appendTransaction:function(t,n,r){if(!t.some(function(e){return e.getMeta("composition")})){var i=t.some(function(e){return e.docChanged})&&!n.doc.eq(r.doc),o=t.some(function(e){return e.getMeta("preventClearDocument")});if(i&&!o){var a=n.selection,s=a.empty,c=a.from,u=a.to,l=Fo.atStart(n.doc).from,d=Fo.atEnd(n.doc).to;if(!s&&(c===l&&u===d))if(Id(r.doc)){var h=r.tr,f=el({state:r,transaction:h});if(new tl({editor:e.editor,state:f}).commands.clearNodes(),h.steps.length)return h}}}}})]}}),Mh=gh.create({name:"paste",addProseMirrorPlugins:function(){var e=this;return[new oa({key:new ca("tiptapPaste"),props:{handlePaste:function(t,n,r){e.editor.emit("paste",{editor:e.editor,event:n,slice:r})}}})]}}),Th=gh.create({name:"tabindex",addProseMirrorPlugins:function(){var e=this;return[new oa({key:new ca("tabindex"),props:{attributes:function(){return e.editor.isEditable?{tabindex:"0"}:{}}}})]}}),Oh=gh.create({name:"textDirection",addOptions:function(){return{direction:void 0}},addGlobalAttributes:function(){var e=this;return this.options.direction?[{types:vd(this.extensions).nodeExtensions.filter(function(e){return"text"!==e.name}).map(function(e){return e.name}),attributes:{dir:{default:this.options.direction,parseHTML:function(t){var n=t.getAttribute("dir");return!n||"ltr"!==n&&"rtl"!==n&&"auto"!==n?e.options.direction:n},renderHTML:function(e){return e.dir?{dir:e.dir}:{}}}}}]:[]},addProseMirrorPlugins:function(){var e=this;return[new oa({key:new ca("textDirection"),props:{attributes:function(){var t=e.options.direction;return t?{dir:t}:{}}}})]}}),Nh=function(){function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;x(this,e),this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=t,this.editor=n,this.currentNode=i}return S(e,[{key:"name",get:function(){return this.node.type.name}},{key:"node",get:function(){return this.currentNode||this.resolvedPos.node()}},{key:"element",get:function(){return this.editor.view.domAtPos(this.pos).node}},{key:"depth",get:function(){var e;return null!=(e=this.actualDepth)?e:this.resolvedPos.depth}},{key:"pos",get:function(){return this.resolvedPos.pos}},{key:"content",get:function(){return this.node.content},set:function(e){var t=this.from,n=this.to;if(this.isBlock){if(0===this.content.size)return void console.error("You can’t set content on a block node. Tried to set content on ".concat(this.name," at ").concat(this.pos));t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},e)}},{key:"attributes",get:function(){return this.node.attrs}},{key:"textContent",get:function(){return this.node.textContent}},{key:"size",get:function(){return this.node.nodeSize}},{key:"from",get:function(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}},{key:"range",get:function(){return{from:this.from,to:this.to}}},{key:"to",get:function(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}},{key:"parent",get:function(){if(0===this.depth)return null;var t=this.resolvedPos.start(this.resolvedPos.depth-1);return new e(this.resolvedPos.doc.resolve(t),this.editor)}},{key:"before",get:function(){var t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new e(t,this.editor)}},{key:"after",get:function(){var t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new e(t,this.editor)}},{key:"children",get:function(){var t=this,n=[];return this.node.content.forEach(function(r,i){var o=r.isBlock&&!r.isTextblock,a=r.isAtom&&!r.isText,s=t.pos+i+(a?0:1);if(!(s<0||s>t.resolvedPos.doc.nodeSize-2)){var c=t.resolvedPos.doc.resolve(s);if(o||!(c.depth<=t.depth)){var u=new e(c,t.editor,o,o?r:null);o&&(u.actualDepth=t.depth+1),n.push(new e(c,t.editor,o,o?r:null))}}}),n}},{key:"firstChild",get:function(){return this.children[0]||null}},{key:"lastChild",get:function(){var e=this.children;return e[e.length-1]||null}},{key:"closest",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,r=this.parent;r&&!n;){if(r.node.type.name===e)if(Object.keys(t).length>0)for(var i=r.node.attrs,o=Object.keys(t),a=0;a<o.length;a+=1){var s=o[a];if(i[s]!==t[s])break}else n=r;r=r.parent}return n}},{key:"querySelector",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.querySelectorAll(e,t,!0)[0]||null}},{key:"querySelectorAll",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=[];if(!this.children||0===this.children.length)return r;var i=Object.keys(t);return this.children.forEach(function(o){if(!(n&&r.length>0)){if(o.node.type.name===e)i.every(function(e){return t[e]===o.node.attrs[e]})&&r.push(o);n&&r.length>0||(r=r.concat(o.querySelectorAll(e,t,n)))}}),r}},{key:"setAttribute",value:function(e){var t=this.editor.state.tr;t.setNodeMarkup(this.from,void 0,g(g({},this.node.attrs),e)),this.editor.view.dispatch(t)}}])}();var Eh=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};x(this,t),(e=r(this,t)).css=null,e.className="tiptap",e.editorView=null,e.isFocused=!1,e.isInitialized=!1,e.extensionStorage={},e.instanceId=Math.random().toString(36).slice(2,9),e.options={element:"undefined"!=typeof document?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:function(){return null},onCreate:function(){return null},onMount:function(){return null},onUnmount:function(){return null},onUpdate:function(){return null},onSelectionUpdate:function(){return null},onTransaction:function(){return null},onFocus:function(){return null},onBlur:function(){return null},onDestroy:function(){return null},onContentError:function(e){throw e.error},onPaste:function(){return null},onDrop:function(){return null},onDelete:function(){return null}},e.isCapturingTransaction=!1,e.capturedTransaction=null,e.utils={getUpdatedPosition:Rd,createMappablePosition:Pd},e.setOptions(n),e.createExtensionManager(),e.createCommandManager(),e.createSchema(),e.on("beforeCreate",e.options.onBeforeCreate),e.emit("beforeCreate",{editor:e}),e.on("mount",e.options.onMount),e.on("unmount",e.options.onUnmount),e.on("contentError",e.options.onContentError),e.on("create",e.options.onCreate),e.on("update",e.options.onUpdate),e.on("selectionUpdate",e.options.onSelectionUpdate),e.on("transaction",e.options.onTransaction),e.on("focus",e.options.onFocus),e.on("blur",e.options.onBlur),e.on("destroy",e.options.onDestroy),e.on("drop",function(t){var n=t.event,r=t.slice,i=t.moved;return e.options.onDrop(n,r,i)}),e.on("paste",function(t){var n=t.event,r=t.slice;return e.options.onPaste(n,r)}),e.on("delete",e.options.onDelete);var i=e.createDoc(),o=Ml(i,e.options.autofocus);return e.editorState=ra.create({doc:i,schema:e.schema,selection:o||void 0}),e.options.element&&e.mount(e.options.element),e}return a(t,e),S(t,[{key:"mount",value:function(e){var t=this;if("undefined"==typeof document)throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(e),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(function(){t.isDestroyed||(!1!==t.options.autofocus&&null!==t.options.autofocus&&t.commands.focus(t.options.autofocus),t.emit("create",{editor:t}),t.isInitialized=!0)},0)}},{key:"unmount",value:function(){if(this.editorView){var e=this.editorView.dom;(null==e?void 0:e.editor)&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(".".concat(this.className)).length)try{"function"==typeof this.css.remove?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}},{key:"storage",get:function(){return this.extensionStorage}},{key:"commands",get:function(){return this.commandManager.commands}},{key:"chain",value:function(){return this.commandManager.chain()}},{key:"can",value:function(){return this.commandManager.can()}},{key:"injectCSS",value:function(){this.options.injectCSS&&"undefined"!=typeof document&&(this.css=function(e,t,n){var r=document.querySelector("style[data-tiptap-style".concat(n?"-".concat(n):"","]"));if(null!==r)return r;var i=document.createElement("style");return t&&i.setAttribute("nonce",t),i.setAttribute("data-tiptap-style".concat(n?"-".concat(n):""),""),i.innerHTML=e,document.getElementsByTagName("head")[0].appendChild(i),i}('.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: "liga" 0; /* the above doesn\'t seem to work in Edge */\n}\n\n.ProseMirror [contenteditable="false"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable="false"] [contenteditable="true"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 0 !important;\n height: 0 !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\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}',this.options.injectNonce))}},{key:"setOptions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.options=g(g({},this.options),e),this.editorView&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}},{key:"setEditable",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}},{key:"isEditable",get:function(){return this.options.editable&&this.view&&this.view.editable}},{key:"view",get:function(){var e=this;return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:function(t){e.editorState=t},dispatch:function(t){e.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:function(t,n){if(e.editorView)return e.editorView[n];if("state"===n)return e.editorState;if(n in t)return Reflect.get(t,n);throw new Error("[tiptap error]: The editor view is not available. Cannot access view['".concat(n,"']. The editor may not be mounted yet."))}})}},{key:"state",get:function(){return this.editorView&&(this.editorState=this.view.state),this.editorState}},{key:"registerPlugin",value:function(e,t){var n=fd(t)?t(e,c(this.state.plugins)):[].concat(c(this.state.plugins),[e]),r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}},{key:"unregisterPlugin",value:function(e){if(!this.isDestroyed){var t=this.state.plugins,n=t;if([].concat(e).forEach(function(e){var t="string"==typeof e?"".concat(e,"$"):e.key;n=n.filter(function(e){return!e.key.startsWith(t)})}),t.length!==n.length){var r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}}}},{key:"createExtensionManager",value:function(){var e,t,n=this,r=this.options.enableCoreExtensions?[xh,yh.configure({blockSeparator:null==(t=null==(e=this.options.coreExtensionOptions)?void 0:e.clipboardTextSerializer)?void 0:t.blockSeparator}),kh,Sh,_h,Th,bh,Mh,wh,Oh.configure({direction:this.options.textDirection})].filter(function(e){return"object"!==T(n.options.enableCoreExtensions)||!1!==n.options.enableCoreExtensions[e.name]}):[],i=[].concat(c(r),c(this.options.extensions)).filter(function(e){return["extension","node","mark"].includes(null==e?void 0:e.type)});this.extensionManager=new mh(i,this)}},{key:"createCommandManager",value:function(){this.commandManager=new tl({editor:this})}},{key:"createSchema",value:function(){this.schema=this.extensionManager.schema}},{key:"createDoc",value:function(){var e,t=this;try{e=ad(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(pt){if(!(pt instanceof Error&&["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(pt.message)))throw pt;this.emit("contentError",{editor:this,error:pt,disableCollaboration:function(){"collaboration"in t.storage&&"object"===T(t.storage.collaboration)&&t.storage.collaboration&&(t.storage.collaboration.isDisabled=!0),t.options.extensions=t.options.extensions.filter(function(e){return"collaboration"!==e.name}),t.createExtensionManager()}}),e=ad(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return e}},{key:"createView",value:function(e){var t;this.editorView=new Ru(e,g(g({},this.options.editorProps),{},{attributes:g({role:"textbox"},null==(t=this.options.editorProps)?void 0:t.attributes),dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews}));var n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.prependClass(),this.injectCSS(),this.view.dom.editor=this}},{key:"createNodeViews",value:function(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}},{key:"prependClass",value:function(){this.view.dom.className="".concat(this.className," ").concat(this.view.dom.className)}},{key:"captureTransaction",value:function(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;var t=this.capturedTransaction;return this.capturedTransaction=null,t}},{key:"dispatchTransaction",value:function(e){var t=this;if(!this.view.isDestroyed){if(this.isCapturingTransaction)return this.capturedTransaction?void e.steps.forEach(function(e){var n;return null==(n=t.capturedTransaction)?void 0:n.step(e)}):void(this.capturedTransaction=e);var n=this.state.applyTransaction(e),r=n.state,i=n.transactions,o=!this.state.selection.eq(r.selection),a=i.includes(e),s=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:e,nextState:r}),a){this.view.updateState(r),this.emit("transaction",{editor:this,transaction:e,appendedTransactions:i.slice(1)}),o&&this.emit("selectionUpdate",{editor:this,transaction:e});var c=i.findLast(function(e){return e.getMeta("focus")||e.getMeta("blur")}),u=null==c?void 0:c.getMeta("focus"),l=null==c?void 0:c.getMeta("blur");u&&this.emit("focus",{editor:this,event:u.event,transaction:c}),l&&this.emit("blur",{editor:this,event:l.event,transaction:c}),e.getMeta("preventUpdate")||!i.some(function(e){return e.docChanged})||s.doc.eq(r.doc)||this.emit("update",{editor:this,transaction:e,appendedTransactions:i.slice(1)})}}}},{key:"getAttributes",value:function(e){return Md(this.state,e)}},{key:"isActive",value:function(e,t){var n="string"==typeof e?e:null,r="string"==typeof e?t:e;return function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!t)return ql(e,null,n)||Ed(e,null,n);var r=Gl(t,e.schema);return"node"===r?ql(e,t,n):"mark"===r&&Ed(e,t,n)}(this.state,n,r)}},{key:"getJSON",value:function(){return this.state.doc.toJSON()}},{key:"getHTML",value:function(){return hd(this.state.doc.content,this.schema)}},{key:"getText",value:function(e){var t=e||{},n=t.blockSeparator,r=void 0===n?"\n\n":n,i=t.textSerializers,o=void 0===i?{}:i;return function(e,t){return Sd(e,{from:0,to:e.content.size},t)}(this.state.doc,{blockSeparator:r,textSerializers:g(g({},_d(this.schema)),o)})}},{key:"isEmpty",get:function(){return Id(this.state.doc)}},{key:"destroy",value:function(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}},{key:"isDestroyed",get:function(){var e,t;return null==(t=null==(e=this.editorView)?void 0:e.isDestroyed)||t}},{key:"$node",value:function(e,t){var n;return(null==(n=this.$doc)?void 0:n.querySelector(e,t))||null}},{key:"$nodes",value:function(e,t){var n;return(null==(n=this.$doc)?void 0:n.querySelectorAll(e,t))||null}},{key:"$pos",value:function(e){var t=this.state.doc.resolve(e);return new Nh(t,this)}},{key:"$doc",get:function(){return this.$pos(0)}}])}(ah);var Ah=function(){return S(function e(t){var n,r,i,o,a,s=this;x(this,e),this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.handleMouseMove=function(e){if(s.isResizing&&s.activeHandle){var t=e.clientX-s.startX,n=e.clientY-s.startY;s.handleResize(t,n)}},this.handleTouchMove=function(e){if(s.isResizing&&s.activeHandle){var t=e.touches[0];if(t){var n=t.clientX-s.startX,r=t.clientY-s.startY;s.handleResize(n,r)}}},this.handleMouseUp=function(){if(s.isResizing){var e=s.element.offsetWidth,t=s.element.offsetHeight;s.onCommit(e,t),s.isResizing=!1,s.activeHandle=null,s.container.dataset.resizeState="false",s.classNames.resizing&&s.container.classList.remove(s.classNames.resizing),document.removeEventListener("mousemove",s.handleMouseMove),document.removeEventListener("mouseup",s.handleMouseUp),document.removeEventListener("keydown",s.handleKeyDown),document.removeEventListener("keyup",s.handleKeyUp)}},this.handleKeyDown=function(e){"Shift"===e.key&&(s.isShiftKeyPressed=!0)},this.handleKeyUp=function(e){"Shift"===e.key&&(s.isShiftKeyPressed=!1)},this.node=t.node,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(null==(n=t.options)?void 0:n.min)&&(this.minSize=g(g({},this.minSize),t.options.min)),(null==(r=t.options)?void 0:r.max)&&(this.maxSize=t.options.max),(null==(i=null==t?void 0:t.options)?void 0:i.directions)&&(this.directions=t.options.directions),(null==(o=t.options)?void 0:o.preserveAspectRatio)&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(null==(a=t.options)?void 0:a.className)&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles()},[{key:"dom",get:function(){return this.container}},{key:"contentDOM",get:function(){return this.contentElement}},{key:"update",value:function(e,t,n){return e.type===this.node.type&&(this.node=e,!this.onUpdate||this.onUpdate(e,t,n))}},{key:"destroy",value:function(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.container.remove()}},{key:"createContainer",value:function(){var e=document.createElement("div");return e.dataset.resizeContainer="",e.dataset.node=this.node.type.name,e.style.display="flex",e.style.justifyContent="flex-start",e.style.alignItems="flex-start",this.classNames.container&&(e.className=this.classNames.container),e.appendChild(this.wrapper),e}},{key:"createWrapper",value:function(){var e=document.createElement("div");return e.style.position="relative",e.style.display="block",e.dataset.resizeWrapper="",this.classNames.wrapper&&(e.className=this.classNames.wrapper),e.appendChild(this.element),e}},{key:"createHandle",value:function(e){var t=document.createElement("div");return t.dataset.resizeHandle=e,t.style.position="absolute",this.classNames.handle&&(t.className=this.classNames.handle),t}},{key:"positionHandle",value:function(e,t){var n=t.includes("top"),r=t.includes("bottom"),i=t.includes("left"),o=t.includes("right");n&&(e.style.top="0"),r&&(e.style.bottom="0"),i&&(e.style.left="0"),o&&(e.style.right="0"),"top"!==t&&"bottom"!==t||(e.style.left="0",e.style.right="0"),"left"!==t&&"right"!==t||(e.style.top="0",e.style.bottom="0")}},{key:"attachHandles",value:function(){var e=this;this.directions.forEach(function(t){var n=e.createHandle(t);e.positionHandle(n,t),n.addEventListener("mousedown",function(n){return e.handleResizeStart(n,t)}),n.addEventListener("touchstart",function(n){return e.handleResizeStart(n,t)}),e.wrapper.appendChild(n)})}},{key:"applyInitialSize",value:function(){var e=this.node.attrs.width,t=this.node.attrs.height;e?(this.element.style.width="".concat(e,"px"),this.initialWidth=e):this.initialWidth=this.element.offsetWidth,t?(this.element.style.height="".concat(t,"px"),this.initialHeight=t):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}},{key:"handleResizeStart",value:function(e,t){e.preventDefault(),e.stopPropagation(),this.isResizing=!0,this.activeHandle=t,!function(e){return"touches"in e}(e)?(this.startX=e.clientX,this.startY=e.clientY):(this.startX=e.touches[0].clientX,this.startY=e.touches[0].clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}},{key:"handleResize",value:function(e,t){if(this.activeHandle){var n=this.preserveAspectRatio||this.isShiftKeyPressed,r=this.calculateNewDimensions(this.activeHandle,e,t),i=r.width,o=r.height,a=this.applyConstraints(i,o,n);this.element.style.width="".concat(a.width,"px"),this.element.style.height="".concat(a.height,"px"),this.onResize&&this.onResize(a.width,a.height)}}},{key:"calculateNewDimensions",value:function(e,t,n){var r=this.startWidth,i=this.startHeight,o=e.includes("right"),a=e.includes("left"),s=e.includes("bottom"),c=e.includes("top");return o?r=this.startWidth+t:a&&(r=this.startWidth-t),s?i=this.startHeight+n:c&&(i=this.startHeight-n),"right"!==e&&"left"!==e||(r=this.startWidth+(o?t:-t)),"top"!==e&&"bottom"!==e||(i=this.startHeight+(s?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,e):{width:r,height:i}}},{key:"applyConstraints",value:function(e,t,n){var r,i,o,a;if(!n){var s=Math.max(this.minSize.width,e),c=Math.max(this.minSize.height,t);return(null==(r=this.maxSize)?void 0:r.width)&&(s=Math.min(this.maxSize.width,s)),(null==(i=this.maxSize)?void 0:i.height)&&(c=Math.min(this.maxSize.height,c)),{width:s,height:c}}var u=e,l=t;return u<this.minSize.width&&(l=(u=this.minSize.width)/this.aspectRatio),l<this.minSize.height&&(u=(l=this.minSize.height)*this.aspectRatio),(null==(o=this.maxSize)?void 0:o.width)&&u>this.maxSize.width&&(l=(u=this.maxSize.width)/this.aspectRatio),(null==(a=this.maxSize)?void 0:a.height)&&l>this.maxSize.height&&(u=(l=this.maxSize.height)*this.aspectRatio),{width:u,height:l}}},{key:"applyAspectRatio",value:function(e,t,n){var r="top"===n||"bottom"===n;return"left"===n||"right"===n?{width:e,height:e/this.aspectRatio}:r?{width:t*this.aspectRatio,height:t}:{width:e,height:e/this.aspectRatio}}}])}();function Dh(e){if(!(null==e?void 0:e.trim()))return{};var t={},n=[],r=e.replace(/["']([^"']*)["']/g,function(e){return n.push(e),"__QUOTED_".concat(n.length-1,"__")}),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){var o=i.map(function(e){return e.trim().slice(1)});t.class=o.join(" ")}var a=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);a&&(t.id=a[1]);Array.from(r.matchAll(/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g)).forEach(function(e){var r,i=d(e,3),o=i[1],a=i[2],s=parseInt((null==(r=a.match(/__QUOTED_(\d+)__/))?void 0:r[1])||"0",10),c=n[s];c&&(t[o]=c.slice(1,-1))});var s=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();s&&s.split(/\s+/).filter(Boolean).forEach(function(e){e.match(/^[a-zA-Z][\w-]*$/)&&(t[e]=!0)});return t}function Ih(e){if(!e||0===Object.keys(e).length)return"";var t=[];e.class&&String(e.class).split(/\s+/).filter(Boolean).forEach(function(e){return t.push(".".concat(e))});return e.id&&t.push("#".concat(e.id)),Object.entries(e).forEach(function(e){var n=d(e,2),r=n[0],i=n[1];"class"!==r&&"id"!==r&&(!0===i?t.push(r):!1!==i&&null!=i&&t.push("".concat(r,'="').concat(String(i),'"')))}),t.join(" ")}function zh(e){var t=e.nodeName,n=e.name,r=e.parseAttributes,i=void 0===r?Dh:r,o=e.serializeAttributes,a=void 0===o?Ih:o,s=e.defaultAttributes,c=void 0===s?{}:s,u=e.requiredAttributes,l=void 0===u?[]:u,d=e.allowedAttributes,h=n||t;return{parseMarkdown:function(e,n){var r=g(g({},c),e.attributes);return n.createNode(t,r,[])},markdownTokenizer:{name:t,level:"block",start:function(e){var t,n=new RegExp("^:::".concat(h,"(?:\\s|$)"),"m"),r=null==(t=e.match(n))?void 0:t.index;return void 0!==r?r:-1},tokenize:function(e,n,r){var o=new RegExp("^:::".concat(h,"(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)")),a=e.match(o);if(a){var s=a[1]||"",c=i(s);if(!l.find(function(e){return!(e in c)}))return{type:t,raw:a[0],attributes:c}}}},renderMarkdown:function(e){var t=function(e){if(!d)return e;var t={};return d.forEach(function(n){n in e&&(t[n]=e[n])}),t}(e.attrs||{}),n=a(t),r=n?" {".concat(n,"}"):"";return":::".concat(h).concat(r," :::")}}}function Rh(e){var t=e.nodeName,n=e.name,r=e.getContent,i=e.parseAttributes,o=void 0===i?Dh:i,a=e.serializeAttributes,s=void 0===a?Ih:a,c=e.defaultAttributes,u=void 0===c?{}:c,l=e.content,h=void 0===l?"block":l,f=e.allowedAttributes,p=n||t;return{parseMarkdown:function(e,n){var i;if(r){var o=r(e);i="string"==typeof o?[{type:"text",text:o}]:o}else i="block"===h?n.parseChildren(e.tokens||[]):n.parseInline(e.tokens||[]);var a=g(g({},u),e.attributes);return n.createNode(t,a,i)},markdownTokenizer:{name:t,level:"block",start:function(e){var t,n=new RegExp("^:::".concat(p),"m"),r=null==(t=e.match(n))?void 0:t.index;return void 0!==r?r:-1},tokenize:function(e,n,r){var i,a=new RegExp("^:::".concat(p,"(?:\\s+\\{([^}]*)\\})?\\s*\\n")),s=e.match(a);if(s){var c=d(s,2),u=c[0],l=c[1],f=o(void 0===l?"":l),v=1,m=u.length,g="",y=/^:::([\w-]*)(\s.*)?/gm,k=e.slice(m);for(y.lastIndex=0;;){var w=y.exec(k);if(null===w)break;var b=w.index,x=w[1];if(!(null==(i=w[2])?void 0:i.endsWith(":::")))if(x)v+=1;else if(0===(v-=1)){var C=k.slice(0,b);g=C.trim();var S=e.slice(0,m+b+w[0].length),_=[];if(g)if("block"===h)for((_=r.blockTokens(C)).forEach(function(e){!e.text||e.tokens&&0!==e.tokens.length||(e.tokens=r.inlineTokens(e.text))});_.length>0;){var M=_[_.length-1];if("paragraph"!==M.type||M.text&&""!==M.text.trim())break;_.pop()}else _=r.inlineTokens(g);return{type:t,raw:S,attributes:f,content:g,tokens:_}}}}}},renderMarkdown:function(e,t){var n=function(e){if(!f)return e;var t={};return f.forEach(function(n){n in e&&(t[n]=e[n])}),t}(e.attrs||{}),r=s(n),i=r?" {".concat(r,"}"):"",o=t.renderChildren(e.content||[],"\n\n");return":::".concat(p).concat(i,"\n\n").concat(o,"\n\n:::")}}}function Ph(e){if(!e.trim())return{};for(var t={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g,r=n.exec(e);null!==r;){var i=d(r,4),o=i[1],a=i[2],s=i[3];t[o]=a||s,r=n.exec(e)}return t}function Lh(e){return Object.entries(e).filter(function(e){var t=d(e,2)[1];return null!=t}).map(function(e){var t=d(e,2),n=t[0],r=t[1];return"".concat(n,'="').concat(r,'"')}).join(" ")}function Bh(e){var t=e.nodeName,n=e.name,r=e.getContent,i=e.parseAttributes,o=void 0===i?Ph:i,a=e.serializeAttributes,s=void 0===a?Lh:a,c=e.defaultAttributes,u=void 0===c?{}:c,l=e.selfClosing,h=void 0!==l&&l,f=e.allowedAttributes,p=n||t,v=p.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:function(e,n){var i=g(g({},u),e.attributes);if(h)return n.createNode(t,i);var o=r?r(e):e.content||"";return o?n.createNode(t,i,[n.createTextNode(o)]):n.createNode(t,i,[])},markdownTokenizer:{name:t,level:"inline",start:function(e){var t=h?new RegExp("\\[".concat(v,"\\s*[^\\]]*\\]")):new RegExp("\\[".concat(v,"\\s*[^\\]]*\\][\\s\\S]*?\\[\\/").concat(v,"\\]")),n=e.match(t),r=null==n?void 0:n.index;return void 0!==r?r:-1},tokenize:function(e,n,r){var i=h?new RegExp("^\\[".concat(v,"\\s*([^\\]]*)\\]")):new RegExp("^\\[".concat(v,"\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/").concat(v,"\\]")),a=e.match(i);if(a){var s="",c="";if(h){c=d(a,2)[1]}else{var u=d(a,3);c=u[1],s=u[2]||""}var l=o(c.trim());return{type:t,raw:a[0],content:s.trim(),attributes:l}}}},renderMarkdown:function(e){var t="";r?t=r(e):e.content&&e.content.length>0&&(t=e.content.filter(function(e){return"text"===e.type}).map(function(e){return e.text}).join(""));var n=function(e){if(!f)return e;var t={};return f.forEach(function(n){n in e&&(t[n]=e[n])}),t}(e.attrs||{}),i=s(n),o=i?" ".concat(i):"";return h?"[".concat(p).concat(o,"]"):"[".concat(p).concat(o,"]").concat(t,"[/").concat(p,"]")}}}function Vh(e,t,n){for(var r,i,o,a,s,c=e.split("\n"),u=[],l="",d=0,h=t.baseIndentSize||2,f=function(){var e=c[d],s=e.match(t.itemPattern);if(!s)return u.length>0?0:""===e.trim()?(d+=1,l="".concat(l).concat(e,"\n"),1):{v:void 0};var f=t.extractItemData(s),p=f.indentLevel,v=f.mainContent;l="".concat(l).concat(e,"\n");var m,g=[v];for(d+=1;d<c.length;){var y=c[d];if(""===y.trim()){var k=c.slice(d+1).findIndex(function(e){return""!==e.trim()});if(-1===k)break;var w=c[d+1+k];if(((null==(i=null==(r=w.match(/^(\s*)/))?void 0:r[1])?void 0:i.length)||0)>p){g.push(y),l="".concat(l).concat(y,"\n"),d+=1;continue}break}if(!(((null==(a=null==(o=y.match(/^(\s*)/))?void 0:o[1])?void 0:a.length)||0)>p))break;g.push(y),l="".concat(l).concat(y,"\n"),d+=1}var b=g.slice(1);if(b.length>0){var x=b.map(function(e){return e.slice(p+h)}).join("\n");x.trim()&&(m=t.customNestedParser?t.customNestedParser(x):n.blockTokens(x))}var C=t.createToken(f,m);u.push(C)};d<c.length&&0!==(s=f());)if(1!==s&&s)return s.v;if(0!==u.length)return{items:u,raw:l}}function Fh(e,t,n,r){if(!e||!Array.isArray(e.content))return"";var i="function"==typeof n?n(r):n,o=function(e){return v(e)||u(e)||f(e)||h()}(e.content),a=o[0],s=o.slice(1),c=t.renderChildren([a]),l=["".concat(i).concat(c)];return s&&s.length>0&&s.forEach(function(e){var n=t.renderChildren([e]);if(n){var r=n.split("\n").map(function(e){return e?t.indent(e):""}).join("\n");l.push(r)}}),l.join("\n")}Qu({},{createAtomBlockMarkdownSpec:function(){return zh},createBlockMarkdownSpec:function(){return Rh},createInlineMarkdownSpec:function(){return Bh},parseAttributes:function(){return Dh},parseIndentedBlocks:function(){return Vh},renderNestedMarkdownContent:function(){return Fh},serializeAttributes:function(){return Ih}});var $h=function(t){function n(){var e;return x(this,n),(e=r(this,n,arguments)).type="node",e}return a(n,t),S(n,[{key:"configure",value:function(t){return e(n,"configure",this,3)([t])}},{key:"extend",value:function(t){var r="function"==typeof t?t():t;return e(n,"extend",this,3)([r])}}],[{key:"create",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new n("function"==typeof e?e():e)}}])}(dh),jh=$h.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:function(e,t){return e.content?t.renderChildren(e.content,"\n\n"):""}}),Hh=jh,Wh=$h.create({name:"text",group:"inline",parseMarkdown:function(e){return{type:"text",text:e.text||""}},renderMarkdown:function(e){return e.text||""}}),qh=$h.create({name:"paragraph",priority:1e3,addOptions:function(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML:function(){return[{tag:"p"}]},renderHTML:function(e){var t=e.HTMLAttributes;return["p",gd(this.options.HTMLAttributes,t),0]},parseMarkdown:function(e,t){var n=e.tokens||[];return 1===n.length&&"image"===n[0].type?t.parseChildren([n[0]]):t.createNode("paragraph",void 0,t.parseInline(n))},renderMarkdown:function(e,t){return e&&Array.isArray(e.content)?t.renderChildren(e.content):""},addCommands:function(){var e=this;return{setParagraph:function(){return function(t){return t.commands.setNode(e.name)}}}},addKeyboardShortcuts:function(){var e=this;return{"Mod-Alt-0":function(){return e.editor.commands.setParagraph()}}}}),Uh=qh;function Jh(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new oa({view:function(t){return new Kh(t,e)}})}var Kh=function(){return S(function e(t,n){var r,i=this;x(this,e),this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!==(r=n.width)&&void 0!==r?r:1,this.color=!1===n.color?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(function(e){var n=function(t){i[e](t)};return t.dom.addEventListener(e,n),{name:e,handler:n}})},[{key:"destroy",value:function(){var e=this;this.handlers.forEach(function(t){var n=t.name,r=t.handler;return e.editorView.dom.removeEventListener(n,r)})}},{key:"update",value:function(e,t){null!=this.cursorPos&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}},{key:"setCursor",value:function(e){e!=this.cursorPos&&(this.cursorPos=e,null==e?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}},{key:"updateOverlay",value:function(){var e,t=this.editorView.state.doc.resolve(this.cursorPos),n=!t.parent.inlineContent,r=this.editorView.dom,i=r.getBoundingClientRect(),o=i.width/r.offsetWidth,a=i.height/r.offsetHeight;if(n){var s=t.nodeBefore,c=t.nodeAfter;if(s||c){var u=this.editorView.nodeDOM(this.cursorPos-(s?s.nodeSize:0));if(u){var l=u.getBoundingClientRect(),d=s?l.bottom:l.top;s&&c&&(d=(d+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);var h=this.width/2*a;e={left:l.left,right:l.right,top:d-h,bottom:d+h}}}}if(!e){var f=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*o;e={left:f.left-p,right:f.left+p,top:f.top,bottom:f.bottom}}var v,m,g=this.editorView.dom.offsetParent;if(this.element||(this.element=g.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n),!g||g==document.body&&"static"==getComputedStyle(g).position)v=-pageXOffset,m=-pageYOffset;else{var y=g.getBoundingClientRect(),k=y.width/g.offsetWidth,w=y.height/g.offsetHeight;v=y.left-g.scrollLeft*k,m=y.top-g.scrollTop*w}this.element.style.left=(e.left-v)/o+"px",this.element.style.top=(e.top-m)/a+"px",this.element.style.width=(e.right-e.left)/o+"px",this.element.style.height=(e.bottom-e.top)/a+"px"}},{key:"scheduleRemoval",value:function(e){var t=this;clearTimeout(this.timeout),this.timeout=setTimeout(function(){return t.setCursor(null)},e)}},{key:"dragover",value:function(e){if(this.editorView.editable){var t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i="function"==typeof r?r(this.editorView,t,e):r;if(t&&!i){var o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){var a=Co(this.editorView.state.doc,o,this.editorView.dragging.slice);null!=a&&(o=a)}this.setCursor(o),this.scheduleRemoval(5e3)}}}},{key:"dragend",value:function(){this.scheduleRemoval(20)}},{key:"drop",value:function(){this.scheduleRemoval(20)}},{key:"dragleave",value:function(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}])}(),Yh=function(e){function t(e){return x(this,t),r(this,t,[e,e])}return a(t,e),S(t,[{key:"map",value:function(e,n){var r=e.resolve(n.map(this.head));return t.valid(r)?new t(r):Fo.near(r)}},{key:"content",value:function(){return Ur.empty}},{key:"eq",value:function(e){return e instanceof t&&e.head==this.head}},{key:"toJSON",value:function(){return{type:"gapcursor",pos:this.head}}},{key:"getBookmark",value:function(){return new Gh(this.anchor)}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new t(e.resolve(n.pos))}},{key:"valid",value:function(e){var t=e.parent;if(t.isTextblock||!function(e){for(var t=e.depth;t>=0;t--){var n=e.index(t),r=e.node(t);if(0!=n)for(var i=r.child(n-1);;i=i.lastChild){if(0==i.childCount&&!i.inlineContent||Xh(i.type))return!0;if(i.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(e)||!function(e){for(var t=e.depth;t>=0;t--){var n=e.indexAfter(t),r=e.node(t);if(n!=r.childCount)for(var i=r.child(n);;i=i.firstChild){if(0==i.childCount&&!i.inlineContent||Xh(i.type))return!0;if(i.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(e))return!1;var n=t.type.spec.allowGapCursor;if(null!=n)return n;var r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}},{key:"findGapCursorFrom",value:function(e,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];e:for(;;){if(!r&&t.valid(e))return e;for(var i=e.pos,o=null,a=e.depth;;a--){var s=e.node(a);if(n>0?e.indexAfter(a)<s.childCount:e.index(a)>0){o=s.child(n>0?e.indexAfter(a):e.index(a)-1);break}if(0==a)return null;i+=n;var c=e.doc.resolve(i);if(t.valid(c))return c}for(;;){var u=n>0?o.firstChild:o.lastChild;if(!u){if(o.isAtom&&!o.isText&&!Uo.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*n),r=!1;continue e}break}o=u,i+=n;var l=e.doc.resolve(i);if(t.valid(l))return l}return null}}}])}(Fo);Yh.prototype.visible=!1,Yh.findFrom=Yh.findGapCursorFrom,Fo.jsonID("gapcursor",Yh);var Gh=function(){function e(t){x(this,e),this.pos=t}return S(e,[{key:"map",value:function(t){return new e(t.map(this.pos))}},{key:"resolve",value:function(e){var t=e.resolve(this.pos);return Yh.valid(t)?new Yh(t):Fo.near(t)}}])}();function Xh(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}var Zh=Xu({ArrowLeft:Qh("horiz",-1),ArrowRight:Qh("horiz",1),ArrowUp:Qh("vert",-1),ArrowDown:Qh("vert",1)});function Qh(e,t){var n="vert"==e?t>0?"down":"up":t>0?"right":"left";return function(e,r,i){var o=e.selection,a=t>0?o.$to:o.$from,s=o.empty;if(o instanceof Wo){if(!i.endOfTextblock(n)||0==a.depth)return!1;s=!1,a=e.doc.resolve(t>0?a.after():a.before())}var c=Yh.findGapCursorFrom(a,t,s);return!!c&&(r&&r(e.tr.setSelection(new Yh(c))),!0)}}function ef(e,t,n){if(!e||!e.editable)return!1;var r=e.state.doc.resolve(t);if(!Yh.valid(r))return!1;var i=e.posAtCoords({left:n.clientX,top:n.clientY});return!(i&&i.inside>-1&&Uo.isSelectable(e.state.doc.nodeAt(i.inside)))&&(e.dispatch(e.state.tr.setSelection(new Yh(r))),!0)}function tf(e,t){if("insertCompositionText"!=t.inputType||!(e.state.selection instanceof Yh))return!1;var n=e.state.selection.$from,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;for(var i=Fr.empty,o=r.length-1;o>=0;o--)i=Fr.from(r[o].createAndFill(null,i));var a=e.state.tr.replace(n.pos,n.pos,new Ur(i,0,0));return a.setSelection(Wo.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function nf(e){if(!(e.selection instanceof Yh))return null;var t=document.createElement("div");return t.className="ProseMirror-gapcursor",uu.create(e.doc,[au.widget(e.selection.head,t,{key:"gapcursor"})])}var rf=200,of=function(){};of.prototype.append=function(e){return e.length?(e=of.from(e),!this.length&&e||e.length<rf&&this.leafAppend(e)||this.length<rf&&e.leafPrepend(this)||this.appendInner(e)):this},of.prototype.prepend=function(e){return e.length?of.from(e).append(this):this},of.prototype.appendInner=function(e){return new sf(this,e)},of.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?of.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},of.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},of.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},of.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},of.from=function(e){return e instanceof of?e:e&&e.length?new af(e):of.empty};var af=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(!1===e(this.values[i],r+i))return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(!1===e(this.values[i],r+i))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=rf)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=rf)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(of);of.empty=new af([]);var sf=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;return!(t<i&&!1===this.left.forEachInner(e,t,Math.min(n,i),r))&&(!(n>i&&!1===this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i))&&void 0)},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;return!(t>i&&!1===this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i))&&(!(n<i&&!1===this.left.forEachInvertedInner(e,Math.min(t,i),n,r))&&void 0)},t.prototype.sliceInner=function(e,t){if(0==e&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(of),cf=function(){function e(t,n){x(this,e),this.items=t,this.eventCount=n}return S(e,[{key:"popEvent",value:function(t,n){var r=this;if(0==this.eventCount)return null;for(var i,o,a=this.items.length;;a--){if(this.items.get(a-1).selection){--a;break}}n&&(i=this.remapping(a,this.items.length),o=i.maps.length);var s,c,u=t.tr,l=[],d=[];return this.items.forEach(function(t,n){if(!t.step)return i||(i=r.remapping(a,n+1),o=i.maps.length),o--,void d.push(t);if(i){d.push(new uf(t.map));var h,f=t.step.map(i.slice(o));f&&u.maybeStep(f).doc&&(h=u.mapping.maps[u.mapping.maps.length-1],l.push(new uf(h,void 0,void 0,l.length+d.length))),o--,h&&i.appendMap(h,o)}else u.maybeStep(t.step);return t.selection?(s=i?t.selection.map(i.slice(o)):t.selection,c=new e(r.items.slice(0,a).append(d.reverse().concat(l)),r.eventCount-1),!1):void 0},this.items.length,0),{remaining:c,transform:u,selection:s}}},{key:"addTransform",value:function(t,n,r,i){for(var o=[],a=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null,u=0;u<t.steps.length;u++){var l,d=t.steps[u].invert(t.docs[u]),h=new uf(t.mapping.maps[u],d,n);(l=c&&c.merge(h))&&(h=l,u?o.pop():s=s.slice(0,s.length-1)),o.push(h),n&&(a++,n=void 0),i||(c=h)}var f=a-r.depth;return f>df&&(s=function(e,t){var n;return e.forEach(function(e,r){if(e.selection&&0==t--)return n=r,!1}),e.slice(n)}(s,f),a-=f),new e(s.append(o),a)}},{key:"remapping",value:function(e,t){var n=new Qi;return this.items.forEach(function(t,r){var i=null!=t.mirrorOffset&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}},{key:"addMaps",value:function(t){return 0==this.eventCount?this:new e(this.items.append(t.map(function(e){return new uf(e)})),this.eventCount)}},{key:"rebased",value:function(t,n){if(!this.eventCount)return this;var r=[],i=Math.max(0,this.items.length-n),o=t.mapping,a=t.steps.length,s=this.eventCount;this.items.forEach(function(e){e.selection&&s--},i);var c=n;this.items.forEach(function(e){var n=o.getMirror(--c);if(null!=n){a=Math.min(a,n);var i=o.maps[n];if(e.step){var u=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(o.slice(c+1,n));l&&s++,r.push(new uf(i,u,l))}else r.push(new uf(i))}},i);for(var u=[],l=n;l<a;l++)u.push(new uf(o.maps[l]));var d=new e(this.items.slice(0,i).append(u).append(r),s);return d.emptyItemCount()>500&&(d=d.compress(this.items.length-r.length)),d}},{key:"emptyItemCount",value:function(){var e=0;return this.items.forEach(function(t){t.step||e++}),e}},{key:"compress",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.items.length,n=this.remapping(0,t),r=n.maps.length,i=[],o=0;return this.items.forEach(function(e,a){if(a>=t)i.push(e),e.selection&&o++;else if(e.step){var s=e.step.map(n.slice(r)),c=s&&s.getMap();if(r--,c&&n.appendMap(c,r),s){var u=e.selection&&e.selection.map(n.slice(r));u&&o++;var l,d=new uf(c.invert(),s,u),h=i.length-1;(l=i.length&&i[h].merge(d))?i[h]=l:i.push(d)}}else e.map&&r--},this.items.length,0),new e(of.from(i.reverse()),o)}}])}();cf.empty=new cf(of.empty,0);var uf=function(){function e(t,n,r,i){x(this,e),this.map=t,this.step=n,this.selection=r,this.mirrorOffset=i}return S(e,[{key:"merge",value:function(t){if(this.step&&t.step&&!t.selection){var n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}}])}(),lf=S(function e(t,n,r,i,o){x(this,e),this.done=t,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}),df=20;function hf(e){for(var t=[],n=e.length-1;n>=0&&0==t.length;n--)e[n].forEach(function(e,n,r,i){return t.push(r,i)});return t}function ff(e,t){if(!e)return null;for(var n=[],r=0;r<e.length;r+=2){var i=t.map(e[r],1),o=t.map(e[r+1],-1);i<=o&&n.push(i,o)}return n}var pf=!1,vf=null;function mf(e){var t=e.plugins;if(vf!=t){pf=!1,vf=t;for(var n=0;n<t.length;n++)if(t[n].spec.historyPreserveItems){pf=!0;break}}return pf}var gf=new ca("history"),yf=new ca("closeHistory");function kf(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new oa({key:gf,state:{init:function(){return new lf(cf.empty,cf.empty,null,0,-1)},apply:function(t,n,r){return function(e,t,n,r){var i,o=n.getMeta(gf);if(o)return o.historyState;n.getMeta(yf)&&(e=new lf(e.done,e.undone,null,0,-1));var a=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(a&&a.getMeta(gf))return a.getMeta(gf).redo?new lf(e.done.addTransform(n,void 0,r,mf(t)),e.undone,hf(n.mapping.maps),e.prevTime,e.prevComposition):new lf(e.done,e.undone.addTransform(n,void 0,r,mf(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||a&&!1===a.getMeta("addToHistory"))return(i=n.getMeta("rebased"))?new lf(e.done.rebased(n,i),e.undone.rebased(n,i),ff(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new lf(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),ff(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);var s=n.getMeta("composition"),c=0==e.prevTime||!a&&e.prevComposition!=s&&(e.prevTime<(n.time||0)-r.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;var n=!1;return e.mapping.maps[0].forEach(function(e,r){for(var i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}(n,e.prevRanges)),u=a?ff(e.prevRanges,n.mapping):hf(n.mapping.maps);return new lf(e.done.addTransform(n,c?t.selection.getBookmark():void 0,r,mf(t)),cf.empty,u,n.time,null==s?e.prevComposition:s)}(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput:function(e,t){var n=t.inputType,r="historyUndo"==n?bf:"historyRedo"==n?xf:null;return!(!r||!e.editable)&&(t.preventDefault(),r(e.state,e.dispatch))}}}})}function wf(e,t){return function(n,r){var i=gf.getState(n);if(!i||0==(e?i.undone:i.done).eventCount)return!1;if(r){var o=function(e,t,n){var r=mf(t),i=gf.get(t).spec.config,o=(n?e.undone:e.done).popEvent(t,r);if(!o)return null;var a=o.selection.resolve(o.transform.doc),s=(n?e.done:e.undone).addTransform(o.transform,t.selection.getBookmark(),i,r),c=new lf(n?s:o.remaining,n?o.remaining:s,null,0,-1);return o.transform.setSelection(a).setMeta(gf,{redo:n,historyState:c})}(i,n,e);o&&r(t?o.scrollIntoView():o)}return!0}}var bf=wf(!1,!0),xf=wf(!0,!0);function Cf(e){var t=e.types,n=e.node;return n&&Array.isArray(t)&&t.includes(n.type)||(null==n?void 0:n.type)===t}gh.create({name:"characterCount",addOptions:function(){return{limit:null,mode:"textSize",textCounter:function(e){return e.length},wordCounter:function(e){return e.split(" ").filter(function(e){return""!==e}).length}}},addStorage:function(){return{characters:function(){return 0},words:function(){return 0}}},onBeforeCreate:function(){var e=this;this.storage.characters=function(t){var n=(null==t?void 0:t.node)||e.editor.state.doc;if("textSize"===((null==t?void 0:t.mode)||e.options.mode)){var r=n.textBetween(0,n.content.size,void 0," ");return e.options.textCounter(r)}return n.nodeSize},this.storage.words=function(t){var n=(null==t?void 0:t.node)||e.editor.state.doc,r=n.textBetween(0,n.content.size," "," ");return e.options.wordCounter(r)}},addProseMirrorPlugins:function(){var e=this,t=!1;return[new oa({key:new ca("characterCount"),appendTransaction:function(n,r,i){if(!t){var o=e.options.limit;if(null!=o&&0!==o){var a=e.storage.characters({node:i.doc});if(a>o){var s=a-o;console.warn("[CharacterCount] Initial content exceeded limit of ".concat(o," characters. Content was automatically trimmed."));var c=i.tr.deleteRange(0,s);return t=!0,c}t=!0}else t=!0}},filterTransaction:function(t,n){var r=e.options.limit;if(!t.docChanged||0===r||null==r)return!0;var i=e.storage.characters({node:n.doc}),o=e.storage.characters({node:t.doc});if(o<=r)return!0;if(i>r&&o>r&&o<=i)return!0;if(i>r&&o>r&&o>i)return!1;if(!t.getMeta("paste"))return!1;var a=t.selection.$head.pos,s=a-(o-r),c=a;return t.deleteRange(s,c),!(e.storage.characters({node:t.doc})>r)}})]}}),gh.create({name:"dropCursor",addOptions:function(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins:function(){return[Jh(this.options)]}}),gh.create({name:"focus",addOptions:function(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins:function(){var e=this;return[new oa({key:new ca("focus"),props:{decorations:function(t){var n=t.doc,r=t.selection,i=e.editor,o=i.isEditable,a=i.isFocused,s=r.anchor,c=[];if(!o||!a)return uu.create(n,[]);var u=0;"deepest"===e.options.mode&&n.descendants(function(e,t){if(!e.isText){if(!(s>=t&&s<=t+e.nodeSize-1))return!1;u+=1}});var l=0;return n.descendants(function(t,n){return!t.isText&&(s>=n&&s<=n+t.nodeSize-1&&(l+=1,"deepest"===e.options.mode&&u-l>0||"shallowest"===e.options.mode&&l>1?"deepest"===e.options.mode:void c.push(au.node(n,n+t.nodeSize,{class:e.options.className}))))}),uu.create(n,c)}}})]}}),gh.create({name:"gapCursor",addProseMirrorPlugins:function(){return[new oa({props:{decorations:nf,createSelectionBetween:function(e,t,n){return t.pos==n.pos&&Yh.valid(n)?new Yh(n):null},handleClick:ef,handleKeyDown:Zh,handleDOMEvents:{beforeinput:tf}}})]},extendNodeSchema:function(e){var t;return{allowGapCursor:null!=(t=pd(ld(e,"allowGapCursor",{name:e.name,options:e.options,storage:e.storage})))?t:null}}}),gh.create({name:"placeholder",addOptions:function(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins:function(){var e=this;return[new oa({key:new ca("placeholder"),props:{decorations:function(t){var n=t.doc,r=t.selection,i=e.editor.isEditable||!e.options.showOnlyWhenEditable,o=r.anchor,a=[];if(!i)return null;var s=e.editor.isEmpty;return n.descendants(function(t,n){var r=o>=n&&o<=n+t.nodeSize,i=!t.isLeaf&&Id(t);if((r||!e.options.showOnlyCurrent)&&i){var c=[e.options.emptyNodeClass];s&&c.push(e.options.emptyEditorClass);var u=au.node(n,n+t.nodeSize,{class:c.join(" "),"data-placeholder":"function"==typeof e.options.placeholder?e.options.placeholder({editor:e.editor,node:t,pos:n,hasAnchor:r}):e.options.placeholder});a.push(u)}return e.options.includeChildren}),uu.create(n,a)}}})]}}),gh.create({name:"selection",addOptions:function(){return{className:"selection"}},addProseMirrorPlugins:function(){var e=this.editor,t=this.options;return[new oa({key:new ca("selection"),props:{decorations:function(n){return n.selection.empty||e.isFocused||!e.isEditable||n.selection instanceof Uo||e.view.dragging?null:uu.create(n.doc,[au.inline(n.selection.from,n.selection.to,{class:t.className})])}}})]}}),gh.create({name:"trailingNode",addOptions:function(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins:function(){var e,t=this,n=new ca(this.name),r=this.options.node||(null==(e=this.editor.schema.topNodeType.contentMatch.defaultType)?void 0:e.name)||"paragraph",i=Object.entries(this.editor.schema.nodes).map(function(e){return d(e,2)[1]}).filter(function(e){return(t.options.notAfter||[]).concat(r).includes(e.name)});return[new oa({key:n,appendTransaction:function(e,t,i){var o=i.doc,a=i.tr,s=i.schema,c=n.getState(i),u=o.content.size,l=s.nodes[r];if(c)return a.insert(u,l.create())},state:{init:function(e,t){return!Cf({node:t.tr.doc.lastChild,types:i})},apply:function(e,t){return e.docChanged?e.getMeta("__uniqueIDTransaction")?t:!Cf({node:e.doc.lastChild,types:i}):t}}})]}});var Sf=gh.create({name:"undoRedo",addOptions:function(){return{depth:100,newGroupDelay:500}},addCommands:function(){return{undo:function(){return function(e){var t=e.state,n=e.dispatch;return bf(t,n)}},redo:function(){return function(e){var t=e.state,n=e.dispatch;return xf(t,n)}}}},addProseMirrorPlugins:function(){return[kf(this.options)]},addKeyboardShortcuts:function(){var e=this;return{"Mod-z":function(){return e.editor.commands.undo()},"Shift-Mod-z":function(){return e.editor.commands.redo()},"Mod-y":function(){return e.editor.commands.redo()},"Mod-я":function(){return e.editor.commands.undo()},"Shift-Mod-я":function(){return e.editor.commands.redo()}}}}),_f=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Mf=$h.create({name:"image",addOptions:function(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline:function(){return this.options.inline},group:function(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes:function(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML:function(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML:function(e){var t=e.HTMLAttributes;return["img",gd(this.options.HTMLAttributes,t)]},parseMarkdown:function(e,t){return t.createNode("image",{src:e.href,title:e.title,alt:e.text})},renderMarkdown:function(e){var t,n,r,i,o,a,s=null!=(n=null==(t=e.attrs)?void 0:t.src)?n:"",c=null!=(i=null==(r=e.attrs)?void 0:r.alt)?i:"",u=null!=(a=null==(o=e.attrs)?void 0:o.title)?a:"";return u?"![".concat(c,"](").concat(s,' "').concat(u,'")'):"![".concat(c,"](").concat(s,")")},addNodeView:function(){var e=this;if(!this.options.resize||!this.options.resize.enabled||"undefined"==typeof document||!this.editor.isEditable)return null;var t=this.options.resize,n=t.directions,r=t.minWidth,i=t.minHeight,o=t.alwaysPreserveAspectRatio;return function(t){var a=t.node,s=t.getPos,c=t.HTMLAttributes,u=document.createElement("img");Object.entries(c).forEach(function(e){var t=d(e,2),n=t[0],r=t[1];if(null!=r)switch(n){case"width":case"height":break;default:u.setAttribute(n,r)}}),u.src=c.src;var l=new Ah({element:u,node:a,getPos:s,onResize:function(e,t){u.style.width="".concat(e,"px"),u.style.height="".concat(t,"px")},onCommit:function(t,n){var r=s();void 0!==r&&e.editor.chain().setNodeSelection(r).updateAttributes(e.name,{width:t,height:n}).run()},onUpdate:function(e,t,n){return e.type===a.type},options:{directions:n,min:{width:r,height:i},preserveAspectRatio:!0===o}}),h=l.dom;return h.style.visibility="hidden",h.style.pointerEvents="none",u.onload=function(){h.style.visibility="",h.style.pointerEvents=""},l}},addCommands:function(){var e=this;return{setImage:function(t){return function(n){return n.commands.insertContent({type:e.name,attrs:t})}}}},addInputRules:function(){return[(e={find:_f,type:this.type,getAttributes:function(e){var t=d(e,5),n=t[2];return{src:t[3],alt:n,title:t[4]}}},new sh({find:e.find,handler:function(t){var n=t.state,r=t.range,i=t.match,o=pd(e.getAttributes,void 0,i)||{},a=n.tr,s=r.from,c=r.to,u=e.type.create(o);if(i[1]){var l=s+i[0].lastIndexOf(i[1]);l>c?l=c:c=l+i[1].length;var d=i[0][i[0].length-1];a.insertText(d,s+i[0].length-1),a.replaceWith(l,c,u)}else if(i[0]){var h=e.type.isInline?s:s-1;a.insert(h,e.type.create(o)).delete(a.mapping.map(s),a.mapping.map(c))}a.scrollIntoView()},undoable:e.undoable}))];var e}}),Tf=gh.create({name:"fileHandler",addOptions:function(){return{onPaste:void 0,onDrop:void 0,allowedMimeTypes:void 0}},addProseMirrorPlugins:function(){return[(e={key:new ca(this.name),editor:this.editor,allowedMimeTypes:this.options.allowedMimeTypes,onDrop:this.options.onDrop,onPaste:this.options.onPaste},t=e.key,n=e.editor,r=e.onPaste,i=e.onDrop,o=e.allowedMimeTypes,new oa({key:t||new ca("fileHandler"),props:{handleDrop:function(e,t){var r;if(!i)return!1;if(!(null==(r=t.dataTransfer)?void 0:r.files.length))return!1;var a=e.posAtCoords({left:t.clientX,top:t.clientY}),s=Array.from(t.dataTransfer.files);return o&&(s=s.filter(function(e){return o.includes(e.type)})),0!==s.length&&(t.preventDefault(),t.stopPropagation(),i(n,s,(null==a?void 0:a.pos)||0),!0)},handlePaste:function(e,t){var i;if(!r)return!1;if(!(null==(i=t.clipboardData)?void 0:i.files.length))return!1;var a=Array.from(t.clipboardData.files),s=t.clipboardData.getData("text/html");return o&&(a=a.filter(function(e){return o.includes(e.type)})),0!==a.length&&(t.preventDefault(),t.stopPropagation(),r(n,a,s),!(s.length>0))}}}))];var e,t,n,r,i,o}}),Of=new pe("chat-editor"),Nf=function(e){var t=e.c,n=e.value,r=e.disabled,i=e.onCreate,o=e.onChange,a=e.onKeyDown,s=Je(null),c=Je(null);return Ue(function(){if(c.current){var e,r,u=window.ibiz.util.file.getUploadHeaders(),l=window.ibiz.util.file.calcFileUpDownUrl(t.context,t.params,{},{enableNoAccess:!0}),d=l.uploadUrl,h=l.downloadUrl,f=function(){var e=b(y().m(function e(t){var n,r,i,o;return y().w(function(e){for(;;)switch(e.n){case 0:return(n=new FormData).append("file",t),e.n=1,window.ibiz.net.axios({url:d,method:"post",headers:u,data:n});case 1:if(r=e.v,i=r.data){e.n=2;break}return e.a(2,{name:"",url:""});case 2:return o=h.replace("%fileId%",i.fileid),e.a(2,{name:i.name,url:o})}},e)}));return function(t){return e.apply(this,arguments)}}(),p=new Eh({element:c.current,extensions:[Hh,Wh.extend({addKeyboardShortcuts:function(){return{"Mod-Enter":function(){var e,t;return null===(e=s.current)||void 0===e||e.commands.enter(),null===(t=s.current)||void 0===t||t.commands.scrollIntoView(),!0},"Shift-Enter":function(){var e,t;return null===(e=s.current)||void 0===e||e.commands.enter(),null===(t=s.current)||void 0===t||t.commands.scrollIntoView(),!0}}}}),Uh,Sf,Mf.configure({inline:!0,allowBase64:!0,HTMLAttributes:{draggable:"false"}}).extend({draggable:!1}),Tf.configure({onDrop:(r=b(y().m(function e(t,n){var r;return y().w(function(e){for(;;)switch(e.n){case 0:if((n=n.filter(function(e){return e.type.startsWith("image/")})).length){e.n=1;break}return e.a(2);case 1:return e.n=2,Promise.all(n.map(function(e){return f(e)}));case 2:if(r=e.v,!t.isDestroyed){e.n=3;break}return e.a(2);case 3:t.chain().deleteSelection().insertContentAt(t.state.selection.from,r.map(function(e){return{type:"image",attrs:{src:e.url,alt:e.name}}})).focus().scrollIntoView().run();case 4:return e.a(2)}},e)})),function(e,t){return r.apply(this,arguments)}),onPaste:(e=b(y().m(function e(t,n){var r;return y().w(function(e){for(;;)switch(e.n){case 0:if((n=n.filter(function(e){return e.type.startsWith("image/")})).length){e.n=1;break}return e.a(2);case 1:return e.n=2,Promise.all(n.map(function(e){return f(e)}));case 2:if(r=e.v,!t.isDestroyed){e.n=3;break}return e.a(2);case 3:t.chain().deleteSelection().insertContentAt(t.state.selection.from,r.map(function(e){return{type:"image",attrs:{src:e.url,alt:e.name}}})).focus().scrollIntoView().run();case 4:return e.a(2)}},e)})),function(t,n){return e.apply(this,arguments)})})],content:n||"",editorProps:{handleKeyDown:function(e,t){return a(t)}},onUpdate:function(){o(p.getHTML())},onCreate:function(){i(p)}});return s.current=p,function(){s.current&&(s.current.destroy(),s.current=null)}}},[]),he("div",{className:"".concat(Of.b()," ").concat(r?Of.m("disabled"):""),children:he("div",{ref:c})})},Ef=new pe("chat-input"),Af=window.SpeechRecognition||window.webkitSpeechRecognition,Df=function(e){var t,n=d(qe(!1),2),r=n[0],i=n[1];Ge($f);var o=e.controller.input,a=At(!1),s=Je(),c=Je(null);Af&&!s.current&&(s.current=new Af,s.current.onstart=function(){a.value=!0},s.current.onend=function(){a.value=!1},s.current.onresult=function(e){var t,n,r=null===(t=e.results)||void 0===t||null===(t=t[0])||void 0===t||null===(t=t[0])||void 0===t?void 0:t.transcript;r&&(null===(n=c.current)||void 0===n||n.commands.insertContent(r))});var u=function(e){var t=(new DOMParser).parseFromString(e,"text/html");var n=Array.from(t.body.childNodes).map(function e(t){if(t.nodeType===Node.TEXT_NODE)return t.textContent||"";if(t.nodeType!==Node.ELEMENT_NODE)return"";var n=t,r=n.tagName.toLowerCase(),i=Array.from(n.childNodes).map(function(t){return e(t)}).join("");switch(r){case"p":return"".concat(i,"\n");case"img":var o=n.getAttribute("src")||"",a=n.getAttribute("alt")||"";return o?"\n![".concat(a,"](").concat(o,")\n"):"";default:return t.textContent||""}}).join("").replace(/\n+/g,"\n").replace(/^\n|\n$/g,"");return n},l=Dt(function(){return u(o.value).length<=0}),h=Ye(b(y().m(function t(){var n,r,i;return y().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,r=u(o.value),o.value="",null===(n=c.current)||void 0===n||n.chain().clearContent().run(),t.n=1,e.controller.question(r);case 1:t.n=3;break;case 2:t.p=2,i=t.v,console.error(i);case 3:return t.p=3,c.current&&!c.current.isDestroyed&&c.current.chain().focus().run(),t.f(3);case 4:return t.a(2)}},t,null,[[0,2,3,4]])})),[o]),f=Ye(b(y().m(function t(){return y().w(function(t){for(;;)switch(t.n){case 0:try{e.controller.abortQuestion()}catch(n){console.error(n)}case 1:return t.a(2)}},t)})),[o]),p=function(){var t=b(y().m(function t(n){var r;return y().w(function(t){for(;;)switch(t.n){case 0:return r=Dr.getMaterialHelper("ossfile",e.controller),t.n=1,r.excuteAction(n);case 1:i(!1);case 2:return t.a(2)}},t)}));return function(e){return t.apply(this,arguments)}}(),v=function(){var t=b(y().m(function t(n,r){var o;return y().w(function(t){for(;;)switch(t.n){case 0:return o=Dr.getMaterialHelper("common",e.controller),t.n=1,o.excuteAction(n,r);case 1:i(!1);case 2:return t.a(2)}},t)}));return function(e,n){return t.apply(this,arguments)}}();return he("div",{className:Ef.b("wrapper"),children:[he("div",{className:Ef.b("material-wrapper"),children:he(Rr,{controller:e.controller})}),he("div",{className:Ef.b("main-wrapper"),children:[he(Nf,{c:e.controller,value:o.value,disabled:e.controller.isLoading.value,onCreate:function(e){c.current=e},onChange:function(e){o.value=e},onKeyDown:function(e){if("Enter"===e.code&&!e.isComposing&&!1===e.shiftKey)return h(),!0}}),he("div",{className:Ef.b("action-wrapper"),children:[he("div",{className:Ef.b("left-action-wrapper"),children:he(kn,{options:e.controller.agentList.value,defaultValue:e.controller.activeAIAgentID,onChange:function(t){var n;n=t,e.controller.setActiveAIAgentID(n)},placeholder:"Auto",disabled:!e.controller.enableAIAgentChange})}),he("div",{className:Ef.b("right-action-wrapper"),children:[he("div",{className:"".concat(Ef.be("right-action-wrapper","action-item")," ").concat(Ef.is("disabled",e.controller.isLoading.value)),title:"上传资料",children:he(Pr,{content:he("div",{className:Ef.b("pop-actions"),children:[he("div",{className:Ef.b("pop-action-item"),onClick:function(e){p(e)},children:[he("span",{className:Ef.b("pop-action-item-icon"),children:he(Qt,{})}),he("span",{className:Ef.b("pop-action-item-title"),children:"文件资料"})]}),null===(t=e.questionToolbarItems)||void 0===t?void 0:t.map(function(e){var t,n,r;return he("div",{className:Ef.b("pop-action-item"),onClick:function(t){v(t,e)},children:[he("span",{className:Ef.b("pop-action-item-icon"),children:"function"==typeof e.icon?e.icon():(null===(t=e.icon)||void 0===t?void 0:t.showIcon)&&he(H,{children:null!==(n=e.icon)&&void 0!==n&&n.cssClass?he("i",{className:e.icon.cssClass}):null!==(r=e.icon)&&void 0!==r&&r.imagePath?xe(e.icon.imagePath)?he("div",{dangerouslySetInnerHTML:{__html:e.icon.imagePath}}):he("img",{src:e.icon.imagePath}):null})}),he("span",{className:Ef.b("pop-action-item-title"),children:e.label})]},e.id)})]}),position:"top-left",isOpen:r,onToggleOpen:i,children:he(Zt,{})})}),he("div",{title:a.value?"语音输入中...":"语音输入",className:"".concat(Ef.be("right-action-wrapper","action-item")," ").concat(Ef.is("disabled",e.controller.isLoading.value)),onClick:function(){s.current&&!a.value&&s.current.start()},children:a.value?he(qt,{}):he(Wt,{})}),e.controller.isLoading.value?he("div",{title:"停止生成",className:"".concat(Ef.be("right-action-wrapper","action-item")),onClick:f,children:he(nn,{})}):he("div",{title:"发送消息",className:"".concat(Ef.be("right-action-wrapper","action-item")," ").concat(Ef.is("disabled",l.value)),onClick:h,children:he(Rt,{})})]})]})]})]})},If=new pe("chat-topic-item"),zf=function(e){var t=e.controller,n=e.topic,r=e.onClick,i=e.onAction,o=Je(null),a=Dt(function(){var e;return(null===(e=t.activedTopic.value)||void 0===e?void 0:e.id)===n.id}),s=d(qe(!1),2),c=s[0],u=s[1],l=At(!1);return he("div",{className:"".concat(If.b()," ").concat(If.is("active",a.value)," ").concat(If.is("edit",l.value)),onClick:r.bind(void 0),children:[he("div",{className:If.e("caption"),title:n.caption,children:l.value?he("input",{ref:o,value:n.caption,onBlur:function(e){e.stopPropagation(),l.value=!1,i("RENAME",e)},onKeyDown:function(e){e.stopPropagation(),"Enter"===e.key&&(l.value=!1)},onClick:function(e){return e.stopPropagation()},onChange:function(e){return(t=e).stopPropagation(),void(n.data.caption=null===(r=t.target)||void 0===r?void 0:r.value);var t,r},className:If.em("caption","editor")}):he("div",{className:If.em("caption","readonly"),children:[he("span",{className:If.em("caption","text"),children:n.caption}),n.isTop?he("span",{className:If.em("caption","icon"),children:he(hn,{})}):null]})}),!l.value&&he("div",{className:If.e("icon"),children:[he("span",{title:"跳转主视图",className:If.em("icon","item"),onClick:function(e){e.stopPropagation(),i("LINK",e)}.bind(void 0),children:he(Jt,{className:If.b("link-icon")})}),a.value?null:he(Pr,{actions:[{id:"PINNED",caption:n.isTop?"取消置顶":"置顶",icon:n.isTop?he(fn,{}):he(hn,{})},{id:"RENAME",caption:"重命名",icon:he(sn,{})},{id:"DELETE",caption:"删除话题",icon:he(Kt,{})}],position:"bottom",isOpen:c,onToggleOpen:u,onAction:function(e,t){"RENAME"===e?(l.value=!0,setTimeout(function(){var e;null===(e=o.current)||void 0===e||e.focus()},100)):i(e,t),u(!1)}.bind(void 0),children:he("span",{className:If.em("icon","item"),title:"更多",children:he(Ut,{className:If.e("more-icon")})})})]})]})},Rf=new pe("chat-search"),Pf=function(e){var t=e.className,n=e.value,r=e.placeholder,i=e.onChange,o=d(qe(!1),2),a=o[0],s=o[1],c=function(e){var t;e.stopPropagation(),null==i||i(null===(t=e.target)||void 0===t?void 0:t.value)};return he("div",{className:"".concat(Rf.b()," ").concat(Rf.is("focus",a)," ").concat(t||""),children:[he("div",{className:Rf.e("prefix"),children:he(un,{})}),he("input",{value:n,className:Rf.e("inner"),placeholder:r,onFocus:function(){return s(!0)},onBlur:function(){return s(!1)},onChange:function(e){return c(e)}})]})},Lf=new pe("chat-topics"),Bf=function(e){var t=Je(null),n=At(void 0),r=At([]);Ue(function(){var t=c(e.controller.topics.value).sort(function(e,t){return e.isTop!==t.isTop?t.isTop?1:-1:e.sequence-t.sequence});r.value=t.filter(function(e){var t,r;return null===(t=e.caption)||void 0===t?void 0:t.toLowerCase().includes((null===(r=n.value)||void 0===r?void 0:r.trim().toLowerCase())||"")})},[e.controller.topics.value]);return Ue(function(){var e=t.current;if(e){var n=e.querySelector(".ibiz-chat-topic-item.is-active");null==n||n.scrollIntoView({behavior:"smooth",block:"nearest"})}},[e.controller.activedTopic.value]),he("div",{className:Lf.b(),children:[he("div",{className:Lf.e("header"),children:he(Pf,{value:n.value,placeholder:"搜索话题",onChange:function(t){n.value=t,r.value=e.controller.topics.value.filter(function(e){var t,r;return null===(t=e.caption)||void 0===t?void 0:t.toLowerCase().includes((null===(r=n.value)||void 0===r?void 0:r.trim().toLowerCase())||"")})}.bind(void 0)})}),he("div",{ref:t,className:Lf.e("main"),children:r.value&&r.value.length>0?r.value.map(function(t){return he(zf,{topic:t,controller:e.controller,onClick:function(){return function(t){e.controller.handleTopicChange(t)}(t)},onAction:function(n,r){return function(t,n,r){e.controller.handleTopicAction(t,n,r)}(n,t,r)}},t.id)}):he("div",{className:Lf.e("empty"),children:"暂无话题"})}),he("div",{className:Lf.e("footer"),children:he("div",{title:"清空会话",className:Lf.e("action"),onClick:function(){return e.controller.clearTopic()},children:[he(Kt,{}),he("span",{children:"清空会话"})]})})]})},Vf=new pe("chat-minimize"),Ff=function(e){var t=Je(null),n=d(qe(""),2),r=n[0],i=n[1],o=d(qe(0),2),a=o[0],s=o[1],c=Je(!1),u={x:(window.innerWidth-86)/window.innerWidth,y:(window.innerHeight-86)/window.innerHeight},l=Dt(function(){var t=e.controller.messages.value[e.controller.messages.value.length-1];return!!t&&("ASSISTANT"===t.role&&20===t.state&&!0!==t.completed)}),h=Dt(function(){var t="";if(!l.value)return i(""),s(0),t;var n=e.controller.messages.value[e.controller.messages.value.length-1];if(t=n.content,-1!==n.content.indexOf("<think>")){var r=function(e){var t=e.indexOf("<think>"),n=e.indexOf("</think>"),r="",i="";return-1===n?(r=e.slice(t+7),i=""):(r=e.slice(t+7,n),i=e.slice(n+8)),{thoughtContent:r,answerContent:i}}(n.content);t=r.thoughtContent+r.answerContent}return t}),f=function(){Object.assign(t.current.style,{left:"".concat(100*u.x,"%"),top:"".concat(100*u.y,"%")}),localStorage.setItem(Cr.MINIMIZE_STYLY_CHCHE,JSON.stringify(u))};return Ue(function(){var e,n=localStorage.getItem(Cr.MINIMIZE_STYLY_CHCHE);if(n){var r=JSON.parse(n);Oe(r)&&Object.assign(u,r)}f(),(e=t.current)&&(e.onmousedown=function(t){document.body.style.userSelect="none";var n=t.clientX-e.offsetLeft,r=t.clientY-e.offsetTop,i=Date.now(),o=function(e){var t=56/window.innerWidth,i=56/window.innerHeight,o=Ne(e.clientX-n,e.clientY-r,t,i),a=o.x,s=o.y;Object.assign(u,{x:a,y:s}),requestAnimationFrame(function(){f()})},a=function(){var e=Date.now();c.current=e-i>300,document.body.style.userSelect="",document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",a)};document.addEventListener("mousemove",o),document.addEventListener("mouseup",a)})},[]),Ue(function(){if(a<h.value.length){var e=setTimeout(function(){i(function(e){return e+h.value[a]}),s(function(e){return e+1})},100);return function(){return clearTimeout(e)}}},[a,h.value]),he("div",{ref:t,title:e.title,className:"".concat(Vf.b()," ").concat(Vf.is("hidden",!e.isMinimize)," ").concat(Vf.is("show-halo",l.value)),onClick:function(){c.current||e.onClick()},children:he("div",{className:"".concat(Vf.e("content")," ").concat(Vf.is("show-border",!l.value)),children:[r&&he("div",{className:"".concat(Vf.em("content","popover")),children:he("div",{className:"typewriter",children:r})}),he(jt,{})]})})},$f=function(e){function t(e){var n,r;return this.getChildContext||(n=new Set,(r={})[t.__c]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&n.forEach(function(e){e.__e=!0,J(e)})},this.sub=function(e){n.add(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n&&n.delete(e),t&&t.call(e)}}),e.children}return t.__c="__cC"+z++,t.__=e,t.Provider=t.__l=(t.Consumer=function(e,t){return e.children(t)}).contextType=t,t}({zIndex:10,enableBackFill:!0}),jf=function(e){function t(e){var n,i,o,a,s,c;return x(this,t),_(c=r(this,t,[e]),"ns",new pe("chat-container")),_(c,"containerRef",{current:null}),_(c,"dragHandle",{current:null}),_(c,"data",{side:{y:0,height:1,width:750/window.innerWidth,x:(window.innerWidth-750)/window.innerWidth},window:{y:0,width:750/window.innerWidth,height:750/window.innerHeight,x:(window.innerWidth-750)/window.innerWidth},minWidth:500,minHeight:300,showMode:"side"}),_(c,"disabled",!1),_(c,"isDragging",!1),_(c,"containerContext",{zIndex:(null===(n=c.props.containerOptions)||void 0===n?void 0:n.zIndex)||10,enableBackFill:void 0===(null===(i=c.props)||void 0===i?void 0:i.enableBackFill)||null===(null===(o=c.props)||void 0===o?void 0:o.enableBackFill)||(null===(a=c.props)||void 0===a?void 0:a.enableBackFill)}),c.state={isFullScreen:!1,isMinimize:!("minimize"!==(null==e?void 0:e.openMode)&&"autoexpand"!==(null==e?void 0:e.openMode)),enableAIMinimize:!0===(null==e||null===(s=e.containerOptions)||void 0===s?void 0:s.enableAIMinimize)},null==e||e.aiChat.evt.on("onCompleteMessage",function(){if(e.autoClose){var t=e.autoClose,n=t.mode,r=t.duration,i=void 0===r?3:r;switch(n){case"minimize":c.minimize();break;case"close":c.close();break;case"closetime":setTimeout(function(){c.close()},1e3*i)}}"autoexpand"===e.openMode&&c.exitMinimize()}),c}return a(t,e),S(t,[{key:"calcWindowStyle",value:function(){var e,t="window"===this.data.showMode?this.data.window:this.data.side;return{left:"".concat(100*t.x,"%"),top:"".concat(100*t.y,"%"),width:"".concat(100*t.width,"%"),height:"".concat(100*t.height,"%"),minWidth:"".concat(this.data.minWidth,"px"),minHeight:"".concat(this.data.minHeight,"px"),"z-index":(null===(e=this.props.containerOptions)||void 0===e||null===(e=e.zIndex)||void 0===e?void 0:e.toString())||"10"}}},{key:"calcSideModeStyle",value:function(e){Object.assign(this.data,{side:{y:0,x:"left"===e?0:(window.innerWidth-750)/window.innerWidth,height:1,width:750/window.innerWidth},showMode:"side"})}},{key:"setStyle",value:function(){Object.assign(this.containerRef.current.style,this.calcWindowStyle()),localStorage.setItem(Cr.STYLE_CACHE,JSON.stringify(this.data))}},{key:"snapToEdge",value:function(){var e=20/window.innerWidth,t=20/window.innerHeight,n=this.data.window,r=n.x,i=n.y,o=n.width,a=n.height;r<e||r+o>1-e?this.calcSideModeStyle(r<e?"left":"right"):(i<t&&(this.data.window.y=0),i+a>1-t&&(this.data.window.y=1-a)),this.setStyle()}},{key:"registerDragDialog",value:function(){var e=this;this.dragHandle.current.onmousedown=function(t){if(!e.state.isFullScreen){document.body.style.userSelect="none";var n=t.clientX-e.containerRef.current.offsetLeft,r=t.clientY-e.containerRef.current.offsetTop,i=function(t){if(!e.disabled){e.data.showMode="window";var i=Ne(t.clientX-n,t.clientY-r,e.data.window.width,e.data.window.height),o=i.x,a=i.y;Object.assign(e.data.window,{x:o,y:a}),e.setStyle()}},o=function(){document.body.style.userSelect="",document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",o),e.disabled||e.snapToEdge()};document.addEventListener("mousemove",i),document.addEventListener("mouseup",o)}}}},{key:"registerDragDialogBorder",value:function(){var e=this;o(this.containerRef.current).resizable({edges:{top:!0,right:!0,bottom:!0,left:!0},margin:6,modifiers:[o.modifiers.restrictEdges({outer:document.body}),o.modifiers.restrictSize({min:{width:this.data.minWidth,height:this.data.minHeight}})],inertia:!0,listeners:{move:function(t){if(!e.state.isFullScreen){var n="side"===e.data.showMode?e.data.side:e.data.window;n.x=t.rect.left/window.innerWidth,n.y=t.rect.top/window.innerHeight,n.width=t.rect.width/window.innerWidth,n.height=t.rect.height/window.innerHeight,e.setStyle()}},start:function(){e.disabled=!0,document.body.style.userSelect="none"},end:function(){e.disabled=!1,document.body.style.userSelect=""}}})}},{key:"handleFullScreenChange",value:function(){this.setState({isFullScreen:null!==document.fullscreenElement})}},{key:"componentDidMount",value:function(){this.handleFullScreenChange=this.handleFullScreenChange.bind(this);var e=localStorage.getItem(Cr.STYLE_CACHE);if(e){var t=JSON.parse(e);t.side&&Oe(t.side)&&t.window&&Oe(t.window)&&Object.assign(this.data,t)}this.setStyle(),this.registerDragDialog(),this.registerDragDialogBorder(),document.addEventListener("fullscreenchange",this.handleFullScreenChange)}},{key:"componentWillUnmount",value:function(){document.removeEventListener("fullscreenchange",this.handleFullScreenChange)}},{key:"close",value:function(){this.props.close()}},{key:"fullScreen",value:function(){var e=this.containerRef.current;e&&(e.requestFullscreen(),this.props.fullscreen(!0))}},{key:"closeFullScreen",value:function(){var e;this.state.isFullScreen&&(null===(e=document)||void 0===e||e.exitFullscreen(),this.props.fullscreen(!1),this.setStyle())}},{key:"minimize",value:function(){this.closeFullScreen(),this.setState({isMinimize:!0}),this.props.minimize(!0)}},{key:"exitMinimize",value:function(){this.setState({isMinimize:!1}),this.props.minimize(!1)}},{key:"stopPropagation",value:function(e){e.stopPropagation()}},{key:"render",value:function(){return he($f.Provider,{value:this.containerContext,children:he("div",{className:"".concat(this.ns.b()),children:[he("div",{className:"".concat(this.ns.e("dialog")," ").concat(this.ns.is("full-screen",this.state.isFullScreen)," ").concat(this.ns.is("hidden",this.state.isMinimize)),ref:this.containerRef,children:[he("div",{ref:this.dragHandle,className:this.ns.b("header"),children:[he("div",{className:this.ns.b("header-caption"),children:this.props.caption||"AI助手"}),he("div",{className:this.ns.b("header-action-wrapper"),children:[this.state.enableAIMinimize&&he("div",{title:"最小化",className:"".concat(this.ns.be("header-action-wrapper","action-item")," ").concat(this.ns.be("header-action-wrapper","minimize")),onMouseDown:this.stopPropagation.bind(this),onClick:this.minimize.bind(this),children:he($t,{})}),this.state.isFullScreen?he("div",{title:"退出全屏",className:"".concat(this.ns.be("header-action-wrapper","action-item")," ").concat(this.ns.be("header-action-wrapper","close-full-screen")),onMouseDown:this.stopPropagation.bind(this),onClick:this.closeFullScreen.bind(this),children:he(Ft,{})}):he("div",{title:"全屏",className:"".concat(this.ns.be("header-action-wrapper","action-item")," ").concat(this.ns.be("header-action-wrapper","full-screen")),onMouseDown:this.stopPropagation.bind(this),onClick:this.fullScreen.bind(this),children:he(Vt,{})}),he("div",{title:"关闭",className:"".concat(this.ns.be("header-action-wrapper","action-item")," ").concat(this.ns.be("header-action-wrapper","action-close")),onMouseDown:this.stopPropagation.bind(this),onClick:this.close.bind(this),children:he(It,{})})]})]}),"TOPIC"===this.props.mode?he("div",{className:"".concat(this.ns.b("main")),children:[!this.props.hideTopicSidebar&&he("div",{className:"".concat(this.ns.be("main","left")),children:he(Bf,{controller:this.props.aiTopic})}),he("div",{className:"".concat(this.ns.be("main","right")),style:{width:this.props.hideTopicSidebar?"100%":"calc(100% - 200px)"},children:[he("div",{className:this.ns.b("content"),children:he(Kn,{controller:this.props.aiChat,toolbarItems:this.props.contentToolbarItems})}),he(qn,{type:"footer",mode:this.props.mode,hideTopicSidebar:this.props.hideTopicSidebar,data:this.props.aiTopic.activedTopic.value,className:"".concat(this.ns.e("toolbar")," ").concat(this.ns.is("has-materials",this.props.aiChat.materials.value.length>0)),controller:this.props.aiChat,items:this.props.footerToolbarItems}),he("div",{className:this.ns.b("footer"),children:he(Df,{controller:this.props.aiChat,questionToolbarItems:this.props.questionToolbarItems})})]})]}):he("div",{className:"".concat(this.ns.be("main","default")),children:[he("div",{className:this.ns.b("content"),children:he(Kn,{controller:this.props.aiChat,toolbarItems:this.props.contentToolbarItems})}),he(qn,{type:"footer",mode:this.props.mode,hideTopicSidebar:this.props.hideTopicSidebar,data:this.props.aiTopic.activedTopic.value,className:"".concat(this.ns.e("toolbar")," ").concat(this.ns.is("has-materials",this.props.aiChat.materials.value.length>0)),controller:this.props.aiChat,items:this.props.footerToolbarItems}),he("div",{className:this.ns.b("footer"),children:he(Df,{controller:this.props.aiChat,questionToolbarItems:this.props.questionToolbarItems})})]})]}),he(Ff,{title:this.props.caption||"AI助手",controller:this.props.aiChat,isMinimize:this.state.isMinimize,onClick:this.exitMinimize.bind(this)})]})})}}])}(W);t("ChatContainer",jf)}}})}();