@pie-element/extended-text-entry 14.2.0-next.3 → 14.2.0-next.5

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.
@@ -0,0 +1 @@
1
+ import{_dll_react as e,_dll_react_dom as t,_dll_mui__material as n,_dll_mui__material_styles as r,_dll_prop_types as i,_dll_mui__icons_material as o,_dll_classnames as s,_dll_pie_lib__render_ui as a,_dll_debug as l,_dll_mui__material_collapse as c}from"../../../@pie-lib/shared-module@^4.1.0/module/index.js";import{_dll_pie_lib__math_rendering as u}from"../../../@pie-lib/math-rendering-module@^4.1.0/module/index.js";import{_dll_pie_lib__math_input as d,_dll_pie_lib__math_toolbar as p}from"../../../@pie-lib/math-edit-module@^3.2.0/module/index.js";import{grey as h}from"@mui/material/colors";import f from"@mui/material/Input";var m="object"==typeof global&&global&&global.Object===Object&&global,g="object"==typeof self&&self&&self.Object===Object&&self,y=m||g||Function("return this")(),v=y.Symbol,b=Object.prototype,w=b.hasOwnProperty,x=b.toString,M=v?v.toStringTag:void 0;var S=Object.prototype.toString;var E=v?v.toStringTag:void 0;function C(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":E&&E in Object(e)?function(e){var t=w.call(e,M),n=e[M];try{e[M]=void 0;var r=!0}catch(e){}var i=x.call(e);return r&&(t?e[M]=n:delete e[M]),i}(e):function(e){return S.call(e)}(e)}function N(e){return null!=e&&"object"==typeof e}function A(e){return"symbol"==typeof e||N(e)&&"[object Symbol]"==C(e)}function k(e,t){for(var n=-1,r=null==e?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}var T=Array.isArray,O=v?v.prototype:void 0,_=O?O.toString:void 0;function R(e){if("string"==typeof e)return e;if(T(e))return k(e,R)+"";if(A(e))return _?_.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}var D=/\s/;var I=/^\s+/;function L(e){return e?e.slice(0,function(e){for(var t=e.length;t--&&D.test(e.charAt(t)););return t}(e)+1).replace(I,""):e}function B(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}var z=/^[-+]0x[0-9a-f]+$/i,P=/^0b[01]+$/i,j=/^0o[0-7]+$/i,F=parseInt;function $(e){if("number"==typeof e)return e;if(A(e))return NaN;if(B(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=B(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=L(e);var n=P.test(e);return n||j.test(e)?F(e.slice(2),n?2:8):z.test(e)?NaN:+e}function H(e){return e}function U(e){if(!B(e))return!1;var t=C(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var q,V=y["__core-js_shared__"],W=(q=/[^.]+$/.exec(V&&V.keys&&V.keys.IE_PROTO||""))?"Symbol(src)_1."+q:"";var K=Function.prototype.toString;function G(e){if(null!=e){try{return K.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var J=/^\[object .+?Constructor\]$/,Y=Function.prototype,Z=Object.prototype,X=Y.toString,Q=Z.hasOwnProperty,ee=RegExp("^"+X.call(Q).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function te(e){return!(!B(e)||(t=e,W&&W in t))&&(U(e)?ee:J).test(G(e));var t}function ne(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return te(n)?n:void 0}var re=ne(y,"WeakMap"),ie=Object.create,oe=function(){function e(){}return function(t){if(!B(t))return{};if(ie)return ie(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function se(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}var ae=Date.now;var le,ce,ue,de=function(){try{var e=ne(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),pe=de,he=pe?function(e,t){return pe(e,"toString",{configurable:!0,enumerable:!1,value:(n=t,function(){return n}),writable:!0});var n}:H,fe=(le=he,ce=0,ue=0,function(){var e=ae(),t=16-(e-ue);if(ue=e,t>0){if(++ce>=800)return arguments[0]}else ce=0;return le.apply(void 0,arguments)});function me(e){return e!=e}function ge(e,t){return!!(null==e?0:e.length)&&function(e,t,n){return t==t?function(e,t,n){for(var r=n-1,i=e.length;++r<i;)if(e[r]===t)return r;return-1}(e,t,n):function(e,t,n,r){for(var i=e.length,o=n+(r?1:-1);r?o--:++o<i;)if(t(e[o],o,e))return o;return-1}(e,me,n)}(e,t,0)>-1}var ye=/^(?:0|[1-9]\d*)$/;function ve(e,t){var n=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==n||"symbol"!=n&&ye.test(e))&&e>-1&&e%1==0&&e<t}function be(e,t,n){"__proto__"==t&&pe?pe(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function we(e,t){return e===t||e!=e&&t!=t}var xe=Object.prototype.hasOwnProperty;function Me(e,t,n){var r=e[t];xe.call(e,t)&&we(r,n)&&(void 0!==n||t in e)||be(e,t,n)}function Se(e,t,n,r){var i=!n;n||(n={});for(var o=-1,s=t.length;++o<s;){var a=t[o],l=r?r(n[a],e[a],a,n,e):void 0;void 0===l&&(l=e[a]),i?be(n,a,l):Me(n,a,l)}return n}var Ee=Math.max;function Ce(e,t,n){return t=Ee(void 0===t?e.length-1:t,0),function(){for(var r=arguments,i=-1,o=Ee(r.length-t,0),s=Array(o);++i<o;)s[i]=r[t+i];i=-1;for(var a=Array(t+1);++i<t;)a[i]=r[i];return a[t]=n(s),function(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}(e,this,a)}}function Ne(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}function Ae(e){return null!=e&&Ne(e.length)&&!U(e)}var ke=Object.prototype;function Te(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||ke)}function Oe(e){return N(e)&&"[object Arguments]"==C(e)}var _e=Object.prototype,Re=_e.hasOwnProperty,De=_e.propertyIsEnumerable,Ie=Oe(function(){return arguments}())?Oe:function(e){return N(e)&&Re.call(e,"callee")&&!De.call(e,"callee")};var Le="object"==typeof exports&&exports&&!exports.nodeType&&exports,Be=Le&&"object"==typeof module&&module&&!module.nodeType&&module,ze=Be&&Be.exports===Le?y.Buffer:void 0,Pe=(ze?ze.isBuffer:void 0)||function(){return!1},je={};function Fe(e){return function(t){return e(t)}}je["[object Float32Array]"]=je["[object Float64Array]"]=je["[object Int8Array]"]=je["[object Int16Array]"]=je["[object Int32Array]"]=je["[object Uint8Array]"]=je["[object Uint8ClampedArray]"]=je["[object Uint16Array]"]=je["[object Uint32Array]"]=!0,je["[object Arguments]"]=je["[object Array]"]=je["[object ArrayBuffer]"]=je["[object Boolean]"]=je["[object DataView]"]=je["[object Date]"]=je["[object Error]"]=je["[object Function]"]=je["[object Map]"]=je["[object Number]"]=je["[object Object]"]=je["[object RegExp]"]=je["[object Set]"]=je["[object String]"]=je["[object WeakMap]"]=!1;var $e="object"==typeof exports&&exports&&!exports.nodeType&&exports,He=$e&&"object"==typeof module&&module&&!module.nodeType&&module,Ue=He&&He.exports===$e&&m.process,qe=function(){try{var e=He&&He.require&&He.require("util").types;return e||Ue&&Ue.binding&&Ue.binding("util")}catch(e){}}(),Ve=qe,We=Ve&&Ve.isTypedArray,Ke=We?Fe(We):function(e){return N(e)&&Ne(e.length)&&!!je[C(e)]},Ge=Object.prototype.hasOwnProperty;function Je(e,t){var n=T(e),r=!n&&Ie(e),i=!n&&!r&&Pe(e),o=!n&&!r&&!i&&Ke(e),s=n||r||i||o,a=s?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],l=a.length;for(var c in e)!t&&!Ge.call(e,c)||s&&("length"==c||i&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||ve(c,l))||a.push(c);return a}function Ye(e,t){return function(n){return e(t(n))}}var Ze=Ye(Object.keys,Object),Xe=Object.prototype.hasOwnProperty;function Qe(e){if(!Te(e))return Ze(e);var t=[];for(var n in Object(e))Xe.call(e,n)&&"constructor"!=n&&t.push(n);return t}function et(e){return Ae(e)?Je(e):Qe(e)}var tt=Object.prototype.hasOwnProperty;function nt(e){if(!B(e))return function(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t}(e);var t=Te(e),n=[];for(var r in e)("constructor"!=r||!t&&tt.call(e,r))&&n.push(r);return n}function rt(e){return Ae(e)?Je(e,!0):nt(e)}var it=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ot=/^\w*$/;var st=ne(Object,"create");var at=Object.prototype.hasOwnProperty;var lt=Object.prototype.hasOwnProperty;function ct(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ut(e,t){for(var n=e.length;n--;)if(we(e[n][0],t))return n;return-1}ct.prototype.clear=function(){this.__data__=st?st(null):{},this.size=0},ct.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},ct.prototype.get=function(e){var t=this.__data__;if(st){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return at.call(t,e)?t[e]:void 0},ct.prototype.has=function(e){var t=this.__data__;return st?void 0!==t[e]:lt.call(t,e)},ct.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=st&&void 0===t?"__lodash_hash_undefined__":t,this};var dt=Array.prototype.splice;function pt(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}pt.prototype.clear=function(){this.__data__=[],this.size=0},pt.prototype.delete=function(e){var t=this.__data__,n=ut(t,e);return!(n<0)&&(n==t.length-1?t.pop():dt.call(t,n,1),--this.size,!0)},pt.prototype.get=function(e){var t=this.__data__,n=ut(t,e);return n<0?void 0:t[n][1]},pt.prototype.has=function(e){return ut(this.__data__,e)>-1},pt.prototype.set=function(e,t){var n=this.__data__,r=ut(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this};var ht=ne(y,"Map");function ft(e,t){var n,r,i=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?i["string"==typeof t?"string":"hash"]:i.map}function mt(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}mt.prototype.clear=function(){this.size=0,this.__data__={hash:new ct,map:new(ht||pt),string:new ct}},mt.prototype.delete=function(e){var t=ft(this,e).delete(e);return this.size-=t?1:0,t},mt.prototype.get=function(e){return ft(this,e).get(e)},mt.prototype.has=function(e){return ft(this,e).has(e)},mt.prototype.set=function(e,t){var n=ft(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this};function gt(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var s=e.apply(this,r);return n.cache=o.set(i,s)||o,s};return n.cache=new(gt.Cache||mt),n}gt.Cache=mt;var yt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,vt=/\\(\\)?/g,bt=function(e){var t=gt(e,function(e){return 500===n.size&&n.clear(),e}),n=t.cache;return t}(function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(yt,function(e,n,r,i){t.push(r?i.replace(vt,"$1"):n||e)}),t}),wt=bt;function xt(e,t){return T(e)?e:function(e,t){if(T(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!A(e))||ot.test(e)||!it.test(e)||null!=t&&e in Object(t)}(e,t)?[e]:wt(function(e){return null==e?"":R(e)}(e))}function Mt(e){if("string"==typeof e||A(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function St(e,t){for(var n=0,r=(t=xt(t,e)).length;null!=e&&n<r;)e=e[Mt(t[n++])];return n&&n==r?e:void 0}function Et(e,t,n){var r=null==e?void 0:St(e,t);return void 0===r?n:r}function Ct(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}var Nt=v?v.isConcatSpreadable:void 0;function At(e){return T(e)||Ie(e)||!!(Nt&&e&&e[Nt])}function kt(e,t,n,r,i){var o=-1,s=e.length;for(n||(n=At),i||(i=[]);++o<s;){var a=e[o];t>0&&n(a)?t>1?kt(a,t-1,n,r,i):Ct(i,a):r||(i[i.length]=a)}return i}function Tt(e){return(null==e?0:e.length)?kt(e,1):[]}var Ot=Ye(Object.getPrototypeOf,Object),_t=Function.prototype,Rt=Object.prototype,Dt=_t.toString,It=Rt.hasOwnProperty,Lt=Dt.call(Object);function Bt(e){if(!N(e)||"[object Object]"!=C(e))return!1;var t=Ot(e);if(null===t)return!0;var n=It.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Dt.call(n)==Lt}function zt(e){var t=this.__data__=new pt(e);this.size=t.size}zt.prototype.clear=function(){this.__data__=new pt,this.size=0},zt.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},zt.prototype.get=function(e){return this.__data__.get(e)},zt.prototype.has=function(e){return this.__data__.has(e)},zt.prototype.set=function(e,t){var n=this.__data__;if(n instanceof pt){var r=n.__data__;if(!ht||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new mt(r)}return n.set(e,t),this.size=n.size,this};var Pt="object"==typeof exports&&exports&&!exports.nodeType&&exports,jt=Pt&&"object"==typeof module&&module&&!module.nodeType&&module,Ft=jt&&jt.exports===Pt?y.Buffer:void 0,$t=Ft?Ft.allocUnsafe:void 0;function Ht(e,t){if(t)return e.slice();var n=e.length,r=$t?$t(n):new e.constructor(n);return e.copy(r),r}function Ut(){return[]}var qt=Object.prototype.propertyIsEnumerable,Vt=Object.getOwnPropertySymbols,Wt=Vt?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var n=-1,r=null==e?0:e.length,i=0,o=[];++n<r;){var s=e[n];t(s,n,e)&&(o[i++]=s)}return o}(Vt(e),function(t){return qt.call(e,t)}))}:Ut,Kt=Wt;var Gt=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)Ct(t,Kt(e)),e=Ot(e);return t}:Ut;function Jt(e,t,n){var r=t(e);return T(e)?r:Ct(r,n(e))}function Yt(e){return Jt(e,et,Kt)}function Zt(e){return Jt(e,rt,Gt)}var Xt=ne(y,"DataView"),Qt=ne(y,"Promise"),en=ne(y,"Set"),tn="[object Map]",nn="[object Promise]",rn="[object Set]",on="[object WeakMap]",sn="[object DataView]",an=G(Xt),ln=G(ht),cn=G(Qt),un=G(en),dn=G(re),pn=C;(Xt&&pn(new Xt(new ArrayBuffer(1)))!=sn||ht&&pn(new ht)!=tn||Qt&&pn(Qt.resolve())!=nn||en&&pn(new en)!=rn||re&&pn(new re)!=on)&&(pn=function(e){var t=C(e),n="[object Object]"==t?e.constructor:void 0,r=n?G(n):"";if(r)switch(r){case an:return sn;case ln:return tn;case cn:return nn;case un:return rn;case dn:return on}return t});var hn=pn,fn=Object.prototype.hasOwnProperty;var mn=y.Uint8Array;function gn(e){var t=new e.constructor(e.byteLength);return new mn(t).set(new mn(e)),t}var yn=/\w*$/;var vn=v?v.prototype:void 0,bn=vn?vn.valueOf:void 0;function wn(e,t){var n=t?gn(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function xn(e,t,n){var r,i,o,s=e.constructor;switch(t){case"[object ArrayBuffer]":return gn(e);case"[object Boolean]":case"[object Date]":return new s(+e);case"[object DataView]":return function(e,t){var n=t?gn(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,n);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return wn(e,n);case"[object Map]":case"[object Set]":return new s;case"[object Number]":case"[object String]":return new s(e);case"[object RegExp]":return(o=new(i=e).constructor(i.source,yn.exec(i))).lastIndex=i.lastIndex,o;case"[object Symbol]":return r=e,bn?Object(bn.call(r)):{}}}function Mn(e){return"function"!=typeof e.constructor||Te(e)?{}:oe(Ot(e))}var Sn=Ve&&Ve.isMap,En=Sn?Fe(Sn):function(e){return N(e)&&"[object Map]"==hn(e)};var Cn=Ve&&Ve.isSet,Nn=Cn?Fe(Cn):function(e){return N(e)&&"[object Set]"==hn(e)},An="[object Arguments]",kn="[object Function]",Tn="[object Object]",On={};function _n(e,t,n,r,i,o){var s,a=1&t,l=2&t,c=4&t;if(n&&(s=i?n(e,r,i,o):n(e)),void 0!==s)return s;if(!B(e))return e;var u=T(e);if(u){if(s=function(e){var t=e.length,n=new e.constructor(t);return t&&"string"==typeof e[0]&&fn.call(e,"index")&&(n.index=e.index,n.input=e.input),n}(e),!a)return se(e,s)}else{var d=hn(e),p=d==kn||"[object GeneratorFunction]"==d;if(Pe(e))return Ht(e,a);if(d==Tn||d==An||p&&!i){if(s=l||p?{}:Mn(e),!a)return l?function(e,t){return Se(e,Gt(e),t)}(e,function(e,t){return e&&Se(t,rt(t),e)}(s,e)):function(e,t){return Se(e,Kt(e),t)}(e,function(e,t){return e&&Se(t,et(t),e)}(s,e))}else{if(!On[d])return i?e:{};s=xn(e,d,a)}}o||(o=new zt);var h=o.get(e);if(h)return h;o.set(e,s),Nn(e)?e.forEach(function(r){s.add(_n(r,t,n,r,e,o))}):En(e)&&e.forEach(function(r,i){s.set(i,_n(r,t,n,i,e,o))});var f=u?void 0:(c?l?Zt:Yt:l?rt:et)(e);return function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r&&!1!==t(e[n],n,e););}(f||e,function(r,i){f&&(r=e[i=r]),Me(s,i,_n(r,t,n,i,e,o))}),s}On[An]=On["[object Array]"]=On["[object ArrayBuffer]"]=On["[object DataView]"]=On["[object Boolean]"]=On["[object Date]"]=On["[object Float32Array]"]=On["[object Float64Array]"]=On["[object Int8Array]"]=On["[object Int16Array]"]=On["[object Int32Array]"]=On["[object Map]"]=On["[object Number]"]=On[Tn]=On["[object RegExp]"]=On["[object Set]"]=On["[object String]"]=On["[object Symbol]"]=On["[object Uint8Array]"]=On["[object Uint8ClampedArray]"]=On["[object Uint16Array]"]=On["[object Uint32Array]"]=!0,On["[object Error]"]=On[kn]=On["[object WeakMap]"]=!1;function Rn(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new mt;++t<n;)this.add(e[t])}function Dn(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}function In(e,t){return e.has(t)}Rn.prototype.add=Rn.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},Rn.prototype.has=function(e){return this.__data__.has(e)};function Ln(e,t,n,r,i,o){var s=1&n,a=e.length,l=t.length;if(a!=l&&!(s&&l>a))return!1;var c=o.get(e),u=o.get(t);if(c&&u)return c==t&&u==e;var d=-1,p=!0,h=2&n?new Rn:void 0;for(o.set(e,t),o.set(t,e);++d<a;){var f=e[d],m=t[d];if(r)var g=s?r(m,f,d,t,e,o):r(f,m,d,e,t,o);if(void 0!==g){if(g)continue;p=!1;break}if(h){if(!Dn(t,function(e,t){if(!In(h,t)&&(f===e||i(f,e,n,r,o)))return h.push(t)})){p=!1;break}}else if(f!==m&&!i(f,m,n,r,o)){p=!1;break}}return o.delete(e),o.delete(t),p}function Bn(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function zn(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}var Pn=v?v.prototype:void 0,jn=Pn?Pn.valueOf:void 0;var Fn=Object.prototype.hasOwnProperty;var $n="[object Arguments]",Hn="[object Array]",Un="[object Object]",qn=Object.prototype.hasOwnProperty;function Vn(e,t,n,r,i,o){var s=T(e),a=T(t),l=s?Hn:hn(e),c=a?Hn:hn(t),u=(l=l==$n?Un:l)==Un,d=(c=c==$n?Un:c)==Un,p=l==c;if(p&&Pe(e)){if(!Pe(t))return!1;s=!0,u=!1}if(p&&!u)return o||(o=new zt),s||Ke(e)?Ln(e,t,n,r,i,o):function(e,t,n,r,i,o,s){switch(n){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=t.byteLength||!o(new mn(e),new mn(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return we(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var a=Bn;case"[object Set]":var l=1&r;if(a||(a=zn),e.size!=t.size&&!l)return!1;var c=s.get(e);if(c)return c==t;r|=2,s.set(e,t);var u=Ln(a(e),a(t),r,i,o,s);return s.delete(e),u;case"[object Symbol]":if(jn)return jn.call(e)==jn.call(t)}return!1}(e,t,l,n,r,i,o);if(!(1&n)){var h=u&&qn.call(e,"__wrapped__"),f=d&&qn.call(t,"__wrapped__");if(h||f){var m=h?e.value():e,g=f?t.value():t;return o||(o=new zt),i(m,g,n,r,o)}}return!!p&&(o||(o=new zt),function(e,t,n,r,i,o){var s=1&n,a=Yt(e),l=a.length;if(l!=Yt(t).length&&!s)return!1;for(var c=l;c--;){var u=a[c];if(!(s?u in t:Fn.call(t,u)))return!1}var d=o.get(e),p=o.get(t);if(d&&p)return d==t&&p==e;var h=!0;o.set(e,t),o.set(t,e);for(var f=s;++c<l;){var m=e[u=a[c]],g=t[u];if(r)var y=s?r(g,m,u,t,e,o):r(m,g,u,e,t,o);if(!(void 0===y?m===g||i(m,g,n,r,o):y)){h=!1;break}f||(f="constructor"==u)}if(h&&!f){var v=e.constructor,b=t.constructor;v==b||!("constructor"in e)||!("constructor"in t)||"function"==typeof v&&v instanceof v&&"function"==typeof b&&b instanceof b||(h=!1)}return o.delete(e),o.delete(t),h}(e,t,n,r,i,o))}function Wn(e,t,n,r,i){return e===t||(null==e||null==t||!N(e)&&!N(t)?e!=e&&t!=t:Vn(e,t,n,r,Wn,i))}var Kn,Gn=function(e,t,n){for(var r=-1,i=Object(e),o=n(e),s=o.length;s--;){var a=o[Kn?s:++r];if(!1===t(i[a],a,i))break}return e},Jn=Gn,Yn=function(){return y.Date.now()},Zn=Math.max,Xn=Math.min;function Qn(e,t,n){var r,i,o,s,a,l,c=0,u=!1,d=!1,p=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function h(t){var n=r,o=i;return r=i=void 0,c=t,s=e.apply(o,n)}function f(e){var n=e-l;return void 0===l||n>=t||n<0||d&&e-c>=o}function m(){var e=Yn();if(f(e))return g(e);a=setTimeout(m,function(e){var n=t-(e-l);return d?Xn(n,o-(e-c)):n}(e))}function g(e){return a=void 0,p&&r?h(e):(r=i=void 0,s)}function y(){var e=Yn(),n=f(e);if(r=arguments,i=this,l=e,n){if(void 0===a)return function(e){return c=e,a=setTimeout(m,t),u?h(e):s}(l);if(d)return clearTimeout(a),a=setTimeout(m,t),h(l)}return void 0===a&&(a=setTimeout(m,t)),s}return t=$(t)||0,B(n)&&(u=!!n.leading,o=(d="maxWait"in n)?Zn($(n.maxWait)||0,t):o,p="trailing"in n?!!n.trailing:p),y.cancel=function(){void 0!==a&&clearTimeout(a),c=0,r=l=i=a=void 0},y.flush=function(){return void 0===a?s:g(Yn())},y}function er(e,t,n){(void 0!==n&&!we(e[t],n)||void 0===n&&!(t in e))&&be(e,t,n)}function tr(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}function nr(e,t,n,r,i,o,s){var a=tr(e,n),l=tr(t,n),c=s.get(l);if(c)er(e,n,c);else{var u,d=o?o(a,l,n+"",e,t,s):void 0,p=void 0===d;if(p){var h=T(l),f=!h&&Pe(l),m=!h&&!f&&Ke(l);d=l,h||f||m?T(a)?d=a:N(u=a)&&Ae(u)?d=se(a):f?(p=!1,d=Ht(l,!0)):m?(p=!1,d=wn(l,!0)):d=[]:Bt(l)||Ie(l)?(d=a,Ie(a)?d=function(e){return Se(e,rt(e))}(a):B(a)&&!U(a)||(d=Mn(l))):p=!1}p&&(s.set(l,d),i(d,l,r,o,s),s.delete(l)),er(e,n,d)}}function rr(e,t,n,r,i){e!==t&&Jn(t,function(o,s){if(i||(i=new zt),B(o))nr(e,t,s,n,rr,r,i);else{var a=r?r(tr(e,s),o,s+"",e,t,i):void 0;void 0===a&&(a=o),er(e,s,a)}},rt)}function ir(e,t,n){for(var r=-1,i=null==e?0:e.length;++r<i;)if(n(t,e[r]))return!0;return!1}function or(e,t){return t.length<2?e:St(e,function(e,t,n){var r=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(n=n>i?i:n)<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var o=Array(i);++r<i;)o[r]=e[r+t];return o}(t,0,-1))}var sr=Object.prototype.hasOwnProperty;function ar(e,t){return Wn(e,t)}var lr=y.isFinite;function cr(e){return"number"==typeof e&&lr(e)}var ur,dr=(ur=function(e,t,n){rr(e,t,n)},function(e,t){return fe(Ce(e,t,H),e+"")}(function(e,t){var n=-1,r=t.length,i=r>1?t[r-1]:void 0,o=r>2?t[2]:void 0;for(i=ur.length>3&&"function"==typeof i?(r--,i):void 0,o&&function(e,t,n){if(!B(n))return!1;var r=typeof t;return!!("number"==r?Ae(n)&&ve(t,n.length):"string"==r&&t in n)&&we(n[t],e)}(t[0],t[1],o)&&(i=r<3?void 0:i,r=1),e=Object(e);++n<r;){var s=t[n];s&&ur(e,s,n,i)}return e})),pr=dr,hr=Object.prototype.hasOwnProperty;function fr(e,t){var n=-1,r=(t=xt(t,e)).length;if(!r)return!0;for(var i=null==e||"object"!=typeof e&&"function"!=typeof e;++n<r;){var o=t[n];if("string"==typeof o){if("__proto__"===o&&!hr.call(e,"__proto__"))return!1;if("constructor"===o&&n+1<r&&"string"==typeof t[n+1]&&"prototype"===t[n+1]){if(i&&0===n)continue;return!1}}}var s=or(e,t);return null==s||delete s[Mt(function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}(t))]}function mr(e){return Bt(e)?void 0:e}var gr=function(e){return fe(Ce(e,void 0,Tt),e+"")}(function(e,t){var n={};if(null==e)return n;var r=!1;t=k(t,function(t){return t=xt(t,e),r||(r=t.length>1),t}),Se(e,Zt(e),n),r&&(n=_n(n,7,mr));for(var i=t.length;i--;)fr(n,t[i]);return n}),yr=gr;function vr(e,t,n){return null==e?e:function(e,t,n,r){if(!B(e))return e;for(var i=-1,o=(t=xt(t,e)).length,s=o-1,a=e;null!=a&&++i<o;){var l=Mt(t[i]),c=n;if("__proto__"===l||"constructor"===l||"prototype"===l)return e;if(i!=s){var u=a[l];void 0===(c=r?r(u,l,a):void 0)&&(c=B(u)?u:ve(t[i+1])?[]:{})}Me(a,l,c),a=a[l]}return e}(e,t,n)}var br=en&&1/zn(new en([,-0]))[1]==1/0?function(e){return new en(e)}:function(){};function wr(e){return e&&e.length?function(e,t,n){var r=-1,i=ge,o=e.length,s=!0,a=[],l=a;if(n)s=!1,i=ir;else if(o>=200){var c=t?null:br(e);if(c)return zn(c);s=!1,i=In,l=new Rn}else l=t?[]:a;e:for(;++r<o;){var u=e[r],d=t?t(u):u;if(u=n||0!==u?u:0,s&&d==d){for(var p=l.length;p--;)if(l[p]===d)continue e;t&&l.push(d),a.push(u)}else i(l,d,n)||(l!==a&&l.push(d),a.push(u))}return a}(e):[]}var xr="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},Mr={exports:{}},Sr={};var Er=e;var Cr="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},Nr=Er.useState,Ar=Er.useEffect,kr=Er.useLayoutEffect,Tr=Er.useDebugValue;function Or(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Cr(e,n)}catch(e){return!0}}var _r="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),r=Nr({inst:{value:n,getSnapshot:t}}),i=r[0].inst,o=r[1];return kr(function(){i.value=n,i.getSnapshot=t,Or(i)&&o({inst:i})},[e,n,t]),Ar(function(){return Or(i)&&o({inst:i}),e(function(){Or(i)&&o({inst:i})})},[e]),Tr(n),n};Sr.useSyncExternalStore=void 0!==Er.useSyncExternalStore?Er.useSyncExternalStore:_r,Mr.exports=Sr;var Rr={exports:{}},Dr={};var Ir=e,Lr=Symbol.for("react.element"),Br=Symbol.for("react.fragment"),zr=Object.prototype.hasOwnProperty,Pr=Ir.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,jr={key:!0,ref:!0,__self:!0,__source:!0};function Fr(e,t,n){var r,i={},o=null,s=null;for(r in void 0!==n&&(o=""+n),void 0!==t.key&&(o=""+t.key),void 0!==t.ref&&(s=t.ref),t)zr.call(t,r)&&!jr.hasOwnProperty(r)&&(i[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===i[r]&&(i[r]=t[r]);return{$$typeof:Lr,type:e,key:o,ref:s,props:i,_owner:Pr.current}}function $r(e){this.content=e}function Hr(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let 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(let e=0;i.text[e]==o.text[e];e++)n++;return n}if(i.content.size||o.content.size){let e=Hr(i.content,o.content,n+1);if(null!=e)return e}n+=i.nodeSize}else n+=i.nodeSize}}function Ur(e,t,n,r){for(let i=e.childCount,o=t.childCount;;){if(0==i||0==o)return i==o?null:{a:n,b:r};let s=e.child(--i),a=t.child(--o),l=s.nodeSize;if(s!=a){if(!s.sameMarkup(a))return{a:n,b:r};if(s.isText&&s.text!=a.text){let e=0,t=Math.min(s.text.length,a.text.length);for(;e<t&&s.text[s.text.length-e-1]==a.text[a.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(s.content.size||a.content.size){let e=Ur(s.content,a.content,n-1,r-1);if(e)return e}n-=l,r-=l}else n-=l,r-=l}}Dr.Fragment=Br,Dr.jsx=Fr,Dr.jsxs=Fr,Rr.exports=Dr,$r.prototype={constructor:$r,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 $r(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 $r(n)},addToStart:function(e,t){return new $r([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new $r(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 $r(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=$r.from(e)).size?new $r(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=$r.from(e)).size?new $r(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=$r.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}},$r.from=function(e){if(e instanceof $r)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new $r(t)};class qr{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let o=0,s=0;s<t;o++){let a=this.content[o],l=s+a.nodeSize;if(l>e&&!1!==n(a,r+s,i||null,o)&&a.content.size){let i=s+1;a.nodesBetween(Math.max(0,e-i),Math.min(a.content.size,t-i),n,r+i)}s=l}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i="",o=!0;return this.nodesBetween(e,t,(s,a)=>{let l=s.isText?s.text.slice(Math.max(e,a)-a,t-a):s.isLeaf?r?"function"==typeof r?r(s):r:s.type.spec.leafText?s.type.spec.leafText(s):"":"";s.isBlock&&(s.isLeaf&&l||s.isTextblock)&&n&&(o?o=!1:i+=n),i+=l},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,r=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(n)&&(r[r.length-1]=t.withText(t.text+n.text),i=1);i<e.content.length;i++)r.push(e.content[i]);return new qr(r,this.size+e.size)}cut(e,t=this.size){if(0==e&&t==this.size)return this;let n=[],r=0;if(t>e)for(let i=0,o=0;o<t;i++){let s=this.content[i],a=o+s.nodeSize;a>e&&((o<e||a>t)&&(s=s.isText?s.cut(Math.max(0,e-o),Math.min(s.text.length,t-o)):s.cut(Math.max(0,e-o-1),Math.min(s.content.size,t-o-1))),n.push(s),r+=s.nodeSize),o=a}return new qr(n,r)}cutByIndex(e,t){return e==t?qr.empty:0==e&&t==this.content.length?this:new qr(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let r=this.content.slice(),i=this.size+t.nodeSize-n.nodeSize;return r[e]=t,new qr(r,i)}addToStart(e){return new qr([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new qr(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return Hr(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Ur(this,e,t,n)}findIndex(e){if(0==e)return Wr(0,e);if(e==this.size)return Wr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=n+this.child(t).nodeSize;if(r>=e)return r==e?Wr(t+1,r):Wr(t,n);n=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return qr.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new qr(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return qr.empty;let t,n=0;for(let r=0;r<e.length;r++){let i=e[r];n+=i.nodeSize,r&&i.isText&&e[r-1].sameMarkup(i)?(t||(t=e.slice(0,r)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new qr(t||e,n)}static from(e){if(!e)return qr.empty;if(e instanceof qr)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new qr([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}qr.empty=new qr([],0);const Vr={index:0,offset:0};function Wr(e,t){return Vr.index=e,Vr.offset=t,Vr}function Kr(e,t){if(e===t)return!0;if(!e||"object"!=typeof e||!t||"object"!=typeof t)return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!Kr(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!Kr(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}class Gr{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let 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}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Kr(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw new RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return Gr.none;if(e instanceof Gr)return[e];let t=e.slice();return t.sort((e,t)=>e.type.rank-t.type.rank),t}}Gr.none=[];class Jr extends Error{}class Yr{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=Xr(this.content,e+this.openStart,t);return n&&new Yr(n,this.openStart,this.openEnd)}removeBetween(e,t){return new Yr(Zr(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return Yr.empty;let n=t.openStart||0,r=t.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new Yr(qr.fromJSON(e,t.content),n,r)}static maxOpen(e,t=!0){let n=0,r=0;for(let r=e.firstChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.lastChild)r++;return new Yr(e,n,r)}}function Zr(e,t,n){let{index:r,offset:i}=e.findIndex(t),o=e.maybeChild(r),{index:s,offset:a}=e.findIndex(n);if(i==t||o.isText){if(a!=n&&!e.child(s).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return e.replaceChild(r,o.copy(Zr(o.content,t-i-1,n-i-1)))}function Xr(e,t,n,r){let{index:i,offset:o}=e.findIndex(t),s=e.maybeChild(i);if(o==t||s.isText)return r&&!r.canReplace(i,i,n)?null:e.cut(0,t).append(n).append(e.cut(t));let a=Xr(s.content,t-o-1,n,s);return a&&e.replaceChild(i,s.copy(a))}function Qr(e,t,n){if(n.openStart>e.depth)throw new Jr("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Jr("Inconsistent open depths");return ei(e,t,n,0)}function ei(e,t,n,r){let i=e.index(r),o=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let s=ei(e,t,n,r+1);return o.copy(o.content.replaceChild(i,s))}if(n.content.size){if(n.openStart||n.openEnd||e.depth!=r||t.depth!=r){let{start:i,end:s}=function(e,t){let n=t.depth-e.openStart,r=t.node(n),i=r.copy(e.content);for(let e=n-1;e>=0;e--)i=t.node(e).copy(qr.from(i));return{start:i.resolveNoCache(e.openStart+n),end:i.resolveNoCache(i.content.size-e.openEnd-n)}}(n,e);return oi(o,si(e,i,s,t,r))}{let r=e.parent,i=r.content;return oi(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}}return oi(o,ai(e,t,r))}function ti(e,t){if(!t.type.compatibleContent(e.type))throw new Jr("Cannot join "+t.type.name+" onto "+e.type.name)}function ni(e,t,n){let r=e.node(n);return ti(r,t.node(n)),r}function ri(e,t){let 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 ii(e,t,n,r){let i=(t||e).node(n),o=0,s=t?t.index(n):i.childCount;e&&(o=e.index(n),e.depth>n?o++:e.textOffset&&(ri(e.nodeAfter,r),o++));for(let e=o;e<s;e++)ri(i.child(e),r);t&&t.depth==n&&t.textOffset&&ri(t.nodeBefore,r)}function oi(e,t){return e.type.checkContent(t),e.copy(t)}function si(e,t,n,r,i){let o=e.depth>i&&ni(e,t,i+1),s=r.depth>i&&ni(n,r,i+1),a=[];return ii(null,e,i,a),o&&s&&t.index(i)==n.index(i)?(ti(o,s),ri(oi(o,si(e,t,n,r,i+1)),a)):(o&&ri(oi(o,ai(e,t,i+1)),a),ii(t,n,i,a),s&&ri(oi(s,ai(n,r,i+1)),a)),ii(r,null,i,a),new qr(a)}function ai(e,t,n){let r=[];if(ii(null,e,n,r),e.depth>n){ri(oi(ni(e,t,n+1),ai(e,t,n+1)),r)}return ii(t,null,n,r),new qr(r)}Yr.empty=new Yr(qr.empty,0,0);class li{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return null==e?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[3*t],r=0==t?0:this.path[3*t-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return Gr.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var o=0;o<i.length;o++)!1!==i[o].type.spec.inclusive||r&&i[o].isInSet(r.marks)||(i=i[o--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var 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}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let 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 pi(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let n=[],r=0,i=t;for(let t=e;;){let{index:e,offset:o}=t.content.findIndex(i),s=i-o;if(n.push(t,e,r+o),!s)break;if(t=t.child(e),t.isText)break;i=s-1,r+=o+1}return new li(t,n,i)}static resolveCached(e,t){let n=di.get(e);if(n)for(let e=0;e<n.elts.length;e++){let r=n.elts[e];if(r.pos==t)return r}else di.set(e,n=new ci);let r=n.elts[n.i]=li.resolve(e,t);return n.i=(n.i+1)%ui,r}}class ci{constructor(){this.elts=[],this.i=0}}const ui=12,di=new WeakMap;class pi{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const hi=Object.create(null);class fi{constructor(e,t,n,r=Gr.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||qr.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&Kr(this.attrs,t||e.defaultAttrs||hi)&&Gr.sameSet(this.marks,n||Gr.none)}copy(e=null){return e==this.content?this:new fi(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new fi(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return Yr.empty;let r=this.resolve(e),i=this.resolve(t),o=n?0:r.sharedDepth(t),s=r.start(o),a=r.node(o).content.cut(r.pos-s,i.pos-s);return new Yr(a,r.depth-o,i.depth-o)}replace(e,t,n){return Qr(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(0==e)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return li.resolveCached(this,e)}resolveNoCache(e){return li.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),gi(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=qr.empty,r=0,i=n.childCount){let o=this.contentMatchAt(e).matchFragment(n,r,i),s=o&&o.matchFragment(this.content,t);if(!s||!s.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),o=i&&i.matchFragment(this.content,t);return!!o&&o.validEnd}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=Gr.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!Gr.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n;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)}let r=qr.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}}fi.prototype.text=void 0;class mi extends fi{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):gi(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new mi(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new mi(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return 0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function gi(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class yi{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new vi(e,t);if(null==n.next)return yi.empty;let r=bi(n);n.next&&n.err("Unexpected trailing text");let i=function(e){let t=Object.create(null);return n(Ci(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);Ci(e,n).forEach(e=>{r||i.push([t,r=[]]),-1==r.indexOf(e)&&r.push(e)})})});let o=t[r.join(",")]=new yi(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(Ei);o.next.push({type:i[e][0],next:t[r.join(",")]||n(r)})}return o}}(function(e){let t=[[]];return i(o(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function o(e,t){if("choice"==e.type)return e.exprs.reduce((e,n)=>e.concat(o(n,t)),[]);if("seq"!=e.type){if("star"==e.type){let s=n();return r(t,s),i(o(e.expr,s),s),[r(s)]}if("plus"==e.type){let 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){let s=t;for(let t=0;t<e.min;t++){let t=n();i(o(e.expr,s),t),s=t}if(-1==e.max)i(o(e.expr,s),s);else for(let t=e.min;t<e.max;t++){let t=n();r(s,t),i(o(e.expr,s),t),s=t}return[r(s)]}if("name"==e.type)return[r(t,void 0,e.value)];throw new Error("Unknown expr type")}for(let r=0;;r++){let s=o(e.exprs[r],t);if(r==e.exprs.length-1)return s;i(s,t=n())}}}(r));return function(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,o=[];for(let t=0;t<e.next.length;t++){let{type:n,next:s}=e.next[t];o.push(n.name),!i||n.isText||n.hasRequiredAttrs()||(i=!1),-1==r.indexOf(s)&&r.push(s)}i&&t.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(i,n),i}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!t.isText&&!t.hasRequiredAttrs())return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];return function i(o,s){let a=o.matchFragment(e,n);if(a&&(!t||a.validEnd))return qr.from(s.map(e=>e.createAndFill()));for(let e=0;e<o.next.length;e++){let{type:t,next:n}=o.next[e];if(!t.isText&&!t.hasRequiredAttrs()&&-1==r.indexOf(n)){r.push(n);let e=i(n,s.concat(t));if(e)return e}}return null}(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:o,next:s}=i.next[e];o.isLeaf||o.hasRequiredAttrs()||o.name in t||r.type&&!s.validEnd||(n.push({match:o.contentMatch,type:o,via:r}),t[o.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];return function t(n){e.push(n);for(let r=0;r<n.next.length;r++)-1==e.indexOf(n.next[r].next)&&t(n.next[r].next)}(this),e.map((t,n)=>{let r=n+(t.validEnd?"*":" ")+" ";for(let n=0;n<t.next.length;n++)r+=(n?", ":"")+t.next[n].type.name+"->"+e.indexOf(t.next[n].next);return r}).join("\n")}}yi.empty=new yi(!0);class vi{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function bi(e){let t=[];do{t.push(wi(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function wi(e){let t=[];do{t.push(xi(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function xi(e){let t=function(e){if(e.eat("(")){let t=bi(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){let t=function(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}0==i.length&&e.err("No node type or group '"+t+"' found");return i}(e,e.next).map(t=>(null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t}));return e.pos++,1==t.length?t[0]:{type:"choice",exprs:t}}e.err("Unexpected token '"+e.next+"'")}(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=Si(e,t)}return t}function Mi(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function Si(e,t){let n=Mi(e),r=n;return e.eat(",")&&(r="}"!=e.next?Mi(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}function Ei(e,t){return t-e}function Ci(e,t){let n=[];return function t(r){let i=e[r];if(1==i.length&&!i[0].term)return t(i[0].to);n.push(r);for(let e=0;e<i.length;e++){let{term:r,to:o}=i[e];r||-1!=n.indexOf(o)||t(o)}}(t),n.sort(Ei)}function Ni(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function Ai(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(void 0===i){let t=e[r];if(!t.hasDefault)throw new RangeError("No value supplied for attribute "+r);i=t.default}n[r]=i}return n}function ki(e,t,n,r){for(let r in t)if(!(r in e))throw new RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let n in e){let r=e[n];r.validate&&r.validate(t[n])}}function Ti(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new _i(e,r,t[r]);return n}class Oi{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=Ti(e,n.attrs),this.defaultAttrs=Ni(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==e),this.isText="text"==e}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==yi.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Ai(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new fi(this,this.computeAttrs(e),qr.from(t),Gr.setFrom(n))}createChecked(e=null,t,n){return t=qr.from(t),this.checkContent(t),new fi(this,this.computeAttrs(e),t,Gr.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=qr.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(qr.empty,!0);return i?new fi(this,e,t.append(i),Gr.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){ki(this.attrs,e,"node",this.name)}allowsMarkType(e){return null==this.markSet||this.markSet.indexOf(e)>-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(null==this.markSet)return e;let t;for(let 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:Gr.none:e}static compile(e,t){let n=Object.create(null);e.forEach((e,r)=>n[e]=new Oi(e,t,r));let r=t.spec.topNode||"doc";if(!n[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let e in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}}class _i{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate="string"==typeof n.validate?function(e,t,n){let r=n.split("|");return n=>{let i=null===n?"null":typeof n;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class Ri{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=Ti(e,r.attrs),this.excluded=null;let i=Ni(this.attrs);this.instance=i?new Gr(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Gr(this,Ai(this.attrs,e))}static compile(e,t){let n=Object.create(null),r=0;return e.forEach((e,i)=>n[e]=new Ri(e,r++,t,i)),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){ki(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Di{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=$r.from(e.nodes),t.marks=$r.from(e.marks||{}),this.nodes=Oi.compile(this.spec.nodes,this),this.marks=Ri.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw new RangeError(e+" can not be both a node and a mark");let t=this.nodes[e],r=t.spec.content||"",i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=yi.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!t.isInline||!t.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=t}t.markSet="_"==i?null:i?Ii(this,i.split(" ")):""!=i&&t.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:Ii(this,n.split(" "))}this.nodeFromJSON=e=>fi.fromJSON(this,e),this.markFromJSON=e=>Gr.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof Oi))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)}text(e,t){let n=this.nodes.text;return new mi(n,n.defaultAttrs,e,Gr.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Ii(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],o=e.marks[i],s=o;if(o)n.push(o);else for(let t in e.marks){let r=e.marks[t];("_"==i||r.spec.group&&r.spec.group.split(" ").indexOf(i)>-1)&&n.push(s=r)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}class Li{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(function(e){return null!=e.tag}(e))this.tags.push(e);else if(function(e){return null!=e.style}(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new $i(this,t,!1);return n.addAll(e,Gr.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new $i(this,t,!0);return n.addAll(e,Gr.none,t.from,t.to),Yr.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(Hi(e,n.tag)&&(void 0===n.namespace||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(!1===t)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],o=r.style;if(!(0!=o.indexOf(e)||r.context&&!n.matchesContext(r.context)||o.length>e.length&&(61!=o.charCodeAt(e.length)||o.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(!1===e)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((null==e.priority?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=Ui(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=Ui(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Li(e,Li.schemaRules(e)))}}const Bi={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},Pi={ol:!0,ul:!0};function ji(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}class Fi{constructor(e,t,n,r,i,o){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=o,this.content=[],this.activeMarks=Gr.none,this.match=i||(4&o?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(qr.from(e));if(!t){let t,n=this.type.contentMatch;return(t=n.findWrapping(e.type))?(this.match=n,t):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e,t=this.content[this.content.length-1];if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let n=t;t.text.length==e[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-e[0].length))}}let t=qr.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(qr.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Bi.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class $i{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r,i=t.topNode,o=ji(null,t.preserveWhitespace,0)|(n?4:0);r=i?new Fi(i.type,i.attrs,Gr.none,!0,t.topMatch||i.type.contentMatch,o):new Fi(n?null:e.schema.topNodeType,null,Gr.none,!0,null,o),this.nodes=[r],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){3==e.nodeType?this.addTextNode(e,t):1==e.nodeType&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=2&r.options?"full":this.localPreserveWS||(1&r.options)>0,{schema:o}=this.parser;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())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(o.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(o.text(e[n]),t,!/\S/.test(e[n]));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){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&"BR"==i.nodeName||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}n&&this.insertNode(o.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o,s=e.nodeName.toLowerCase();Pi.hasOwnProperty(s)&&this.parser.normalizeLists&&function(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&Pi.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));e:if(a?a.ignore:zi.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let n,r=this.needsBlock;if(Bi.hasOwnProperty(s))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let o=a&&a.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,a,n,!1===a.consuming?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),t)}ignoreFallback(e,t){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),!1!==n.consuming)break;e=n}}return t}addElementByRule(e,t,n,r){let i,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),n,"BR"==e.nodeName)||this.leafFallback(e,n);else{let e=this.enter(o,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let s=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(e=>this.insertNode(e,n,!1));else{let r=e;"string"==typeof t.contentElement?r=e.querySelector(t.contentElement):"function"==typeof t.contentElement?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(s)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let o=n?e.childNodes[n]:e.firstChild,s=null==r?null:e.childNodes[r];o!=s;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,o=0;t>=0;t--){let s=this.nodes[t],a=s.findWrapping(e);if(a&&(!r||r.length>a.length+o)&&(r=a,i=s,!a.length))break;if(s.solid){if(n)break;o+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&(t.match=t.match.matchType(e.type));let n=Gr.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):qi(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&(i=this.enterInner(e,t,n,!0,r)),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let s=ji(e,i,o.options);4&o.options&&0==o.content.length&&(s|=4);let a=Gr.none;return n=n.filter(t=>!(o.type?o.type.allowsMarkType(t.type):qi(t.type,e))||(a=t.addToSet(a),!1)),this.nodes.push(new Fi(e,t,a,r,null,s)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!(!this.isOpen&&!this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=1)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let 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)}}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,r=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),i=-(n?n.depth+1:0)+(r?0:1),o=(e,s)=>{for(;e>=0;e--){let a=t[e];if(""==a){if(e==t.length-1||0==e)continue;for(;s>=i;s--)if(o(e-1,s))return!0;return!1}{let e=s>0||0==s&&r?this.nodes[s].type:n&&s>=i?n.node(s-i).type:null;if(!e||e.name!=a&&!e.isInGroup(a))return!1;s--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}}function Hi(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Ui(e){let t={};for(let n in e)t[n]=e[n];return t}function qi(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let o=[],s=e=>{o.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t)return!0;if(o.indexOf(i)<0&&s(i))return!0}};if(s(i.contentMatch))return!0}}class Vi{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=Ki(t).createDocumentFragment());let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,o=0;for(;n<i.length&&o<e.marks.length;){let t=e.marks[o];if(this.marks[t.type.name]){if(!t.eq(i[n][0])||!1===t.type.spec.spanning)break;n++,o++}else o++}for(;n<i.length;)r=i.pop()[1];for(;o<e.marks.length;){let n=e.marks[o++],s=this.serializeMark(n,e.isInline,t);s&&(i.push([n,r]),r.appendChild(s.dom),r=s.contentDOM||s.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){let{dom:n,contentDOM:r}=Yi(Ki(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&Yi(Ki(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return Yi(e,t,n,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Vi(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Wi(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return Wi(e.marks)}}function Wi(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function Ki(e){return e.document||window.document}const Gi=new WeakMap;function Ji(e){let t=Gi.get(e);return void 0===t&&Gi.set(e,t=function(e){let t=null;function n(e){if(e&&"object"==typeof e)if(Array.isArray(e))if("string"==typeof e[0])t||(t=[]),t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}(e)),t}function Yi(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;let i,o=t[0];if("string"!=typeof o)throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=Ji(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.");let s,a=o.indexOf(" ");a>0&&(n=o.slice(0,a),o=o.slice(a+1));let l=n?e.createElementNS(n,o):e.createElement(o),c=t[1],u=1;if(c&&"object"==typeof c&&null==c.nodeType&&!Array.isArray(c)){u=2;for(let e in c)if(null!=c[e]){let t=e.indexOf(" ");t>0?l.setAttributeNS(e.slice(0,t),e.slice(t+1),c[e]):"style"==e&&l.style?l.style.cssText=c[e]:l.setAttribute(e,c[e])}}for(let i=u;i<t.length;i++){let o=t[i];if(0===o){if(i<t.length-1||i>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}{let{dom:t,contentDOM:i}=Yi(e,o,n,r);if(l.appendChild(t),i){if(s)throw new RangeError("Multiple content holes");s=i}}}return{dom:l,contentDOM:s}}const Zi=Math.pow(2,16);function Xi(e,t){return e+t*Zi}function Qi(e){return 65535&e}class eo{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class to{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&to.empty)return to.empty}recover(e){let t=0,n=Qi(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[3*e+2]-this.ranges[3*e+1];return this.ranges[3*n]+t+function(e){return(e-(65535&e))/Zi}(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let s=0;s<this.ranges.length;s+=3){let a=this.ranges[s]-(this.inverted?r:0);if(a>e)break;let l=this.ranges[s+i],c=this.ranges[s+o],u=a+l;if(e<=u){let i=a+r+((l?e==a?-1:e==u?1:t:t)<0?0:c);if(n)return i;let o=e==(t<0?a:u)?null:Xi(s/3,e-a),d=e==a?2:e==u?1:4;return(t<0?e!=a:e!=u)&&(d|=8),new eo(i,d,o)}r+=c-l}return n?e+r:new eo(e+r,0,null)}touches(e,t){let n=0,r=Qi(t),i=this.inverted?2:1,o=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let s=this.ranges[t]-(this.inverted?n:0);if(s>e)break;let a=this.ranges[t+i];if(e<=s+a&&t==3*r)return!0;n+=this.ranges[t+o]-a}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let o=this.ranges[r],s=o-(this.inverted?i:0),a=o+(this.inverted?0:i),l=this.ranges[r+t],c=this.ranges[r+n];e(s,s+l,a,a+c),i+=c-l}}invert(){return new to(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?to.empty:new to(e<0?[0,-e,0]:[0,0,e])}}to.empty=new to([]);class no{constructor(e,t,n=0,r=(e?e.length:0)){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new no(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),null!=t&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],null!=r&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror)for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),null!=r&&r>t?n-r-1:void 0)}}invert(){let e=new no;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(null!=i.recover){let t=this.getMirror(n);if(null!=t&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new eo(e,r,null)}}const ro=Object.create(null);class io{getMap(){return to.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=ro[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in ro)throw new RangeError("Duplicate use of step JSON ID "+e);return ro[e]=t,t.prototype.jsonID=e,t}}class oo{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new oo(e,null)}static fail(e){return new oo(null,e)}static fromReplace(e,t,n,r){try{return oo.ok(e.replace(t,n,r))}catch(e){if(e instanceof Jr)return oo.fail(e.message);throw e}}}function so(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let o=e.child(i);o.content.size&&(o=o.copy(so(o.content,t,o))),o.isInline&&(o=t(o,n,i)),r.push(o)}return qr.fromArray(r)}class ao extends io{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new Yr(so(t.content,(e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e,r),t.openStart,t.openEnd);return oo.fromReplace(e,this.from,this.to,i)}invert(){return new lo(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new ao(t.pos,n.pos,this.mark)}merge(e){return e instanceof ao&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ao(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new ao(t.from,t.to,e.markFromJSON(t.mark))}}io.jsonID("addMark",ao);class lo extends io{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new Yr(so(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return oo.fromReplace(e,this.from,this.to,n)}invert(){return new ao(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new lo(t.pos,n.pos,this.mark)}merge(e){return e instanceof lo&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new lo(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new lo(t.from,t.to,e.markFromJSON(t.mark))}}io.jsonID("removeMark",lo);class co extends io{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return oo.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return oo.fromReplace(e,this.pos,this.pos+1,new Yr(qr.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let e=this.mark.addToSet(t.marks);if(e.length==t.marks.length){for(let n=0;n<t.marks.length;n++)if(!t.marks[n].isInSet(e))return new co(this.pos,t.marks[n]);return new co(this.pos,this.mark)}}return new uo(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new co(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new co(t.pos,e.markFromJSON(t.mark))}}io.jsonID("addNodeMark",co);class uo extends io{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return oo.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return oo.fromReplace(e,this.pos,this.pos+1,new Yr(qr.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new co(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new uo(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new uo(t.pos,e.markFromJSON(t.mark))}}io.jsonID("removeNodeMark",uo);class po extends io{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&fo(e,this.from,this.to)?oo.fail("Structure replace would overwrite content"):oo.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new to([this.from,this.to-this.from,this.slice.size])}invert(e){return new po(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deletedAcross&&n.deletedAcross?null:new po(t.pos,Math.max(t.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof po)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;{let t=this.slice.size+e.slice.size==0?Yr.empty:new Yr(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new po(e.from,this.to,t,this.structure)}}{let t=this.slice.size+e.slice.size==0?Yr.empty:new Yr(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new po(this.from,this.to+(e.to-e.from),t,this.structure)}}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new po(t.from,t.to,Yr.fromJSON(e,t.slice),!!t.structure)}}io.jsonID("replace",po);class ho extends io{constructor(e,t,n,r,i,o,s=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=o,this.structure=s}apply(e){if(this.structure&&(fo(e,this.from,this.gapFrom)||fo(e,this.gapTo,this.to)))return oo.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return oo.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?oo.fromReplace(e,this.from,this.to,n):oo.fail("Content does not fit in gap")}getMap(){return new to([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new ho(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),r=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||r<t.pos||i>n.pos?null:new ho(t.pos,n.pos,r,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ho(t.from,t.to,t.gapFrom,t.gapTo,Yr.fromJSON(e,t.slice),t.insert,!!t.structure)}}function fo(e,t,n){let r=e.resolve(t),i=n-t,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let e=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function mo(e,t,n,r=n.contentMatch,i=!0){let o=e.doc.nodeAt(t),s=[],a=t+1;for(let t=0;t<o.childCount;t++){let l=o.child(t),c=a+l.nodeSize,u=r.matchType(l.type);if(u){r=u;for(let t=0;t<l.marks.length;t++)n.allowsMarkType(l.marks[t].type)||e.step(new lo(a,c,l.marks[t]));if(i&&l.isText&&"pre"!=n.whitespace){let e,t,r=/\r?\n|\r/g;for(;e=r.exec(l.text);)t||(t=new Yr(qr.from(n.schema.text(" ",n.allowedMarks(l.marks))),0,0)),s.push(new po(a+e.index,a+e.index+e[0].length,t))}}else s.push(new po(a,c,Yr.empty));a=c}if(!r.validEnd){let t=r.fillBefore(qr.empty,!0);e.replace(a,a,new Yr(t,0,0))}for(let t=s.length-1;t>=0;t--)e.step(s[t])}function go(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function yo(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let o=e.$from.node(n),s=e.$from.index(n)+r,a=e.$to.indexAfter(n)-i;if(n<e.depth&&o.canReplace(s,a,t))return n;if(0==n||o.type.spec.isolating||!go(o,s,a))break;s&&(r=1),a<o.childCount&&(i=1)}return null}function vo(e,t,n=null,r=e){let i=function(e,t){let{parent:n,startIndex:r,endIndex:i}=e,o=n.contentMatchAt(r).findWrapping(t);if(!o)return null;let s=o.length?o[0]:t;return n.canReplaceWith(r,i,s)?o:null}(e,t),o=i&&function(e,t){let{parent:n,startIndex:r,endIndex:i}=e,o=n.child(r),s=t.contentMatch.findWrapping(o.type);if(!s)return null;let a=(s.length?s[s.length-1]:t).contentMatch;for(let e=r;a&&e<i;e++)a=a.matchType(n.child(e).type);return a&&a.validEnd?s:null}(r,t);return o?i.map(bo).concat({type:t,attrs:n}).concat(o.map(bo)):null}function bo(e){return{type:e,attrs:null}}function wo(e,t,n,r){t.forEach((i,o)=>{if(i.isText){let s,a=/\r?\n|\r/g;for(;s=a.exec(i.text);){let i=e.mapping.slice(r).map(n+1+o+s.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function xo(e,t,n,r){t.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+o);e.replaceWith(i,i+1,t.type.schema.text("\n"))}})}function Mo(e,t,n=1,r){let i=e.resolve(t),o=i.depth-n,s=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>o;e--,t--){let n=i.node(e),o=i.index(e);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(o,n.childCount),a=r&&r[t+1];a&&(s=s.replaceChild(0,a.type.create(a.attrs)));let l=r&&r[t]||n;if(!n.canReplace(o+1,n.childCount)||!l.type.validContent(s))return!1}let a=i.indexAfter(o),l=r&&r[0];return i.node(o).canReplaceWith(a,a,l?l.type:i.node(o+1).type)}function So(e,t){let n=e.resolve(t),r=n.index();return Eo(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Eo(e,t){return!(!e||!t||e.isLeaf||!function(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i<t.childCount;i++){let o=t.child(i),s=o.type==r?e.type.schema.nodes.text:o.type;if(n=n.matchType(s),!n)return!1;if(!e.type.allowsMarks(o.marks))return!1}return n.validEnd}(e,t))}function Co(e,t,n=-1){let r=e.resolve(t);for(let e=r.depth;;e--){let i,o,s=r.index(e);if(e==r.depth?(i=r.nodeBefore,o=r.nodeAfter):n>0?(i=r.node(e+1),s++,o=r.node(e).maybeChild(s)):(i=r.node(e).maybeChild(s-1),o=r.node(e+1)),i&&!i.isTextblock&&Eo(i,o)&&r.node(e).canReplace(s,s+1))return t;if(0==e)break;t=n<0?r.before(e):r.after(e)}}function No(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let i=n.content;for(let e=0;e<n.openStart;e++)i=i.firstChild.content;for(let e=1;e<=(0==n.openStart&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,o=r.index(t)+(n>0?1:0),s=r.node(t),a=!1;if(1==e)a=s.canReplace(o,o,i);else{let e=s.contentMatchAt(o).findWrapping(i.firstChild.type);a=e&&s.canReplaceWith(o,o,e[0])}if(a)return 0==n?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function Ao(e,t,n=t,r=Yr.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),o=e.resolve(n);return ko(i,o,r)?new po(t,n,r):new To(i,o,r).fit()}function ko(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}io.jsonID("replaceAround",ho);class To{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=qr.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=qr.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,o=n.depth,s=r.depth;for(;o&&s&&1==i.childCount;)i=i.firstChild.content,o--,s--;let a=new Yr(i,o,s);return e>-1?new ho(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new po(n.pos,r.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let i=t.firstChild;if(t.childCount>1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let t=1;t<=2;t++)for(let n=1==t?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=Ro(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let i=e.firstChild;for(let e=this.depth;e>=0;e--){let o,{type:s,match:a}=this.frontier[e],l=null;if(1==t&&(i?a.matchType(i.type)||(l=a.fillBefore(qr.from(i),!1)):r&&s.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:l};if(2==t&&i&&(o=a.findWrapping(i.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:o};if(r&&a.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Ro(e,t);return!(!r.childCount||r.firstChild.isLeaf)&&(this.unplaced=new Yr(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Ro(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new Yr(Oo(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new Yr(Oo(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let e=0;e<i.length;e++)this.openFrontierNode(i[e]);let o=this.unplaced,s=n?n.content:o.content,a=o.openStart-e,l=0,c=[],{match:u,type:d}=this.frontier[t];if(r){for(let e=0;e<r.childCount;e++)c.push(r.child(e));u=u.matchFragment(r)}let p=s.size+e-(o.content.size-o.openEnd);for(;l<s.childCount;){let e=s.child(l),t=u.matchType(e.type);if(!t)break;l++,(l>1||0==a||e.content.size)&&(u=t,c.push(Do(e.mark(d.allowedMarks(e.marks)),1==l?a:0,l==s.childCount?p:-1)))}let h=l==s.childCount;h||(p=-1),this.placed=_o(this.placed,t,qr.from(c)),this.frontier[t].match=u,h&&p<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=s;e<p;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=h?0==e?Yr.empty:new Yr(Oo(o.content,e-1,1),e-1,p<0?o.openEnd:e-1):new Yr(Oo(o.content,e,l),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e,t=this.frontier[this.depth];if(!t.type.isTextblock||!Io(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=Io(e,t,r,n,i);if(o){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],i=Io(e,n,r,t,!0);if(!i||i.childCount)continue e}return{depth:t,fit:o,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=_o(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=_o(this.placed,this.depth,qr.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(qr.empty,!0);e.childCount&&(this.placed=_o(this.placed,this.frontier.length,e))}}function Oo(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(Oo(e.firstChild.content,t-1,n)))}function _o(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(_o(e.lastChild.content,t-1,n)))}function Ro(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function Do(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,Do(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(qr.empty,!0)))),e.copy(r)}function Io(e,t,n,r,i){let o=e.node(t),s=i?e.indexAfter(t):e.index(t);if(s==o.childCount&&!n.compatibleContent(o.type))return null;let a=r.fillBefore(o.content,!0,s);return a&&!function(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}(n,o.content,s)?a:null}function Lo(e){return e.spec.defining||e.spec.definingForContent}function Bo(e,t,n,r,i){if(t<n){let i=e.firstChild;e=e.replaceChild(0,i.copy(Bo(i.content,t+1,n,r,i)))}if(t>r){let t=i.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(qr.empty,!0))}return e}function zo(e,t){let n=[];for(let r=Math.min(e.depth,t.depth);r>=0;r--){let 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}class Po extends io{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return oo.fail("No node at attribute step's position");let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return oo.fromReplace(e,this.pos,this.pos+1,new Yr(qr.from(r),0,t.isLeaf?0:1))}getMap(){return to.empty}invert(e){return new Po(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Po(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if("number"!=typeof t.pos||"string"!=typeof t.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new Po(t.pos,t.attr,t.value)}}io.jsonID("attr",Po);class jo extends io{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return oo.ok(n)}getMap(){return to.empty}invert(e){return new jo(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if("string"!=typeof t.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new jo(t.attr,t.value)}}io.jsonID("docAttr",jo);let Fo=class extends Error{};Fo=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},(Fo.prototype=Object.create(Error.prototype)).constructor=Fo,Fo.prototype.name="TransformError";class $o{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new no}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Fo(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((n,r,i,o)=>{e=Math.min(e,i),t=Math.max(t,o)})}return 1e9==e?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=Yr.empty){let r=Ao(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new Yr(qr.from(n),0,0))}delete(e,t){return this.replace(e,t,Yr.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return function(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let i=e.doc.resolve(t),o=e.doc.resolve(n);if(ko(i,o,r))return e.step(new po(t,n,r));let s=zo(i,o);0==s[s.length-1]&&s.pop();let a=-(i.depth+1);s.unshift(a);for(let e=i.depth,t=i.pos-1;e>0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;s.indexOf(e)>-1?a=e:i.before(e)==t&&s.splice(1,0,-e)}let l=s.indexOf(a),c=[],u=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(c.push(n),t==r.openStart)break;e=n.content}for(let e=u-1;e>=0;e--){let t=c[e],n=Lo(t.type);if(n&&!t.sameMarkup(i.node(Math.abs(a)-1)))u=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let a=(t+u+1)%(r.openStart+1),d=c[a];if(d)for(let t=0;t<s.length;t++){let c=s[(t+l)%s.length],u=!0;c<0&&(u=!1,c=-c);let p=i.node(c-1),h=i.index(c-1);if(p.canReplaceWith(h,h,d.type,d.marks))return e.replace(i.before(c),u?o.after(c):n,new Yr(Bo(r.content,0,r.openStart,a),a,r.openEnd))}}let d=e.steps.length;for(let a=s.length-1;a>=0&&(e.replace(t,n,r),!(e.steps.length>d));a--){let e=s[a];e<0||(t=i.before(e),n=o.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,n){return function(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=function(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(0==r.parentOffset)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}(e.doc,t,r.type);null!=i&&(t=n=i)}e.replaceRange(t,n,new Yr(qr.from(r),0,0))}(this,e,t,n),this}deleteRange(e,t){return function(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n),o=zo(r,i);for(let t=0;t<o.length;t++){let n=o[t],s=t==o.length-1;if(s&&0==n||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),i.end(n));if(n>0&&(s||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return e.delete(r.before(n),i.after(n))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(t-r.start(o)==r.depth-o&&n>r.end(o)&&i.end(o)-n!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return e.delete(r.before(o),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return function(e,t,n){let{$from:r,$to:i,depth:o}=t,s=r.before(o+1),a=i.after(o+1),l=s,c=a,u=qr.empty,d=0;for(let e=o,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=qr.from(r.node(e).copy(u)),d++):l--;let p=qr.empty,h=0;for(let e=o,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,p=qr.from(i.node(e).copy(p)),h++):c++;e.step(new ho(l,c,s,a,new Yr(u.append(p),d,h),u.size-d,!0))}(this,e,t),this}join(e,t=1){return function(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,o=e.doc.resolve(t-n),s=o.node().type;if(i&&s.inlineContent){let e="pre"==s.whitespace,t=!!s.contentMatch.matchType(i);e&&!t?r=!1:!e&&t&&(r=!0)}let a=e.steps.length;if(!1===r){let r=e.doc.resolve(t+n);xo(e,r.node(),r.before(),a)}s.inlineContent&&mo(e,t+n-1,s,o.node().contentMatchAt(o.index()),null==r);let l=e.mapping.slice(a),c=l.map(t-n);if(e.step(new po(c,l.map(t+n,-1),Yr.empty,!0)),!0===r){let t=e.doc.resolve(c);wo(e,t.node(),t.before(),e.steps.length)}}(this,e,t),this}wrap(e,t){return function(e,t,n){let r=qr.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=qr.from(n[e].type.create(n[e].attrs,r))}let i=t.start,o=t.end;e.step(new ho(i,o,i,o,new Yr(r,0,0),n.length,!0))}(this,e,t),this}setBlockType(e,t=e,n,r=null){return function(e,t,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let s="function"==typeof i?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,s)&&function(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}(e.doc,e.mapping.slice(o).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e="pre"==r.whitespace,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}!1===i&&xo(e,t,n,o),mo(e,e.mapping.slice(o).map(n,1),r,void 0,null===i);let a=e.mapping.slice(o),l=a.map(n,1),c=a.map(n+t.nodeSize,1);return e.step(new ho(l,c,l+1,c-1,new Yr(qr.from(r.create(s,null,t.marks)),0,0),1,!0)),!0===i&&wo(e,t,n,o),!1}})}(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return function(e,t,n,r,i){let o=e.doc.nodeAt(t);if(!o)throw new RangeError("No node at given position");n||(n=o.type);let s=n.create(r,null,i||o.marks);if(o.isLeaf)return e.replaceWith(t,t+o.nodeSize,s);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new ho(t,t+o.nodeSize,t+1,t+o.nodeSize-1,new Yr(qr.from(s),0,0),1,!0))}(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new Po(e,t,n)),this}setDocAttribute(e,t){return this.step(new jo(e,t)),this}addNodeMark(e,t){return this.step(new co(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof Gr)t.isInSet(n.marks)&&this.step(new uo(e,t));else{let r,i=n.marks,o=[];for(;r=t.isInSet(i);)o.push(new uo(e,r)),i=r.removeFromSet(i);for(let e=o.length-1;e>=0;e--)this.step(o[e])}return this}split(e,t=1,n){return function(e,t,n=1,r){let i=e.doc.resolve(t),o=qr.empty,s=qr.empty;for(let e=i.depth,t=i.depth-n,a=n-1;e>t;e--,a--){o=qr.from(i.node(e).copy(o));let t=r&&r[a];s=qr.from(t?t.type.create(t.attrs,s):i.node(e).copy(s))}e.step(new po(t,t,new Yr(o.append(s),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){return function(e,t,n,r){let i,o,s=[],a=[];e.doc.nodesBetween(t,n,(e,l,c)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&c.type.allowsMarkType(r.type)){let c=Math.max(l,t),d=Math.min(l+e.nodeSize,n),p=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(p)||(i&&i.to==c&&i.mark.eq(u[e])?i.to=d:s.push(i=new lo(c,d,u[e])));o&&o.to==c?o.to=d:a.push(o=new ao(c,d,r))}}),s.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}(this,e,t,n),this}removeMark(e,t,n){return function(e,t,n,r){let i=[],o=0;e.doc.nodesBetween(t,n,(e,s)=>{if(!e.isInline)return;o++;let a=null;if(r instanceof Ri){let t,n=e.marks;for(;t=r.isInSet(n);)(a||(a=[])).push(t),n=t.removeFromSet(n)}else r?r.isInSet(e.marks)&&(a=[r]):a=e.marks;if(a&&a.length){let r=Math.min(s+e.nodeSize,n);for(let e=0;e<a.length;e++){let n,l=a[e];for(let e=0;e<i.length;e++){let t=i[e];t.step==o-1&&l.eq(i[e].style)&&(n=t)}n?(n.to=r,n.step=o):i.push({style:l,from:Math.max(s,t),to:r,step:o})}}}),i.forEach(t=>e.step(new lo(t.from,t.to,t.style)))}(this,e,t,n),this}clearIncompatible(e,t,n){return mo(this,e,t,n),this}}const Ho=Object.create(null);class Uo{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new qo(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=Yr.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let i=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:a,$to:l}=o[s],c=e.mapping.slice(i);e.replaceRange(c.map(a.pos),c.map(l.pos),s?Yr.empty:t),0==s&&es(e,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:o,$to:s}=r[i],a=e.mapping.slice(n),l=a.map(o.pos),c=a.map(s.pos);i?e.deleteRange(l,c):(e.replaceRangeWith(l,c,t),es(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new Ko(e):Qo(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let i=t<0?Qo(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):Qo(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Zo(e.node(0))}static atStart(e){return Qo(e,e,0,0,1)||new Zo(e)}static atEnd(e){return Qo(e,e,e.content.size,e.childCount,-1)||new Zo(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Ho[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Ho)throw new RangeError("Duplicate use of selection JSON ID "+e);return Ho[e]=t,t.prototype.jsonID=e,t}getBookmark(){return Ko.between(this.$anchor,this.$head).getBookmark()}}Uo.prototype.visible=!0;class qo{constructor(e,t){this.$from=e,this.$to=t}}let Vo=!1;function Wo(e){Vo||e.parent.inlineContent||(Vo=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class Ko extends Uo{constructor(e,t=e){Wo(e),Wo(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return Uo.near(n);let r=e.resolve(t.map(this.anchor));return new Ko(r.parent.inlineContent?r:n,n)}replace(e,t=Yr.empty){if(super.replace(e,t),t==Yr.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof Ko&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Go(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new Ko(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(e,t,n){let r=e.pos-t.pos;if(n&&!r||(n=r>=0?1:-1),!t.parent.inlineContent){let e=Uo.findFrom(t,n,!0)||Uo.findFrom(t,-n,!0);if(!e)return Uo.near(t,n);t=e.$head}return e.parent.inlineContent||(0==r||(e=(Uo.findFrom(e,-n,!0)||Uo.findFrom(e,n,!0)).$anchor).pos<t.pos!=r<0)&&(e=t),new Ko(e,t)}}Uo.jsonID("text",Ko);class Go{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Go(e.map(this.anchor),e.map(this.head))}resolve(e){return Ko.between(e.resolve(this.anchor),e.resolve(this.head))}}class Jo extends Uo{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:r}=t.mapResult(this.anchor),i=e.resolve(r);return n?Uo.near(i):new Jo(i)}content(){return new Yr(qr.from(this.node),0,0)}eq(e){return e instanceof Jo&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Yo(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Jo(e.resolve(t.anchor))}static create(e,t){return new Jo(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}Jo.prototype.visible=!1,Uo.jsonID("node",Jo);class Yo{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new Go(n,n):new Yo(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&Jo.isSelectable(n)?new Jo(t):Uo.near(t)}}class Zo extends Uo{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=Yr.empty){if(t==Yr.empty){e.delete(0,e.doc.content.size);let t=Uo.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Zo(e)}map(e){return new Zo(e)}eq(e){return e instanceof Zo}getBookmark(){return Xo}}Uo.jsonID("all",Zo);const Xo={map(){return this},resolve:e=>new Zo(e)};function Qo(e,t,n,r,i,o=!1){if(t.inlineContent)return Ko.create(e,n);for(let s=r-(i>0?0:1);i>0?s<t.childCount:s>=0;s+=i){let r=t.child(s);if(r.isAtom){if(!o&&Jo.isSelectable(r))return Jo.create(e,n-(i<0?r.nodeSize:0))}else{let t=Qo(e,r,n+i,i<0?r.childCount:0,i,o);if(t)return t}n+=r.nodeSize*i}return null}function es(e,t,n){let r=e.steps.length-1;if(r<t)return;let i,o=e.steps[r];(o instanceof po||o instanceof ho)&&(e.mapping.maps[r].forEach((e,t,n,r)=>{null==i&&(i=r)}),e.setSelection(Uo.near(e.doc.resolve(i),n)))}class ts extends $o{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=-3&this.updated|1,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return Gr.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(e,t){super.addStep(e,t),this.updated=-3&this.updated,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||Gr.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let 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);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=n==t?e.marks():e.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(Uo.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function ns(e,t){return t&&e?e.bind(t):e}class rs{constructor(e,t,n){this.name=e,this.init=ns(t.init,n),this.apply=ns(t.apply,n)}}const is=[new rs("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new rs("selection",{init:(e,t)=>e.selection||Uo.atStart(t.doc),apply:e=>e.selection}),new rs("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,r)=>r.selection.$cursor?e.storedMarks:null}),new rs("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class ss{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=is.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new rs(e.key,e.spec.state,e))})}}class as{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let i=!1;for(let o=0;o<this.config.plugins.length;o++){let s=this.config.plugins[o];if(s.spec.appendTransaction){let a=r?r[o].n:0,l=r?r[o].state:this,c=a<t.length&&s.spec.appendTransaction.call(s,a?t.slice(a):t,l,n);if(c&&n.filterTransaction(c,o)){if(c.setMeta("appendedTransaction",e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<o?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),i=!0}r&&(r[o]={state:n,n:t.length})}}if(!i)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new as(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let i=n[r];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new ts(this)}static create(e){let t=new ss(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new as(t);for(let r=0;r<t.fields.length;r++)n[t.fields[r].name]=t.fields[r].init(e,n);return n}reconfigure(e){let t=new ss(this.schema,e.plugins),n=t.fields,r=new as(t);for(let t=0;t<n.length;t++){let i=n[t].name;r[i]=this.hasOwnProperty(i)?this[i]:n[t].init(e,r)}return r}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&"object"==typeof e)for(let n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let r=new ss(e.schema,e.plugins),i=new as(r);return r.fields.forEach(r=>{if("doc"==r.name)i.doc=fi.fromJSON(e.schema,t.doc);else if("selection"==r.name)i.selection=Uo.fromJSON(i.doc,t.selection);else if("storedMarks"==r.name)t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let o in n){let s=n[o],a=s.spec.state;if(s.key==r.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(t,o))return void(i[r.name]=a.fromJSON.call(s,e,t[o],i))}i[r.name]=r.init(e,i)}}),i}}function ls(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):"handleDOMEvents"==r&&(i=ls(i,t,{})),n[r]=i}return n}class cs{constructor(e){this.spec=e,this.props={},e.props&&ls(e.props,this,this.props),this.key=e.key?e.key.key:ds("plugin")}getState(e){return e[this.key]}}const us=Object.create(null);function ds(e){return e in us?e+"$"+ ++us[e]:(us[e]=0,e+"$")}class ps{constructor(e="key"){this.key=ds(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const hs=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},fs=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t};let ms=null;const gs=function(e,t,n){let r=ms||(ms=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},ys=function(e,t,n,r){return n&&(bs(e,t,n,r,-1)||bs(e,t,n,r,1))},vs=/^(img|br|input|textarea|hr)$/i;function bs(e,t,n,r,i){for(var o;;){if(e==n&&t==r)return!0;if(t==(i<0?0:ws(e))){let n=e.parentNode;if(!n||1!=n.nodeType||xs(e)||vs.test(e.nodeName)||"false"==e.contentEditable)return!1;t=hs(e)+(i<0?0:1),e=n}else{if(1!=e.nodeType)return!1;{let n=e.childNodes[t+(i<0?-1:0)];if(1==n.nodeType&&"false"==n.contentEditable){if(!(null===(o=n.pmViewDesc)||void 0===o?void 0:o.ignoreForSelection))return!1;t+=i}else e=n,t=i<0?ws(e):0}}}}function ws(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function xs(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const Ms=function(e){return e.focusNode&&ys(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function Ss(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}const Es="undefined"!=typeof navigator?navigator:null,Cs="undefined"!=typeof document?document:null,Ns=Es&&Es.userAgent||"",As=/Edge\/(\d+)/.exec(Ns),ks=/MSIE \d/.exec(Ns),Ts=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ns),Os=!!(ks||Ts||As),_s=ks?document.documentMode:Ts?+Ts[1]:As?+As[1]:0,Rs=!Os&&/gecko\/(\d+)/i.test(Ns);Rs&&(/Firefox\/(\d+)/.exec(Ns)||[0,0])[1];const Ds=!Os&&/Chrome\/(\d+)/.exec(Ns),Is=!!Ds,Ls=Ds?+Ds[1]:0,Bs=!Os&&!!Es&&/Apple Computer/.test(Es.vendor),zs=Bs&&(/Mobile\/\w+/.test(Ns)||!!Es&&Es.maxTouchPoints>2),Ps=zs||!!Es&&/Mac/.test(Es.platform),js=!!Es&&/Win/.test(Es.platform),Fs=/Android \d/.test(Ns),$s=!!Cs&&"webkitFontSmoothing"in Cs.documentElement.style,Hs=$s?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Us(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function qs(e,t){return"number"==typeof e?e:e[t]}function Vs(e){let 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 Ws(e,t,n){let r=e.someProp("scrollThreshold")||0,i=e.someProp("scrollMargin")||5,o=e.dom.ownerDocument;for(let s=n||e.dom;s;){if(1!=s.nodeType){s=fs(s);continue}let e=s,n=e==o.body,a=n?Us(o):Vs(e),l=0,c=0;if(t.top<a.top+qs(r,"top")?c=-(a.top-t.top+qs(i,"top")):t.bottom>a.bottom-qs(r,"bottom")&&(c=t.bottom-t.top>a.bottom-a.top?t.top+qs(i,"top")-a.top:t.bottom-a.bottom+qs(i,"bottom")),t.left<a.left+qs(r,"left")?l=-(a.left-t.left+qs(i,"left")):t.right>a.right-qs(r,"right")&&(l=t.right-a.right+qs(i,"right")),l||c)if(n)o.defaultView.scrollBy(l,c);else{let n=e.scrollLeft,r=e.scrollTop;c&&(e.scrollTop+=c),l&&(e.scrollLeft+=l);let i=e.scrollLeft-n,o=e.scrollTop-r;t={left:t.left-i,top:t.top-o,right:t.right-i,bottom:t.bottom-o}}let u=n?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(u))break;s="absolute"==u?s.offsetParent:fs(s)}}function Ks(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=fs(r));return t}function Gs(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:i,left:o}=e[n];r.scrollTop!=i+t&&(r.scrollTop=i+t),r.scrollLeft!=o&&(r.scrollLeft=o)}}let Js=null;function Ys(e,t){let n,r,i,o,s=2e8,a=0,l=t.top,c=t.top;for(let u=e.firstChild,d=0;u;u=u.nextSibling,d++){let e;if(1==u.nodeType)e=u.getClientRects();else{if(3!=u.nodeType)continue;e=gs(u).getClientRects()}for(let p=0;p<e.length;p++){let h=e[p];if(h.top<=l&&h.bottom>=c){l=Math.max(h.bottom,l),c=Math.min(h.top,c);let e=h.left>t.left?h.left-t.left:h.right<t.left?t.left-h.right:0;if(e<s){n=u,s=e,r=e&&3==n.nodeType?{left:h.right<t.left?h.right:h.left,top:t.top}:t,1==u.nodeType&&e&&(a=d+(t.left>=(h.left+h.right)/2?1:0));continue}}else h.top>t.top&&!i&&h.left<=t.left&&h.right>=t.left&&(i=u,o={left:Math.max(h.left,Math.min(h.right,t.left)),top:h.top});!n&&(t.left>=h.right&&t.top>=h.top||t.left>=h.left&&t.top>=h.bottom)&&(a=d+1)}}return!n&&i&&(n=i,r=o,s=0),n&&3==n.nodeType?function(e,t){let n,r=e.nodeValue.length,i=document.createRange();for(let o=0;o<r;o++){i.setEnd(e,o+1),i.setStart(e,o);let r=ta(i,1);if(r.top!=r.bottom&&Zs(t,r)){n={node:e,offset:o+(t.left>=(r.left+r.right)/2?1:0)};break}}return i.detach(),n||{node:e,offset:0}}(n,r):!n||s&&1==n.nodeType?{node:e,offset:a}:Ys(n,r)}function Zs(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function Xs(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),o=i;;){let n=e.childNodes[o];if(1==n.nodeType){let e=n.getClientRects();for(let r=0;r<e.length;r++){let i=e[r];if(Zs(t,i))return Xs(n,t,i)}}if((o=(o+1)%r)==i)break}return e}function Qs(e,t){let n,r=e.dom.ownerDocument,i=0,o=function(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(ws(r.offsetNode),r.offset)}}catch(e){}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(ws(r.startContainer),r.startOffset)}}}(r,t.left,t.top);o&&({node:n,offset:i}=o);let s,a=(e.root.elementFromPoint?e.root:r).elementFromPoint(t.left,t.top);if(!a||!e.dom.contains(1!=a.nodeType?a.parentNode:a)){let n=e.dom.getBoundingClientRect();if(!Zs(t,n))return null;if(a=Xs(e.dom,t,n),!a)return null}if(Bs)for(let e=a;n&&e;e=fs(e))e.draggable&&(n=void 0);if(a=function(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(a,t),n){if(Rs&&1==n.nodeType&&(i=Math.min(i,n.childNodes.length),i<n.childNodes.length)){let e,r=n.childNodes[i];"IMG"==r.nodeName&&(e=r.getBoundingClientRect()).right<=t.left&&e.bottom>t.top&&i++}let r;$s&&i&&1==n.nodeType&&1==(r=n.childNodes[i-1]).nodeType&&"false"==r.contentEditable&&r.getBoundingClientRect().top>=t.top&&i--,n==e.dom&&i==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:0!=i&&1==n.nodeType&&"BR"==n.childNodes[i-1].nodeName||(s=function(e,t,n,r){let i=-1;for(let n=t,o=!1;n!=e.dom;){let t,s=e.docView.nearestDesc(n,!0);if(!s)return null;if(1==s.dom.nodeType&&(s.node.isBlock&&s.parent||!s.contentDOM)&&((t=s.dom.getBoundingClientRect()).width||t.height)&&(s.node.isBlock&&s.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(s.dom.nodeName)&&(!o&&t.left>r.left||t.top>r.top?i=s.posBefore:(!o&&t.right<r.left||t.bottom<r.top)&&(i=s.posAfter),o=!0),!s.contentDOM&&i<0&&!s.node.isText))return(s.node.isBlock?r.top<(t.top+t.bottom)/2:r.left<(t.left+t.right)/2)?s.posBefore:s.posAfter;n=s.dom.parentNode}return i>-1?i:e.docView.posFromDOM(t,n,-1)}(e,n,i,t))}null==s&&(s=function(e,t,n){let{node:r,offset:i}=Ys(t,n),o=-1;if(1==r.nodeType&&!r.firstChild){let e=r.getBoundingClientRect();o=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,i,o)}(e,a,t));let l=e.docView.nearestDesc(a,!0);return{pos:s,inside:l?l.posAtStart-l.border:-1}}function ea(e){return e.top<e.bottom||e.left<e.right}function ta(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(ea(e))return e}return Array.prototype.find.call(n,ea)||e.getBoundingClientRect()}const na=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function ra(e,t,n){let{node:r,offset:i,atom:o}=e.docView.domFromPos(t,n<0?-1:1),s=$s||Rs;if(3==r.nodeType){if(!s||!na.test(r.nodeValue)&&(n<0?i:i!=r.nodeValue.length)){let e=i,t=i,o=n<0?1:-1;return n<0&&!i?(t++,o=-1):n>=0&&i==r.nodeValue.length?(e--,o=1):n<0?e--:t++,ia(ta(gs(r,e,t),o),o<0)}{let e=ta(gs(r,i,i),n);if(Rs&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let t=ta(gs(r,i-1,i-1),-1);if(t.top==e.top){let n=ta(gs(r,i,i+1),-1);if(n.top!=e.top)return ia(n,n.left<t.left)}}return e}}if(!e.state.doc.resolve(t-(o||0)).parent.inlineContent){if(null==o&&i&&(n<0||i==ws(r))){let e=r.childNodes[i-1];if(1==e.nodeType)return oa(e.getBoundingClientRect(),!1)}if(null==o&&i<ws(r)){let e=r.childNodes[i];if(1==e.nodeType)return oa(e.getBoundingClientRect(),!0)}return oa(r.getBoundingClientRect(),n>=0)}if(null==o&&i&&(n<0||i==ws(r))){let e=r.childNodes[i-1],t=3==e.nodeType?gs(e,ws(e)-(s?0:1)):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return ia(ta(t,1),!1)}if(null==o&&i<ws(r)){let e=r.childNodes[i];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?gs(e,0,s?0:1):1==e.nodeType?e:null:null;if(t)return ia(ta(t,-1),!0)}return ia(ta(3==r.nodeType?gs(r):r,-n),n>=0)}function ia(e,t){if(0==e.width)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function oa(e,t){if(0==e.height)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function sa(e,t,n){let 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()}}const aa=/[\u0590-\u08ac]/;let la=null,ca=null,ua=!1;function da(e,t,n){return la==t&&ca==n?ua:(la=t,ca=n,ua="up"==n||"down"==n?function(e,t,n){let r=t.selection,i="up"==n?r.$from:r.$to;return sa(e,t,()=>{let{node:t}=e.docView.domFromPos(i.pos,"up"==n?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=ra(e,i.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=gs(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let i=t[e];if(i.bottom>i.top+1&&("up"==n?r.top-i.top>2*(i.bottom-r.top):i.bottom-r.bottom>2*(r.bottom-i.top)))return!1}}return!0})}(e,t,n):function(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,s=i==r.parent.content.size,a=e.domSelection();return a?aa.test(r.parent.textContent)&&a.modify?sa(e,t,()=>{let{focusNode:t,focusOffset:i,anchorNode:o,anchorOffset:s}=e.domSelectionRange(),l=a.caretBidiLevel;a.modify("move",n,"character");let c=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:u,focusOffset:d}=e.domSelectionRange(),p=u&&!c.contains(1==u.nodeType?u:u.parentNode)||t==u&&i==d;try{a.collapse(o,s),t&&(t!=o||i!=s)&&a.extend&&a.extend(t,i)}catch(e){}return null!=l&&(a.caretBidiLevel=l),p}):"left"==n||"backward"==n?o:s:r.pos==r.start()||r.pos==r.end()}(e,t,n))}class pa{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=0,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)return n;n+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}}let r;if(e==this.dom&&this.contentDOM)r=t>hs(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(null==r&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return(null==r?n>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let i,o=this.getDesc(r);if(o&&(!t||o.node)){if(!n||!(i=o.nodeDOM)||(1==i.nodeType?i.contains(1==e.nodeType?e:e.parentNode):i==e))return o;n=!1}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],i=n+r.size;if(n==e&&i!=n){for(;!r.border&&r.children.length;)for(let e=0;e<r.children.length;e++){let t=r.children[e];if(t.size){r=t;break}}return r}if(e<i)return r.descAt(e-n-r.border);n=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let t=0;n<this.children.length;n++){let i=this.children[n],o=t+i.size;if(o>e||i instanceof ba){r=e-t;break}t=o}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof ha&&e.side>=0;n--);if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,e&&e.dom.parentNode!=this.contentDOM;n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?hs(e.dom)+1:0}}{let e,r=!0;for(;e=n<this.children.length?this.children[n]:null,e&&e.dom.parentNode!=this.contentDOM;n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?hs(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,i=-1;for(let o=n,s=0;;s++){let n=this.children[s],a=o+n.size;if(-1==r&&e<=a){let i=o+n.border;if(e>=i&&t<=a-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,i);e=o;for(let t=s;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=hs(n.dom)+1;break}e-=n.size}-1==r&&(r=0)}if(r>-1&&(a>t||s==this.children.length-1)){t=a;for(let e=s+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){i=hs(n.dom);break}t+=n.size}-1==i&&(i=this.contentDOM.childNodes.length);break}o=a}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(1!=t.nodeType||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let i=Math.min(e,t),o=Math.max(e,t);for(let s=0,a=0;s<this.children.length;s++){let l=this.children[s],c=a+l.size;if(i>a&&o<c)return l.setSelection(e-a-l.border,t-a-l.border,n,r);a=c}let s=this.domFromPos(e,e?-1:1),a=t==e?s:this.domFromPos(t,t?-1:1),l=n.root.getSelection(),c=n.domSelectionRange(),u=!1;if((Rs||Bs)&&e==t){let{node:e,offset:t}=s;if(3==e.nodeType){if(u=!(!t||"\n"!=e.nodeValue[t-1]),u&&t==e.nodeValue.length)for(let t,n=e;n;n=n.parentNode){if(t=n.nextSibling){"BR"==t.nodeName&&(s=a={node:t.parentNode,offset:hs(t)+1});break}let e=n.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];u=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(Rs&&c.focusNode&&c.focusNode!=a.node&&1==c.focusNode.nodeType){let e=c.focusNode.childNodes[c.focusOffset];e&&"false"==e.contentEditable&&(r=!0)}if(!(r||u&&Bs)&&ys(s.node,s.offset,c.anchorNode,c.anchorOffset)&&ys(a.node,a.offset,c.focusNode,c.focusOffset))return;let d=!1;if((l.extend||e==t)&&(!u||!Rs)){l.collapse(s.node,s.offset);try{e!=t&&l.extend(a.node,a.offset),d=!0}catch(e){}}if(!d){if(e>t){let e=s;s=a,a=e}let n=document.createRange();n.setEnd(a.node,a.offset),n.setStart(s.node,s.offset),l.removeAllRanges(),l.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let i=this.children[r],o=n+i.size;if(n==o?e<=o&&t>=n:e<o&&t>n){let r=n+i.border,s=o-i.border;if(e>=r&&t<=s)return this.dirty=e==n||t==o?2:1,void(e!=r||t!=s||!i.contentLost&&i.dom.parentNode==this.contentDOM?i.markDirty(e-r,t-r):i.dirty=3);i.dirty=i.dom!=i.contentDOM||i.dom.parentNode!=this.contentDOM||i.children.length?3:2}n=o}this.dirty=2}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=1==e?2:1;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class ha extends pa{constructor(e,t,n,r){let i,o=t.type.toDOM;if("function"==typeof o&&(o=o(n,()=>i?i.parent?i.parent.posBeforeChild(i):void 0:r)),!t.type.spec.raw){if(1!=o.nodeType){let e=document.createElement("span");e.appendChild(o),o=e}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return 0==this.dirty&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return!!t&&t(e)}ignoreMutation(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class fa extends pa{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue}}class ma extends pa{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(e,t,n,r){let i=r.nodeViews[t.type.name],o=i&&i(t,r,n);return o&&o.dom||(o=Vi.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new ma(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return 3!=this.dirty&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),0!=this.dirty){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=0}}slice(e,t,n){let r=ma.create(this.parent,this.mark,!0,n),i=this.children,o=this.size;t<o&&(i=Ra(i,t,o,n)),e>0&&(i=Ra(i,0,e,n));for(let e=0;e<i.length;e++)i[e].parent=r;return r.children=i,r}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class ga extends pa{constructor(e,t,n,r,i,o,s,a,l){super(e,[],i,o),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=s}static create(e,t,n,r,i,o){let s,a=i.nodeViews[t.type.name],l=a&&a(t,i,()=>s?s.parent?s.parent.posBeforeChild(s):void 0:o,n,r),c=l&&l.dom,u=l&&l.contentDOM;if(t.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(t.text);else if(!c){let e=Vi.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs);({dom:c,contentDOM:u}=e)}u||t.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let d=c;return c=Aa(c,n,t),l?s=new wa(e,t,n,r,c,u||null,d,l,i,o+1):t.isText?new va(e,t,n,r,c,d,i):new ga(e,t,n,r,c,u||null,d,i,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>qr.empty)}else e.contentElement=this.contentDOM;else e.getContent=()=>this.node.content;return e}matchesNode(e,t,n){return 0==this.dirty&&e.eq(this.node)&&ka(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,o=i&&i.pos>-1?i:null,s=i&&i.pos<0,a=new Oa(this,o&&o.node,e);!function(e,t,n,r){let i=t.locals(e),o=0;if(0==i.length){for(let n=0;n<e.childCount;n++){let s=e.child(n);r(s,i,t.forChild(o,s),n),o+=s.nodeSize}return}let s=0,a=[],l=null;for(let c=0;;){let u,d,p,h;for(;s<i.length&&i[s].to==o;){let e=i[s++];e.widget&&(u?(d||(d=[u])).push(e):u=e)}if(u)if(d){d.sort(_a);for(let e=0;e<d.length;e++)n(d[e],c,!!l)}else n(u,c,!!l);if(l)h=-1,p=l,l=null;else{if(!(c<e.childCount))break;h=c,p=e.child(c++)}for(let e=0;e<a.length;e++)a[e].to<=o&&a.splice(e--,1);for(;s<i.length&&i[s].from<=o&&i[s].to>o;)a.push(i[s++]);let f=o+p.nodeSize;if(p.isText){let e=f;s<i.length&&i[s].from<e&&(e=i[s].from);for(let t=0;t<a.length;t++)a[t].to<e&&(e=a[t].to);e<f&&(l=p.cut(e-o),p=p.cut(0,e-o),f=e,h=-1)}else for(;s<i.length&&i[s].to<f;)s++;r(p,p.isInline&&!p.isLeaf?a.filter(e=>!e.inline):a.slice(),t.forChild(o,p),h),o=f}}(this.node,this.innerDeco,(t,i,o)=>{t.spec.marks?a.syncToMarks(t.spec.marks,n,e,i):t.type.side>=0&&!o&&a.syncToMarks(i==this.node.childCount?Gr.none:this.node.child(i).marks,n,e,i),a.placeWidget(t,e,r)},(t,o,l,c)=>{let u;a.syncToMarks(t.marks,n,e,c),a.findNodeMatch(t,o,l,c)||s&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(u=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(t,o,l,u,e)||a.updateNextNode(t,o,l,e,c,r)||a.addNode(t,o,l,e,r),r+=t.nodeSize}),a.syncToMarks([],n,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||2==this.dirty)&&(o&&this.protectLocalComposition(e,o),xa(this.contentDOM,this.children,e),zs&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof Ko)||n<t||r>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let e=i.nodeValue,o=function(e,t,n,r){for(let i=0,o=0;i<e.childCount&&o<=r;){let s=e.child(i++),a=o;if(o+=s.nodeSize,!s.isText)continue;let l=s.text;for(;i<e.childCount;){let t=e.child(i++);if(o+=t.nodeSize,!t.isText)break;l+=t.text}if(o>=n){if(o>=r&&l.slice(r-t.length-a,r-a)==t)return r-t.length;let e=a<r?l.lastIndexOf(t,r-a-1):-1;if(e>=0&&e+t.length+a>=n)return a+e;if(n==r&&l.length>=r+t.length-a&&l.slice(r-a,r-a+t.length)==t)return r}}return-1}(this.node.content,e,n-t,r-t);return o<0?null:{node:i,pos:o,text:e}}return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new fa(this,i,t,r);e.input.compositionNodes.push(o),this.children=Ra(this.children,n,n+r.length,e,o)}update(e,t,n,r){return!(3==this.dirty||!e.sameMarkup(this.node))&&(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(ka(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=Ca(this.dom,this.nodeDOM,Ea(this.outerDeco,this.node,t),Ea(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.nodeDOM.draggable=!0))}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function ya(e,t,n,r,i){Aa(r,t,e);let o=new ga(void 0,e,t,n,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}class va extends ga{constructor(e,t,n,r,i,o,s){super(e,t,n,r,i,null,o,s,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(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)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return"characterData"!=e.type&&"selection"!=e.type}slice(e,t,n){let r=this.node.cut(e,t),i=document.createTextNode(r.text);return new va(this.parent,r,this.outerDeco,this.innerDeco,i,i,n)}markDirty(e,t){super.markDirty(e,t),this.dom==this.nodeDOM||0!=e&&t!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}isText(e){return this.node.text==e}}class ba extends pa{parseRule(){return{ignore:!0}}matchesHack(e){return 0==this.dirty&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class wa extends ga{constructor(e,t,n,r,i,o,s,a,l,c){super(e,t,n,r,i,o,s,l,c),this.spec=a}update(e,t,n,r){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}return!(!this.contentDOM&&!e.isLeaf)&&super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function xa(e,t,n){let r=e.firstChild,i=!1;for(let o=0;o<t.length;o++){let s=t[o],a=s.dom;if(a.parentNode==e){for(;a!=r;)r=Ta(r),i=!0;r=r.nextSibling}else i=!0,e.insertBefore(a,r);if(s instanceof ma){let t=r?r.previousSibling:e.lastChild;xa(s.contentDOM,s.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=Ta(r),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}const Ma=function(e){e&&(this.nodeName=e)};Ma.prototype=Object.create(null);const Sa=[new Ma];function Ea(e,t,n){if(0==e.length)return Sa;let r=n?Sa[0]:new Ma,i=[r];for(let o=0;o<e.length;o++){let s=e[o].type.attrs;if(s){s.nodeName&&i.push(r=new Ma(s.nodeName));for(let e in s){let o=s[e];null!=o&&(n&&1==i.length&&i.push(r=new Ma(t.isInline?"span":"div")),"class"==e?r.class=(r.class?r.class+" ":"")+o:"style"==e?r.style=(r.style?r.style+";":"")+o:"nodeName"!=e&&(r[e]=o))}}}return i}function Ca(e,t,n,r){if(n==Sa&&r==Sa)return t;let i=t;for(let t=0;t<r.length;t++){let o=r[t],s=n[t];if(t){let t;s&&s.nodeName==o.nodeName&&i!=e&&(t=i.parentNode)&&t.nodeName.toLowerCase()==o.nodeName||(t=document.createElement(o.nodeName),t.pmIsDeco=!0,t.appendChild(i),s=Sa[0]),i=t}Na(i,s||Sa[0],o)}return i}function Na(e,t,n){for(let r in t)"class"==r||"style"==r||"nodeName"==r||r in n||e.removeAttribute(r);for(let r in n)"class"!=r&&"style"!=r&&"nodeName"!=r&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<r.length;t++)-1==i.indexOf(r[t])&&e.classList.remove(r[t]);for(let t=0;t<i.length;t++)-1==r.indexOf(i[t])&&e.classList.add(i[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n,r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=r.exec(t.style);)e.style.removeProperty(n[1])}n.style&&(e.style.cssText+=n.style)}}function Aa(e,t,n){return Ca(e,e,Sa,Ea(t,n,1!=e.nodeType))}function ka(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function Ta(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class Oa{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=function(e,t){let n=t,r=n.children.length,i=e.childCount,o=new Map,s=[];e:for(;i>0;){let a;for(;;)if(r){let e=n.children[r-1];if(!(e instanceof ma)){a=e,r--;break}n=e,r=e.children.length}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=e.child(i-1))break;--i,o.set(a,i),s.push(a)}}return{index:i,matched:o,matches:s.reverse()}}(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,r){let i=0,o=this.stack.length>>1,s=Math.min(o,e.length);for(;i<s&&(i==o-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&!1!==e[i].type.spec.spanning;)i++;for(;i<o;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let i=-1,s=this.top.children.length;r<this.preMatch.index&&(s=Math.min(this.index+3,s));for(let t=this.index;t<s;t++){let n=this.top.children[t];if(n.matchesMark(e[o])&&!this.isLocked(n.dom)){i=t;break}}if(i>-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let r=ma.create(this.top,e[o],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,n,r){let 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(let r=this.index,i=Math.min(this.top.children.length,r+5);r<i;r++){let i=this.top.children[r];if(i.matchesNode(e,t,n)&&!this.preMatch.matched.has(i)){o=r;break}}return!(o<0)&&(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,t,n,r,i){let 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)}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t)for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e;return-1}e=t}}updateNextNode(e,t,n,r,i,o){for(let s=this.index;s<this.top.children.length;s++){let a=this.top.children[s];if(a instanceof ga){let l=this.preMatch.matched.get(a);if(null!=l&&l!=i)return!1;let c,u=a.dom,d=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&3!=a.dirty&&ka(t,a.outerDeco));if(!d&&a.update(e,t,n,r))return this.destroyBetween(this.index,s),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!d&&(c=this.recreateWrapper(a,e,t,n,r,o)))return this.destroyBetween(this.index,s),this.top.children[this.index]=c,c.contentDOM&&(c.dirty=2,c.updateChildren(r,o+1),c.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,i,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!ka(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let s=ga.create(this.top,t,n,r,i,o);if(s.contentDOM){s.children=e.children,e.children=[];for(let e of s.children)e.parent=s}return e.destroy(),s}addNode(e,t,n,r,i){let o=ga.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}placeWidget(e,t,n){let 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){let r=new ha(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}else this.index++}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof ma;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof va)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Bs||Is)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");let r=new ba(this.top,[],n,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}}function _a(e,t){return e.type.side-t.type.side}function Ra(e,t,n,r,i){let o=[];for(let s=0,a=0;s<e.length;s++){let l=e[s],c=a,u=a+=l.size;c>=n||u<=t?o.push(l):(c<t&&o.push(l.slice(0,t-c,r)),i&&(o.push(i),i=void 0),u>n&&o.push(l.slice(n-c,l.size,r)))}return o}function Da(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),o=i&&0==i.size,s=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let a,l,c=r.resolve(s);if(Ms(n)){for(a=s;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&Jo.isSelectable(e)&&i.parent&&(!e.isInline||!function(e,t,n){for(let r=0==t,i=t==ws(e);r||i;){if(e==n)return!0;let t=hs(e);if(!(e=e.parentNode))return!1;r=r&&0==t,i=i&&t==ws(e)}}(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new Jo(s==e?c:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=s,i=s;for(let r=0;r<n.rangeCount;r++){let o=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(o.startContainer,o.startOffset,1)),i=Math.max(i,e.docView.posFromDOM(o.endContainer,o.endOffset,-1))}if(t<0)return null;[a,s]=i==e.state.selection.anchor?[i,t]:[t,i],c=r.resolve(s)}else a=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!l){l=Ha(e,u,c,"pointer"==t||e.state.selection.head<c.pos&&!o?1:-1)}return l}function Ia(e){return e.editable?e.hasFocus():qa(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function La(e,t=!1){let n=e.state.selection;if(Fa(e,n),Ia(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&Is){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&ys(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset))return e.input.mouseDown.delayedSelectionSync=!0,void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r="IMG"==n.nodeName;r?t.collapse(n.parentNode,hs(n)+1):t.collapse(n,0);!r&&!e.state.selection.visible&&Os&&_s<=11&&(n.disabled=!0,n.disabled=!1)}(e);else{let r,i,{anchor:o,head:s}=n;!Ba||n instanceof Ko||(n.$from.parent.inlineContent||(r=za(e,n.from)),n.empty||n.$from.parent.inlineContent||(i=za(e,n.to))),e.docView.setSelection(o,s,e,t),Ba&&(r&&ja(r),i&&ja(i)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{n.anchorNode==r&&n.anchorOffset==i||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{Ia(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")},20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const Ba=Bs||Is&&Ls<63;function za(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),i=r<n.childNodes.length?n.childNodes[r]:null,o=r?n.childNodes[r-1]:null;if(Bs&&i&&"false"==i.contentEditable)return Pa(i);if(!(i&&"false"!=i.contentEditable||o&&"false"!=o.contentEditable)){if(i)return Pa(i);if(o)return Pa(o)}}function Pa(e){return e.contentEditable="true",Bs&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function ja(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function Fa(e,t){if(t instanceof Jo){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&($a(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else $a(e)}function $a(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Ha(e,t,n,r){return e.someProp("createSelectionBetween",r=>r(e,t,n))||Ko.between(t,n,r)}function Ua(e){return!(e.editable&&!e.hasFocus())&&qa(e)}function qa(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function Va(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),o=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return o&&Uo.findFrom(o,t)}function Wa(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Ka(e,t,n){let r=e.state.selection;if(!(r instanceof Ko)){if(r instanceof Jo&&r.node.isInline)return Wa(e,new Ko(t>0?r.$to:r.$from));{let n=Va(e.state,t);return!!n&&Wa(e,n)}}if(n.indexOf("s")>-1){let{$head:n}=r,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=e.state.doc.resolve(n.pos+i.nodeSize*(t<0?-1:1));return Wa(e,new Ko(r.$anchor,o))}if(!r.empty)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){let n=Va(e.state,t);return!!(n&&n instanceof Jo)&&Wa(e,n)}if(!(Ps&&n.indexOf("m")>-1)){let n,i=r.$head,o=i.textOffset?null:t<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText)return!1;let s=t<0?i.pos-o.nodeSize:i.pos;return!!(o.isAtom||(n=e.docView.descAt(s))&&!n.contentDOM)&&(Jo.isSelectable(o)?Wa(e,new Jo(t<0?e.state.doc.resolve(i.pos-o.nodeSize):i)):!!$s&&Wa(e,new Ko(e.state.doc.resolve(t<0?s:s+o.nodeSize))))}}function Ga(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Ja(e,t){let n=e.pmViewDesc;return n&&0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function Ya(e,t){return t<0?function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,o,s=!1;Rs&&1==n.nodeType&&r<Ga(n)&&Ja(n.childNodes[r],-1)&&(s=!0);for(;;)if(r>0){if(1!=n.nodeType)break;{let e=n.childNodes[r-1];if(Ja(e,-1))i=n,o=--r;else{if(3!=e.nodeType)break;n=e,r=n.nodeValue.length}}}else{if(Za(n))break;{let t=n.previousSibling;for(;t&&Ja(t,-1);)i=n.parentNode,o=hs(t),t=t.previousSibling;if(t)n=t,r=Ga(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}s?Xa(e,n,r):i&&Xa(e,i,o)}(e):function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,o,s=Ga(n);for(;;)if(r<s){if(1!=n.nodeType)break;if(!Ja(n.childNodes[r],1))break;i=n,o=++r}else{if(Za(n))break;{let t=n.nextSibling;for(;t&&Ja(t,1);)i=t.parentNode,o=hs(t)+1,t=t.nextSibling;if(t)n=t,r=0,s=Ga(n);else{if(n=n.parentNode,n==e.dom)break;r=s=0}}}i&&Xa(e,i,o)}(e)}function Za(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Xa(e,t,n){if(3!=t.nodeType){let e,r;(r=function(e,t){for(;e&&t==e.childNodes.length&&!xs(e);)t=hs(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let 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=r,n=0):(e=function(e,t){for(;e&&!t&&!xs(e);)t=hs(e),e=e.parentNode;for(;e&&t;){let 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=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(Ms(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:i}=e;setTimeout(()=>{e.state==i&&La(e)},50)}function Qa(e,t){let n=e.state.doc.resolve(t);if(!Is&&!js&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?"ltr":"rtl"}if(t<n.end()){let n=e.coordsAtPos(t+1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function el(e,t,n){let r=e.state.selection;if(r instanceof Ko&&!r.empty||n.indexOf("s")>-1)return!1;if(Ps&&n.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=Va(e.state,t);if(n&&n instanceof Jo)return Wa(e,n)}if(!i.parent.inlineContent){let n=t<0?i:o,s=r instanceof Zo?Uo.near(n,t):Uo.findFrom(n,t);return!!s&&Wa(e,s)}return!1}function tl(e,t){if(!(e.state.selection instanceof Ko))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let o=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(o&&!o.isText){let r=e.state.tr;return t<0?r.delete(n.pos-o.nodeSize,n.pos):r.delete(n.pos,n.pos+o.nodeSize),e.dispatch(r),!0}return!1}function nl(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function rl(e,t){let n=t.keyCode,r=function(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);if(8==n||Ps&&72==n&&"c"==r)return tl(e,-1)||Ya(e,-1);if(46==n&&!t.shiftKey||Ps&&68==n&&"c"==r)return tl(e,1)||Ya(e,1);if(13==n||27==n)return!0;if(37==n||Ps&&66==n&&"c"==r){let t=37==n?"ltr"==Qa(e,e.state.selection.from)?-1:1:-1;return Ka(e,t,r)||Ya(e,t)}if(39==n||Ps&&70==n&&"c"==r){let t=39==n?"ltr"==Qa(e,e.state.selection.from)?1:-1:1;return Ka(e,t,r)||Ya(e,t)}return 38==n||Ps&&80==n&&"c"==r?el(e,-1,r)||Ya(e,-1):40==n||Ps&&78==n&&"c"==r?function(e){if(!Bs||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&1==t.nodeType&&0==n&&t.firstChild&&"false"==t.firstChild.contentEditable){let n=t.firstChild;nl(e,n,"true"),setTimeout(()=>nl(e,n,"false"),20)}return!1}(e)||el(e,1,r)||Ya(e,1):r==(Ps?"m":"c")&&(66==n||73==n||89==n||90==n)}function il(e,t){e.someProp("transformCopied",n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:o}=t;for(;i>1&&o>1&&1==r.childCount&&1==r.firstChild.childCount;){i--,o--;let e=r.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),r=e.content}let s=e.someProp("clipboardSerializer")||Vi.fromSchema(e.state.schema),a=fl(),l=a.createElement("div");l.appendChild(s.serializeFragment(r,{document:a}));let c,u=l.firstChild,d=0;for(;u&&1==u.nodeType&&(c=pl[u.nodeName.toLowerCase()]);){for(let e=c.length-1;e>=0;e--){let t=a.createElement(c[e]);for(;l.firstChild;)t.appendChild(l.firstChild);l.appendChild(t),d++}u=l.firstChild}u&&1==u.nodeType&&u.setAttribute("data-pm-slice",`${i} ${o}${d?` -${d}`:""} ${JSON.stringify(n)}`);let p=e.someProp("clipboardTextSerializer",n=>n(t,e))||t.content.textBetween(0,t.content.size,"\n\n");return{dom:l,text:p,slice:t}}function ol(e,t,n,r,i){let o,s,a=i.parent.type.spec.code;if(!n&&!t)return null;let l=!!t&&(r||a||!n);if(l){if(e.someProp("transformPastedText",n=>{t=n(t,a||r,e)}),a)return s=new Yr(qr.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0),e.someProp("transformPasted",t=>{s=t(s,e,!0)}),s;let n=e.someProp("clipboardTextParser",n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,s=Vi.fromSchema(r);o=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement("p"));e&&t.appendChild(s.serializeNode(r.text(e,n)))})}}else e.someProp("transformPastedHTML",t=>{n=t(n,e)}),o=function(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n,r=fl().createElement("div"),i=/<([a-z][^>\s]+)/i.exec(e);(n=i&&pl[i[1].toLowerCase()])&&(e=n.map(e=>"<"+e+">").join("")+e+n.map(e=>"</"+e+">").reverse().join(""));if(r.innerHTML=function(e){let t=window.trustedTypes;if(!t)return e;ml||(ml=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:e=>e}));return ml.createHTML(e)}(e),n)for(let e=0;e<n.length;e++)r=r.querySelector(n[e])||r;return r}(n),$s&&function(e){let t=e.querySelectorAll(Is?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}(o);let c=o&&o.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let e=+u[3];e>0;e--){let e=o.firstChild;for(;e&&1!=e.nodeType;)e=e.nextSibling;if(!e)break;o=e}if(!s){let t=e.someProp("clipboardParser")||e.someProp("domParser")||Li.fromSchema(e.state.schema);s=t.parseSlice(o,{preserveWhitespace:!(!l&&!u),context:i,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||sl.test(e.parentNode.nodeName)?null:{ignore:!0}})}if(u)s=function(e,t){if(!e.size)return e;let n,r=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(t){return e}let{content:i,openStart:o,openEnd:s}=e;for(let e=n.length-2;e>=0;e-=2){let t=r.nodes[n[e]];if(!t||t.hasRequiredAttrs())break;i=qr.from(t.create(n[e+1],i)),o++,s++}return new Yr(i,o,s)}(dl(s,+u[1],+u[2]),u[4]);else if(s=Yr.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r,i=t.node(n).contentMatchAt(t.index(n)),o=[];if(e.forEach(e=>{if(!o)return;let t,n=i.findWrapping(e.type);if(!n)return o=null;if(t=o.length&&r.length&&ll(n,r,e,o[o.length-1],0))o[o.length-1]=t;else{o.length&&(o[o.length-1]=cl(o[o.length-1],r.length));let t=al(e,n);o.push(t),i=i.matchType(t.type),r=n}}),o)return qr.from(o)}return e}(s.content,i),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=dl(s,e,t)}return e.someProp("transformPasted",t=>{s=t(s,e,l)}),s}const sl=/^(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 al(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,qr.from(e));return e}function ll(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let o=ll(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(qr.from(al(n,e,i+1))))}}function cl(e,t){if(0==t)return e;let n=e.content.replaceChild(e.childCount-1,cl(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(qr.empty,!0);return e.copy(n.append(r))}function ul(e,t,n,r,i,o){let s=t<0?e.firstChild:e.lastChild,a=s.content;return e.childCount>1&&(o=0),i<r-1&&(a=ul(a,t,n,r,i+1,o)),i>=n&&(a=t<0?s.contentMatchAt(0).fillBefore(a,o<=i).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(qr.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,s.copy(a))}function dl(e,t,n){return t<e.openStart&&(e=new Yr(ul(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new Yr(ul(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const pl={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let hl=null;function fl(){return hl||(hl=document.implementation.createHTMLDocument("title"))}let ml=null;const gl={},yl={},vl={touchstart:!0,touchmove:!0};class bl{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function wl(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function xl(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>Ml(e,t))})}function Ml(e,t){return e.someProp("handleDOMEvents",n=>{let r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)})}function Sl(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function El(e){return{left:e.clientX,top:e.clientY}}function Cl(e,t,n,r,i){if(-1==r)return!1;let o=e.state.doc.resolve(r);for(let r=o.depth+1;r>0;r--)if(e.someProp(t,t=>r>o.depth?t(e,n,o.nodeAfter,o.before(r),i,!0):t(e,n,o.node(r),o.before(r),i,!1)))return!0;return!1}function Nl(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);"pointer"==n&&r.setMeta("pointer",!0),e.dispatch(r)}function Al(e,t,n,r,i){return Cl(e,"handleClickOn",t,n,r)||e.someProp("handleClick",n=>n(e,t,r))||(i?function(e,t){if(-1==t)return!1;let n,r,i=e.state.selection;i instanceof Jo&&(n=i.node);let o=e.state.doc.resolve(t);for(let e=o.depth+1;e>0;e--){let t=e>o.depth?o.nodeAfter:o.node(e);if(Jo.isSelectable(t)){r=n&&i.$from.depth>0&&e>=i.$from.depth&&o.before(i.$from.depth+1)==i.$from.pos?o.before(i.$from.depth):o.before(e);break}}return null!=r&&(Nl(e,Jo.create(e.state.doc,r),"pointer"),!0)}(e,n):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return!!(r&&r.isAtom&&Jo.isSelectable(r))&&(Nl(e,new Jo(n),"pointer"),!0)}(e,n))}function kl(e,t,n,r){return Cl(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",n=>n(e,t,r))}function Tl(e,t,n,r){return Cl(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",n=>n(e,t,r))||function(e,t,n){if(0!=n.button)return!1;let r=e.state.doc;if(-1==t)return!!r.inlineContent&&(Nl(e,Ko.create(r,0,r.content.size),"pointer"),!0);let i=r.resolve(t);for(let t=i.depth+1;t>0;t--){let n=t>i.depth?i.nodeAfter:i.node(t),o=i.before(t);if(n.inlineContent)Nl(e,Ko.create(r,o+1,o+1+n.content.size),"pointer");else{if(!Jo.isSelectable(n))continue;Nl(e,Jo.create(r,o),"pointer")}return!0}}(e,n,r)}function Ol(e){return Pl(e)}yl.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!Dl(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!Fs||!Is||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!zs||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",t=>t(e,n))||rl(e,n)?n.preventDefault():wl(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",t=>t(e,Ss(13,"Enter"))),e.input.lastIOSEnter=0)},200)}},yl.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},yl.keypress=(e,t)=>{let n=t;if(Dl(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||Ps&&n.metaKey)return;if(e.someProp("handleKeyPress",t=>t(e,n)))return void n.preventDefault();let r=e.state.selection;if(!(r instanceof Ko&&r.$from.sameParent(r.$to))){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();/[\r\n]/.test(t)||e.someProp("handleTextInput",n=>n(e,r.$from.pos,r.$to.pos,t,i))||e.dispatch(i()),n.preventDefault()}};const _l=Ps?"metaKey":"ctrlKey";gl.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=Ol(e),i=Date.now(),o="singleClick";i-e.input.lastClick.time<500&&function(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}(n,e.input.lastClick)&&!n[_l]&&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};let s=e.posAtCoords(El(n));s&&("singleClick"==o?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new Rl(e,s,n,!!r)):("doubleClick"==o?kl:Tl)(e,s.pos,s.inside,n)?n.preventDefault():wl(e,"pointer"))};class Rl{constructor(e,t,n,r){let i,o;if(this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[_l],this.allowDefault=n.shiftKey,t.inside>-1)i=e.state.doc.nodeAt(t.inside),o=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,o=n.depth?n.before():0}const s=r?null:n.target,a=s?e.docView.nearestDesc(s,!0):null;this.target=a&&1==a.nodeDOM.nodeType?a.nodeDOM:null;let{selection:l}=e.state;(0==n.button&&i.type.spec.draggable&&!1!==i.type.spec.selectable||l instanceof Jo&&l.from<=o&&l.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!Rs||this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),wl(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>La(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(El(e))),this.updateAllowDefault(e),this.allowDefault||!t?wl(this.view,"pointer"):Al(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||Bs&&this.mightDrag&&!this.mightDrag.node.isAtom||Is&&!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)?(Nl(this.view,Uo.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):wl(this.view,"pointer")}move(e){this.updateAllowDefault(e),wl(this.view,"pointer"),0==e.buttons&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}function Dl(e,t){return!!e.composing||!!(Bs&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}gl.touchstart=e=>{e.input.lastTouch=Date.now(),Ol(e),wl(e,"pointer")},gl.touchmove=e=>{e.input.lastTouch=Date.now(),wl(e,"pointer")},gl.contextmenu=e=>Ol(e);const Il=Fs?5e3:-1;function Ll(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Pl(e),t))}function Bl(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=function(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function zl(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let 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=ws(e=e.childNodes[t-1])}else{if(!e.parentNode||xs(e))return null;t=hs(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||xs(e))return null;t=hs(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(e&&e.isText(n.nodeValue))return r}}return n||r}function Pl(e,t=!1){if(!(Fs&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),Bl(e),t||e.docView&&e.docView.dirty){let n=Da(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}}yl.compositionstart=yl.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof Ko&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>!1===e.type.spec.inclusive)||Is&&js&&function(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||1!=t.nodeType||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return 1==r.nodeType&&"false"==r.contentEditable}(e)))e.markCursor=e.state.storedMarks||n.marks(),Pl(e,!0),e.markCursor=null;else if(Pl(e,!t.selection.empty),Rs&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&1==n.nodeType&&0!=r;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(3==t.nodeType){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}Ll(e,Il)},yl.compositionend=(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.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,Ll(e,20))};const jl=Os&&_s<15||zs&&Hs<604;function Fl(e,t,n,r,i){let o=ol(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",t=>t(e,i,o||Yr.empty)))return!0;if(!o)return!1;let s=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(o),a=s?e.state.tr.replaceSelectionWith(s,r):e.state.tr.replaceSelection(o);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function $l(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}gl.copy=yl.cut=(e,t)=>{let n=t,r=e.state.selection,i="cut"==n.type;if(r.empty)return;let o=jl?null:n.clipboardData,s=r.content(),{dom:a,text:l}=il(e,s);o?(n.preventDefault(),o.clearData(),o.setData("text/html",a.innerHTML),o.setData("text/plain",l)):function(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}(e,a),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},yl.paste=(e,t)=>{let n=t;if(e.composing&&!Fs)return;let r=jl?null:n.clipboardData,i=e.input.shiftKey&&45!=e.input.lastKeyCode;r&&Fl(e,$l(r),r.getData("text/html"),i,n)?n.preventDefault():function(e,t){if(!e.dom.parentNode)return;let 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();let i=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Fl(e,r.value,null,i,t):Fl(e,r.textContent,r.innerHTML,i,t)},50)}(e,n)};class Hl{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const Ul=Ps?"altKey":"ctrlKey";function ql(e,t){let n=e.someProp("dragCopies",e=>!e(t));return null!=n?n:!t[Ul]}gl.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i,o=e.state.selection,s=o.empty?null:e.posAtCoords(El(n));if(s&&s.pos>=o.from&&s.pos<=(o instanceof Jo?o.to-1:o.to));else if(r&&r.mightDrag)i=Jo.create(e.state.doc,r.mightDrag.pos);else if(n.target&&1==n.target.nodeType){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(i=Jo.create(e.state.doc,t.posBefore))}let a=(i||e.state.selection).content(),{dom:l,text:c,slice:u}=il(e,a);(!n.dataTransfer.files.length||!Is||Ls>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(jl?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",jl||n.dataTransfer.setData("text/plain",c),e.dragging=new Hl(u,ql(e,n),i)},gl.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},yl.dragover=yl.dragenter=(e,t)=>t.preventDefault(),yl.drop=(e,t)=>{try{!function(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(El(t));if(!r)return;let i=e.state.doc.resolve(r.pos),o=n&&n.slice;o?e.someProp("transformPasted",t=>{o=t(o,e,!1)}):o=ol(e,$l(t.dataTransfer),jl?null:t.dataTransfer.getData("text/html"),!1,i);let s=!(!n||!ql(e,t));if(e.someProp("handleDrop",n=>n(e,t,o||Yr.empty,s)))return void t.preventDefault();if(!o)return;t.preventDefault();let a=o?No(e.state.doc,i.pos,o):i.pos;null==a&&(a=i.pos);let l=e.state.tr;if(s){let{node:e}=n;e?e.replace(l):l.deleteSelection()}let c=l.mapping.map(a),u=0==o.openStart&&0==o.openEnd&&1==o.content.childCount,d=l.doc;u?l.replaceRangeWith(c,c,o.content.firstChild):l.replaceRange(c,c,o);if(l.doc.eq(d))return;let p=l.doc.resolve(c);if(u&&Jo.isSelectable(o.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(o.content.firstChild))l.setSelection(new Jo(p));else{let t=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),l.setSelection(Ha(e,p,l.doc.resolve(t)))}e.focus(),e.dispatch(l.setMeta("uiEvent","drop"))}(e,t,e.dragging)}finally{e.dragging=null}},gl.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&La(e)},20))},gl.blur=(e,t)=>{let 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)},gl.beforeinput=(e,t)=>{if(Is&&Fs&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",t=>t(e,Ss(8,"Backspace"))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in yl)gl[e]=yl[e];function Vl(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class Wl{constructor(e,t){this.toDOM=e,this.spec=t||Zl,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:o}=e.mapResult(t.from+r,this.side<0?-1:1);return o?null:new Jl(i-n,i-n,this)}valid(){return!0}eq(e){return this==e||e instanceof Wl&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Vl(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Kl{constructor(e,t){this.attrs=e,this.spec=t||Zl}map(e,t,n,r){let 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 Jl(i,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Kl&&Vl(this.attrs,e.attrs)&&Vl(this.spec,e.spec)}static is(e){return e.type instanceof Kl}destroy(){}}class Gl{constructor(e,t){this.attrs=e,this.spec=t||Zl}map(e,t,n,r){let i=e.mapResult(t.from+r,1);if(i.deleted)return null;let o=e.mapResult(t.to+r,-1);return o.deleted||o.pos<=i.pos?null:new Jl(i.pos-n,o.pos-n,this)}valid(e,t){let n,{index:r,offset:i}=e.content.findIndex(t.from);return i==t.from&&!(n=e.child(r)).isText&&i+n.nodeSize==t.to}eq(e){return this==e||e instanceof Gl&&Vl(this.attrs,e.attrs)&&Vl(this.spec,e.spec)}destroy(){}}class Jl{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new Jl(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new Jl(e,e,new Wl(t,n))}static inline(e,t,n,r){return new Jl(e,t,new Kl(n,r))}static node(e,t,n,r){return new Jl(e,t,new Gl(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof Kl}get widget(){return this.type instanceof Wl}}const Yl=[],Zl={};class Xl{constructor(e,t){this.local=e.length?e:Yl,this.children=t.length?t:Yl}static create(e,t){return t.length?ic(t,e,0,Zl):Ql}find(e,t,n){let r=[];return this.findInner(null==e?0:e,null==t?1e9:t,r,0,n),r}findInner(e,t,n,r,i){for(let o=0;o<this.local.length;o++){let s=this.local[o];s.from<=t&&s.to>=e&&(!i||i(s.spec))&&n.push(s.copy(s.from+r,s.to+r))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let s=this.children[o]+1;this.children[o+2].findInner(e-s,t-s,n,r+s,i)}}map(e,t,n){return this==Ql||0==e.maps.length?this:this.mapInner(e,t,0,0,n||Zl)}mapInner(e,t,n,r,i){let o;for(let s=0;s<this.local.length;s++){let a=this.local[s].map(e,n,r);a&&a.type.valid(t,a)?(o||(o=[])).push(a):i.onRemove&&i.onRemove(this.local[s].spec)}return this.children.length?function(e,t,n,r,i,o,s){let a=e.slice();for(let e=0,t=o;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,i,o)=>{let s=o-i-(n-e);for(let i=0;i<a.length;i+=3){let o=a[i+1];if(o<0||e>o+t-r)continue;let l=a[i]+t-r;n>=l?a[i+1]=e<=l?-2:-1:e>=t&&s&&(a[i]+=s,a[i+1]+=s)}r+=s}),t=n.maps[e].map(t,-1)}let l=!1;for(let t=0;t<a.length;t+=3)if(a[t+1]<0){if(-2==a[t+1]){l=!0,a[t+1]=-1;continue}let c=n.map(e[t]+o),u=c-i;if(u<0||u>=r.content.size){l=!0;continue}let d=n.map(e[t+1]+o,-1)-i,{index:p,offset:h}=r.content.findIndex(u),f=r.maybeChild(p);if(f&&h==u&&h+f.nodeSize==d){let r=a[t+2].mapInner(n,f,c+1,e[t]+o+1,s);r!=Ql?(a[t]=u,a[t+1]=d,a[t+2]=r):(a[t+1]=-2,l=!0)}else l=!0}if(l){let l=function(e,t,n,r,i,o,s){function a(e,t){for(let o=0;o<e.local.length;o++){let a=e.local[o].map(r,i,t);a?n.push(a):s.onRemove&&s.onRemove(e.local[o].spec)}for(let n=0;n<e.children.length;n+=3)a(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)-1==e[n+1]&&a(e[n+2],t[n]+o+1);return n}(a,e,t,n,i,o,s),c=ic(l,r,0,s);t=c.local;for(let e=0;e<a.length;e+=3)a[e+1]<0&&(a.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<a.length&&a[t]<n;)t+=3;a.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new Xl(t.sort(oc),a)}(this.children,o||[],e,t,n,r,i):o?new Xl(o.sort(oc),Yl):Ql}add(e,t){return t.length?this==Ql?Xl.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let r,i=0;e.forEach((e,o)=>{let s,a=o+n;if(s=nc(t,e,a)){for(r||(r=this.children.slice());i<r.length&&r[i]<o;)i+=3;r[i]==o?r[i+2]=r[i+2].addInner(e,s,a+1):r.splice(i,0,o,o+e.nodeSize,ic(s,e,a+1,Zl)),i+=3}});let o=tc(i?rc(t):t,-n);for(let t=0;t<o.length;t++)o[t].type.valid(e,o[t])||o.splice(t--,1);return new Xl(o.length?this.local.concat(o).sort(oc):this.local,r||this.children)}remove(e){return 0==e.length||this==Ql?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,r=this.local;for(let r=0;r<n.length;r+=3){let i,o=n[r]+t,s=n[r+1]+t;for(let t,n=0;n<e.length;n++)(t=e[n])&&t.from>o&&t.to<s&&(e[n]=null,(i||(i=[])).push(t));if(!i)continue;n==this.children&&(n=this.children.slice());let a=n[r+2].removeInner(i,o+1);a!=Ql?n[r+2]=a:(n.splice(r,3),r-=3)}if(r.length)for(let n,i=0;i<e.length;i++)if(n=e[i])for(let e=0;e<r.length;e++)r[e].eq(n,t)&&(r==this.local&&(r=this.local.slice()),r.splice(e--,1));return n==this.children&&r==this.local?this:r.length||n.length?new Xl(r,n):Ql}forChild(e,t){if(this==Ql)return this;if(t.isLeaf)return Xl.empty;let n,r;for(let t=0;t<this.children.length;t+=3)if(this.children[t]>=e){this.children[t]==e&&(n=this.children[t+2]);break}let i=e+1,o=i+t.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<o&&t.to>i&&t.type instanceof Kl){let e=Math.max(i,t.from)-i,n=Math.min(o,t.to)-i;e<n&&(r||(r=[])).push(t.copy(e,n))}}if(r){let e=new Xl(r.sort(oc),Yl);return n?new ec([e,n]):e}return n||Ql}eq(e){if(this==e)return!0;if(!(e instanceof Xl)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return sc(this.localsInner(e))}localsInner(e){if(this==Ql)return Yl;if(e.inlineContent||!this.local.some(Kl.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof Kl||t.push(this.local[e]);return t}forEachSet(e){e(this)}}Xl.empty=new Xl([],[]),Xl.removeOverlap=sc;const Ql=Xl.empty;class ec{constructor(e){this.members=e}map(e,t){const n=this.members.map(n=>n.map(e,t,Zl));return ec.from(n)}forChild(e,t){if(t.isLeaf)return Xl.empty;let n=[];for(let r=0;r<this.members.length;r++){let i=this.members[r].forChild(e,t);i!=Ql&&(i instanceof ec?n=n.concat(i.members):n.push(i))}return ec.from(n)}eq(e){if(!(e instanceof ec)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(e);if(i.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<i.length;e++)t.push(i[e])}else t=i}return t?sc(n?t:t.sort(oc)):Yl}static from(e){switch(e.length){case 0:return Ql;case 1:return e[0];default:return new ec(e.every(e=>e instanceof Xl)?e:e.reduce((e,t)=>e.concat(t instanceof Xl?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function tc(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(new Jl(i.from+t,i.to+t,i.type))}return n}function nc(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,i=null;for(let t,o=0;o<e.length;o++)(t=e[o])&&t.from>n&&t.to<r&&((i||(i=[])).push(t),e[o]=null);return i}function rc(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function ic(e,t,n,r){let i=[],o=!1;t.forEach((t,s)=>{let a=nc(e,t,s+n);if(a){o=!0;let e=ic(a,t,n+s+1,r);e!=Ql&&i.push(s,s+t.nodeSize,e)}});let s=tc(o?rc(e):e,-n).sort(oc);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||(r.onRemove&&r.onRemove(s[e].spec),s.splice(e--,1));return s.length||i.length?new Xl(s,i):Ql}function oc(e,t){return e.from-t.from||e.to-t.to}function sc(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let i=n+1;i<t.length;i++){let 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),ac(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),ac(t,i+1,o.copy(r.to,o.to)))}}return t}function ac(e,t,n){for(;t<e.length&&oc(n,e[t])>0;)t++;e.splice(t,0,n)}function lc(e){let t=[];return e.someProp("decorations",n=>{let r=n(e.state);r&&r!=Ql&&t.push(r)}),e.cursorWrapper&&t.push(Xl.create(e.state.doc,[e.cursorWrapper.deco])),ec.from(t)}const cc={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},uc=Os&&_s<=11;class dc{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class pc{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new dc,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);Os&&_s<=11&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():Bs&&e.composing&&t.some(e=>"childList"==e.type&&"TR"==e.target.nodeName)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),uc&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,cc)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Ua(this.view)){if(this.suppressingSelectionUpdates)return La(this.view);if(Os&&_s<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&ys(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t,n=new Set;for(let t=e.focusNode;t;t=fs(t))n.add(t);for(let r=e.anchorNode;r;r=fs(r))if(n.has(r)){t=r;break}let r=t&&this.view.docView.nearestDesc(t);return r&&r.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Ua(e)&&!this.ignoreSelectionChange(n),i=-1,o=-1,s=!1,a=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],a);n&&(i=i<0?n.from:Math.min(n.from,i),o=o<0?n.to:Math.max(n.to,o),n.typeOver&&(s=!0))}if(Rs&&a.length){let t=a.filter(e=>"BR"==e.nodeName);if(2==t.length){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;!t||"LI"!=t.nodeName||n&&gc(e,n)==t||r.remove()}}}else if((Is||Bs)&&a.some(e=>"BR"==e.nodeName)&&(8==e.input.lastKeyCode||46==e.input.lastKeyCode))for(let e of a)if("BR"==e.nodeName&&e.parentNode){let t=e.nextSibling;t&&1==t.nodeType&&"false"==t.contentEditable&&e.parentNode.removeChild(e)}let l=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Ms(n)&&(l=Da(e))&&l.eq(Uo.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,La(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,o),function(e){if(hc.has(e))return;if(hc.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)){if(e.requiresGeckoHackNode=Rs,fc)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."),fc=!0}}(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,function(e,t){var n;let{focusNode:r,focusOffset:i}=e.domSelectionRange();for(let o of t)if("TR"==(null===(n=o.parentNode)||void 0===n?void 0:n.nodeName)){let t=o.nextSibling;for(;t&&"TD"!=t.nodeName&&"TH"!=t.nodeName;)t=t.nextSibling;if(t){let n=t;for(;;){let e=n.firstChild;if(!e||1!=e.nodeType||"false"==e.contentEditable||/^(BR|IMG)$/.test(e.nodeName))break;n=e}n.insertBefore(o,n.firstChild),r==o&&e.domSelection().collapse(o,i)}else o.parentNode.removeChild(o)}}(e,a)),this.handleDOMChange(i,o,s,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||La(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let 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(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),3==r.nodeType&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling;if(Os&&_s<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:o}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!o||Array.prototype.indexOf.call(e.addedNodes,o)<0)&&(i=o)}let o=r&&r.parentNode==e.target?hs(r)+1:0,s=n.localPosFromDOM(e.target,o,-1),a=i&&i.parentNode==e.target?hs(i):e.target.childNodes.length;return{from:s,to:n.localPosFromDOM(e.target,a,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})}}let hc=new WeakMap,fc=!1;function mc(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,o=t.endOffset,s=e.domAtPos(e.state.selection.anchor);return ys(s.node,s.offset,i,o)&&([n,r,i,o]=[i,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}}function gc(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function yc(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(Bs&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}if(e.parentNode.lastChild==e||Bs&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}const vc=/^(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 bc(e,t,n,r,i){let o=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=Da(e,t);if(n&&!e.state.selection.eq(n)){if(Is&&Fs&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",t=>t(e,Ss(13,"Enter"))))return;let r=e.state.tr.setSelection(n);"pointer"==t?r.setMeta("pointer",!0):"key"==t&&r.scrollIntoView(),o&&r.setMeta("composition",o),e.dispatch(r)}return}let s=e.state.doc.resolve(t),a=s.sharedDepth(n);t=s.before(a+1),n=e.state.doc.resolve(n).after(a+1);let l,c,u=e.state.selection,d=function(e,t,n){let r,{node:i,fromOffset:o,toOffset:s,from:a,to:l}=e.docView.parseRange(t,n),c=e.domSelectionRange(),u=c.anchorNode;if(u&&e.dom.contains(1==u.nodeType?u:u.parentNode)&&(r=[{node:u,offset:c.anchorOffset}],Ms(c)||r.push({node:c.focusNode,offset:c.focusOffset})),Is&&8===e.input.lastKeyCode)for(let e=s;e>o;e--){let t=i.childNodes[e-1],n=t.pmViewDesc;if("BR"==t.nodeName&&!n){s=e;break}if(!n||n.size)break}let d=e.state.doc,p=e.someProp("domParser")||Li.fromSchema(e.state.schema),h=d.resolve(a),f=null,m=p.parse(i,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:o,to:s,preserveWhitespace:"pre"!=h.parent.type.whitespace||"full",findPositions:r,ruleFromNode:yc,context:h});if(r&&null!=r[0].pos){let e=r[0].pos,t=r[1]&&r[1].pos;null==t&&(t=e),f={anchor:e+a,head:t+a}}return{doc:m,sel:f,from:a,to:l}}(e,t,n),p=e.state.doc,h=p.slice(d.from,d.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(l=e.state.selection.to,c="end"):(l=e.state.selection.from,c="start"),e.input.lastKeyCode=null;let f=function(e,t,n,r,i){let o=e.findDiffStart(t,n);if(null==o)return null;let{a:s,b:a}=e.findDiffEnd(t,n+e.size,n+t.size);if("end"==i){r-=s+Math.max(0,o-Math.min(s,a))-o}if(s<o&&e.size<t.size){let e=r<=o&&r>=s?o-r:0;o-=e,o&&o<t.size&&Mc(t.textBetween(o-1,o+1))&&(o+=e?1:-1),a=o+(a-s),s=o}else if(a<o){let t=r<=o&&r>=a?o-r:0;o-=t,o&&o<e.size&&Mc(e.textBetween(o-1,o+1))&&(o+=t?1:-1),s=o+(s-a),a=o}return{start:o,endA:s,endB:a}}(h.content,d.doc.content,d.from,l,c);if(f&&e.input.domChangeCount++,(zs&&e.input.lastIOSEnter>Date.now()-225||Fs)&&i.some(e=>1==e.nodeType&&!vc.test(e.nodeName))&&(!f||f.endA>=f.endB)&&e.someProp("handleKeyDown",t=>t(e,Ss(13,"Enter"))))return void(e.input.lastIOSEnter=0);if(!f){if(!(r&&u instanceof Ko&&!u.empty&&u.$head.sameParent(u.$anchor))||e.composing||d.sel&&d.sel.anchor!=d.sel.head){if(d.sel){let t=wc(e,e.state.doc,d.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);o&&n.setMeta("composition",o),e.dispatch(n)}}return}f={start:u.from,endA:u.to,endB:u.to}}e.state.selection.from<e.state.selection.to&&f.start==f.endB&&e.state.selection instanceof Ko&&(f.start>e.state.selection.from&&f.start<=e.state.selection.from+2&&e.state.selection.from>=d.from?f.start=e.state.selection.from:f.endA<e.state.selection.to&&f.endA>=e.state.selection.to-2&&e.state.selection.to<=d.to&&(f.endB+=e.state.selection.to-f.endA,f.endA=e.state.selection.to)),Os&&_s<=11&&f.endB==f.start+1&&f.endA==f.start&&f.start>d.from&&"  "==d.doc.textBetween(f.start-d.from-1,f.start-d.from+1)&&(f.start--,f.endA--,f.endB--);let m=d.doc.resolveNoCache(f.start-d.from),g=d.doc.resolveNoCache(f.endB-d.from),y=p.resolve(f.start),v=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=f.endA;if((zs&&e.input.lastIOSEnter>Date.now()-225&&(!v||i.some(e=>"DIV"==e.nodeName||"P"==e.nodeName))||!v&&m.pos<d.doc.content.size&&(!m.sameParent(g)||!m.parent.inlineContent)&&m.pos<g.pos&&!/\S/.test(d.doc.textBetween(m.pos,g.pos,"","")))&&e.someProp("handleKeyDown",t=>t(e,Ss(13,"Enter"))))return void(e.input.lastIOSEnter=0);if(e.state.selection.anchor>f.start&&function(e,t,n,r,i){if(n-t<=i.pos-r.pos||xc(r,!0,!1)<i.pos)return!1;let o=e.resolve(t);if(!r.parent.isTextblock){let e=o.nodeAfter;return null!=e&&n==t+e.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let s=e.resolve(xc(o,!0,!0));return!(!s.parent.isTextblock||s.pos>n||xc(s,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(s.parent.content)}(p,f.start,f.endA,m,g)&&e.someProp("handleKeyDown",t=>t(e,Ss(8,"Backspace"))))return void(Fs&&Is&&e.domObserver.suppressSelectionUpdates());Is&&f.endB==f.start&&(e.input.lastChromeDelete=Date.now()),Fs&&!v&&m.start()!=g.start()&&0==g.parentOffset&&m.depth==g.depth&&d.sel&&d.sel.anchor==d.sel.head&&d.sel.head==f.endA&&(f.endB-=2,g=d.doc.resolveNoCache(f.endB-d.from),setTimeout(()=>{e.someProp("handleKeyDown",function(t){return t(e,Ss(13,"Enter"))})},20));let b,w=f.start,x=f.endA,M=t=>{let n=t||e.state.tr.replace(w,x,d.doc.slice(f.start-d.from,f.endB-d.from));if(d.sel){let t=wc(e,n.doc,d.sel);t&&!(Is&&e.composing&&t.empty&&(f.start!=f.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==w||t.head==n.mapping.map(x)-1)||Os&&t.empty&&t.head==w)&&n.setSelection(t)}return o&&n.setMeta("composition",o),n.scrollIntoView()};if(v)if(m.pos==g.pos){Os&&_s<=11&&0==m.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>La(e),20));let t=M(e.state.tr.delete(w,x)),n=p.resolve(f.start).marksAcross(p.resolve(f.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(f.endA==f.endB&&(b=function(e,t){let n,r,i,o=e.firstChild.marks,s=t.firstChild.marks,a=o,l=s;for(let e=0;e<s.length;e++)a=s[e].removeFromSet(a);for(let e=0;e<o.length;e++)l=o[e].removeFromSet(l);if(1==a.length&&0==l.length)r=a[0],n="add",i=e=>e.mark(r.addToSet(e.marks));else{if(0!=a.length||1!=l.length)return null;r=l[0],n="remove",i=e=>e.mark(r.removeFromSet(e.marks))}let c=[];for(let e=0;e<t.childCount;e++)c.push(i(t.child(e)));if(qr.from(c).eq(e))return{mark:r,type:n}}(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,f.endA-y.start())))){let t=M(e.state.tr);"add"==b.type?t.addMark(w,x,b.mark):t.removeMark(w,x,b.mark),e.dispatch(t)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let t=m.parent.textBetween(m.parentOffset,g.parentOffset),n=()=>M(e.state.tr.insertText(t,w,x));e.someProp("handleTextInput",r=>r(e,w,x,t,n))||e.dispatch(n())}else e.dispatch(M());else e.dispatch(M())}function wc(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Ha(e,t.resolve(n.anchor),t.resolve(n.head))}function xc(e,t,n){let r=e.depth,i=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function Mc(e){if(2!=e.length)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}class Sc{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new bl,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(kc),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Nc(this),Cc(this),this.nodeViews=Ac(this),this.docView=ya(this.state.doc,Ec(this),lc(this),this.dom,this),this.domObserver=new pc(this,(e,t,n,r)=>bc(this,e,t,n,r)),this.domObserver.start(),function(e){for(let t in gl){let n=gl[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!Sl(e,t)||Ml(e,t)||!e.editable&&t.type in yl||n(e,t)},vl[t]?{passive:!0}:void 0)}Bs&&e.dom.addEventListener("input",()=>null),xl(e)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&xl(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(kc),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let r=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(Bl(this),o=!0),this.state=e;let s=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(s||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=Ac(this);(function(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r})(e,this.nodeViews)&&(this.nodeViews=e,i=!0)}(s||t.handleDOMEvents!=this._props.handleDOMEvents)&&xl(this),this.editable=Nc(this),Cc(this);let a=lc(this),l=Ec(this),c=r.plugins==e.plugins||r.doc.eq(e.doc)?e.scrollToSelection>r.scrollToSelection?"to selection":"preserve":"reset",u=i||!this.docView.matchesNode(e.doc,l,a);!u&&e.selection.eq(r.selection)||(o=!0);let d="preserve"==c&&o&&null==this.dom.style.overflowAnchor&&function(e){let t,n,r=e.dom.getBoundingClientRect(),i=Math.max(0,r.top);for(let o=(r.left+r.right)/2,s=i+1;s<Math.min(innerHeight,r.bottom);s+=5){let r=e.root.elementFromPoint(o,s);if(!r||r==e.dom||!e.dom.contains(r))continue;let a=r.getBoundingClientRect();if(a.top>=i-20){t=r,n=a.top;break}}return{refDOM:t,refTop:n,stack:Ks(e.dom)}}(this);if(o){this.domObserver.stop();let t=u&&(Os||Is)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&function(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}(r.selection,e.selection);if(u){let n=Is?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=zl(this)),!i&&this.docView.update(e.doc,l,a,this)||(this.docView.updateOuterDeco(l),this.docView.destroy(),this.docView=ya(e.doc,l,a,this.dom,this)),!n||this.trackWrites&&this.dom.contains(this.trackWrites)||(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return ys(t.node,t.offset,n.anchorNode,n.anchorOffset)}(this))?La(this,t):(Fa(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"==c?this.dom.scrollTop=0:"to selection"==c?this.scrollToSelection():d&&function({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;Gs(n,0==r?0:r-t)}(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&this.dom.contains(1==e.nodeType?e:e.parentNode))if(this.someProp("handleScrollToSelection",e=>e(this)));else if(this.state.selection instanceof Jo){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&Ws(this,t.getBoundingClientRect(),e)}else Ws(this,this.coordsAtPos(this.state.selection.head,1),e);else;}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(e&&e.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}}updateDraggedNode(e,t){let n=e.node,r=-1;if(this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new Hl(e.slice,e.move,r<0?void 0:Jo.create(this.state.doc,r))}someProp(e,t){let n,r=this._props&&this._props[e];if(null!=r&&(n=t?t(r):r))return n;for(let r=0;r<this.directPlugins.length;r++){let i=this.directPlugins[r].props[e];if(null!=i&&(n=t?t(i):i))return n}let i=this.state.plugins;if(i)for(let r=0;r<i.length;r++){let o=i[r].props[e];if(null!=o&&(n=t?t(o):o))return n}}hasFocus(){if(Os){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(Js)return e.focus(Js);let t=Ks(e);e.focus(null==Js?{get preventScroll(){return Js={preventScroll:!0},!0}}:void 0),Js||(Js=!1,Gs(t,0))}(this.dom),La(this),this.domObserver.start()}get root(){let e=this._root;if(null==e)for(let e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e;return e||document}updateRoot(){this._root=null}posAtCoords(e){return Qs(this,e)}coordsAtPos(e,t=1){return ra(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return da(this,t||this.state,e)}pasteHTML(e,t){return Fl(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Fl(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return il(this,e)}destroy(){this.docView&&(!function(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],lc(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,ms=null)}get isDestroyed(){return null==this.docView}dispatchEvent(e){return function(e,t){Ml(e,t)||!gl[t.type]||!e.editable&&t.type in yl||gl[t.type](e,t)}(this,e)}domSelectionRange(){let e=this.domSelection();return e?Bs&&11===this.root.nodeType&&function(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return mc(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",r,!0),n?mc(e,n):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Ec(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",n=>{if("function"==typeof n&&(n=n(e.state)),n)for(let e in n)"class"==e?t.class+=" "+n[e]:"style"==e?t.style=(t.style?t.style+";":"")+n[e]:t[e]||"contenteditable"==e||"nodeName"==e||(t[e]=String(n[e]))}),t.translate||(t.translate="no"),[Jl.node(0,e.state.doc.content.size,t)]}function Cc(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:Jl.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Nc(e){return!e.someProp("editable",t=>!1===t(e.state))}function Ac(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function kc(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")}Sc.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};for(var Tc={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:"'"},Oc={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},_c="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Rc="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Dc=0;Dc<10;Dc++)Tc[48+Dc]=Tc[96+Dc]=String(Dc);for(Dc=1;Dc<=24;Dc++)Tc[Dc+111]="F"+Dc;for(Dc=65;Dc<=90;Dc++)Tc[Dc]=String.fromCharCode(Dc+32),Oc[Dc]=String.fromCharCode(Dc);for(var Ic in Tc)Oc.hasOwnProperty(Ic)||(Oc[Ic]=Tc[Ic]);const Lc="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Bc="undefined"!=typeof navigator&&/Win/.test(navigator.platform);function zc(e){let t,n,r,i,o=e.split(/-(?!$)/),s=o[o.length-1];"Space"==s&&(s=" ");for(let e=0;e<o.length-1;e++){let s=o[e];if(/^(cmd|meta|m)$/i.test(s))i=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else if(/^s(hift)?$/i.test(s))r=!0;else{if(!/^mod$/i.test(s))throw new Error("Unrecognized modifier name: "+s);Lc?i=!0:n=!0}}return t&&(s="Alt-"+s),n&&(s="Ctrl-"+s),i&&(s="Meta-"+s),r&&(s="Shift-"+s),s}function Pc(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function jc(e){let t=function(e){let t=Object.create(null);for(let n in e)t[zc(n)]=e[n];return t}(e);return function(e,n){let r,i=function(e){var t=!(_c&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Rc&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?Oc:Tc)[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[Pc(i,n)];if(o&&o(e.state,e.dispatch,e))return!0;if(1==i.length&&" "!=i){if(n.shiftKey){let r=t[Pc(i,n,!1)];if(r&&r(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(Bc&&n.ctrlKey&&n.altKey)&&(r=Tc[n.keyCode])&&r!=i){let i=t[Pc(r,n)];if(i&&i(e.state,e.dispatch,e))return!0}}return!1}}const Fc=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function $c(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}const Hc=(e,t,n)=>{let r=$c(e,n);if(!r)return!1;let i=Gc(r);if(!i){let n=r.blockRange(),i=n&&yo(n);return null!=i&&(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let o=i.nodeBefore;if(lu(e,i,t,-1))return!0;if(0==r.parent.content.size&&(Wc(o,"end")||Jo.isSelectable(o)))for(let n=r.depth;;n--){let s=Ao(e.doc,r.before(n),r.after(n),Yr.empty);if(s&&s.slice.size<s.to-s.from){if(t){let n=e.tr.step(s);n.setSelection(Wc(o,"end")?Uo.findFrom(n.doc.resolve(n.mapping.map(i.pos,-1)),-1):Jo.create(n.doc,i.pos-o.nodeSize)),t(n.scrollIntoView())}return!0}if(1==n||r.node(n-1).childCount>1)break}return!(!o.isAtom||i.depth!=r.depth-1)&&(t&&t(e.tr.delete(i.pos-o.nodeSize,i.pos).scrollIntoView()),!0)},Uc=(e,t,n)=>{let r=$c(e,n);if(!r)return!1;let i=Gc(r);return!!i&&Vc(e,i,t)},qc=(e,t,n)=>{let r=Jc(e,n);if(!r)return!1;let i=Xc(r);return!!i&&Vc(e,i,t)};function Vc(e,t,n){let r=t.nodeBefore,i=t.pos-1;for(;!r.isTextblock;i--){if(r.type.spec.isolating)return!1;let e=r.lastChild;if(!e)return!1;r=e}let o=t.nodeAfter,s=t.pos+1;for(;!o.isTextblock;s++){if(o.type.spec.isolating)return!1;let e=o.firstChild;if(!e)return!1;o=e}let a=Ao(e.doc,i,s,Yr.empty);if(!a||a.from!=i||a instanceof po&&a.slice.size>=s-i)return!1;if(n){let t=e.tr.step(a);t.setSelection(Ko.create(t.doc,i)),n(t.scrollIntoView())}return!0}function Wc(e,t,n=!1){for(let r=e;r;r="start"==t?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)return!1}return!1}const Kc=(e,t,n)=>{let{$head:r,empty:i}=e.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;o=Gc(r)}let s=o&&o.nodeBefore;return!(!s||!Jo.isSelectable(s))&&(t&&t(e.tr.setSelection(Jo.create(e.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function Gc(e){if(!e.parent.type.spec.isolating)for(let 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 Jc(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}const Yc=(e,t,n)=>{let r=Jc(e,n);if(!r)return!1;let i=Xc(r);if(!i)return!1;let o=i.nodeAfter;if(lu(e,i,t,1))return!0;if(0==r.parent.content.size&&(Wc(o,"start")||Jo.isSelectable(o))){let n=Ao(e.doc,r.before(),r.after(),Yr.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(Wc(o,"start")?Uo.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):Jo.create(r.doc,r.mapping.map(i.pos))),t(r.scrollIntoView())}return!0}}return!(!o.isAtom||i.depth!=r.depth-1)&&(t&&t(e.tr.delete(i.pos,i.pos+o.nodeSize).scrollIntoView()),!0)},Zc=(e,t,n)=>{let{$head:r,empty:i}=e.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;o=Xc(r)}let s=o&&o.nodeAfter;return!(!s||!Jo.isSelectable(s))&&(t&&t(e.tr.setSelection(Jo.create(e.doc,o.pos)).scrollIntoView()),!0)};function Xc(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let 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}const Qc=(e,t)=>{let n,r=e.selection,i=r instanceof Jo;if(i){if(r.node.isTextblock||!So(e.doc,r.from))return!1;n=r.from}else if(n=Co(e.doc,r.from,-1),null==n)return!1;if(t){let r=e.tr.join(n);i&&r.setSelection(Jo.create(r.doc,n-e.doc.resolve(n).nodeBefore.nodeSize)),t(r.scrollIntoView())}return!0},eu=(e,t)=>{let n,r=e.selection;if(r instanceof Jo){if(r.node.isTextblock||!So(e.doc,r.to))return!1;n=r.to}else if(n=Co(e.doc,r.to,1),null==n)return!1;return t&&t(e.tr.join(n).scrollIntoView()),!0},tu=(e,t)=>{let{$from:n,$to:r}=e.selection,i=n.blockRange(r),o=i&&yo(i);return null!=o&&(t&&t(e.tr.lift(i,o).scrollIntoView()),!0)},nu=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!(!n.parent.type.spec.code||!n.sameParent(r))&&(t&&t(e.tr.insertText("\n").scrollIntoView()),!0)};function ru(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const iu=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),o=n.indexAfter(-1),s=ru(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,s.createAndFill());i.setSelection(Uo.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},ou=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof Zo||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=ru(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,s=e.tr.insert(n,o.createAndFill());s.setSelection(Ko.create(s.doc,n+1)),t(s.scrollIntoView())}return!0},su=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(Mo(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&yo(r);return null!=i&&(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)},au=(e,t)=>{let n,{$from:r,to:i}=e.selection,o=r.sharedDepth(i);return 0!=o&&(n=r.before(o),t&&t(e.tr.setSelection(Jo.create(e.doc,n))),!0)};function lu(e,t,n,r){let i,o,s=t.nodeBefore,a=t.nodeAfter,l=s.type.spec.isolating||a.type.spec.isolating;if(!l&&function(e,t,n){let 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&&!So(e.doc,t.pos)||(n&&n(e.tr.join(t.pos).scrollIntoView()),0)))}(e,t,n))return!0;let c=!l&&t.parent.canReplace(t.index(),t.index()+1);if(c&&(i=(o=s.contentMatchAt(s.childCount)).findWrapping(a.type))&&o.matchType(i[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,o=qr.empty;for(let e=i.length-1;e>=0;e--)o=qr.from(i[e].create(null,o));o=qr.from(s.copy(o));let l=e.tr.step(new ho(t.pos-1,r,t.pos,r,new Yr(o,1,0),i.length,!0)),c=l.doc.resolve(r+2*i.length);c.nodeAfter&&c.nodeAfter.type==s.type&&So(l.doc,c.pos)&&l.join(c.pos),n(l.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&l?null:Uo.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),p=d&&yo(d);if(null!=p&&p>=t.depth)return n&&n(e.tr.lift(d,p).scrollIntoView()),!0;if(c&&Wc(a,"start",!0)&&Wc(s,"end")){let r=s,i=[];for(;i.push(r),!r.isTextblock;)r=r.lastChild;let o=a,l=1;for(;!o.isTextblock;o=o.firstChild)l++;if(r.canReplace(r.childCount,r.childCount,o.content)){if(n){let r=qr.empty;for(let e=i.length-1;e>=0;e--)r=qr.from(i[e].copy(r));n(e.tr.step(new ho(t.pos-i.length,t.pos+a.nodeSize,t.pos+l,t.pos+a.nodeSize-l,new Yr(r,i.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function cu(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return!!i.node(o).isTextblock&&(n&&n(t.tr.setSelection(Ko.create(t.doc,e<0?i.start(o):i.end(o)))),!0)}}const uu=cu(-1),du=cu(1);function pu(e,t=null){return function(n,r){let{$from:i,$to:o}=n.selection,s=i.blockRange(o),a=s&&vo(s,e,t);return!!a&&(r&&r(n.tr.wrap(s,a).scrollIntoView()),!0)}}function hu(e,t=null){return function(n,r){let i=!1;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:o},$to:{pos:s}}=n.selection.ranges[r];n.doc.nodesBetween(o,s,(r,o)=>{if(i)return!1;if(r.isTextblock&&!r.hasMarkup(e,t))if(r.type==e)i=!0;else{let t=n.doc.resolve(o),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:o},$to:{pos:s}}=n.selection.ranges[r];i.setBlockType(o,s,e,t)}r(i.scrollIntoView())}return!0}}function fu(e,t=null){return function(n,r){let{$from:i,$to:o}=n.selection,s=i.blockRange(o);if(!s)return!1;let a=r?n.tr:null;return!!function(e,t,n,r=null){let i=!1,o=t,s=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;let e=s.resolve(t.start-2);o=new pi(e,e,t.depth),t.endIndex<t.parent.childCount&&(t=new pi(t.$from,s.resolve(t.$to.end(t.depth)),t.depth)),i=!0}let a=vo(o,n,r,t);if(!a)return!1;e&&function(e,t,n,r,i){let o=qr.empty;for(let e=n.length-1;e>=0;e--)o=qr.from(n[e].type.create(n[e].attrs,o));e.step(new ho(t.start-(r?2:0),t.end,t.start,t.end,new Yr(o,0,0),n.length,!0));let s=0;for(let e=0;e<n.length;e++)n[e].type==i&&(s=e+1);let a=n.length-s,l=t.start+n.length-(r?2:0),c=t.parent;for(let n=t.startIndex,r=t.endIndex,i=!0;n<r;n++,i=!1)!i&&Mo(e.doc,l,a)&&(e.split(l,a),l+=2*a),l+=c.child(n).nodeSize}(e,t,a,i,n);return!0}(a,s,e,t)&&(r&&r(a.scrollIntoView()),!0)}}function mu(e){return function(t,n){let{$from:r,$to:i}=t.selection,o=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);return!!o&&(!n||(r.node(o.depth-1).type==e?function(e,t,n,r){let i=e.tr,o=r.end,s=r.$to.end(r.depth);o<s&&(i.step(new ho(o-1,s,o,s,new Yr(qr.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new pi(i.doc.resolve(r.$from.pos),i.doc.resolve(s),r.depth));const a=yo(r);if(null==a)return!1;i.lift(r,a);let l=i.doc.resolve(i.mapping.map(o,-1)-1);So(i.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&i.join(l.pos);return t(i.scrollIntoView()),!0}(t,n,e,o):function(e,t,n){let r=e.tr,i=n.parent;for(let e=n.end,t=n.endIndex-1,o=n.startIndex;t>o;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let o=r.doc.resolve(n.start),s=o.nodeAfter;if(r.mapping.map(n.end)!=n.start+o.nodeAfter.nodeSize)return!1;let a=0==n.startIndex,l=n.endIndex==i.childCount,c=o.node(-1),u=o.index(-1);if(!c.canReplace(u+(a?0:1),u+1,s.content.append(l?qr.empty:qr.from(i))))return!1;let d=o.pos,p=d+s.nodeSize;return r.step(new ho(d-(a?1:0),p+(l?1:0),d+1,p-1,new Yr((a?qr.empty:qr.from(i.copy(qr.empty))).append(l?qr.empty:qr.from(i.copy(qr.empty))),a?0:1,l?0:1),a?0:1)),t(r.scrollIntoView()),!0}(t,n,o)))}}function gu(e){return function(t,n){let{$from:r,$to:i}=t.selection,o=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);if(!o)return!1;let s=o.startIndex;if(0==s)return!1;let a=o.parent,l=a.child(s-1);if(l.type!=e)return!1;if(n){let r=l.lastChild&&l.lastChild.type==a.type,i=qr.from(r?e.create():null),s=new Yr(qr.from(e.create(null,qr.from(a.type.create(null,i)))),r?3:1,0),c=o.start,u=o.end;n(t.tr.step(new ho(c-(r?3:1),u,c,u,s,1,!0)).scrollIntoView())}return!0}}"undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&os.platform();var yu=Object.defineProperty,vu=(e,t)=>{for(var n in t)yu(e,n,{get:t[n],enumerable:!0})};function bu(e){const{state:t,transaction:n}=e;let{selection:r}=n,{doc:i}=n,{storedMarks:o}=n;return{...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 wu=class{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:n}=this,{view:r}=t,{tr:i}=n,o=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,(...e)=>{const n=t(...e)(o);return i.getMeta("preventDispatch")||this.hasCustomState||r.dispatch(i),n}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:n,editor:r,state:i}=this,{view:o}=r,s=[],a=!!e,l=e||i.tr,c={...Object.fromEntries(Object.entries(n).map(([e,n])=>[e,(...e)=>{const r=this.buildProps(l,t),i=n(...e)(r);return s.push(i),c}])),run:()=>(a||!t||l.getMeta("preventDispatch")||this.hasCustomState||o.dispatch(l),s.every(e=>!0===e))};return c}createCan(e){const{rawCommands:t,state:n}=this,r=!1,i=e||n.tr,o=this.buildProps(i,r),s=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,(...e)=>t(...e)({...o,dispatch:void 0})]));return{...s,chain:()=>this.createChain(i,r)}}buildProps(e,t=!0){const{rawCommands:n,editor:r,state:i}=this,{view:o}=r,s={tr:e,editor:r,view:o,state:bu({state:i,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,(...e)=>t(...e)(s)]))}};return s}},xu=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){const n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}once(e,t){const n=(...r)=>{this.off(e,n),t.apply(this,r)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}};var Mu=e=>{const t=e.childNodes;for(let n=t.length-1;n>=0;n-=1){const r=t[n];3===r.nodeType&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):1===r.nodeType&&Mu(r)}return e};function Su(e){if("undefined"==typeof window)throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const t=`<body>${e}</body>`,n=(new window.DOMParser).parseFromString(t,"text/html").body;return Mu(n)}function Eu(e,t,n){if(e instanceof fi||e instanceof qr)return e;n={slice:!0,parseOptions:{},...n};const r="string"==typeof e;if("object"==typeof e&&null!==e)try{if(Array.isArray(e)&&e.length>0)return qr.fromArray(e.map(e=>t.nodeFromJSON(e)));const r=t.nodeFromJSON(e);return n.errorOnInvalidContent&&r.check(),r}catch(r){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:r});return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",r),Eu("",t,n)}if(r){if(n.errorOnInvalidContent){let r=!1,i="";const o=new Di({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:e=>(r=!0,i="string"==typeof e?e:e.outerHTML,null)}]}})});if(n.slice?Li.fromSchema(o).parseSlice(Su(e),n.parseOptions):Li.fromSchema(o).parse(Su(e),n.parseOptions),n.errorOnInvalidContent&&r)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${i}`)})}const r=Li.fromSchema(t);return n.slice?r.parseSlice(Su(e),n.parseOptions).content:r.parse(Su(e),n.parseOptions)}return Eu("",t,n)}function Cu(e,t,n={},r={}){return Eu(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}function Nu(e,t){for(let n=e.depth;n>0;n-=1){const r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}function Au(e){return t=>Nu(t.$from,e)}function ku(e,t,n){if(void 0===e.config[t]&&e.parent)return ku(e.parent,t,n);if("function"==typeof e.config[t]){return e.config[t].bind({...n,parent:e.parent?ku(e.parent,t,n):null})}return e.config[t]}function Tu(e){return e.map(e=>{const t=ku(e,"addExtensions",{name:e.name,options:e.options,storage:e.storage});return t?[e,...Tu(t())]:e}).flat(10)}function Ou(e,t){const n=Vi.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function _u(e){return"function"==typeof e}function Ru(e,t=void 0,...n){return _u(e)?t?e.bind(t)(...n):e(...n):e}function Du(e){return{baseExtensions:e.filter(e=>"extension"===e.type),nodeExtensions:e.filter(e=>"node"===e.type),markExtensions:e.filter(e=>"mark"===e.type)}}function Iu(e){const t=[],{nodeExtensions:n,markExtensions:r}=Du(e),i=[...n,...r],o={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return e.forEach(e=>{const n=ku(e,"addGlobalAttributes",{name:e.name,options:e.options,storage:e.storage,extensions:i});if(!n)return;n().forEach(e=>{e.types.forEach(n=>{Object.entries(e.attributes).forEach(([e,r])=>{t.push({type:n,name:e,attribute:{...o,...r}})})})})}),i.forEach(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=ku(e,"addAttributes",n);if(!r)return;const i=r();Object.entries(i).forEach(([n,r])=>{const i={...o,...r};"function"==typeof(null==i?void 0:i.default)&&(i.default=i.default()),(null==i?void 0:i.isRequired)&&void 0===(null==i?void 0:i.default)&&delete i.default,t.push({type:e.name,name:n,attribute:i})})}),t}function Lu(...e){return e.filter(e=>!!e).reduce((e,t)=>{const n={...e};return Object.entries(t).forEach(([e,t])=>{if(n[e])if("class"===e){const r=t?String(t).split(" "):[],i=n[e]?n[e].split(" "):[],o=r.filter(e=>!i.includes(e));n[e]=[...i,...o].join(" ")}else if("style"===e){const r=t?t.split(";").map(e=>e.trim()).filter(Boolean):[],i=n[e]?n[e].split(";").map(e=>e.trim()).filter(Boolean):[],o=new Map;i.forEach(e=>{const[t,n]=e.split(":").map(e=>e.trim());o.set(t,n)}),r.forEach(e=>{const[t,n]=e.split(":").map(e=>e.trim());o.set(t,n)}),n[e]=Array.from(o.entries()).map(([e,t])=>`${e}: ${t}`).join("; ")}else n[e]=t;else n[e]=t}),n},{})}function Bu(e,t){return t.filter(t=>t.type===e.type.name).filter(e=>e.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:{[t.name]:e.attrs[t.name]}).reduce((e,t)=>Lu(e,t),{})}function zu(e,t){return"style"in e?e:{...e,getAttrs:n=>{const r=e.getAttrs?e.getAttrs(n):e.attrs;if(!1===r)return!1;const i=t.reduce((e,t)=>{const 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:{...e,[t.name]:r}},{});return{...r,...i}}}}function Pu(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>("attrs"!==e||!function(e={}){return 0===Object.keys(e).length&&e.constructor===Object}(t))&&null!=t))}function ju(e){return e.sort((e,t)=>{const n=ku(e,"priority")||100,r=ku(t,"priority")||100;return n>r?-1:n<r?1:0})}function Fu(e){const t=ju(Tu(e)),n=function(e){const t=e.filter((t,n)=>e.indexOf(t)!==n);return Array.from(new Set(t))}(t.map(e=>e.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(e=>`'${e}'`).join(", ")}]. This can lead to issues.`),t}function $u(e,t,n){const{from:r,to:i}=t,{blockSeparator:o="\n\n",textSerializers:s={}}=n||{};let a="";return e.nodesBetween(r,i,(e,n,l,c)=>{var u;e.isBlock&&n>r&&(a+=o);const d=null==s?void 0:s[e.type.name];if(d)return l&&(a+=d({node:e,pos:n,parent:l,index:c,range:t})),!1;e.isText&&(a+=null==(u=null==e?void 0:e.text)?void 0:u.slice(Math.max(r,n)-n,i-n))}),a}function Hu(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function Uu(e,t){if("string"==typeof e){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}function qu(e,t){const n=Uu(t,e.schema),{from:r,to:i,empty:o}=e.selection,s=[];o?(e.storedMarks&&s.push(...e.storedMarks),s.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,i,e=>{s.push(...e.marks)});const a=s.find(e=>e.type.name===n.name);return a?{...a.attrs}:{}}function Vu(e,t){if("string"==typeof e){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}function Wu(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function Ku(e,t){const n=Wu("string"==typeof t?t:t.name,e.schema);return"node"===n?function(e,t){const n=Vu(t,e.schema),{from:r,to:i}=e.selection,o=[];e.doc.nodesBetween(r,i,e=>{o.push(e)});const s=o.reverse().find(e=>e.type.name===n.name);return s?{...s.attrs}:{}}(e,t):"mark"===n?qu(e,t):{}}function Gu(e){const t=function(e,t=JSON.stringify){const n={};return e.filter(e=>{const r=t(e);return!Object.prototype.hasOwnProperty.call(n,r)&&(n[r]=!0)})}(e);return 1===t.length?t:t.filter((e,n)=>{const r=t.filter((e,t)=>t!==n);return!r.some(t=>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 Ju(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function Yu(e,t,n={strict:!0}){const r=Object.keys(t);return!r.length||r.every(r=>n.strict?t[r]===e[r]:Ju(t[r])?t[r].test(e[r]):t[r]===e[r])}function Zu(e,t,n={}){return e.find(e=>e.type===t&&Yu(Object.fromEntries(Object.keys(n).map(t=>[t,e.attrs[t]])),n))}function Xu(e,t,n={}){return!!Zu(e,t,n)}function Qu(e,t,n){var r;if(!e||!t)return;let i=e.parent.childAfter(e.parentOffset);if(i.node&&i.node.marks.some(e=>e.type===t)||(i=e.parent.childBefore(e.parentOffset)),!i.node||!i.node.marks.some(e=>e.type===t))return;n=n||(null==(r=i.node.marks[0])?void 0:r.attrs);if(!Zu([...i.node.marks],t,n))return;let o=i.index,s=e.start()+i.offset,a=o+1,l=s+i.node.nodeSize;for(;o>0&&Xu([...e.parent.child(o-1).marks],t,n);)o-=1,s-=e.parent.child(o).nodeSize;for(;a<e.parent.childCount&&Xu([...e.parent.child(a).marks],t,n);)l+=e.parent.child(a).nodeSize,a+=1;return{from:s,to:l}}function ed(e,t){return t.nodes[e]||t.marks[e]||null}function td(e,t,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{const r=e.find(e=>e.type===t&&e.name===n);return!!r&&r.attribute.keepOnSplit}))}function nd(e,t,n={}){const{empty:r,ranges:i}=e.selection,o=t?Uu(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>!o||o.name===e.type.name).find(e=>Yu(e.attrs,n,{strict:!1}));let s=0;const a=[];if(i.forEach(({$from:t,$to:n})=>{const r=t.pos,i=n.pos;e.doc.nodesBetween(r,i,(e,t)=>{if(!e.isText&&!e.marks.length)return;const n=Math.max(r,t),o=Math.min(i,t+e.nodeSize);s+=o-n,a.push(...e.marks.map(e=>({mark:e,from:n,to:o})))})}),0===s)return!1;const l=a.filter(e=>!o||o.name===e.mark.type.name).filter(e=>Yu(e.mark.attrs,n,{strict:!1})).reduce((e,t)=>e+t.to-t.from,0),c=a.filter(e=>!o||e.mark.type!==o&&e.mark.type.excludes(o)).reduce((e,t)=>e+t.to-t.from,0);return(l>0?l+c:l)>=s}function rd(e,t,n={}){const{from:r,to:i,empty:o}=e.selection,s=t?Vu(t,e.schema):null,a=[];e.doc.nodesBetween(r,i,(e,t)=>{if(e.isText)return;const n=Math.max(r,t),o=Math.min(i,t+e.nodeSize);a.push({node:e,from:n,to:o})});const l=i-r,c=a.filter(e=>!s||s.name===e.node.type.name).filter(e=>Yu(e.node.attrs,n,{strict:!1}));if(o)return!!c.length;const u=c.reduce((e,t)=>e+t.to-t.from,0);return u>=l}function id(e,t){return Array.isArray(t)?t.some(t=>("string"==typeof t?t:t.name)===e.name):t}function od(e,t){const{nodeExtensions:n}=Du(t),r=n.find(t=>t.name===e);if(!r)return!1;const i=Ru(ku(r,"group",{name:r.name,options:r.options,storage:r.storage}));return"string"==typeof i&&i.split(" ").includes("list")}function sd(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if("hardBreak"===e.type.name)return!0;if(e.isText)return/^\s*$/m.test(null!=(r=e.text)?r:"")}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(0===e.content.childCount)return!0;if(t){let r=!0;return e.content.forEach(e=>{!1!==r&&(sd(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function ad(e){return e instanceof Ko}function ld(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function cd(e,t=null){if(!t)return null;const n=Uo.atStart(e),r=Uo.atEnd(e);if("start"===t||!0===t)return n;if("end"===t)return r;const i=n.from,o=r.to;return"all"===t?Ko.create(e,ld(0,i,o),ld(e.content.size,i,o)):Ko.create(e,ld(t,i,o),ld(t,i,o))}var ud=class{constructor(e){this.find=e.find,this.handler=e.handler}};function dd(e){var t;const{editor:n,from:r,to:i,text:o,rules:s,plugin:a}=e,{view:l}=n;if(l.composing)return!1;const c=l.state.doc.resolve(r);if(c.parent.type.spec.code||(null==(t=c.nodeBefore||c.nodeAfter)?void 0:t.marks.find(e=>e.type.spec.code)))return!1;let u=!1;const d=((e,t=500)=>{let n="";const r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(e,t,i,o)=>{var s,a;const l=(null==(a=(s=e.type.spec).toText)?void 0:a.call(s,{node:e,pos:t,parent:i,index:o}))||e.textContent||"%leaf%";n+=e.isAtom&&!e.isText?l:l.slice(0,Math.max(0,r-t))}),n})(c)+o;return s.forEach(e=>{if(u)return;const t=((e,t)=>{if(Ju(t))return t.exec(e);const n=t(e);if(!n)return null;const 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)return;const s=l.state.tr,c=bu({state:l.state,transaction:s}),p={from:r-(t[0].length-o.length),to:i},{commands:h,chain:f,can:m}=new wu({editor:n,state:c});null!==e.handler({state:c,range:p,match:t,commands:h,chain:f,can:m})&&s.steps.length&&(s.setMeta(a,{transform:s,from:r,to:i,text:o}),l.dispatch(s),u=!0)}),u}function pd(e){const{editor:t,rules:n}=e,r=new cs({state:{init:()=>null,apply(e,i,o){const s=e.getMeta(r);if(s)return s;const a=e.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:e}=a;"string"==typeof e||(e=Ou(qr.from(e),o.schema));const{from:i}=a,s=i+e.length;dd({editor:t,from:i,to:s,text:e,rules:n,plugin:r})}),e.selectionSet||e.docChanged?null:i}},props:{handleTextInput:(e,i,o,s)=>dd({editor:t,from:i,to:o,text:s,rules:n,plugin:r}),handleDOMEvents:{compositionend:e=>(setTimeout(()=>{const{$cursor:i}=e.state.selection;i&&dd({editor:t,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(e,i){if("Enter"!==i.key)return!1;const{$cursor:o}=e.state.selection;return!!o&&dd({editor:t,from:o.pos,to:o.pos,text:"\n",rules:n,plugin:r})}},isInputRules:!0});return r}function hd(e){return"Object"===function(e){return Object.prototype.toString.call(e).slice(8,-1)}(e)&&(e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype)}function fd(e,t){const n={...e};return hd(e)&&hd(t)&&Object.keys(t).forEach(r=>{hd(t[r])&&hd(e[r])?n[r]=fd(e[r],t[r]):n[r]=t[r]}),n}var md=class{constructor(e={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...e},this.name=this.config.name}get options(){return{...Ru(ku(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Ru(ku(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(e={}){const t=this.extend({...this.config,addOptions:()=>fd(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new this.constructor({...this.config,...e});return t.parent=this,this.child=t,t.name="name"in e?e.name:t.parent.name,t}},gd=class e extends md{constructor(){super(...arguments),this.type="mark"}static create(t={}){const n="function"==typeof t?t():t;return new e(n)}static handleExit({editor:e,mark:t}){const{tr:n}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){const i=r.marks(),o=!!i.find(e=>(null==e?void 0:e.type.name)===t.name);if(!o)return!1;const s=i.find(e=>(null==e?void 0:e.type.name)===t.name);return s&&n.removeStoredMark(s),n.insertText(" ",r.pos),e.view.dispatch(n),!0}return!1}configure(e){return super.configure(e)}extend(e){const t="function"==typeof e?e():e;return super.extend(t)}};function yd(e){const{editor:t,state:n,from:r,to:i,rule:o,pasteEvent:s,dropEvent:a}=e,{commands:l,chain:c,can:u}=new wu({editor:t,state:n}),d=[];n.doc.nodesBetween(r,i,(e,t)=>{if(!e.isTextblock||e.type.spec.code)return;const p=Math.max(r,t),h=Math.min(i,t+e.content.size),f=((e,t,n)=>{if(Ju(t))return[...e.matchAll(t)];const r=t(e,n);return r?r.map(t=>{const 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.textBetween(p-t,h-t,void 0,""),o.find,s);f.forEach(e=>{if(void 0===e.index)return;const t=p+e.index+1,r=t+e[0].length,i={from:n.tr.mapping.map(t),to:n.tr.mapping.map(r)},h=o.handler({state:n,range:i,match:e,commands:l,chain:c,can:u,pasteEvent:s,dropEvent:a});d.push(h)})});return d.every(e=>null!==e)}var vd=null;function bd(e){const{editor:t,rules:n}=e;let r,i=null,o=!1,s=!1,a="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null;try{r="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch(e){r=null}const l=({state:e,from:n,to:i,rule:o,pasteEvt:s})=>{const l=e.tr,c=bu({state:e,transaction:l});if(yd({editor:t,state:c,from:Math.max(n-1,0),to:i.b-1,rule:o,pasteEvent:s,dropEvent:r})&&l.steps.length){try{r="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch(e){r=null}return a="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null,l}};return n.map(e=>new cs({view(e){const n=n=>{var r;i=(null==(r=e.dom.parentElement)?void 0:r.contains(n.target))?e.dom.parentElement:null,i&&(vd=t)},r=()=>{vd&&(vd=null)};return window.addEventListener("dragstart",n),window.addEventListener("dragend",r),{destroy(){window.removeEventListener("dragstart",n),window.removeEventListener("dragend",r)}}},props:{handleDOMEvents:{drop:(e,t)=>{if(s=i===e.dom.parentElement,r=t,!s){const e=vd;(null==e?void 0:e.isEditable)&&setTimeout(()=>{const t=e.state.selection;t&&e.commands.deleteRange({from:t.from,to:t.to})},10)}return!1},paste:(e,t)=>{var n;const r=null==(n=t.clipboardData)?void 0:n.getData("text/html");return a=t,o=!!(null==r?void 0:r.includes("data-pm-slice")),!1}}},appendTransaction:(t,n,r)=>{const i=t[0],c="paste"===i.getMeta("uiEvent")&&!o,u="drop"===i.getMeta("uiEvent")&&!s,d=i.getMeta("applyPasteRules"),p=!!d;if(!c&&!u&&!p)return;if(p){let{text:t}=d;"string"==typeof t||(t=Ou(qr.from(t),r.schema));const{from:n}=d,i=n+t.length,o=(e=>{var t;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return null==(t=n.clipboardData)||t.setData("text/html",e),n})(t);return l({rule:e,state:r,from:n,to:{b:i},pasteEvt:o})}const h=n.doc.content.findDiffStart(r.doc.content),f=n.doc.content.findDiffEnd(r.doc.content);return"number"==typeof h&&f&&h!==f.b?l({rule:e,state:r,from:h,to:f,pasteEvt:a}):void 0}}))}var wd=class{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=Fu(e),this.schema=function(e,t){var n;const r=Iu(e),{nodeExtensions:i,markExtensions:o}=Du(e),s=null==(n=i.find(e=>ku(e,"topNode")))?void 0:n.name,a=Object.fromEntries(i.map(n=>{const i=r.filter(e=>e.type===n.name),o={name:n.name,options:n.options,storage:n.storage,editor:t},s=e.reduce((e,t)=>{const r=ku(t,"extendNodeSchema",o);return{...e,...r?r(n):{}}},{}),a=Pu({...s,content:Ru(ku(n,"content",o)),marks:Ru(ku(n,"marks",o)),group:Ru(ku(n,"group",o)),inline:Ru(ku(n,"inline",o)),atom:Ru(ku(n,"atom",o)),selectable:Ru(ku(n,"selectable",o)),draggable:Ru(ku(n,"draggable",o)),code:Ru(ku(n,"code",o)),whitespace:Ru(ku(n,"whitespace",o)),linebreakReplacement:Ru(ku(n,"linebreakReplacement",o)),defining:Ru(ku(n,"defining",o)),isolating:Ru(ku(n,"isolating",o)),attrs:Object.fromEntries(i.map(e=>{var t,n;return[e.name,{default:null==(t=null==e?void 0:e.attribute)?void 0:t.default,validate:null==(n=null==e?void 0:e.attribute)?void 0:n.validate}]}))}),l=Ru(ku(n,"parseHTML",o));l&&(a.parseDOM=l.map(e=>zu(e,i)));const c=ku(n,"renderHTML",o);c&&(a.toDOM=e=>c({node:e,HTMLAttributes:Bu(e,i)}));const u=ku(n,"renderText",o);return u&&(a.toText=u),[n.name,a]})),l=Object.fromEntries(o.map(n=>{const i=r.filter(e=>e.type===n.name),o={name:n.name,options:n.options,storage:n.storage,editor:t},s=e.reduce((e,t)=>{const r=ku(t,"extendMarkSchema",o);return{...e,...r?r(n):{}}},{}),a=Pu({...s,inclusive:Ru(ku(n,"inclusive",o)),excludes:Ru(ku(n,"excludes",o)),group:Ru(ku(n,"group",o)),spanning:Ru(ku(n,"spanning",o)),code:Ru(ku(n,"code",o)),attrs:Object.fromEntries(i.map(e=>{var t,n;return[e.name,{default:null==(t=null==e?void 0:e.attribute)?void 0:t.default,validate:null==(n=null==e?void 0:e.attribute)?void 0:n.validate}]}))}),l=Ru(ku(n,"parseHTML",o));l&&(a.parseDOM=l.map(e=>zu(e,i)));const c=ku(n,"renderHTML",o);return c&&(a.toDOM=e=>c({mark:e,HTMLAttributes:Bu(e,i)})),[n.name,a]}));return new Di({topNode:s,nodes:a,marks:l})}(this.extensions,t),this.setupExtensions()}get commands(){return this.extensions.reduce((e,t)=>{const n=ku(t,"addCommands",{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:ed(t.name,this.schema)});return n?{...e,...n()}:e},{})}get plugins(){const{editor:e}=this,t=ju([...this.extensions].reverse()),n=[],r=[],i=t.map(t=>{const i={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:ed(t.name,this.schema)},o=[],s=ku(t,"addKeyboardShortcuts",i);let a={};if("mark"===t.type&&ku(t,"exitable",i)&&(a.ArrowRight=()=>gd.handleExit({editor:e,mark:t})),s){const t=Object.fromEntries(Object.entries(s()).map(([t,n])=>[t,()=>n({editor:e})]));a={...a,...t}}const l=new cs({props:{handleKeyDown:jc(a)}});o.push(l);const c=ku(t,"addInputRules",i);id(t,e.options.enableInputRules)&&c&&n.push(...c());const u=ku(t,"addPasteRules",i);id(t,e.options.enablePasteRules)&&u&&r.push(...u());const d=ku(t,"addProseMirrorPlugins",i);if(d){const e=d();o.push(...e)}return o}).flat();return[pd({editor:e,rules:n}),...bd({editor:e,rules:r}),...i]}get attributes(){return Iu(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=Du(this.extensions);return Object.fromEntries(t.filter(e=>!!ku(e,"addNodeView")).map(t=>{const n=this.attributes.filter(e=>e.type===t.name),r={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:Vu(t.name,this.schema)},i=ku(t,"addNodeView",r);if(!i)return[];return[t.name,(r,o,s,a,l)=>{const c=Bu(r,n);return i()({node:r,view:o,getPos:s,decorations:a,innerDecorations:l,editor:e,extension:t,HTMLAttributes:c})}]}))}get markViews(){const{editor:e}=this,{markExtensions:t}=Du(this.extensions);return Object.fromEntries(t.filter(e=>!!ku(e,"addMarkView")).map(t=>{const n=this.attributes.filter(e=>e.type===t.name),r={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:Uu(t.name,this.schema)},i=ku(t,"addMarkView",r);if(!i)return[];return[t.name,(r,o,s)=>{const a=Bu(r,n);return i()({mark:r,view:o,inline:s,editor:e,extension:t,HTMLAttributes:a,updateAttributes:t=>{!function(e,t,n={}){const{state:r}=t,{doc:i,tr:o}=r,s=e;i.descendants((t,r)=>{const i=o.mapping.map(r),a=o.mapping.map(r)+t.nodeSize;let l=null;if(t.marks.forEach(e=>{if(e!==s)return!1;l=e}),!l)return;let c=!1;if(Object.keys(n).forEach(e=>{n[e]!==l.attrs[e]&&(c=!0)}),c){const t=e.type.create({...e.attrs,...n});o.removeMark(i,a,e.type),o.addMark(i,a,t)}}),o.docChanged&&t.view.dispatch(o)}(r,e,t)}})}]}))}setupExtensions(){const e=this.extensions;this.editor.extensionStorage=Object.fromEntries(e.map(e=>[e.name,e.storage])),e.forEach(e=>{var t;const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:ed(e.name,this.schema)};if("mark"===e.type){(null==(t=Ru(ku(e,"keepOnSplit",n)))||t)&&this.splittableMarks.push(e.name)}const r=ku(e,"onBeforeCreate",n),i=ku(e,"onCreate",n),o=ku(e,"onUpdate",n),s=ku(e,"onSelectionUpdate",n),a=ku(e,"onTransaction",n),l=ku(e,"onFocus",n),c=ku(e,"onBlur",n),u=ku(e,"onDestroy",n);r&&this.editor.on("beforeCreate",r),i&&this.editor.on("create",i),o&&this.editor.on("update",o),s&&this.editor.on("selectionUpdate",s),a&&this.editor.on("transaction",a),l&&this.editor.on("focus",l),c&&this.editor.on("blur",c),u&&this.editor.on("destroy",u)})}};wd.resolve=Fu,wd.sort=ju,wd.flatten=Tu;vu({},{ClipboardTextSerializer:()=>Md,Commands:()=>Lp,Delete:()=>Bp,Drop:()=>zp,Editable:()=>Pp,FocusEvents:()=>Fp,Keymap:()=>$p,Paste:()=>Hp,Tabindex:()=>Up,focusEventsPluginKey:()=>jp});var xd=class e extends md{constructor(){super(...arguments),this.type="extension"}static create(t={}){const n="function"==typeof t?t():t;return new e(n)}configure(e){return super.configure(e)}extend(e){const t="function"==typeof e?e():e;return super.extend(t)}},Md=xd.create({name:"clipboardTextSerializer",addOptions:()=>({blockSeparator:void 0}),addProseMirrorPlugins(){return[new cs({key:new ps("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:i}=t,{ranges:o}=i,s=Math.min(...o.map(e=>e.$from.pos)),a=Math.max(...o.map(e=>e.$to.pos)),l=Hu(n);return $u(r,{from:s,to:a},{...void 0!==this.options.blockSeparator?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),Sd={};vu(Sd,{blur:()=>Ed,clearContent:()=>Cd,clearNodes:()=>Nd,command:()=>Ad,createParagraphNear:()=>kd,cut:()=>Td,deleteCurrentNode:()=>Od,deleteNode:()=>_d,deleteRange:()=>Rd,deleteSelection:()=>Dd,enter:()=>Id,exitCode:()=>Ld,extendMarkRange:()=>Bd,first:()=>zd,focus:()=>Fd,forEach:()=>$d,insertContent:()=>Hd,insertContentAt:()=>Ud,joinBackward:()=>Wd,joinDown:()=>Vd,joinForward:()=>Kd,joinItemBackward:()=>Gd,joinItemForward:()=>Jd,joinTextblockBackward:()=>Yd,joinTextblockForward:()=>Zd,joinUp:()=>qd,keyboardShortcut:()=>Qd,lift:()=>ep,liftEmptyBlock:()=>tp,liftListItem:()=>np,newlineInCode:()=>rp,resetAttributes:()=>op,scrollIntoView:()=>sp,selectAll:()=>ap,selectNodeBackward:()=>lp,selectNodeForward:()=>cp,selectParentNode:()=>up,selectTextblockEnd:()=>dp,selectTextblockStart:()=>pp,setContent:()=>hp,setMark:()=>fp,setMeta:()=>mp,setNode:()=>gp,setNodeSelection:()=>yp,setTextSelection:()=>vp,sinkListItem:()=>bp,splitBlock:()=>xp,splitListItem:()=>Mp,toggleList:()=>Cp,toggleMark:()=>Np,toggleNode:()=>Ap,toggleWrap:()=>kp,undoInputRule:()=>Tp,unsetAllMarks:()=>Op,unsetMark:()=>_p,updateAttributes:()=>Rp,wrapIn:()=>Dp,wrapInList:()=>Ip});var Ed=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(t.dom.blur(),null==(n=null==window?void 0:window.getSelection())||n.removeAllRanges())}),!0),Cd=(e=!0)=>({commands:t})=>t.setContent("",{emitUpdate:e}),Nd=()=>({state:e,tr:t,dispatch:n})=>{const{selection:r}=t,{ranges:i}=r;return!n||(i.forEach(({$from:n,$to:r})=>{e.doc.nodesBetween(n.pos,r.pos,(e,n)=>{if(e.type.isText)return;const{doc:r,mapping:i}=t,o=r.resolve(i.map(n)),s=r.resolve(i.map(n+e.nodeSize)),a=o.blockRange(s);if(!a)return;const l=yo(a);if(e.type.isTextblock){const{defaultType:e}=o.parent.contentMatchAt(o.index());t.setNodeMarkup(a.start,e)}(l||0===l)&&t.lift(a,l)})}),!0)},Ad=e=>t=>e(t),kd=()=>({state:e,dispatch:t})=>ou(e,t),Td=(e,t)=>({editor:n,tr:r})=>{const{state:i}=n,o=i.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);const s=r.mapping.map(t);return r.insert(s,o.content),r.setSelection(new Ko(r.doc.resolve(Math.max(s-1,0)))),!0},Od=()=>({tr:e,dispatch:t})=>{const{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;const i=e.selection.$anchor;for(let n=i.depth;n>0;n-=1){if(i.node(n).type===r.type){if(t){const t=i.before(n),r=i.after(n);e.delete(t,r).scrollIntoView()}return!0}}return!1},_d=e=>({tr:t,state:n,dispatch:r})=>{const i=Vu(e,n.schema),o=t.selection.$anchor;for(let e=o.depth;e>0;e-=1){if(o.node(e).type===i){if(r){const n=o.before(e),r=o.after(e);t.delete(n,r).scrollIntoView()}return!0}}return!1},Rd=e=>({tr:t,dispatch:n})=>{const{from:r,to:i}=e;return n&&t.delete(r,i),!0},Dd=()=>({state:e,dispatch:t})=>Fc(e,t),Id=()=>({commands:e})=>e.keyboardShortcut("Enter"),Ld=()=>({state:e,dispatch:t})=>iu(e,t),Bd=(e,t={})=>({tr:n,state:r,dispatch:i})=>{const o=Uu(e,r.schema),{doc:s,selection:a}=n,{$from:l,from:c,to:u}=a;if(i){const e=Qu(l,o,t);if(e&&e.from<=c&&e.to>=u){const t=Ko.create(s,e.from,e.to);n.setSelection(t)}}return!0},zd=e=>t=>{const n="function"==typeof e?e(t):e;for(let e=0;e<n.length;e+=1)if(n[e](t))return!0;return!1};function Pd(){return"Android"===navigator.platform||/android/i.test(navigator.userAgent)}function jd(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var Fd=(e=null,t={})=>({editor:n,view:r,tr:i,dispatch:o})=>{t={scrollIntoView:!0,...t};const s=()=>{(jd()||Pd())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),(null==t?void 0:t.scrollIntoView)&&n.commands.scrollIntoView())})};if(r.hasFocus()&&null===e||!1===e)return!0;if(o&&null===e&&!ad(n.state.selection))return s(),!0;const a=cd(i.doc,e)||n.state.selection,l=n.state.selection.eq(a);return o&&(l||i.setSelection(a),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),s()),!0},$d=(e,t)=>n=>e.every((e,r)=>t(e,{...n,index:r})),Hd=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),Ud=(e,t,n)=>({tr:r,dispatch:i,editor:o})=>{var s;if(i){let i;n={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};const{selection:a}=o.state,l=e=>{o.emit("contentError",{editor:o,error:e,disableCollaboration:()=>{"collaboration"in o.storage&&"object"==typeof o.storage.collaboration&&o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{Eu(t,o.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(e){l(e)}try{i=Eu(t,o.schema,{parseOptions:c,errorOnInvalidContent:null!=(s=n.errorOnInvalidContent)?s:o.options.enableContentCheck})}catch(e){return l(e),!1}let{from:u,to:d}="number"==typeof e?{from:e,to:e}:{from:e.from,to:e.to},p=!0,h=!0;if(("type"in i?[i]:i).forEach(e=>{e.check(),p=!!p&&(e.isText&&0===e.marks.length),h=!!h&&e.isBlock}),u===d&&h){const{parent:e}=r.doc.resolve(u);e.isTextblock&&!e.type.spec.code&&!e.childCount&&(u-=1,d+=1)}let f;if(p){if(Array.isArray(t))f=t.map(e=>e.text||"").join("");else if(t instanceof qr){let e="";t.forEach(t=>{t.text&&(e+=t.text)}),f=e}else f="object"==typeof t&&t&&t.text?t.text:t;r.insertText(f,u,d)}else{f=i;const e=0===a.$from.parentOffset,t=a.$from.node().isText||a.$from.node().isTextblock,n=a.$from.node().content.size>0;e&&t&&n&&(u=Math.max(0,u-1)),r.replaceWith(u,d,f)}n.updateSelection&&function(e,t,n){const r=e.steps.length-1;if(r<t)return;const i=e.steps[r];if(!(i instanceof po||i instanceof ho))return;const o=e.mapping.maps[r];let s=0;o.forEach((e,t,n,r)=>{0===s&&(s=r)}),e.setSelection(Uo.near(e.doc.resolve(s),n))}(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:f}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:f})}return!0},qd=()=>({state:e,dispatch:t})=>Qc(e,t),Vd=()=>({state:e,dispatch:t})=>eu(e,t),Wd=()=>({state:e,dispatch:t})=>Hc(e,t),Kd=()=>({state:e,dispatch:t})=>Yc(e,t),Gd=()=>({state:e,dispatch:t,tr:n})=>{try{const r=Co(e.doc,e.selection.$from.pos,-1);return null!=r&&(n.join(r,2),t&&t(n),!0)}catch(e){return!1}},Jd=()=>({state:e,dispatch:t,tr:n})=>{try{const r=Co(e.doc,e.selection.$from.pos,1);return null!=r&&(n.join(r,2),t&&t(n),!0)}catch(e){return!1}},Yd=()=>({state:e,dispatch:t})=>Uc(e,t),Zd=()=>({state:e,dispatch:t})=>qc(e,t);function Xd(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}var Qd=e=>({editor:t,view:n,tr:r,dispatch:i})=>{const o=function(e){const t=e.split(/-(?!$)/);let n,r,i,o,s=t[t.length-1];"Space"===s&&(s=" ");for(let e=0;e<t.length-1;e+=1){const s=t[e];if(/^(cmd|meta|m)$/i.test(s))o=!0;else if(/^a(lt)?$/i.test(s))n=!0;else if(/^(c|ctrl|control)$/i.test(s))r=!0;else if(/^s(hift)?$/i.test(s))i=!0;else{if(!/^mod$/i.test(s))throw new Error(`Unrecognized modifier name: ${s}`);jd()||Xd()?o=!0:r=!0}}return n&&(s=`Alt-${s}`),r&&(s=`Ctrl-${s}`),o&&(s=`Meta-${s}`),i&&(s=`Shift-${s}`),s}(e).split(/-(?!$)/),s=o.find(e=>!["Alt","Ctrl","Meta","Shift"].includes(e)),a=new KeyboardEvent("keydown",{key:"Space"===s?" ":s,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),l=t.captureTransaction(()=>{n.someProp("handleKeyDown",e=>e(n,a))});return null==l||l.steps.forEach(e=>{const t=e.map(r.mapping);t&&i&&r.maybeStep(t)}),!0},ep=(e,t={})=>({state:n,dispatch:r})=>!!rd(n,Vu(e,n.schema),t)&&tu(n,r),tp=()=>({state:e,dispatch:t})=>su(e,t),np=e=>({state:t,dispatch:n})=>mu(Vu(e,t.schema))(t,n),rp=()=>({state:e,dispatch:t})=>nu(e,t);function ip(e,t){const n="string"==typeof t?[t]:t;return Object.keys(e).reduce((t,r)=>(n.includes(r)||(t[r]=e[r]),t),{})}var op=(e,t)=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null;const a=Wu("string"==typeof e?e:e.name,r.schema);return!!a&&("node"===a&&(o=Vu(e,r.schema)),"mark"===a&&(s=Uu(e,r.schema)),i&&n.selection.ranges.forEach(e=>{r.doc.nodesBetween(e.$from.pos,e.$to.pos,(e,r)=>{o&&o===e.type&&n.setNodeMarkup(r,void 0,ip(e.attrs,t)),s&&e.marks.length&&e.marks.forEach(i=>{s===i.type&&n.addMark(r,r+e.nodeSize,s.create(ip(i.attrs,t)))})})}),!0)},sp=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),ap=()=>({tr:e,dispatch:t})=>{if(t){const t=new Zo(e.doc);e.setSelection(t)}return!0},lp=()=>({state:e,dispatch:t})=>Kc(e,t),cp=()=>({state:e,dispatch:t})=>Zc(e,t),up=()=>({state:e,dispatch:t})=>au(e,t),dp=()=>({state:e,dispatch:t})=>du(e,t),pp=()=>({state:e,dispatch:t})=>uu(e,t),hp=(e,{errorOnInvalidContent:t,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:o,dispatch:s,commands:a})=>{const{doc:l}=o;if("full"!==r.preserveWhitespace){const a=Cu(e,i.schema,r,{errorOnInvalidContent:null!=t?t:i.options.enableContentCheck});return s&&o.replaceWith(0,l.content.size,a).setMeta("preventUpdate",!n),!0}return s&&o.setMeta("preventUpdate",!n),a.insertContentAt({from:0,to:l.content.size},e,{parseOptions:r,errorOnInvalidContent:null!=t?t:i.options.enableContentCheck})};var fp=(e,t={})=>({tr:n,state:r,dispatch:i})=>{const{selection:o}=n,{empty:s,ranges:a}=o,l=Uu(e,r.schema);if(i)if(s){const e=qu(r,l);n.addStoredMark(l.create({...e,...t}))}else a.forEach(e=>{const i=e.$from.pos,o=e.$to.pos;r.doc.nodesBetween(i,o,(e,r)=>{const s=Math.max(r,i),a=Math.min(r+e.nodeSize,o);e.marks.find(e=>e.type===l)?e.marks.forEach(e=>{l===e.type&&n.addMark(s,a,l.create({...e.attrs,...t}))}):n.addMark(s,a,l.create(t))})});return function(e,t,n){var r;const{selection:i}=t;let o=null;if(ad(i)&&(o=i.$cursor),o){const t=null!=(r=e.storedMarks)?r:o.marks();return!!n.isInSet(t)||!t.some(e=>e.type.excludes(n))}const{ranges:s}=i;return s.some(({$from:t,$to:r})=>{let i=0===t.depth&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(t.pos,r.pos,(e,t,r)=>{if(i)return!1;if(e.isInline){const t=!r||r.type.allowsMarkType(n),o=!!n.isInSet(e.marks)||!e.marks.some(e=>e.type.excludes(n));i=t&&o}return!i}),i})}(r,n,l)},mp=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),gp=(e,t={})=>({state:n,dispatch:r,chain:i})=>{const o=Vu(e,n.schema);let s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),o.isTextblock?i().command(({commands:e})=>!!hu(o,{...s,...t})(n)||e.clearNodes()).command(({state:e})=>hu(o,{...s,...t})(e,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},yp=e=>({tr:t,dispatch:n})=>{if(n){const{doc:n}=t,r=ld(e,0,n.content.size),i=Jo.create(n,r);t.setSelection(i)}return!0},vp=e=>({tr:t,dispatch:n})=>{if(n){const{doc:n}=t,{from:r,to:i}="number"==typeof e?{from:e,to:e}:e,o=Ko.atStart(n).from,s=Ko.atEnd(n).to,a=ld(r,o,s),l=ld(i,o,s),c=Ko.create(n,a,l);t.setSelection(c)}return!0},bp=e=>({state:t,dispatch:n})=>gu(Vu(e,t.schema))(t,n);function wp(e,t){const n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){const r=n.filter(e=>null==t?void 0:t.includes(e.type.name));e.tr.ensureMarks(r)}}var xp=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:i})=>{const{selection:o,doc:s}=t,{$from:a,$to:l}=o,c=td(i.extensionManager.attributes,a.node().type.name,a.node().attrs);if(o instanceof Jo&&o.node.isBlock)return!(!a.parentOffset||!Mo(s,a.pos))&&(r&&(e&&wp(n,i.extensionManager.splittableMarks),t.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const u=l.parentOffset===l.parent.content.size,d=0===a.depth?void 0:function(e){for(let t=0;t<e.edgeCount;t+=1){const{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}(a.node(-1).contentMatchAt(a.indexAfter(-1)));let p=u&&d?[{type:d,attrs:c}]:void 0,h=Mo(t.doc,t.mapping.map(a.pos),1,p);if(p||h||!Mo(t.doc,t.mapping.map(a.pos),1,d?[{type:d}]:void 0)||(h=!0,p=d?[{type:d,attrs:c}]:void 0),r){if(h&&(o instanceof Ko&&t.deleteSelection(),t.split(t.mapping.map(a.pos),1,p),d&&!u&&!a.parentOffset&&a.parent.type!==d)){const e=t.mapping.map(a.before()),n=t.doc.resolve(e);a.node(-1).canReplaceWith(n.index(),n.index()+1,d)&&t.setNodeMarkup(t.mapping.map(a.before()),d)}e&&wp(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return h},Mp=(e,t={})=>({tr:n,state:r,dispatch:i,editor:o})=>{var s;const a=Vu(e,r.schema),{$from:l,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||l.depth<2||!l.sameParent(c))return!1;const d=l.node(-1);if(d.type!==a)return!1;const p=o.extensionManager.attributes;if(0===l.parent.content.size&&l.node(-1).childCount===l.indexAfter(-1)){if(2===l.depth||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(i){let e=qr.empty;const r=l.index(-1)?1:l.index(-2)?2:3;for(let t=l.depth-r;t>=l.depth-3;t-=1)e=qr.from(l.node(t).copy(e));const i=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,o={...td(p,l.node().type.name,l.node().attrs),...t},c=(null==(s=a.contentMatch.defaultType)?void 0:s.createAndFill(o))||void 0;e=e.append(qr.from(a.createAndFill(null,c)||void 0));const u=l.before(l.depth-(r-1));n.replace(u,l.after(-i),new Yr(e,4-r,0));let d=-1;n.doc.nodesBetween(u,n.doc.content.size,(e,t)=>{if(d>-1)return!1;e.isTextblock&&0===e.content.size&&(d=t+1)}),d>-1&&n.setSelection(Ko.near(n.doc.resolve(d))),n.scrollIntoView()}return!0}const h=c.pos===l.end()?d.contentMatchAt(0).defaultType:null,f={...td(p,d.type.name,d.attrs),...t},m={...td(p,l.node().type.name,l.node().attrs),...t};n.delete(l.pos,c.pos);const g=h?[{type:a,attrs:f},{type:h,attrs:m}]:[{type:a,attrs:f}];if(!Mo(n.doc,l.pos,2))return!1;if(i){const{selection:e,storedMarks:t}=r,{splittableMarks:s}=o.extensionManager,a=t||e.$to.parentOffset&&e.$from.marks();if(n.split(l.pos,2,g).scrollIntoView(),!a||!i)return!0;const c=a.filter(e=>s.includes(e.type.name));n.ensureMarks(c)}return!0},Sp=(e,t)=>{const n=Au(e=>e.type===t)(e.selection);if(!n)return!0;const r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===r)return!0;const i=e.doc.nodeAt(r);return n.node.type!==(null==i?void 0:i.type)||!So(e.doc,n.pos)||(e.join(n.pos),!0)},Ep=(e,t)=>{const n=Au(e=>e.type===t)(e.selection);if(!n)return!0;const r=e.doc.resolve(n.start).after(n.depth);if(void 0===r)return!0;const i=e.doc.nodeAt(r);return n.node.type!==(null==i?void 0:i.type)||!So(e.doc,r)||(e.join(r),!0)},Cp=(e,t,n,r={})=>({editor:i,tr:o,state:s,dispatch:a,chain:l,commands:c,can:u})=>{const{extensions:d,splittableMarks:p}=i.extensionManager,h=Vu(e,s.schema),f=Vu(t,s.schema),{selection:m,storedMarks:g}=s,{$from:y,$to:v}=m,b=y.blockRange(v),w=g||m.$to.parentOffset&&m.$from.marks();if(!b)return!1;const x=Au(e=>od(e.type.name,d))(m);if(b.depth>=1&&x&&b.depth-x.depth<=1){if(x.node.type===h)return c.liftListItem(f);if(od(x.node.type.name,d)&&h.validContent(x.node.content)&&a)return l().command(()=>(o.setNodeMarkup(x.pos,h),!0)).command(()=>Sp(o,h)).command(()=>Ep(o,h)).run()}return n&&w&&a?l().command(()=>{const e=u().wrapInList(h,r),t=w.filter(e=>p.includes(e.type.name));return o.ensureMarks(t),!!e||c.clearNodes()}).wrapInList(h,r).command(()=>Sp(o,h)).command(()=>Ep(o,h)).run():l().command(()=>!!u().wrapInList(h,r)||c.clearNodes()).wrapInList(h,r).command(()=>Sp(o,h)).command(()=>Ep(o,h)).run()},Np=(e,t={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:o=!1}=n,s=Uu(e,r.schema);return nd(r,s,t)?i.unsetMark(s,{extendEmptyMarkRange:o}):i.setMark(s,t)},Ap=(e,t,n={})=>({state:r,commands:i})=>{const o=Vu(e,r.schema),s=Vu(t,r.schema),a=rd(r,o,n);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),a?i.setNode(s,l):i.setNode(o,{...l,...n})},kp=(e,t={})=>({state:n,commands:r})=>{const i=Vu(e,n.schema);return rd(n,i,t)?r.lift(i):r.wrapIn(i,t)},Tp=()=>({state:e,dispatch:t})=>{const n=e.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let o;if(i.spec.isInputRules&&(o=i.getState(e))){if(t){const t=e.tr,n=o.transform;for(let e=n.steps.length-1;e>=0;e-=1)t.step(n.steps[e].invert(n.docs[e]));if(o.text){const n=t.doc.resolve(o.from).marks();t.replaceWith(o.from,o.to,e.schema.text(o.text,n))}else t.delete(o.from,o.to)}return!0}}return!1},Op=()=>({tr:e,dispatch:t})=>{const{selection:n}=e,{empty:r,ranges:i}=n;return r||t&&i.forEach(t=>{e.removeMark(t.$from.pos,t.$to.pos)}),!0},_p=(e,t={})=>({tr:n,state:r,dispatch:i})=>{var o;const{extendEmptyMarkRange:s=!1}=t,{selection:a}=n,l=Uu(e,r.schema),{$from:c,empty:u,ranges:d}=a;if(!i)return!0;if(u&&s){let{from:e,to:t}=a;const r=null==(o=c.marks().find(e=>e.type===l))?void 0:o.attrs,i=Qu(c,l,r);i&&(e=i.from,t=i.to),n.removeMark(e,t,l)}else d.forEach(e=>{n.removeMark(e.$from.pos,e.$to.pos,l)});return n.removeStoredMark(l),!0},Rp=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null;const a=Wu("string"==typeof e?e:e.name,r.schema);return!!a&&("node"===a&&(o=Vu(e,r.schema)),"mark"===a&&(s=Uu(e,r.schema)),i&&n.selection.ranges.forEach(e=>{const i=e.$from.pos,a=e.$to.pos;let l,c,u,d;n.selection.empty?r.doc.nodesBetween(i,a,(e,t)=>{o&&o===e.type&&(u=Math.max(t,i),d=Math.min(t+e.nodeSize,a),l=t,c=e)}):r.doc.nodesBetween(i,a,(e,r)=>{r<i&&o&&o===e.type&&(u=Math.max(r,i),d=Math.min(r+e.nodeSize,a),l=r,c=e),r>=i&&r<=a&&(o&&o===e.type&&n.setNodeMarkup(r,void 0,{...e.attrs,...t}),s&&e.marks.length&&e.marks.forEach(o=>{if(s===o.type){const l=Math.max(r,i),c=Math.min(r+e.nodeSize,a);n.addMark(l,c,s.create({...o.attrs,...t}))}}))}),c&&(void 0!==l&&n.setNodeMarkup(l,void 0,{...c.attrs,...t}),s&&c.marks.length&&c.marks.forEach(e=>{s===e.type&&n.addMark(u,d,s.create({...e.attrs,...t}))}))}),!0)},Dp=(e,t={})=>({state:n,dispatch:r})=>pu(Vu(e,n.schema),t)(n,r),Ip=(e,t={})=>({state:n,dispatch:r})=>fu(Vu(e,n.schema),t)(n,r),Lp=xd.create({name:"commands",addCommands:()=>({...Sd})}),Bp=xd.create({name:"delete",onUpdate({transaction:e,appendedTransactions:t}){var n,r,i;const o=()=>{var n,r,i,o;if(null!=(o=null==(i=null==(r=null==(n=this.editor.options.coreExtensionOptions)?void 0:n.delete)?void 0:r.filterTransaction)?void 0:i.call(r,e))?o:e.getMeta("y-sync$"))return;const s=function(e,t){const n=new $o(e);return t.forEach(e=>{e.steps.forEach(e=>{n.step(e)})}),n}(e.before,[e,...t]),a=function(e){const{mapping:t,steps:n}=e,r=[];return t.maps.forEach((e,i)=>{const o=[];if(e.ranges.length)e.forEach((e,t)=>{o.push({from:e,to:t})});else{const{from:e,to:t}=n[i];if(void 0===e||void 0===t)return;o.push({from:e,to:t})}o.forEach(({from:e,to:n})=>{const o=t.slice(i).map(e,-1),s=t.slice(i).map(n),a=t.invert().map(o,-1),l=t.invert().map(s);r.push({oldRange:{from:a,to:l},newRange:{from:o,to:s}})})}),Gu(r)}(s);a.forEach(t=>{s.mapping.mapResult(t.oldRange.from).deletedAfter&&s.mapping.mapResult(t.oldRange.to).deletedBefore&&s.before.nodesBetween(t.oldRange.from,t.oldRange.to,(n,r)=>{const i=r+n.nodeSize-2,o=t.oldRange.from<=r&&i<=t.oldRange.to;this.editor.emit("delete",{type:"node",node:n,from:r,to:i,newFrom:s.mapping.map(r),newTo:s.mapping.map(i),deletedRange:t.oldRange,newRange:t.newRange,partial:!o,editor:this.editor,transaction:e,combinedTransform:s})})});const l=s.mapping;s.steps.forEach((t,n)=>{var r,i;if(t instanceof lo){const o=l.slice(n).map(t.from,-1),a=l.slice(n).map(t.to),c=l.invert().map(o,-1),u=l.invert().map(a),d=null==(r=s.doc.nodeAt(o-1))?void 0:r.marks.some(e=>e.eq(t.mark)),p=null==(i=s.doc.nodeAt(a))?void 0:i.marks.some(e=>e.eq(t.mark));this.editor.emit("delete",{type:"mark",mark:t.mark,from:t.from,to:t.to,deletedRange:{from:c,to:u},newRange:{from:o,to:a},partial:Boolean(p||d),editor:this.editor,transaction:e,combinedTransform:s})}})};null==(i=null==(r=null==(n=this.editor.options.coreExtensionOptions)?void 0:n.delete)?void 0:r.async)||i?setTimeout(o,0):o()}}),zp=xd.create({name:"drop",addProseMirrorPlugins(){return[new cs({key:new ps("tiptapDrop"),props:{handleDrop:(e,t,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),Pp=xd.create({name:"editable",addProseMirrorPlugins(){return[new cs({key:new ps("editable"),props:{editable:()=>this.editor.options.editable}})]}}),jp=new ps("focusEvents"),Fp=xd.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:e}=this;return[new cs({key:jp,props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;const r=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;const r=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1}}}})]}}),$p=xd.create({name:"keymap",addKeyboardShortcuts(){const e=()=>this.editor.commands.first(({commands:e})=>[()=>e.undoInputRule(),()=>e.command(({tr:t})=>{const{selection:n,doc:r}=t,{empty:i,$anchor:o}=n,{pos:s,parent:a}=o,l=o.parent.isTextblock&&s>0?t.doc.resolve(s-1):o,c=l.parent.type.spec.isolating,u=o.pos-o.parentOffset,d=c&&1===l.parent.childCount?u===o.pos:Uo.atStart(r).from===s;return!(!i||!a.type.isTextblock||a.textContent.length||!d||d&&"paragraph"===o.parent.type.name)&&e.clearNodes()}),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:e})=>[()=>e.deleteSelection(),()=>e.deleteCurrentNode(),()=>e.joinForward(),()=>e.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},i={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return jd()||Xd()?i:r},addProseMirrorPlugins(){return[new cs({key:new ps("clearDocument"),appendTransaction:(e,t,n)=>{if(e.some(e=>e.getMeta("composition")))return;const r=e.some(e=>e.docChanged)&&!t.doc.eq(n.doc),i=e.some(e=>e.getMeta("preventClearDocument"));if(!r||i)return;const{empty:o,from:s,to:a}=t.selection,l=Uo.atStart(t.doc).from,c=Uo.atEnd(t.doc).to;if(o||!(s===l&&a===c))return;if(!sd(n.doc))return;const u=n.tr,d=bu({state:n,transaction:u}),{commands:p}=new wu({editor:this.editor,state:d});return p.clearNodes(),u.steps.length?u:void 0}})]}}),Hp=xd.create({name:"paste",addProseMirrorPlugins(){return[new cs({key:new ps("tiptapPaste"),props:{handlePaste:(e,t,n)=>{this.editor.emit("paste",{editor:this.editor,event:t,slice:n})}}})]}}),Up=xd.create({name:"tabindex",addProseMirrorPlugins(){return[new cs({key:new ps("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),qp=class e{constructor(e,t,n=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=e,this.editor=t,this.currentNode=r}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return null!=(e=this.actualDepth)?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let 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 ${this.name} at ${this.pos}`);t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(0===this.depth)return null;const t=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(t);return new e(n,this.editor)}get before(){let 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)}get after(){let 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)}get children(){const t=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,o=n.isAtom&&!n.isText,s=this.pos+r+(o?0:1);if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;const a=this.resolvedPos.doc.resolve(s);if(!i&&a.depth<=this.depth)return;const l=new e(a,this.editor,i,i?n:null);i&&(l.actualDepth=this.depth+1),t.push(new e(a,this.editor,i,i?n:null))}),t}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let n=null,r=this.parent;for(;r&&!n;){if(r.node.type.name===e)if(Object.keys(t).length>0){const e=r.node.attrs,n=Object.keys(t);for(let r=0;r<n.length;r+=1){const i=n[r];if(e[i]!==t[i])break}}else n=r;r=r.parent}return n}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},n=!1){let r=[];if(!this.children||0===this.children.length)return r;const i=Object.keys(t);return this.children.forEach(o=>{if(!(n&&r.length>0)){if(o.node.type.name===e){const e=i.every(e=>t[e]===o.node.attrs[e]);e&&r.push(o)}n&&r.length>0||(r=r.concat(o.querySelectorAll(e,t,n)))}}),r}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}};var Vp=class extends xu{constructor(e={}){super(),this.css=null,this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:"undefined"!=typeof document?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:e})=>{throw e},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:e,slice:t,moved:n})=>this.options.onDrop(e,t,n)),this.on("paste",({event:e,slice:t})=>this.options.onPaste(e,t)),this.on("delete",this.options.onDelete);const t=this.createDoc(),n=cd(t,this.options.autofocus);this.editorState=as.create({doc:t,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(e){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),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){var e;if(this.editorView){const e=this.editorView.dom;(null==e?void 0:e.editor)&&delete e.editor,this.editorView.destroy()}this.editorView=null,this.isInitialized=!1,null==(e=this.css)||e.remove(),this.css=null}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&"undefined"!=typeof document&&(this.css=function(e,t,n){const r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:""}]`);if(null!==r)return r;const i=document.createElement("style");return t&&i.setAttribute("nonce",t),i.setAttribute("data-tiptap-style"+(n?`-${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))}setOptions(e={}){this.options={...this.options,...e},this.editorView&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:e=>{this.editorState=e},dispatch:e=>{this.editorState=this.state.apply(e)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(e,t)=>{if("state"===t)return this.editorState;if(t in e)return Reflect.get(e,t);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${t}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(e,t){const n=_u(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(e){if(this.isDestroyed)return;const t=this.state.plugins;let n=t;if([].concat(e).forEach(e=>{const t="string"==typeof e?`${e}$`:e.key;n=n.filter(e=>!e.key.startsWith(t))}),t.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var e,t;const n=[...this.options.enableCoreExtensions?[Pp,Md.configure({blockSeparator:null==(t=null==(e=this.options.coreExtensionOptions)?void 0:e.clipboardTextSerializer)?void 0:t.blockSeparator}),Lp,Fp,$p,Up,zp,Hp,Bp].filter(e=>"object"!=typeof this.options.enableCoreExtensions||!1!==this.options.enableCoreExtensions[e.name]):[],...this.options.extensions].filter(e=>["extension","node","mark"].includes(null==e?void 0:e.type));this.extensionManager=new wd(n,this)}createCommandManager(){this.commandManager=new wu({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=Cu(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(t){if(!(t instanceof Error&&["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(t.message)))throw t;this.emit("contentError",{editor:this,error:t,disableCollaboration:()=>{"collaboration"in this.storage&&"object"==typeof this.storage.collaboration&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(e=>"collaboration"!==e.name),this.createExtensionManager()}}),e=Cu(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return e}createView(e){var t;this.editorView=new Sc(e,{...this.options.editorProps,attributes:{role:"textbox",...null==(t=this.options.editorProps)?void 0:t.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.createNodeViews(),this.prependClass(),this.injectCSS();this.view.dom.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction)return this.capturedTransaction?void e.steps.forEach(e=>{var t;return null==(t=this.capturedTransaction)?void 0:t.step(e)}):void(this.capturedTransaction=e);const{state:t,transactions:n}=this.state.applyTransaction(e),r=!this.state.selection.eq(t.selection),i=n.includes(e),o=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),!i)return;this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});const s=n.findLast(e=>e.getMeta("focus")||e.getMeta("blur")),a=null==s?void 0:s.getMeta("focus"),l=null==s?void 0:s.getMeta("blur");a&&this.emit("focus",{editor:this,event:a.event,transaction:s}),l&&this.emit("blur",{editor:this,event:l.event,transaction:s}),e.getMeta("preventUpdate")||!n.some(e=>e.docChanged)||o.doc.eq(t.doc)||this.emit("update",{editor:this,transaction:e,appendedTransactions:n.slice(1)})}getAttributes(e){return Ku(this.state,e)}isActive(e,t){const n="string"==typeof e?e:null,r="string"==typeof e?t:e;return function(e,t,n={}){if(!t)return rd(e,null,n)||nd(e,null,n);const r=Wu(t,e.schema);return"node"===r?rd(e,t,n):"mark"===r&&nd(e,t,n)}(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Ou(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t="\n\n",textSerializers:n={}}=e||{};return function(e,t){return $u(e,{from:0,to:e.content.size},t)}(this.state.doc,{blockSeparator:t,textSerializers:{...Hu(this.schema),...n}})}get isEmpty(){return sd(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var e,t;return null==(t=null==(e=this.editorView)?void 0:e.isDestroyed)||t}$node(e,t){var n;return(null==(n=this.$doc)?void 0:n.querySelector(e,t))||null}$nodes(e,t){var n;return(null==(n=this.$doc)?void 0:n.querySelectorAll(e,t))||null}$pos(e){const t=this.state.doc.resolve(e);return new qp(t,this)}get $doc(){return this.$pos(0)}};function Wp(e){return new ud({find:e.find,handler:({state:t,range:n,match:r})=>{const i=Ru(e.getAttributes,void 0,r)||{},{tr:o}=t,s=n.from;let a=n.to;const l=e.type.create(i);if(r[1]){let e=s+r[0].lastIndexOf(r[1]);e>a?e=a:a=e+r[1].length;const t=r[0][r[0].length-1];o.insertText(t,s+r[0].length-1),o.replaceWith(e,a,l)}else if(r[0]){const t=e.type.isInline?s:s-1;o.insert(t,e.type.create(i)).delete(o.mapping.map(s),o.mapping.map(a))}o.scrollIntoView()}})}var Kp=class e extends md{constructor(){super(...arguments),this.type="node"}static create(t={}){const n="function"==typeof t?t():t;return new e(n)}configure(e){return super.configure(e)}extend(e){const t="function"==typeof e?e():e;return super.extend(t)}},Gp=class{constructor(e,t,n){this.isDragging=!1,this.component=e,this.editor=t.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=t.extension,this.node=t.node,this.decorations=t.decorations,this.innerDecorations=t.innerDecorations,this.view=t.view,this.HTMLAttributes=t.HTMLAttributes,this.getPos=t.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(e){var t,n,r,i,o,s,a;const{view:l}=this.editor,c=e.target,u=3===c.nodeType?null==(t=c.parentElement)?void 0:t.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(null==(n=this.contentDOM)?void 0:n.contains(c))||!u)return;let d=0,p=0;if(this.dom!==u){const t=this.dom.getBoundingClientRect(),n=u.getBoundingClientRect(),a=null!=(i=e.offsetX)?i:null==(r=e.nativeEvent)?void 0:r.offsetX,l=null!=(s=e.offsetY)?s:null==(o=e.nativeEvent)?void 0:o.offsetY;d=n.x-t.x+a,p=n.y-t.y+l}const h=this.dom.cloneNode(!0);null==(a=e.dataTransfer)||a.setDragImage(h,d,p);const f=this.getPos();if("number"!=typeof f)return;const m=Jo.create(l.state.doc,f),g=l.state.tr.setSelection(m);l.dispatch(g)}stopEvent(e){var t;if(!this.dom)return!1;if("function"==typeof this.options.stopEvent)return this.options.stopEvent({event:e});const n=e.target;if(!(this.dom.contains(n)&&!(null==(t=this.contentDOM)?void 0:t.contains(n))))return!1;const r=e.type.startsWith("drag"),i="drop"===e.type;if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!i&&!r)return!0;const{isEditable:o}=this.editor,{isDragging:s}=this,a=!!this.node.type.spec.draggable,l=Jo.isSelectable(this.node),c="copy"===e.type,u="paste"===e.type,d="cut"===e.type,p="mousedown"===e.type;if(!a&&l&&r&&e.target===this.dom&&e.preventDefault(),a&&r&&!s&&e.target===this.dom)return e.preventDefault(),!1;if(a&&o&&!s&&p){const e=n.closest("[data-drag-handle]");e&&(this.dom===e||this.dom.contains(e))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(s||i||c||u||d||p&&l)}ignoreMutation(e){if(!this.dom||!this.contentDOM)return!0;if("function"==typeof this.options.ignoreMutation)return this.options.ignoreMutation({mutation:e});if(this.node.isLeaf||this.node.isAtom)return!0;if("selection"===e.type)return!1;if(this.dom.contains(e.target)&&"childList"===e.type&&(jd()||Pd())&&this.editor.isFocused){if([...Array.from(e.addedNodes),...Array.from(e.removedNodes)].every(e=>e.isContentEditable))return!1}return this.contentDOM===e.target&&"attributes"===e.type||!this.contentDOM.contains(e.target)}updateAttributes(e){this.editor.commands.command(({tr:t})=>{const n=this.getPos();return"number"==typeof n&&(t.setNodeMarkup(n,void 0,{...this.node.attrs,...e}),!0)})}deleteNode(){const e=this.getPos();if("number"!=typeof e)return;const t=e+this.node.nodeSize;this.editor.commands.deleteRange({from:e,to:t})}},Jp=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var r,i,o;if(Array.isArray(t)){if((r=t.length)!=n.length)return!1;for(i=r;0!==i--;)if(!e(t[i],n[i]))return!1;return!0}if(t instanceof Map&&n instanceof Map){if(t.size!==n.size)return!1;for(i of t.entries())if(!n.has(i[0]))return!1;for(i of t.entries())if(!e(i[1],n.get(i[0])))return!1;return!0}if(t instanceof Set&&n instanceof Set){if(t.size!==n.size)return!1;for(i of t.entries())if(!n.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(n)){if((r=t.length)!=n.length)return!1;for(i=r;0!==i--;)if(t[i]!==n[i])return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((r=(o=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(i=r;0!==i--;)if(!Object.prototype.hasOwnProperty.call(n,o[i]))return!1;for(i=r;0!==i--;){var s=o[i];if(("_owner"!==s||!t.$$typeof)&&!e(t[s],n[s]))return!1}return!0}return t!=t&&n!=n},Yp={exports:{}},Zp={};var Xp=e,Qp=Mr.exports;var eh="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},th=Qp.useSyncExternalStore,nh=Xp.useRef,rh=Xp.useEffect,ih=Xp.useMemo,oh=Xp.useDebugValue;Zp.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var o=nh(null);if(null===o.current){var s={hasValue:!1,value:null};o.current=s}else s=o.current;o=ih(function(){function e(e){if(!l){if(l=!0,o=e,e=r(e),void 0!==i&&s.hasValue){var t=s.value;if(i(t,e))return a=t}return a=e}if(t=a,eh(o,e))return t;var n=r(e);return void 0!==i&&i(t,n)?(o=e,t):(o=e,a=n)}var o,a,l=!1,c=void 0===n?null:n;return[function(){return e(t())},null===c?void 0:function(){return e(c())}]},[t,n,r,i]);var a=th(e,o[0],o[1]);return rh(function(){s.hasValue=!0,s.value=a},[a]),oh(a),a},Yp.exports=Zp;const sh=e,ah=e,lh=e,{createContext:ch}=e,{forwardRef:uh}=e,{useDebugValue:dh}=e,{useEffect:ph}=e,{useRef:hh}=e,{useState:fh}=e,{useDebugValue:mh}=e,{useEffect:gh}=e,{useLayoutEffect:yh}=e,{useState:vh}=e,{createContext:bh}=e,{useContext:wh}=e,{version:xh}=e,{createElement:Mh}=e,{createRef:Sh}=e,{memo:Eh}=e,Ch=t,{flushSync:Nh}=t;var Ah=(...e)=>t=>{e.forEach(e=>{"function"==typeof e?e(t):e&&(e.current=t)})},kh=({contentComponent:e})=>{const t=Mr.exports.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getServerSnapshot);return Rr.exports.jsx(Rr.exports.Fragment,{children:Object.values(t)})};var Th=class extends sh.Component{constructor(e){var t;super(e),this.editorContentRef=sh.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:Boolean(null==(t=e.editor)?void 0:t.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const e=this.props.editor;if(e&&!e.isDestroyed&&e.options.element){if(e.contentComponent)return;const t=this.editorContentRef.current;t.append(...e.options.element.childNodes),e.setOptions({element:t}),e.contentComponent=function(){const e=new Set;let t={};return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),getSnapshot:()=>t,getServerSnapshot:()=>t,setRenderer(n,r){t={...t,[n]:Ch.createPortal(r.reactElement,r.element,n)},e.forEach(e=>e())},removeRenderer(n){const r={...t};delete r[n],t=r,e.forEach(e=>e())}}}(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(e=>e.hasContentComponentInitialized?e:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var e;const t=this.props.editor;if(!t)return;if(this.initialized=!1,t.isDestroyed||t.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),t.contentComponent=null,!(null==(e=t.options.element)?void 0:e.firstChild))return;const n=document.createElement("div");n.append(...t.options.element.childNodes),t.setOptions({element:n})}render(){const{editor:e,innerRef:t,...n}=this.props;return Rr.exports.jsxs(Rr.exports.Fragment,{children:[Rr.exports.jsx("div",{ref:Ah(t,this.editorContentRef),...n}),(null==e?void 0:e.contentComponent)&&Rr.exports.jsx(kh,{contentComponent:e.contentComponent})]})}},Oh=uh((e,t)=>{const n=sh.useMemo(()=>Math.floor(4294967295*Math.random()).toString(),[e.editor]);return sh.createElement(Th,{key:n,innerRef:t,...e})}),_h=sh.memo(Oh),Rh="undefined"!=typeof window?yh:gh,Dh=class{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber||(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber}),this.lastSnapshot}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(e=>e())},t=this.editor;return t.on("transaction",e),()=>{t.off("transaction",e)}}}};function Ih(e){var t;const[n]=vh(()=>new Dh(e.editor)),r=Yp.exports.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,e.selector,null!=(t=e.equalityFn)?t:Jp);return Rh(()=>n.watch(e.editor),[e.editor,n]),mh(r),r}var Lh="undefined"==typeof window,Bh=Lh||Boolean("undefined"!=typeof window&&window.next),zh=class e{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(e=>e())}getInitialEditor(){return void 0===this.options.current.immediatelyRender?Lh||Bh?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...e)=>{var t,n;return null==(n=(t=this.options.current).onBeforeCreate)?void 0:n.call(t,...e)},onBlur:(...e)=>{var t,n;return null==(n=(t=this.options.current).onBlur)?void 0:n.call(t,...e)},onCreate:(...e)=>{var t,n;return null==(n=(t=this.options.current).onCreate)?void 0:n.call(t,...e)},onDestroy:(...e)=>{var t,n;return null==(n=(t=this.options.current).onDestroy)?void 0:n.call(t,...e)},onFocus:(...e)=>{var t,n;return null==(n=(t=this.options.current).onFocus)?void 0:n.call(t,...e)},onSelectionUpdate:(...e)=>{var t,n;return null==(n=(t=this.options.current).onSelectionUpdate)?void 0:n.call(t,...e)},onTransaction:(...e)=>{var t,n;return null==(n=(t=this.options.current).onTransaction)?void 0:n.call(t,...e)},onUpdate:(...e)=>{var t,n;return null==(n=(t=this.options.current).onUpdate)?void 0:n.call(t,...e)},onContentError:(...e)=>{var t,n;return null==(n=(t=this.options.current).onContentError)?void 0:n.call(t,...e)},onDrop:(...e)=>{var t,n;return null==(n=(t=this.options.current).onDrop)?void 0:n.call(t,...e)},onPaste:(...e)=>{var t,n;return null==(n=(t=this.options.current).onPaste)?void 0:n.call(t,...e)},onDelete:(...e)=>{var t,n;return null==(n=(t=this.options.current).onDelete)?void 0:n.call(t,...e)}};return new Vp(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(n=>!!["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(n)||("extensions"===n&&e.extensions&&t.extensions?e.extensions.length===t.extensions.length&&e.extensions.every((e,n)=>{var r;return e===(null==(r=t.extensions)?void 0:r[n])}):e[n]===t[n]))}onRender(t){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&0===t.length?e.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(t),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(null===this.previousDeps)return void(this.previousDeps=e);const t=this.previousDeps.length===e.length&&this.previousDeps.every((t,n)=>t===e[n]);if(t)return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{this.isComponentMounted&&this.instanceId===e?t&&t.setOptions(this.options.current):t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};ch({editor:null}).Consumer;var Ph=bh({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),jh=ah.forwardRef((e,t)=>{const{onDragStart:n}=wh(Ph),r=e.as||"div";return Rr.exports.jsx(r,{...e,ref:t,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...e.style}})});function Fh(e){return!("function"!=typeof e||!e.prototype||!e.prototype.isReactComponent)}function $h(e){return!("object"!=typeof e||!e.$$typeof||"Symbol(react.forward_ref)"!==e.$$typeof.toString()&&"react.forward_ref"!==e.$$typeof.description)}var Hh=class{constructor(e,{editor:t,props:n={},as:r="div",className:i=""}){this.ref=null,this.id=Math.floor(4294967295*Math.random()).toString(),this.component=e,this.editor=t,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),i&&this.element.classList.add(...i.split(" ")),this.editor.isInitialized?Nh(()=>{this.render()}):queueMicrotask(()=>{this.render()})}render(){var e;const t=this.component,n=this.props,r=this.editor,i=function(){try{if(xh)return parseInt(xh.split(".")[0],10)>=19}catch(e){}return!1}(),o=function(e){if(Fh(e))return!0;if($h(e))return!0;if(function(e){return!("object"!=typeof e||!e.$$typeof||"Symbol(react.memo)"!==e.$$typeof.toString()&&"react.memo"!==e.$$typeof.description)}(e)){const t=e.type;if(t)return Fh(t)||$h(t)}return!1}(t),s={...n};!s.ref||i||o||delete s.ref,s.ref||!i&&!o||(s.ref=e=>{this.ref=e}),this.reactElement=Rr.exports.jsx(t,{...s}),null==(e=null==r?void 0:r.contentComponent)||e.setRenderer(this.id,this)}updateProps(e={}){this.props={...this.props,...e},this.render()}destroy(){var e;const t=this.editor;null==(e=null==t?void 0:t.contentComponent)||e.removeRenderer(this.id)}updateAttributes(e){Object.keys(e).forEach(t=>{this.element.setAttribute(t,e[t])})}};lh.createContext({markViewContentRef:()=>{}});var Uh=class extends Gp{constructor(e,t,n){if(super(e,t,n),!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const e=this.dom.querySelector("[data-node-view-content]");if(!e)return;e.appendChild(this.contentDOMElement)}}mount(){const e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(e={})=>this.updateAttributes(e),deleteNode:()=>this.deleteNode(),ref:Sh()};if(!this.component.displayName){const e=e=>e.charAt(0).toUpperCase()+e.substring(1);this.component.displayName=e(this.extension.name)}const t={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:e=>{e&&this.contentDOMElement&&e.firstChild!==this.contentDOMElement&&(e.hasAttribute("data-node-view-wrapper")&&e.removeAttribute("data-node-view-wrapper"),e.appendChild(this.contentDOMElement))}},n=this.component,r=Eh(e=>Rr.exports.jsx(Ph.Provider,{value:t,children:Mh(n,e)}));r.displayName="ReactNodeView";let i=this.node.isInline?"span":"div";this.options.as&&(i=this.options.as);const{className:o=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new Hh(r,{editor:this.editor,props:e,as:i,className:`node-${this.node.type.name} ${o}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var e;if(this.renderer.element.firstElementChild&&!(null==(e=this.renderer.element.firstElementChild)?void 0:e.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){const{from:e,to:t}=this.editor.state.selection,n=this.getPos();if("number"==typeof n)if(e<=n&&t>=n+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(e,t,n){const r=e=>{this.renderer.updateProps(e),"function"==typeof this.options.attrs&&this.updateElementAttributes()};if(e.type!==this.node.type)return!1;if("function"==typeof this.options.update){const i=this.node,o=this.decorations,s=this.innerDecorations;return this.node=e,this.decorations=t,this.innerDecorations=n,this.options.update({oldNode:i,oldDecorations:o,newNode:e,newDecorations:t,oldInnerDecorations:s,innerDecorations:n,updateProps:()=>r({node:e,decorations:t,innerDecorations:n})})}return e===this.node&&this.decorations===t&&this.innerDecorations===n||(this.node=e,this.decorations=t,this.innerDecorations=n,r({node:e,decorations:t,innerDecorations:n})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null}updateElementAttributes(){if(this.options.attrs){let e={};if("function"==typeof this.options.attrs){const t=this.editor.extensionManager.attributes,n=Bu(this.node,t);e=this.options.attrs({node:this.node,HTMLAttributes:n})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}};function qh(e,t){return n=>n.editor.contentComponent?new Uh(e,n,t):{}}var Vh=Object.defineProperty,Wh=(e,t)=>{for(var n in t)Vh(e,n,{get:t[n],enumerable:!0})};function Kh(e){const{state:t,transaction:n}=e;let{selection:r}=n,{doc:i}=n,{storedMarks:o}=n;return{...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 Gh=class{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:n}=this,{view:r}=t,{tr:i}=n,o=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,(...e)=>{const n=t(...e)(o);return i.getMeta("preventDispatch")||this.hasCustomState||r.dispatch(i),n}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:n,editor:r,state:i}=this,{view:o}=r,s=[],a=!!e,l=e||i.tr,c={...Object.fromEntries(Object.entries(n).map(([e,n])=>[e,(...e)=>{const r=this.buildProps(l,t),i=n(...e)(r);return s.push(i),c}])),run:()=>(a||!t||l.getMeta("preventDispatch")||this.hasCustomState||o.dispatch(l),s.every(e=>!0===e))};return c}createCan(e){const{rawCommands:t,state:n}=this,r=!1,i=e||n.tr,o=this.buildProps(i,r),s=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,(...e)=>t(...e)({...o,dispatch:void 0})]));return{...s,chain:()=>this.createChain(i,r)}}buildProps(e,t=!0){const{rawCommands:n,editor:r,state:i}=this,{view:o}=r,s={tr:e,editor:r,view:o,state:Kh({state:i,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,(...e)=>t(...e)(s)]))}};return s}},Jh={};Wh(Jh,{blur:()=>Yh,clearContent:()=>Zh,clearNodes:()=>Xh,command:()=>Qh,createParagraphNear:()=>ef,cut:()=>tf,deleteCurrentNode:()=>nf,deleteNode:()=>of,deleteRange:()=>sf,deleteSelection:()=>af,enter:()=>lf,exitCode:()=>cf,extendMarkRange:()=>mf,first:()=>gf,focus:()=>xf,forEach:()=>Mf,insertContent:()=>Sf,insertContentAt:()=>Af,joinBackward:()=>Of,joinDown:()=>Tf,joinForward:()=>_f,joinItemBackward:()=>Rf,joinItemForward:()=>Df,joinTextblockBackward:()=>If,joinTextblockForward:()=>Lf,joinUp:()=>kf,keyboardShortcut:()=>zf,lift:()=>jf,liftEmptyBlock:()=>Ff,liftListItem:()=>$f,newlineInCode:()=>Hf,resetAttributes:()=>Vf,scrollIntoView:()=>Wf,selectAll:()=>Kf,selectNodeBackward:()=>Gf,selectNodeForward:()=>Jf,selectParentNode:()=>Yf,selectTextblockEnd:()=>Zf,selectTextblockStart:()=>Xf,setContent:()=>Qf,setMark:()=>mm,setMeta:()=>gm,setNode:()=>ym,setNodeSelection:()=>vm,setTextDirection:()=>bm,setTextSelection:()=>wm,sinkListItem:()=>xm,splitBlock:()=>Sm,splitListItem:()=>Em,toggleList:()=>Am,toggleMark:()=>km,toggleNode:()=>Tm,toggleWrap:()=>Om,undoInputRule:()=>_m,unsetAllMarks:()=>Rm,unsetMark:()=>Dm,unsetTextDirection:()=>Im,updateAttributes:()=>Lm,wrapIn:()=>Bm,wrapInList:()=>zm});var Yh=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(t.dom.blur(),null==(n=null==window?void 0:window.getSelection())||n.removeAllRanges())}),!0),Zh=(e=!0)=>({commands:t})=>t.setContent("",{emitUpdate:e}),Xh=()=>({state:e,tr:t,dispatch:n})=>{const{selection:r}=t,{ranges:i}=r;return!n||(i.forEach(({$from:n,$to:r})=>{e.doc.nodesBetween(n.pos,r.pos,(e,n)=>{if(e.type.isText)return;const{doc:r,mapping:i}=t,o=r.resolve(i.map(n)),s=r.resolve(i.map(n+e.nodeSize)),a=o.blockRange(s);if(!a)return;const l=yo(a);if(e.type.isTextblock){const{defaultType:e}=o.parent.contentMatchAt(o.index());t.setNodeMarkup(a.start,e)}(l||0===l)&&t.lift(a,l)})}),!0)},Qh=e=>t=>e(t),ef=()=>({state:e,dispatch:t})=>ou(e,t),tf=(e,t)=>({editor:n,tr:r})=>{const{state:i}=n,o=i.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);const s=r.mapping.map(t);return r.insert(s,o.content),r.setSelection(new Ko(r.doc.resolve(Math.max(s-1,0)))),!0},nf=()=>({tr:e,dispatch:t})=>{const{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;const i=e.selection.$anchor;for(let n=i.depth;n>0;n-=1){if(i.node(n).type===r.type){if(t){const t=i.before(n),r=i.after(n);e.delete(t,r).scrollIntoView()}return!0}}return!1};function rf(e,t){if("string"==typeof e){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}var of=e=>({tr:t,state:n,dispatch:r})=>{const i=rf(e,n.schema),o=t.selection.$anchor;for(let e=o.depth;e>0;e-=1){if(o.node(e).type===i){if(r){const n=o.before(e),r=o.after(e);t.delete(n,r).scrollIntoView()}return!0}}return!1},sf=e=>({tr:t,dispatch:n})=>{const{from:r,to:i}=e;return n&&t.delete(r,i),!0},af=()=>({state:e,dispatch:t})=>Fc(e,t),lf=()=>({commands:e})=>e.keyboardShortcut("Enter"),cf=()=>({state:e,dispatch:t})=>iu(e,t);function uf(e,t,n={strict:!0}){const r=Object.keys(t);return!r.length||r.every(r=>{return n.strict?t[r]===e[r]:(i=t[r],"[object RegExp]"===Object.prototype.toString.call(i)?t[r].test(e[r]):t[r]===e[r]);var i})}function df(e,t,n={}){return e.find(e=>e.type===t&&uf(Object.fromEntries(Object.keys(n).map(t=>[t,e.attrs[t]])),n))}function pf(e,t,n={}){return!!df(e,t,n)}function hf(e,t,n){var r;if(!e||!t)return;let i=e.parent.childAfter(e.parentOffset);if(i.node&&i.node.marks.some(e=>e.type===t)||(i=e.parent.childBefore(e.parentOffset)),!i.node||!i.node.marks.some(e=>e.type===t))return;n=n||(null==(r=i.node.marks[0])?void 0:r.attrs);if(!df([...i.node.marks],t,n))return;let o=i.index,s=e.start()+i.offset,a=o+1,l=s+i.node.nodeSize;for(;o>0&&pf([...e.parent.child(o-1).marks],t,n);)o-=1,s-=e.parent.child(o).nodeSize;for(;a<e.parent.childCount&&pf([...e.parent.child(a).marks],t,n);)l+=e.parent.child(a).nodeSize,a+=1;return{from:s,to:l}}function ff(e,t){if("string"==typeof e){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}var mf=(e,t={})=>({tr:n,state:r,dispatch:i})=>{const o=ff(e,r.schema),{doc:s,selection:a}=n,{$from:l,from:c,to:u}=a;if(i){const e=hf(l,o,t);if(e&&e.from<=c&&e.to>=u){const t=Ko.create(s,e.from,e.to);n.setSelection(t)}}return!0},gf=e=>t=>{const n="function"==typeof e?e(t):e;for(let e=0;e<n.length;e+=1)if(n[e](t))return!0;return!1};function yf(e){return e instanceof Ko}function vf(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function bf(){return"Android"===navigator.platform||/android/i.test(navigator.userAgent)}function wf(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var xf=(e=null,t={})=>({editor:n,view:r,tr:i,dispatch:o})=>{t={scrollIntoView:!0,...t};const s=()=>{(wf()||bf())&&r.dom.focus(),"undefined"==typeof navigator||!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)||wf()||bf()||r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),(null==t?void 0:t.scrollIntoView)&&n.commands.scrollIntoView())})};if(r.hasFocus()&&null===e||!1===e)return!0;if(o&&null===e&&!yf(n.state.selection))return s(),!0;const a=function(e,t=null){if(!t)return null;const n=Uo.atStart(e),r=Uo.atEnd(e);if("start"===t||!0===t)return n;if("end"===t)return r;const i=n.from,o=r.to;return"all"===t?Ko.create(e,vf(0,i,o),vf(e.content.size,i,o)):Ko.create(e,vf(t,i,o),vf(t,i,o))}(i.doc,e)||n.state.selection,l=n.state.selection.eq(a);return o&&(l||i.setSelection(a),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),s()),!0},Mf=(e,t)=>n=>e.every((e,r)=>t(e,{...n,index:r})),Sf=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),Ef=e=>{const t=e.childNodes;for(let n=t.length-1;n>=0;n-=1){const r=t[n];3===r.nodeType&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):1===r.nodeType&&Ef(r)}return e};function Cf(e){if("undefined"==typeof window)throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const t=`<body>${e}</body>`,n=(new window.DOMParser).parseFromString(t,"text/html").body;return Ef(n)}function Nf(e,t,n){if(e instanceof fi||e instanceof qr)return e;n={slice:!0,parseOptions:{},...n};const r="string"==typeof e;if("object"==typeof e&&null!==e)try{if(Array.isArray(e)&&e.length>0)return qr.fromArray(e.map(e=>t.nodeFromJSON(e)));const r=t.nodeFromJSON(e);return n.errorOnInvalidContent&&r.check(),r}catch(r){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:r});return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",r),Nf("",t,n)}if(r){if(n.errorOnInvalidContent){let r=!1,i="";const o=new Di({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:e=>(r=!0,i="string"==typeof e?e:e.outerHTML,null)}]}})});if(n.slice?Li.fromSchema(o).parseSlice(Cf(e),n.parseOptions):Li.fromSchema(o).parse(Cf(e),n.parseOptions),n.errorOnInvalidContent&&r)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${i}`)})}const r=Li.fromSchema(t);return n.slice?r.parseSlice(Cf(e),n.parseOptions).content:r.parse(Cf(e),n.parseOptions)}return Nf("",t,n)}var Af=(e,t,n)=>({tr:r,dispatch:i,editor:o})=>{var s;if(i){let i;const a=e=>{o.emit("contentError",{editor:o,error:e,disableCollaboration:()=>{"collaboration"in o.storage&&"object"==typeof o.storage.collaboration&&o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},l={preserveWhitespace:"full",...(n={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n}).parseOptions};if(!n.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{Nf(t,o.schema,{parseOptions:l,errorOnInvalidContent:!0})}catch(e){a(e)}try{i=Nf(t,o.schema,{parseOptions:l,errorOnInvalidContent:null!=(s=n.errorOnInvalidContent)?s:o.options.enableContentCheck})}catch(e){return a(e),!1}let{from:c,to:u}="number"==typeof e?{from:e,to:e}:{from:e.from,to:e.to},d=!0,p=!0;if(("type"in i?[i]:i).forEach(e=>{e.check(),d=!!d&&(e.isText&&0===e.marks.length),p=!!p&&e.isBlock}),c===u&&p){const{parent:e}=r.doc.resolve(c);e.isTextblock&&!e.type.spec.code&&!e.childCount&&(c-=1,u+=1)}let h;if(d){if(Array.isArray(t))h=t.map(e=>e.text||"").join("");else if(t instanceof qr){let e="";t.forEach(t=>{t.text&&(e+=t.text)}),h=e}else h="object"==typeof t&&t&&t.text?t.text:t;r.insertText(h,c,u)}else{h=i;const e=r.doc.resolve(c),t=e.node(),n=0===e.parentOffset,o=t.isText||t.isTextblock,s=t.content.size>0;n&&o&&s&&(c=Math.max(0,c-1)),r.replaceWith(c,u,h)}n.updateSelection&&function(e,t,n){const r=e.steps.length-1;if(r<t)return;const i=e.steps[r];if(!(i instanceof po||i instanceof ho))return;const o=e.mapping.maps[r];let s=0;o.forEach((e,t,n,r)=>{0===s&&(s=r)}),e.setSelection(Uo.near(e.doc.resolve(s),n))}(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:c,text:h}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:c,text:h})}return!0},kf=()=>({state:e,dispatch:t})=>Qc(e,t),Tf=()=>({state:e,dispatch:t})=>eu(e,t),Of=()=>({state:e,dispatch:t})=>Hc(e,t),_f=()=>({state:e,dispatch:t})=>Yc(e,t),Rf=()=>({state:e,dispatch:t,tr:n})=>{try{const r=Co(e.doc,e.selection.$from.pos,-1);return null!=r&&(n.join(r,2),t&&t(n),!0)}catch(e){return!1}},Df=()=>({state:e,dispatch:t,tr:n})=>{try{const r=Co(e.doc,e.selection.$from.pos,1);return null!=r&&(n.join(r,2),t&&t(n),!0)}catch(e){return!1}},If=()=>({state:e,dispatch:t})=>Uc(e,t),Lf=()=>({state:e,dispatch:t})=>qc(e,t);function Bf(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}var zf=e=>({editor:t,view:n,tr:r,dispatch:i})=>{const o=function(e){const t=e.split(/-(?!$)/);let n,r,i,o,s=t[t.length-1];"Space"===s&&(s=" ");for(let e=0;e<t.length-1;e+=1){const s=t[e];if(/^(cmd|meta|m)$/i.test(s))o=!0;else if(/^a(lt)?$/i.test(s))n=!0;else if(/^(c|ctrl|control)$/i.test(s))r=!0;else if(/^s(hift)?$/i.test(s))i=!0;else{if(!/^mod$/i.test(s))throw new Error(`Unrecognized modifier name: ${s}`);wf()||Bf()?o=!0:r=!0}}return n&&(s=`Alt-${s}`),r&&(s=`Ctrl-${s}`),o&&(s=`Meta-${s}`),i&&(s=`Shift-${s}`),s}(e).split(/-(?!$)/),s=o.find(e=>!["Alt","Ctrl","Meta","Shift"].includes(e)),a=new KeyboardEvent("keydown",{key:"Space"===s?" ":s,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),l=t.captureTransaction(()=>{n.someProp("handleKeyDown",e=>e(n,a))});return null==l||l.steps.forEach(e=>{const t=e.map(r.mapping);t&&i&&r.maybeStep(t)}),!0};function Pf(e,t,n={}){const{from:r,to:i,empty:o}=e.selection,s=t?rf(t,e.schema):null,a=[];e.doc.nodesBetween(r,i,(e,t)=>{if(e.isText)return;const n=Math.max(r,t),o=Math.min(i,t+e.nodeSize);a.push({node:e,from:n,to:o})});const l=i-r,c=a.filter(e=>!s||s.name===e.node.type.name).filter(e=>uf(e.node.attrs,n,{strict:!1}));if(o)return!!c.length;const u=c.reduce((e,t)=>e+t.to-t.from,0);return u>=l}var jf=(e,t={})=>({state:n,dispatch:r})=>!!Pf(n,rf(e,n.schema),t)&&tu(n,r),Ff=()=>({state:e,dispatch:t})=>su(e,t),$f=e=>({state:t,dispatch:n})=>mu(rf(e,t.schema))(t,n),Hf=()=>({state:e,dispatch:t})=>nu(e,t);function Uf(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function qf(e,t){const n="string"==typeof t?[t]:t;return Object.keys(e).reduce((t,r)=>(n.includes(r)||(t[r]=e[r]),t),{})}var Vf=(e,t)=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null;const a=Uf("string"==typeof e?e:e.name,r.schema);if(!a)return!1;"node"===a&&(o=rf(e,r.schema)),"mark"===a&&(s=ff(e,r.schema));let l=!1;return n.selection.ranges.forEach(e=>{r.doc.nodesBetween(e.$from.pos,e.$to.pos,(e,r)=>{o&&o===e.type&&(l=!0,i&&n.setNodeMarkup(r,void 0,qf(e.attrs,t))),s&&e.marks.length&&e.marks.forEach(o=>{s===o.type&&(l=!0,i&&n.addMark(r,r+e.nodeSize,s.create(qf(o.attrs,t))))})})}),l},Wf=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),Kf=()=>({tr:e,dispatch:t})=>{if(t){const t=new Zo(e.doc);e.setSelection(t)}return!0},Gf=()=>({state:e,dispatch:t})=>Kc(e,t),Jf=()=>({state:e,dispatch:t})=>Zc(e,t),Yf=()=>({state:e,dispatch:t})=>au(e,t),Zf=()=>({state:e,dispatch:t})=>du(e,t),Xf=()=>({state:e,dispatch:t})=>uu(e,t);var Qf=(e,{errorOnInvalidContent:t,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:o,dispatch:s,commands:a})=>{const{doc:l}=o;if("full"!==r.preserveWhitespace){const a=function(e,t,n={},r={}){return Nf(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}(e,i.schema,r,{errorOnInvalidContent:null!=t?t:i.options.enableContentCheck});return s&&o.replaceWith(0,l.content.size,a).setMeta("preventUpdate",!n),!0}return s&&o.setMeta("preventUpdate",!n),a.insertContentAt({from:0,to:l.content.size},e,{parseOptions:r,errorOnInvalidContent:null!=t?t:i.options.enableContentCheck})};function em(e,t){const n=ff(t,e.schema),{from:r,to:i,empty:o}=e.selection,s=[];o?(e.storedMarks&&s.push(...e.storedMarks),s.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,i,e=>{s.push(...e.marks)});const a=s.find(e=>e.type.name===n.name);return a?{...a.attrs}:{}}function tm(e,t){const n=new $o(e);return t.forEach(e=>{e.steps.forEach(e=>{n.step(e)})}),n}function nm(e){return t=>function(e,t){for(let n=e.depth;n>0;n-=1){const 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 rm(e,t,n){if(void 0===e.config[t]&&e.parent)return rm(e.parent,t,n);if("function"==typeof e.config[t]){return e.config[t].bind({...n,parent:e.parent?rm(e.parent,t,n):null})}return e.config[t]}function im(e,t=void 0,...n){return function(e){return"function"==typeof e}(e)?t?e.bind(t)(...n):e(...n):e}function om(e){return{baseExtensions:e.filter(e=>"extension"===e.type),nodeExtensions:e.filter(e=>"node"===e.type),markExtensions:e.filter(e=>"mark"===e.type)}}function sm(...e){return e.filter(e=>!!e).reduce((e,t)=>{const n={...e};return Object.entries(t).forEach(([e,t])=>{if(n[e])if("class"===e){const r=t?String(t).split(" "):[],i=n[e]?n[e].split(" "):[],o=r.filter(e=>!i.includes(e));n[e]=[...i,...o].join(" ")}else if("style"===e){const r=t?t.split(";").map(e=>e.trim()).filter(Boolean):[],i=n[e]?n[e].split(";").map(e=>e.trim()).filter(Boolean):[],o=new Map;i.forEach(e=>{const[t,n]=e.split(":").map(e=>e.trim());o.set(t,n)}),r.forEach(e=>{const[t,n]=e.split(":").map(e=>e.trim());o.set(t,n)}),n[e]=Array.from(o.entries()).map(([e,t])=>`${e}: ${t}`).join("; ")}else n[e]=t;else n[e]=t}),n},{})}function am(e,t){const n=Uf("string"==typeof t?t:t.name,e.schema);return"node"===n?function(e,t){const n=rf(t,e.schema),{from:r,to:i}=e.selection,o=[];e.doc.nodesBetween(r,i,e=>{o.push(e)});const s=o.reverse().find(e=>e.type.name===n.name);return s?{...s.attrs}:{}}(e,t):"mark"===n?em(e,t):{}}function lm(e){const t=function(e,t=JSON.stringify){const n={};return e.filter(e=>{const r=t(e);return!Object.prototype.hasOwnProperty.call(n,r)&&(n[r]=!0)})}(e);return 1===t.length?t:t.filter((e,n)=>{const r=t.filter((e,t)=>t!==n);return!r.some(t=>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 cm(e){const{mapping:t,steps:n}=e,r=[];return t.maps.forEach((e,i)=>{const o=[];if(e.ranges.length)e.forEach((e,t)=>{o.push({from:e,to:t})});else{const{from:e,to:t}=n[i];if(void 0===e||void 0===t)return;o.push({from:e,to:t})}o.forEach(({from:e,to:n})=>{const o=t.slice(i).map(e,-1),s=t.slice(i).map(n),a=t.invert().map(o,-1),l=t.invert().map(s);r.push({oldRange:{from:a,to:l},newRange:{from:o,to:s}})})}),lm(r)}function um(e,t,n){const r=[];return e===t?n.resolve(e).marks().forEach(t=>{const i=hf(n.resolve(e),t.type);i&&r.push({mark:t,...i})}):n.nodesBetween(e,t,(e,t)=>{e&&void 0!==(null==e?void 0:e.nodeSize)&&r.push(...e.marks.map(n=>({from:t,to:t+e.nodeSize,mark:n})))}),r}function dm(e,t,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{const r=e.find(e=>e.type===t&&e.name===n);return!!r&&r.attribute.keepOnSplit}))}function pm(e,t){const{nodeExtensions:n}=om(t),r=n.find(t=>t.name===e);if(!r)return!1;const i=im(rm(r,"group",{name:r.name,options:r.options,storage:r.storage}));return"string"==typeof i&&i.split(" ").includes("list")}function hm(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if("hardBreak"===e.type.name)return!0;if(e.isText)return/^\s*$/m.test(null!=(r=e.text)?r:"")}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(0===e.content.childCount)return!0;if(t){let r=!0;return e.content.forEach(e=>{!1!==r&&(hm(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function fm(e){return e instanceof Jo}var mm=(e,t={})=>({tr:n,state:r,dispatch:i})=>{const{selection:o}=n,{empty:s,ranges:a}=o,l=ff(e,r.schema);if(i)if(s){const e=em(r,l);n.addStoredMark(l.create({...e,...t}))}else a.forEach(e=>{const i=e.$from.pos,o=e.$to.pos;r.doc.nodesBetween(i,o,(e,r)=>{const s=Math.max(r,i),a=Math.min(r+e.nodeSize,o);e.marks.find(e=>e.type===l)?e.marks.forEach(e=>{l===e.type&&n.addMark(s,a,l.create({...e.attrs,...t}))}):n.addMark(s,a,l.create(t))})});return function(e,t,n){var r;const{selection:i}=t;let o=null;if(yf(i)&&(o=i.$cursor),o){const t=null!=(r=e.storedMarks)?r:o.marks();return o.parent.type.allowsMarkType(n)&&(!!n.isInSet(t)||!t.some(e=>e.type.excludes(n)))}const{ranges:s}=i;return s.some(({$from:t,$to:r})=>{let i=0===t.depth&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(t.pos,r.pos,(e,t,r)=>{if(i)return!1;if(e.isInline){const t=!r||r.type.allowsMarkType(n),o=!!n.isInSet(e.marks)||!e.marks.some(e=>e.type.excludes(n));i=t&&o}return!i}),i})}(r,n,l)},gm=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),ym=(e,t={})=>({state:n,dispatch:r,chain:i})=>{const o=rf(e,n.schema);let s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),o.isTextblock?i().command(({commands:e})=>!!hu(o,{...s,...t})(n)||e.clearNodes()).command(({state:e})=>hu(o,{...s,...t})(e,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},vm=e=>({tr:t,dispatch:n})=>{if(n){const{doc:n}=t,r=vf(e,0,n.content.size),i=Jo.create(n,r);t.setSelection(i)}return!0},bm=(e,t)=>({tr:n,state:r,dispatch:i})=>{const{selection:o}=r;let s,a;return"number"==typeof t?(s=t,a=t):t&&"from"in t&&"to"in t?(s=t.from,a=t.to):(s=o.from,a=o.to),i&&n.doc.nodesBetween(s,a,(t,r)=>{t.isText||n.setNodeMarkup(r,void 0,{...t.attrs,dir:e})}),!0},wm=e=>({tr:t,dispatch:n})=>{if(n){const{doc:n}=t,{from:r,to:i}="number"==typeof e?{from:e,to:e}:e,o=Ko.atStart(n).from,s=Ko.atEnd(n).to,a=vf(r,o,s),l=vf(i,o,s),c=Ko.create(n,a,l);t.setSelection(c)}return!0},xm=e=>({state:t,dispatch:n})=>gu(rf(e,t.schema))(t,n);function Mm(e,t){const n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){const r=n.filter(e=>null==t?void 0:t.includes(e.type.name));e.tr.ensureMarks(r)}}var Sm=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:i})=>{const{selection:o,doc:s}=t,{$from:a,$to:l}=o,c=dm(i.extensionManager.attributes,a.node().type.name,a.node().attrs);if(o instanceof Jo&&o.node.isBlock)return!(!a.parentOffset||!Mo(s,a.pos))&&(r&&(e&&Mm(n,i.extensionManager.splittableMarks),t.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const u=l.parentOffset===l.parent.content.size,d=0===a.depth?void 0:function(e){for(let t=0;t<e.edgeCount;t+=1){const{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}(a.node(-1).contentMatchAt(a.indexAfter(-1)));let p=u&&d?[{type:d,attrs:c}]:void 0,h=Mo(t.doc,t.mapping.map(a.pos),1,p);if(p||h||!Mo(t.doc,t.mapping.map(a.pos),1,d?[{type:d}]:void 0)||(h=!0,p=d?[{type:d,attrs:c}]:void 0),r){if(h&&(o instanceof Ko&&t.deleteSelection(),t.split(t.mapping.map(a.pos),1,p),d&&!u&&!a.parentOffset&&a.parent.type!==d)){const e=t.mapping.map(a.before()),n=t.doc.resolve(e);a.node(-1).canReplaceWith(n.index(),n.index()+1,d)&&t.setNodeMarkup(t.mapping.map(a.before()),d)}e&&Mm(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return h},Em=(e,t={})=>({tr:n,state:r,dispatch:i,editor:o})=>{var s;const a=rf(e,r.schema),{$from:l,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||l.depth<2||!l.sameParent(c))return!1;const d=l.node(-1);if(d.type!==a)return!1;const p=o.extensionManager.attributes;if(0===l.parent.content.size&&l.node(-1).childCount===l.indexAfter(-1)){if(2===l.depth||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(i){let e=qr.empty;const r=l.index(-1)?1:l.index(-2)?2:3;for(let t=l.depth-r;t>=l.depth-3;t-=1)e=qr.from(l.node(t).copy(e));const i=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,o={...dm(p,l.node().type.name,l.node().attrs),...t},c=(null==(s=a.contentMatch.defaultType)?void 0:s.createAndFill(o))||void 0;e=e.append(qr.from(a.createAndFill(null,c)||void 0));const u=l.before(l.depth-(r-1));n.replace(u,l.after(-i),new Yr(e,4-r,0));let d=-1;n.doc.nodesBetween(u,n.doc.content.size,(e,t)=>{if(d>-1)return!1;e.isTextblock&&0===e.content.size&&(d=t+1)}),d>-1&&n.setSelection(Ko.near(n.doc.resolve(d))),n.scrollIntoView()}return!0}const h=c.pos===l.end()?d.contentMatchAt(0).defaultType:null,f={...dm(p,d.type.name,d.attrs),...t},m={...dm(p,l.node().type.name,l.node().attrs),...t};n.delete(l.pos,c.pos);const g=h?[{type:a,attrs:f},{type:h,attrs:m}]:[{type:a,attrs:f}];if(!Mo(n.doc,l.pos,2))return!1;if(i){const{selection:e,storedMarks:t}=r,{splittableMarks:s}=o.extensionManager,a=t||e.$to.parentOffset&&e.$from.marks();if(n.split(l.pos,2,g).scrollIntoView(),!a||!i)return!0;const c=a.filter(e=>s.includes(e.type.name));n.ensureMarks(c)}return!0},Cm=(e,t)=>{const n=nm(e=>e.type===t)(e.selection);if(!n)return!0;const r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===r)return!0;const i=e.doc.nodeAt(r);return n.node.type!==(null==i?void 0:i.type)||!So(e.doc,n.pos)||(e.join(n.pos),!0)},Nm=(e,t)=>{const n=nm(e=>e.type===t)(e.selection);if(!n)return!0;const r=e.doc.resolve(n.start).after(n.depth);if(void 0===r)return!0;const i=e.doc.nodeAt(r);return n.node.type!==(null==i?void 0:i.type)||!So(e.doc,r)||(e.join(r),!0)},Am=(e,t,n,r={})=>({editor:i,tr:o,state:s,dispatch:a,chain:l,commands:c,can:u})=>{const{extensions:d,splittableMarks:p}=i.extensionManager,h=rf(e,s.schema),f=rf(t,s.schema),{selection:m,storedMarks:g}=s,{$from:y,$to:v}=m,b=y.blockRange(v),w=g||m.$to.parentOffset&&m.$from.marks();if(!b)return!1;const x=nm(e=>pm(e.type.name,d))(m);if(b.depth>=1&&x&&b.depth-x.depth<=1){if(x.node.type===h)return c.liftListItem(f);if(pm(x.node.type.name,d)&&h.validContent(x.node.content)&&a)return l().command(()=>(o.setNodeMarkup(x.pos,h),!0)).command(()=>Cm(o,h)).command(()=>Nm(o,h)).run()}return n&&w&&a?l().command(()=>{const e=u().wrapInList(h,r),t=w.filter(e=>p.includes(e.type.name));return o.ensureMarks(t),!!e||c.clearNodes()}).wrapInList(h,r).command(()=>Cm(o,h)).command(()=>Nm(o,h)).run():l().command(()=>!!u().wrapInList(h,r)||c.clearNodes()).wrapInList(h,r).command(()=>Cm(o,h)).command(()=>Nm(o,h)).run()},km=(e,t={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:o=!1}=n,s=ff(e,r.schema),a=function(e,t,n={}){const{empty:r,ranges:i}=e.selection,o=t?ff(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>!o||o.name===e.type.name).find(e=>uf(e.attrs,n,{strict:!1}));let s=0;const a=[];if(i.forEach(({$from:t,$to:n})=>{const r=t.pos,i=n.pos;e.doc.nodesBetween(r,i,(e,t)=>{if(!e.isText&&!e.marks.length)return;const n=Math.max(r,t),o=Math.min(i,t+e.nodeSize);s+=o-n,a.push(...e.marks.map(e=>({mark:e,from:n,to:o})))})}),0===s)return!1;const l=a.filter(e=>!o||o.name===e.mark.type.name).filter(e=>uf(e.mark.attrs,n,{strict:!1})).reduce((e,t)=>e+t.to-t.from,0),c=a.filter(e=>!o||e.mark.type!==o&&e.mark.type.excludes(o)).reduce((e,t)=>e+t.to-t.from,0);return(l>0?l+c:l)>=s}(r,s,t);return a?i.unsetMark(s,{extendEmptyMarkRange:o}):i.setMark(s,t)},Tm=(e,t,n={})=>({state:r,commands:i})=>{const o=rf(e,r.schema),s=rf(t,r.schema),a=Pf(r,o,n);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),a?i.setNode(s,l):i.setNode(o,{...l,...n})},Om=(e,t={})=>({state:n,commands:r})=>{const i=rf(e,n.schema);return Pf(n,i,t)?r.lift(i):r.wrapIn(i,t)},_m=()=>({state:e,dispatch:t})=>{const n=e.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let o;if(i.spec.isInputRules&&(o=i.getState(e))){if(t){const t=e.tr,n=o.transform;for(let e=n.steps.length-1;e>=0;e-=1)t.step(n.steps[e].invert(n.docs[e]));if(o.text){const n=t.doc.resolve(o.from).marks();t.replaceWith(o.from,o.to,e.schema.text(o.text,n))}else t.delete(o.from,o.to)}return!0}}return!1},Rm=()=>({tr:e,dispatch:t})=>{const{selection:n}=e,{empty:r,ranges:i}=n;return r||t&&i.forEach(t=>{e.removeMark(t.$from.pos,t.$to.pos)}),!0},Dm=(e,t={})=>({tr:n,state:r,dispatch:i})=>{var o;const{extendEmptyMarkRange:s=!1}=t,{selection:a}=n,l=ff(e,r.schema),{$from:c,empty:u,ranges:d}=a;if(!i)return!0;if(u&&s){let{from:e,to:t}=a;const r=null==(o=c.marks().find(e=>e.type===l))?void 0:o.attrs,i=hf(c,l,r);i&&(e=i.from,t=i.to),n.removeMark(e,t,l)}else d.forEach(e=>{n.removeMark(e.$from.pos,e.$to.pos,l)});return n.removeStoredMark(l),!0},Im=e=>({tr:t,state:n,dispatch:r})=>{const{selection:i}=n;let o,s;return"number"==typeof e?(o=e,s=e):e&&"from"in e&&"to"in e?(o=e.from,s=e.to):(o=i.from,s=i.to),r&&t.doc.nodesBetween(o,s,(e,n)=>{if(e.isText)return;const r={...e.attrs};delete r.dir,t.setNodeMarkup(n,void 0,r)}),!0},Lm=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null;const a=Uf("string"==typeof e?e:e.name,r.schema);if(!a)return!1;"node"===a&&(o=rf(e,r.schema)),"mark"===a&&(s=ff(e,r.schema));let l=!1;return n.selection.ranges.forEach(e=>{const a=e.$from.pos,c=e.$to.pos;let u,d,p,h;n.selection.empty?r.doc.nodesBetween(a,c,(e,t)=>{o&&o===e.type&&(l=!0,p=Math.max(t,a),h=Math.min(t+e.nodeSize,c),u=t,d=e)}):r.doc.nodesBetween(a,c,(e,r)=>{r<a&&o&&o===e.type&&(l=!0,p=Math.max(r,a),h=Math.min(r+e.nodeSize,c),u=r,d=e),r>=a&&r<=c&&(o&&o===e.type&&(l=!0,i&&n.setNodeMarkup(r,void 0,{...e.attrs,...t})),s&&e.marks.length&&e.marks.forEach(o=>{if(s===o.type&&(l=!0,i)){const i=Math.max(r,a),l=Math.min(r+e.nodeSize,c);n.addMark(i,l,s.create({...o.attrs,...t}))}}))}),d&&(void 0!==u&&i&&n.setNodeMarkup(u,void 0,{...d.attrs,...t}),s&&d.marks.length&&d.marks.forEach(e=>{s===e.type&&i&&n.addMark(p,h,s.create({...e.attrs,...t}))}))}),l},Bm=(e,t={})=>({state:n,dispatch:r})=>pu(rf(e,n.schema),t)(n,r),zm=(e,t={})=>({state:n,dispatch:r})=>fu(rf(e,n.schema),t)(n,r),Pm=class{constructor(e){var t;this.find=e.find,this.handler=e.handler,this.undoable=null==(t=e.undoable)||t}};function jm(e){return"Object"===function(e){return Object.prototype.toString.call(e).slice(8,-1)}(e)&&(e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype)}function Fm(e,t){const n={...e};return jm(e)&&jm(t)&&Object.keys(t).forEach(r=>{jm(t[r])&&jm(e[r])?n[r]=Fm(e[r],t[r]):n[r]=t[r]}),n}var $m=class{constructor(e={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...e},this.name=this.config.name}get options(){return{...im(rm(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...im(rm(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Fm(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new this.constructor({...this.config,...e});return t.parent=this,this.child=t,t.name="name"in e?e.name:t.parent.name,t}},Hm=class e extends $m{constructor(){super(...arguments),this.type="mark"}static create(t={}){const n="function"==typeof t?t():t;return new e(n)}static handleExit({editor:e,mark:t}){const{tr:n}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){const i=r.marks(),o=!!i.find(e=>(null==e?void 0:e.type.name)===t.name);if(!o)return!1;const s=i.find(e=>(null==e?void 0:e.type.name)===t.name);return s&&n.removeStoredMark(s),n.insertText(" ",r.pos),e.view.dispatch(n),!0}return!1}configure(e){return super.configure(e)}extend(e){const t="function"==typeof e?e():e;return super.extend(t)}},Um=class{constructor(e){this.find=e.find,this.handler=e.handler}};Wh({},{ClipboardTextSerializer:()=>Vm,Commands:()=>Wm,Delete:()=>Km,Drop:()=>Gm,Editable:()=>Jm,FocusEvents:()=>Zm,Keymap:()=>Xm,Paste:()=>Qm,Tabindex:()=>eg,TextDirection:()=>tg,focusEventsPluginKey:()=>Ym});var qm=class e extends $m{constructor(){super(...arguments),this.type="extension"}static create(t={}){const n="function"==typeof t?t():t;return new e(n)}configure(e){return super.configure(e)}extend(e){const t="function"==typeof e?e():e;return super.extend(t)}},Vm=qm.create({name:"clipboardTextSerializer",addOptions:()=>({blockSeparator:void 0}),addProseMirrorPlugins(){return[new cs({key:new ps("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:i}=t,{ranges:o}=i,s=Math.min(...o.map(e=>e.$from.pos)),a=Math.max(...o.map(e=>e.$to.pos)),l=function(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}(n);return function(e,t,n){const{from:r,to:i}=t,{blockSeparator:o="\n\n",textSerializers:s={}}=n||{};let a="";return e.nodesBetween(r,i,(e,n,l,c)=>{var u;e.isBlock&&n>r&&(a+=o);const d=null==s?void 0:s[e.type.name];if(d)return l&&(a+=d({node:e,pos:n,parent:l,index:c,range:t})),!1;e.isText&&(a+=null==(u=null==e?void 0:e.text)?void 0:u.slice(Math.max(r,n)-n,i-n))}),a}(r,{from:s,to:a},{...void 0!==this.options.blockSeparator?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),Wm=qm.create({name:"commands",addCommands:()=>({...Jh})}),Km=qm.create({name:"delete",onUpdate({transaction:e,appendedTransactions:t}){var n,r,i;const o=()=>{var n,r,i,o;if(null!=(o=null==(i=null==(r=null==(n=this.editor.options.coreExtensionOptions)?void 0:n.delete)?void 0:r.filterTransaction)?void 0:i.call(r,e))?o:e.getMeta("y-sync$"))return;const s=tm(e.before,[e,...t]);cm(s).forEach(t=>{s.mapping.mapResult(t.oldRange.from).deletedAfter&&s.mapping.mapResult(t.oldRange.to).deletedBefore&&s.before.nodesBetween(t.oldRange.from,t.oldRange.to,(n,r)=>{const i=r+n.nodeSize-2,o=t.oldRange.from<=r&&i<=t.oldRange.to;this.editor.emit("delete",{type:"node",node:n,from:r,to:i,newFrom:s.mapping.map(r),newTo:s.mapping.map(i),deletedRange:t.oldRange,newRange:t.newRange,partial:!o,editor:this.editor,transaction:e,combinedTransform:s})})});const a=s.mapping;s.steps.forEach((t,n)=>{var r,i;if(t instanceof lo){const o=a.slice(n).map(t.from,-1),l=a.slice(n).map(t.to),c=a.invert().map(o,-1),u=a.invert().map(l),d=null==(r=s.doc.nodeAt(o-1))?void 0:r.marks.some(e=>e.eq(t.mark)),p=null==(i=s.doc.nodeAt(l))?void 0:i.marks.some(e=>e.eq(t.mark));this.editor.emit("delete",{type:"mark",mark:t.mark,from:t.from,to:t.to,deletedRange:{from:c,to:u},newRange:{from:o,to:l},partial:Boolean(p||d),editor:this.editor,transaction:e,combinedTransform:s})}})};null==(i=null==(r=null==(n=this.editor.options.coreExtensionOptions)?void 0:n.delete)?void 0:r.async)||i?setTimeout(o,0):o()}}),Gm=qm.create({name:"drop",addProseMirrorPlugins(){return[new cs({key:new ps("tiptapDrop"),props:{handleDrop:(e,t,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),Jm=qm.create({name:"editable",addProseMirrorPlugins(){return[new cs({key:new ps("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Ym=new ps("focusEvents"),Zm=qm.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:e}=this;return[new cs({key:Ym,props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;const r=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;const r=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1}}}})]}}),Xm=qm.create({name:"keymap",addKeyboardShortcuts(){const e=()=>this.editor.commands.first(({commands:e})=>[()=>e.undoInputRule(),()=>e.command(({tr:t})=>{const{selection:n,doc:r}=t,{empty:i,$anchor:o}=n,{pos:s,parent:a}=o,l=o.parent.isTextblock&&s>0?t.doc.resolve(s-1):o,c=l.parent.type.spec.isolating,u=o.pos-o.parentOffset,d=c&&1===l.parent.childCount?u===o.pos:Uo.atStart(r).from===s;return!(!i||!a.type.isTextblock||a.textContent.length||!d||d&&"paragraph"===o.parent.type.name)&&e.clearNodes()}),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:e})=>[()=>e.deleteSelection(),()=>e.deleteCurrentNode(),()=>e.joinForward(),()=>e.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},i={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return wf()||Bf()?i:r},addProseMirrorPlugins(){return[new cs({key:new ps("clearDocument"),appendTransaction:(e,t,n)=>{if(e.some(e=>e.getMeta("composition")))return;const r=e.some(e=>e.docChanged)&&!t.doc.eq(n.doc),i=e.some(e=>e.getMeta("preventClearDocument"));if(!r||i)return;const{empty:o,from:s,to:a}=t.selection,l=Uo.atStart(t.doc).from,c=Uo.atEnd(t.doc).to;if(o||!(s===l&&a===c))return;if(!hm(n.doc))return;const u=n.tr,d=Kh({state:n,transaction:u}),{commands:p}=new Gh({editor:this.editor,state:d});return p.clearNodes(),u.steps.length?u:void 0}})]}}),Qm=qm.create({name:"paste",addProseMirrorPlugins(){return[new cs({key:new ps("tiptapPaste"),props:{handlePaste:(e,t,n)=>{this.editor.emit("paste",{editor:this.editor,event:t,slice:n})}}})]}}),eg=qm.create({name:"tabindex",addProseMirrorPlugins(){return[new cs({key:new ps("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),tg=qm.create({name:"textDirection",addOptions:()=>({direction:void 0}),addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:e}=om(this.extensions);return[{types:e.filter(e=>"text"!==e.name).map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const t=e.getAttribute("dir");return!t||"ltr"!==t&&"rtl"!==t&&"auto"!==t?this.options.direction:t},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new cs({key:new ps("textDirection"),props:{attributes:()=>{const e=this.options.direction;return e?{dir:e}:{}}}})]}});function ng(e){return new Pm({find:e.find,handler:({state:t,range:n,match:r})=>{const i=im(e.getAttributes,void 0,r);if(!1===i||null===i)return null;const{tr:o}=t,s=r[r.length-1],a=r[0];if(s){const r=a.search(/\S/),l=n.from+a.indexOf(s),c=l+s.length;if(um(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>l).length)return null;c<n.to&&o.delete(c,n.to),l>n.from&&o.delete(n.from+r,l);const u=n.from+r+s.length;o.addMark(n.from+r,u,e.type.create(i||{})),o.removeStoredMark(e.type)}},undoable:e.undoable})}function rg(e){return new Pm({find:e.find,handler:({state:t,range:n,match:r})=>{const i=im(e.getAttributes,void 0,r)||{},{tr:o}=t,s=n.from;let a=n.to;const l=e.type.create(i);if(r[1]){let e=s+r[0].lastIndexOf(r[1]);e>a?e=a:a=e+r[1].length;const t=r[0][r[0].length-1];o.insertText(t,s+r[0].length-1),o.replaceWith(e,a,l)}else if(r[0]){const t=e.type.isInline?s:s-1;o.insert(t,e.type.create(i)).delete(o.mapping.map(s),o.mapping.map(a))}o.scrollIntoView()},undoable:e.undoable})}function ig(e){return new Pm({find:e.find,handler:({state:t,range:n,match:r})=>{const i=t.doc.resolve(n.from),o=im(e.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,o)},undoable:e.undoable})}function og(e){return new Pm({find:e.find,handler:({state:t,range:n,match:r,chain:i})=>{const o=im(e.getAttributes,void 0,r)||{},s=t.tr.delete(n.from,n.to),a=s.doc.resolve(n.from).blockRange(),l=a&&vo(a,e.type,o);if(!l)return null;if(s.wrap(a,l),e.keepMarks&&e.editor){const{selection:n,storedMarks:r}=t,{splittableMarks:i}=e.editor.extensionManager,o=r||n.$to.parentOffset&&n.$from.marks();if(o){const e=o.filter(e=>i.includes(e.type.name));s.ensureMarks(e)}}if(e.keepAttributes){const t="bulletList"===e.type.name||"orderedList"===e.type.name?"listItem":"taskList";i().updateAttributes(t,o).run()}const c=s.doc.resolve(n.from-1).nodeBefore;c&&c.type===e.type&&So(s.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,c))&&s.join(n.from-1)},undoable:e.undoable})}function sg(e){if(!(null==e?void 0:e.trim()))return{};const t={},n=[],r=e.replace(/["']([^"']*)["']/g,e=>(n.push(e),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const e=i.map(e=>e.trim().slice(1));t.class=e.join(" ")}const o=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);o&&(t.id=o[1]);Array.from(r.matchAll(/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g)).forEach(([,e,r])=>{var i;const o=parseInt((null==(i=r.match(/__QUOTED_(\d+)__/))?void 0:i[1])||"0",10),s=n[o];s&&(t[e]=s.slice(1,-1))});const 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();if(s){s.split(/\s+/).filter(Boolean).forEach(e=>{e.match(/^[a-zA-Z][\w-]*$/)&&(t[e]=!0)})}return t}function ag(e){if(!e||0===Object.keys(e).length)return"";const t=[];if(e.class){String(e.class).split(/\s+/).filter(Boolean).forEach(e=>t.push(`.${e}`))}return e.id&&t.push(`#${e.id}`),Object.entries(e).forEach(([e,n])=>{"class"!==e&&"id"!==e&&(!0===n?t.push(e):!1!==n&&null!=n&&t.push(`${e}="${String(n)}"`))}),t.join(" ")}function lg(e){const{nodeName:t,name:n,parseAttributes:r=sg,serializeAttributes:i=ag,defaultAttributes:o={},requiredAttributes:s=[],allowedAttributes:a}=e,l=n||t;return{parseMarkdown:(e,n)=>{const r={...o,...e.attributes};return n.createNode(t,r,[])},markdownTokenizer:{name:t,level:"block",start(e){var t;const n=new RegExp(`^:::${l}(?:\\s|$)`,"m"),r=null==(t=e.match(n))?void 0:t.index;return void 0!==r?r:-1},tokenize(e,n,i){const o=new RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),a=e.match(o);if(!a)return;const c=a[1]||"",u=r(c);return s.find(e=>!(e in u))?void 0:{type:t,raw:a[0],attributes:u}}},renderMarkdown:e=>{const t=(e=>{if(!a)return e;const t={};return a.forEach(n=>{n in e&&(t[n]=e[n])}),t})(e.attrs||{}),n=i(t);return`:::${l}${n?` {${n}}`:""} :::`}}}function cg(e){const{nodeName:t,name:n,getContent:r,parseAttributes:i=sg,serializeAttributes:o=ag,defaultAttributes:s={},content:a="block",allowedAttributes:l}=e,c=n||t;return{parseMarkdown:(e,n)=>{let i;if(r){const t=r(e);i="string"==typeof t?[{type:"text",text:t}]:t}else i="block"===a?n.parseChildren(e.tokens||[]):n.parseInline(e.tokens||[]);const o={...s,...e.attributes};return n.createNode(t,o,i)},markdownTokenizer:{name:t,level:"block",start(e){var t;const n=new RegExp(`^:::${c}`,"m"),r=null==(t=e.match(n))?void 0:t.index;return void 0!==r?r:-1},tokenize(e,n,r){var o;const s=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),l=e.match(s);if(!l)return;const[u,d=""]=l,p=i(d);let h=1;const f=u.length;let m="";const g=/^:::([\w-]*)(\s.*)?/gm,y=e.slice(f);for(g.lastIndex=0;;){const n=g.exec(y);if(null===n)break;const i=n.index,s=n[1];if(!(null==(o=n[2])?void 0:o.endsWith(":::")))if(s)h+=1;else if(h-=1,0===h){const o=y.slice(0,i);m=o.trim();const s=e.slice(0,f+i+n[0].length);let l=[];if(m)if("block"===a)for(l=r.blockTokens(o),l.forEach(e=>{!e.text||e.tokens&&0!==e.tokens.length||(e.tokens=r.inlineTokens(e.text))});l.length>0;){const e=l[l.length-1];if("paragraph"!==e.type||e.text&&""!==e.text.trim())break;l.pop()}else l=r.inlineTokens(m);return{type:t,raw:s,attributes:p,content:m,tokens:l}}}}},renderMarkdown:(e,t)=>{const n=(e=>{if(!l)return e;const t={};return l.forEach(n=>{n in e&&(t[n]=e[n])}),t})(e.attrs||{}),r=o(n),i=r?` {${r}}`:"",s=t.renderChildren(e.content||[],"\n\n");return`:::${c}${i}\n\n${s}\n\n:::`}}}function ug(e){if(!e.trim())return{};const t={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(e);for(;null!==r;){const[,i,o,s]=r;t[i]=o||s,r=n.exec(e)}return t}function dg(e){return Object.entries(e).filter(([,e])=>null!=e).map(([e,t])=>`${e}="${t}"`).join(" ")}function pg(e){const{nodeName:t,name:n,getContent:r,parseAttributes:i=ug,serializeAttributes:o=dg,defaultAttributes:s={},selfClosing:a=!1,allowedAttributes:l}=e,c=n||t,u=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(e,n)=>{const i={...s,...e.attributes};if(a)return n.createNode(t,i);const 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(e){const t=a?new RegExp(`\\[${u}\\s*[^\\]]*\\]`):new RegExp(`\\[${u}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${u}\\]`),n=e.match(t),r=null==n?void 0:n.index;return void 0!==r?r:-1},tokenize(e,n,r){const o=a?new RegExp(`^\\[${u}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${u}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${u}\\]`),s=e.match(o);if(!s)return;let l="",c="";if(a){const[,e]=s;c=e}else{const[,e,t]=s;c=e,l=t||""}const d=i(c.trim());return{type:t,raw:s[0],content:l.trim(),attributes:d}}},renderMarkdown:e=>{let t="";r?t=r(e):e.content&&e.content.length>0&&(t=e.content.filter(e=>"text"===e.type).map(e=>e.text).join(""));const n=(e=>{if(!l)return e;const t={};return l.forEach(n=>{const r="string"==typeof n?n:n.name,i="string"==typeof n?void 0:n.skipIfDefault;if(r in e){const n=e[r];if(void 0!==i&&n===i)return;t[r]=n}}),t})(e.attrs||{}),i=o(n),s=i?` ${i}`:"";return a?`[${c}${s}]`:`[${c}${s}]${t}[/${c}]`}}}function hg(e,t,n){var r,i,o,s;const a=e.split("\n"),l=[];let c="",u=0;const d=t.baseIndentSize||2;for(;u<a.length;){const e=a[u],p=e.match(t.itemPattern);if(!p){if(l.length>0)break;if(""===e.trim()){u+=1,c=`${c}${e}\n`;continue}return}const h=t.extractItemData(p),{indentLevel:f,mainContent:m}=h;c=`${c}${e}\n`;const g=[m];for(u+=1;u<a.length;){const e=a[u];if(""===e.trim()){const t=a.slice(u+1).findIndex(e=>""!==e.trim());if(-1===t)break;if(((null==(i=null==(r=a[u+1+t].match(/^(\s*)/))?void 0:r[1])?void 0:i.length)||0)>f){g.push(e),c=`${c}${e}\n`,u+=1;continue}break}if(!(((null==(s=null==(o=e.match(/^(\s*)/))?void 0:o[1])?void 0:s.length)||0)>f))break;g.push(e),c=`${c}${e}\n`,u+=1}let y;const v=g.slice(1);if(v.length>0){const e=v.map(e=>e.slice(f+d)).join("\n");e.trim()&&(y=t.customNestedParser?t.customNestedParser(e):n.blockTokens(e))}const b=t.createToken(h,y);l.push(b)}if(0!==l.length)return{items:l,raw:c}}function fg(e,t,n,r){if(!e||!Array.isArray(e.content))return"";const i="function"==typeof n?n(r):n,[o,...s]=e.content,a=[`${i}${t.renderChildren([o])}`];return s&&s.length>0&&s.forEach(e=>{const n=t.renderChildren([e]);if(n){const e=n.split("\n").map(e=>e?t.indent(e):"").join("\n");a.push(e)}}),a.join("\n")}Wh({},{createAtomBlockMarkdownSpec:()=>lg,createBlockMarkdownSpec:()=>cg,createInlineMarkdownSpec:()=>pg,parseAttributes:()=>sg,parseIndentedBlocks:()=>hg,renderNestedMarkdownContent:()=>fg,serializeAttributes:()=>ag});var mg=class e extends $m{constructor(){super(...arguments),this.type="node"}static create(t={}){const n="function"==typeof t?t():t;return new e(n)}configure(e){return super.configure(e)}extend(e){const t="function"==typeof e?e():e;return super.extend(t)}};function gg(e){return new Um({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:i})=>{const o=im(e.getAttributes,void 0,r,i);if(!1===o||null===o)return null;const{tr:s}=t,a=r[r.length-1],l=r[0];let c=n.to;if(a){const r=l.search(/\S/),i=n.from+l.indexOf(a),u=i+a.length;if(um(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>i).length)return null;u<n.to&&s.delete(u,n.to),i>n.from&&s.delete(n.from+r,i),c=n.from+r+a.length,s.addMark(n.from+r,c,e.type.create(o||{})),s.removeStoredMark(e.type)}}})}var yg=(e,t)=>{if("slot"===e)return 0;if(e instanceof Function)return e(t);const{children:n,...r}=null!=t?t:{};if("svg"===e)throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[e,r,n]},vg=/^\s*>\s$/,bg=mg.create({name:"blockquote",addOptions:()=>({HTMLAttributes:{}}),content:"block+",group:"block",defining:!0,parseHTML:()=>[{tag:"blockquote"}],renderHTML({HTMLAttributes:e}){return yg("blockquote",{...sm(this.options.HTMLAttributes,e),children:yg("slot",{})})},parseMarkdown:(e,t)=>t.createNode("blockquote",void 0,t.parseChildren(e.tokens||[])),renderMarkdown:(e,t)=>{if(!e.content)return"";const n=[];return e.content.forEach(e=>{const r=t.renderChildren([e]).split("\n").map(e=>""===e.trim()?">":`> ${e}`);n.push(r.join("\n"))}),n.join("\n>\n")},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[og({find:vg,type:this.type})]}}),wg=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,xg=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Mg=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Sg=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Eg=Hm.create({name:"bold",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:e=>"normal"!==e.style.fontWeight&&null},{style:"font-weight=400",clearMark:e=>e.type.name===this.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return yg("strong",{...sm(this.options.HTMLAttributes,e),children:yg("slot",{})})},markdownTokenName:"strong",parseMarkdown:(e,t)=>t.applyMark("bold",t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`**${t.renderChildren(e)}**`,addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[ng({find:wg,type:this.type}),ng({find:Mg,type:this.type})]},addPasteRules(){return[gg({find:xg,type:this.type}),gg({find:Sg,type:this.type})]}}),Cg=/(^|[^`])`([^`]+)`(?!`)$/,Ng=/(^|[^`])`([^`]+)`(?!`)/g,Ag=Hm.create({name:"code",addOptions:()=>({HTMLAttributes:{}}),excludes:"_",code:!0,exitable:!0,parseHTML:()=>[{tag:"code"}],renderHTML({HTMLAttributes:e}){return["code",sm(this.options.HTMLAttributes,e),0]},markdownTokenName:"codespan",parseMarkdown:(e,t)=>t.applyMark("code",[{type:"text",text:e.text||""}]),renderMarkdown:(e,t)=>e.content?`\`${t.renderChildren(e.content)}\``:"",addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[ng({find:Cg,type:this.type})]},addPasteRules(){return[gg({find:Ng,type:this.type})]}}),kg=/^```([a-z]+)?[\s\n]$/,Tg=/^~~~([a-z]+)?[\s\n]$/,Og=mg.create({name:"codeBlock",addOptions:()=>({languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}),content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{var t;const{languageClassPrefix:n}=this.options;if(!n)return null;const r=[...(null==(t=e.firstElementChild)?void 0:t.classList)||[]].filter(e=>e.startsWith(n)).map(e=>e.replace(n,""))[0];return r||null},rendered:!1}}},parseHTML:()=>[{tag:"pre",preserveWhitespace:"full"}],renderHTML({node:e,HTMLAttributes:t}){return["pre",sm(this.options.HTMLAttributes,t),["code",{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(e,t)=>{var n;return!1===(null==(n=e.raw)?void 0:n.startsWith("```"))&&"indented"!==e.codeBlockStyle?[]:t.createNode("codeBlock",{language:e.lang||null},e.text?[t.createTextNode(e.text)]:[])},renderMarkdown:(e,t)=>{var n;let r="";const i=(null==(n=e.attrs)?void 0:n.language)||"";if(e.content){r=[`\`\`\`${i}`,t.renderChildren(e.content),"```"].join("\n")}else r=`\`\`\`${i}\n\n\`\`\``;return r},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:e,$anchor:t}=this.editor.state.selection,n=1===t.pos;return!(!e||t.parent.type.name!==this.name)&&(!(!n&&t.parent.textContent.length)&&this.editor.commands.clearNodes())},Tab:({editor:e})=>{var t;if(!this.options.enableTabIndentation)return!1;const n=null!=(t=this.options.tabSize)?t:4,{state:r}=e,{selection:i}=r,{$from:o,empty:s}=i;if(o.parent.type!==this.type)return!1;const a=" ".repeat(n);return s?e.commands.insertContent(a):e.commands.command(({tr:e})=>{const{from:t,to:n}=i,o=r.doc.textBetween(t,n,"\n","\n").split("\n").map(e=>a+e).join("\n");return e.replaceWith(t,n,r.schema.text(o)),!0})},"Shift-Tab":({editor:e})=>{var t;if(!this.options.enableTabIndentation)return!1;const n=null!=(t=this.options.tabSize)?t:4,{state:r}=e,{selection:i}=r,{$from:o,empty:s}=i;return o.parent.type===this.type&&(s?e.commands.command(({tr:e})=>{var t;const{pos:i}=o,s=o.start(),a=o.end(),l=r.doc.textBetween(s,a,"\n","\n").split("\n");let c=0,u=0;const d=i-s;for(let e=0;e<l.length;e+=1){if(u+l[e].length>=d){c=e;break}u+=l[e].length+1}const p=(null==(t=l[c].match(/^ */))?void 0:t[0])||"",h=Math.min(p.length,n);if(0===h)return!0;let f=s;for(let e=0;e<c;e+=1)f+=l[e].length+1;e.delete(f,f+h);return i-f<=h&&e.setSelection(Ko.create(e.doc,f)),!0}):e.commands.command(({tr:e})=>{const{from:t,to:o}=i,s=r.doc.textBetween(t,o,"\n","\n").split("\n").map(e=>{var t;const r=(null==(t=e.match(/^ */))?void 0:t[0])||"",i=Math.min(r.length,n);return e.slice(i)}).join("\n");return e.replaceWith(t,o,r.schema.text(s)),!0}))},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const o=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith("\n\n");return!(!o||!s)&&e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;const{state:t}=e,{selection:n,doc:r}=t,{$from:i,empty:o}=n;if(!o||i.parent.type!==this.type)return!1;if(!(i.parentOffset===i.parent.nodeSize-2))return!1;const s=i.after();if(void 0===s)return!1;return r.nodeAt(s)?e.commands.command(({tr:e})=>(e.setSelection(Uo.near(r.resolve(s))),!0)):e.commands.exitCode()}}},addInputRules(){return[ig({find:kg,type:this.type,getAttributes:e=>({language:e[1]})}),ig({find:Tg,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new cs({key:new ps("codeBlockVSCodeHandler"),props:{handlePaste:(e,t)=>{if(!t.clipboardData)return!1;if(this.editor.isActive(this.type.name))return!1;const n=t.clipboardData.getData("text/plain"),r=t.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,o=null==i?void 0:i.mode;if(!n||!o)return!1;const{tr:s,schema:a}=e.state,l=a.text(n.replace(/\r\n?/g,"\n"));return s.replaceSelectionWith(this.type.create({language:o},l)),s.selection.$from.parent.type!==this.type&&s.setSelection(Ko.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),e.dispatch(s),!0}}})]}}),_g=mg.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,"\n\n"):""}),Rg=mg.create({name:"hardBreak",markdownTokenName:"br",addOptions:()=>({keepMarks:!0,HTMLAttributes:{}}),inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML:()=>[{tag:"br"}],renderHTML({HTMLAttributes:e}){return["br",sm(this.options.HTMLAttributes,e)]},renderText:()=>"\n",renderMarkdown:()=>" \n",parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{const{selection:e,storedMarks:i}=n;if(e.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:s}=r.extensionManager,a=i||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&a&&o){const t=a.filter(e=>s.includes(e.type.name));e.ensureMarks(t)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Dg=mg.create({name:"heading",addOptions:()=>({levels:[1,2,3,4,5,6],HTMLAttributes:{}}),content:"inline*",group:"block",defining:!0,addAttributes:()=>({level:{default:1,rendered:!1}}),parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,sm(this.options.HTMLAttributes,t),0]},parseMarkdown:(e,t)=>t.createNode("heading",{level:e.depth||1},t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>{var n;const r=(null==(n=e.attrs)?void 0:n.level)?parseInt(e.attrs.level,10):1,i="#".repeat(r);return e.content?`${i} ${t.renderChildren(e.content)}`:""},addCommands(){return{setHeading:e=>({commands:t})=>!!this.options.levels.includes(e.level)&&t.setNode(this.name,e),toggleHeading:e=>({commands:t})=>!!this.options.levels.includes(e.level)&&t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>ig({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),Ig=mg.create({name:"horizontalRule",addOptions:()=>({HTMLAttributes:{},nextNodeType:"paragraph"}),group:"block",parseHTML:()=>[{tag:"hr"}],renderHTML({HTMLAttributes:e}){return["hr",sm(this.options.HTMLAttributes,e)]},markdownTokenName:"hr",parseMarkdown:(e,t)=>t.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!function(e,t){const{selection:n}=e,{$from:r}=n;if(n instanceof Jo){const e=r.index();return r.parent.canReplaceWith(e,e+1,t)}let i=r.depth;for(;i>=0;){const e=r.index(i);if(r.node(i).contentMatchAt(e).matchType(t))return!0;i-=1}return!1}(t,t.schema.nodes[this.name]))return!1;const{selection:n}=t,{$to:r}=n,i=e();return fm(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:e,tr:t,dispatch:n})=>{if(n){const{$to:n}=t.selection,r=n.end();if(n.nodeAfter)n.nodeAfter.isTextblock?t.setSelection(Ko.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(Jo.create(t.doc,n.pos)):t.setSelection(Ko.create(t.doc,n.pos));else{const i=e.schema.nodes[this.options.nextNodeType]||n.parent.type.contentMatch.defaultType,o=null==i?void 0:i.create();o&&(t.insert(r,o),t.setSelection(Ko.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[rg({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Lg=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Bg=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,zg=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Pg=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,jg=Hm.create({name:"italic",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:e=>"normal"!==e.style.fontStyle&&null},{style:"font-style=normal",clearMark:e=>e.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:e}){return["em",sm(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(e,t)=>t.applyMark("italic",t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[ng({find:Lg,type:this.type}),ng({find:zg,type:this.type})]},addPasteRules(){return[gg({find:Bg,type:this.type}),gg({find:Pg,type:this.type})]}});const Fg="numeric",$g="ascii",Hg="alpha",Ug="asciinumeric",qg="alphanumeric",Vg="domain",Wg="emoji",Kg="scheme",Gg="slashscheme",Jg="whitespace";function Yg(e,t){return e in t||(t[e]=[]),t[e]}function Zg(e,t,n){t[Fg]&&(t[Ug]=!0,t[qg]=!0),t[$g]&&(t[Ug]=!0,t[Hg]=!0),t[Ug]&&(t[qg]=!0),t[Hg]&&(t[qg]=!0),t[qg]&&(t[Vg]=!0),t[Wg]&&(t[Vg]=!0);for(const r in t){const t=Yg(r,n);t.indexOf(e)<0&&t.push(e)}}function Xg(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}Xg.groups={},Xg.prototype={accepts(){return!!this.t},go(e){const t=this,n=t.j[e];if(n)return n;for(let n=0;n<t.jr.length;n++){const r=t.jr[n][0],i=t.jr[n][1];if(i&&r.test(e))return i}return t.jd},has(e,t=!1){return t?e in this.j:!!this.go(e)},ta(e,t,n,r){for(let i=0;i<e.length;i++)this.tt(e[i],t,n,r)},tr(e,t,n,r){let i;return r=r||Xg.groups,t&&t.j?i=t:(i=new Xg(t),n&&r&&Zg(t,n,r)),this.jr.push([e,i]),i},ts(e,t,n,r){let i=this;const o=e.length;if(!o)return i;for(let t=0;t<o-1;t++)i=i.tt(e[t]);return i.tt(e[o-1],t,n,r)},tt(e,t,n,r){r=r||Xg.groups;const i=this;if(t&&t.j)return i.j[e]=t,t;const o=t;let s,a=i.go(e);if(a?(s=new Xg,Object.assign(s.j,a.j),s.jr.push.apply(s.jr,a.jr),s.jd=a.jd,s.t=a.t):s=new Xg,o){if(r)if(s.t&&"string"==typeof s.t){const e=Object.assign(function(e,t){const n={};for(const r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}(s.t,r),n);Zg(o,e,r)}else n&&Zg(o,n,r);s.t=o}return i.j[e]=s,s}};const Qg=(e,t,n,r,i)=>e.ta(t,n,r,i),ey=(e,t,n,r,i)=>e.tr(t,n,r,i),ty=(e,t,n,r,i)=>e.ts(t,n,r,i),ny=(e,t,n,r,i)=>e.tt(t,n,r,i),ry="WORD",iy="UWORD",oy="ASCIINUMERICAL",sy="ALPHANUMERICAL",ay="LOCALHOST",ly="TLD",cy="UTLD",uy="SCHEME",dy="SLASH_SCHEME",py="NUM",hy="WS",fy="NL",my="OPENBRACE",gy="CLOSEBRACE",yy="OPENBRACKET",vy="CLOSEBRACKET",by="OPENPAREN",wy="CLOSEPAREN",xy="OPENANGLEBRACKET",My="CLOSEANGLEBRACKET",Sy="FULLWIDTHLEFTPAREN",Ey="FULLWIDTHRIGHTPAREN",Cy="LEFTCORNERBRACKET",Ny="RIGHTCORNERBRACKET",Ay="LEFTWHITECORNERBRACKET",ky="RIGHTWHITECORNERBRACKET",Ty="FULLWIDTHLESSTHAN",Oy="FULLWIDTHGREATERTHAN",_y="AMPERSAND",Ry="APOSTROPHE",Dy="ASTERISK",Iy="AT",Ly="BACKSLASH",By="BACKTICK",zy="CARET",Py="COLON",jy="COMMA",Fy="DOLLAR",$y="DOT",Hy="EQUALS",Uy="EXCLAMATION",qy="HYPHEN",Vy="PERCENT",Wy="PIPE",Ky="PLUS",Gy="POUND",Jy="QUERY",Yy="QUOTE",Zy="FULLWIDTHMIDDLEDOT",Xy="SEMI",Qy="SLASH",ev="TILDE",tv="UNDERSCORE",nv="EMOJI",rv="SYM";var iv=Object.freeze({__proto__:null,ALPHANUMERICAL:sy,AMPERSAND:_y,APOSTROPHE:Ry,ASCIINUMERICAL:oy,ASTERISK:Dy,AT:Iy,BACKSLASH:Ly,BACKTICK:By,CARET:zy,CLOSEANGLEBRACKET:My,CLOSEBRACE:gy,CLOSEBRACKET:vy,CLOSEPAREN:wy,COLON:Py,COMMA:jy,DOLLAR:Fy,DOT:$y,EMOJI:nv,EQUALS:Hy,EXCLAMATION:Uy,FULLWIDTHGREATERTHAN:Oy,FULLWIDTHLEFTPAREN:Sy,FULLWIDTHLESSTHAN:Ty,FULLWIDTHMIDDLEDOT:Zy,FULLWIDTHRIGHTPAREN:Ey,HYPHEN:qy,LEFTCORNERBRACKET:Cy,LEFTWHITECORNERBRACKET:Ay,LOCALHOST:ay,NL:fy,NUM:py,OPENANGLEBRACKET:xy,OPENBRACE:my,OPENBRACKET:yy,OPENPAREN:by,PERCENT:Vy,PIPE:Wy,PLUS:Ky,POUND:Gy,QUERY:Jy,QUOTE:Yy,RIGHTCORNERBRACKET:Ny,RIGHTWHITECORNERBRACKET:ky,SCHEME:uy,SEMI:Xy,SLASH:Qy,SLASH_SCHEME:dy,SYM:rv,TILDE:ev,TLD:ly,UNDERSCORE:tv,UTLD:cy,UWORD:iy,WORD:ry,WS:hy});const ov=/[a-z]/,sv=/\p{L}/u,av=/\p{Emoji}/u,lv=/\d/,cv=/\s/;Object.freeze({__proto__:null,ASCII_LETTER:ov,DIGIT:lv,EMOJI:av,EMOJI_VARIATION:/\ufe0f/,LETTER:sv,SPACE:cv});let uv=null,dv=null;function pv(e,t){const n=function(e){const t=[],n=e.length;let r=0;for(;r<n;){let i,o=e.charCodeAt(r),s=o<55296||o>56319||r+1===n||(i=e.charCodeAt(r+1))<56320||i>57343?e[r]:e.slice(r,r+2);t.push(s),r+=s.length}return t}(t.replace(/[A-Z]/g,e=>e.toLowerCase())),r=n.length,i=[];let o=0,s=0;for(;s<r;){let a=e,l=null,c=0,u=null,d=-1,p=-1;for(;s<r&&(l=a.go(n[s]));)a=l,a.accepts()?(d=0,p=0,u=a):d>=0&&(d+=n[s].length,p++),c+=n[s].length,o+=n[s].length,s++;o-=d,s-=p,c-=d,i.push({t:u.t,v:t.slice(o-c,o),s:o-c,e:o})}return i}function hv(e,t,n,r,i){let o;const s=t.length;for(let n=0;n<s-1;n++){const s=t[n];e.j[s]?o=e.j[s]:(o=new Xg(r),o.jr=i.slice(),e.j[s]=o),e=o}return o=new Xg(n),o.jr=i.slice(),e.j[t[s-1]]=o,o}function fv(e){const t=[],n=[];let r=0;for(;r<e.length;){let i=0;for(;"0123456789".indexOf(e[r+i])>=0;)i++;if(i>0){t.push(n.join(""));for(let t=parseInt(e.substring(r,r+i),10);t>0;t--)n.pop();r+=i}else n.push(e[r]),r++}return t}const mv={defaultProtocol:"http",events:null,format:yv,formatHref:yv,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function gv(e,t=null){let n=Object.assign({},mv);e&&(n=Object.assign(n,e instanceof gv?e.o:e));const r=n.ignoreTags,i=[];for(let e=0;e<r.length;e++)i.push(r[e].toUpperCase());this.o=n,t&&(this.defaultRender=t),this.ignoreTags=i}function yv(e){return e}function vv(e,t){this.t="token",this.v=e,this.tk=t}function bv(e,t){class n extends vv{constructor(t,n){super(t,n),this.t=e}}for(const e in t)n.prototype[e]=t[e];return n.t=e,n}gv.prototype={o:mv,ignoreTags:[],defaultRender:e=>e,check(e){return this.get("validate",e.toString(),e)},get(e,t,n){const r=null!=t;let i=this.o[e];return i?("object"==typeof i?(i=n.t in i?i[n.t]:mv[e],"function"==typeof i&&r&&(i=i(t,n))):"function"==typeof i&&r&&(i=i(t,n.t,n)),i):i},getObj(e,t,n){let r=this.o[e];return"function"==typeof r&&null!=t&&(r=r(t,n.t,n)),r},render(e){const t=e.render(this);return(this.get("render",null,e)||this.defaultRender)(t,e.t,e)}},Object.freeze({__proto__:null,Options:gv,defaults:mv}),vv.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){const t=this.toString(),n=e.get("truncate",t,this),r=e.get("format",t,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(e){return e.get("formatHref",this.toHref(e.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=mv.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get("validate",this.toString(),this)},render(e){const t=this,n=this.toHref(e.get("defaultProtocol")),r=e.get("formatHref",n,this),i=e.get("tagName",n,t),o=this.toFormattedString(e),s={},a=e.get("className",n,t),l=e.get("target",n,t),c=e.get("rel",n,t),u=e.getObj("attributes",n,t),d=e.getObj("events",n,t);return s.href=r,a&&(s.class=a),l&&(s.target=l),c&&(s.rel=c),u&&Object.assign(s,u),{tagName:i,attributes:s,content:o,eventListeners:d}}};const wv=bv("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),xv=bv("text"),Mv=bv("nl"),Sv=bv("url",{isLink:!0,toHref(e=mv.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){const e=this.tk;return e.length>=2&&e[0].t!==ay&&e[1].t===Py}});Object.freeze({__proto__:null,Base:vv,Email:wv,MultiToken:vv,Nl:Mv,Text:xv,Url:Sv,createTokenClass:bv});const Ev=e=>new Xg(e);function Cv(e,t,n){const r=n[0].s,i=n[n.length-1].e;return new e(t.slice(r,i),n)}const Nv="undefined"!=typeof console&&console&&console.warn||(()=>{}),Av={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function kv(e,t=!1){if(Av.initialized&&Nv(`linkifyjs: already initialized - will not register custom scheme "${e}" until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw new Error('linkifyjs: incorrect scheme format.\n1. Must only contain digits, lowercase ASCII letters or "-"\n2. Cannot start or end with "-"\n3. "-" cannot repeat');Av.customSchemes.push([e,t])}function Tv(){Av.scanner=function(e=[]){const t={};Xg.groups=t;const n=new Xg;null==uv&&(uv=fv("aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2")),null==dv&&(dv=fv("ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2")),ny(n,"'",Ry),ny(n,"{",my),ny(n,"}",gy),ny(n,"[",yy),ny(n,"]",vy),ny(n,"(",by),ny(n,")",wy),ny(n,"<",xy),ny(n,">",My),ny(n,"(",Sy),ny(n,")",Ey),ny(n,"「",Cy),ny(n,"」",Ny),ny(n,"『",Ay),ny(n,"』",ky),ny(n,"<",Ty),ny(n,">",Oy),ny(n,"&",_y),ny(n,"*",Dy),ny(n,"@",Iy),ny(n,"`",By),ny(n,"^",zy),ny(n,":",Py),ny(n,",",jy),ny(n,"$",Fy),ny(n,".",$y),ny(n,"=",Hy),ny(n,"!",Uy),ny(n,"-",qy),ny(n,"%",Vy),ny(n,"|",Wy),ny(n,"+",Ky),ny(n,"#",Gy),ny(n,"?",Jy),ny(n,'"',Yy),ny(n,"/",Qy),ny(n,";",Xy),ny(n,"~",ev),ny(n,"_",tv),ny(n,"\\",Ly),ny(n,"・",Zy);const r=ey(n,lv,py,{[Fg]:!0});ey(r,lv,r);const i=ey(r,ov,oy,{[Ug]:!0}),o=ey(r,sv,sy,{[qg]:!0}),s=ey(n,ov,ry,{[$g]:!0});ey(s,lv,i),ey(s,ov,s),ey(i,lv,i),ey(i,ov,i);const a=ey(n,sv,iy,{[Hg]:!0});ey(a,ov),ey(a,lv,o),ey(a,sv,a),ey(o,lv,o),ey(o,ov),ey(o,sv,o);const l=ny(n,"\n",fy,{[Jg]:!0}),c=ny(n,"\r",hy,{[Jg]:!0}),u=ey(n,cv,hy,{[Jg]:!0});ny(n,"",u),ny(c,"\n",l),ny(c,"",u),ey(c,cv,u),ny(u,"\r"),ny(u,"\n"),ey(u,cv,u),ny(u,"",u);const d=ey(n,av,nv,{[Wg]:!0});ny(d,"#"),ey(d,av,d),ny(d,"️",d);const p=ny(d,"‍");ny(p,"#"),ey(p,av,d);const h=[[ov,s],[lv,i]],f=[[ov,null],[sv,a],[lv,o]];for(let e=0;e<uv.length;e++)hv(n,uv[e],ly,ry,h);for(let e=0;e<dv.length;e++)hv(n,dv[e],cy,iy,f);Zg(ly,{tld:!0,ascii:!0},t),Zg(cy,{utld:!0,alpha:!0},t),hv(n,"file",uy,ry,h),hv(n,"mailto",uy,ry,h),hv(n,"http",dy,ry,h),hv(n,"https",dy,ry,h),hv(n,"ftp",dy,ry,h),hv(n,"ftps",dy,ry,h),Zg(uy,{scheme:!0,ascii:!0},t),Zg(dy,{slashscheme:!0,ascii:!0},t),e=e.sort((e,t)=>e[0]>t[0]?1:-1);for(let t=0;t<e.length;t++){const r=e[t][0],i=e[t][1]?{[Kg]:!0}:{[Gg]:!0};r.indexOf("-")>=0?i[Vg]=!0:ov.test(r)?lv.test(r)?i[Ug]=!0:i[$g]=!0:i[Fg]=!0,ty(n,r,r,i)}return ty(n,"localhost",ay,{ascii:!0}),n.jd=new Xg(rv),{start:n,tokens:Object.assign({groups:t},iv)}}(Av.customSchemes);for(let e=0;e<Av.tokenQueue.length;e++)Av.tokenQueue[e][1]({scanner:Av.scanner});Av.parser=function({groups:e}){const t=e.domain.concat([_y,Dy,Iy,Ly,By,zy,Fy,Hy,qy,py,Vy,Wy,Ky,Gy,Qy,rv,ev,tv]),n=[Ry,Py,jy,$y,Uy,Vy,Jy,Yy,Xy,xy,My,my,gy,vy,yy,by,wy,Sy,Ey,Cy,Ny,Ay,ky,Ty,Oy],r=[_y,Ry,Dy,Ly,By,zy,Fy,Hy,qy,my,gy,Vy,Wy,Ky,Gy,Jy,Qy,rv,ev,tv],i=Ev(),o=ny(i,ev);Qg(o,r,o),Qg(o,e.domain,o);const s=Ev(),a=Ev(),l=Ev();Qg(i,e.domain,s),Qg(i,e.scheme,a),Qg(i,e.slashscheme,l),Qg(s,r,o),Qg(s,e.domain,s);const c=ny(s,Iy);ny(o,Iy,c),ny(a,Iy,c),ny(l,Iy,c);const u=ny(o,$y);Qg(u,r,o),Qg(u,e.domain,o);const d=Ev();Qg(c,e.domain,d),Qg(d,e.domain,d);const p=ny(d,$y);Qg(p,e.domain,d);const h=Ev(wv);Qg(p,e.tld,h),Qg(p,e.utld,h),ny(c,ay,h);const f=ny(d,qy);ny(f,qy,f),Qg(f,e.domain,d),Qg(h,e.domain,d),ny(h,$y,p),ny(h,qy,f);const m=ny(h,Py);Qg(m,e.numeric,wv);const g=ny(s,qy),y=ny(s,$y);ny(g,qy,g),Qg(g,e.domain,s),Qg(y,r,o),Qg(y,e.domain,s);const v=Ev(Sv);Qg(y,e.tld,v),Qg(y,e.utld,v),Qg(v,e.domain,s),Qg(v,r,o),ny(v,$y,y),ny(v,qy,g),ny(v,Iy,c);const b=ny(v,Py),w=Ev(Sv);Qg(b,e.numeric,w);const x=Ev(Sv),M=Ev();Qg(x,t,x),Qg(x,n,M),Qg(M,t,x),Qg(M,n,M),ny(v,Qy,x),ny(w,Qy,x);const S=ny(a,Py),E=ny(l,Py),C=ny(E,Qy),N=ny(C,Qy);Qg(a,e.domain,s),ny(a,$y,y),ny(a,qy,g),Qg(l,e.domain,s),ny(l,$y,y),ny(l,qy,g),Qg(S,e.domain,x),ny(S,Qy,x),ny(S,Jy,x),Qg(N,e.domain,x),Qg(N,t,x),ny(N,Qy,x);const A=[[my,gy],[yy,vy],[by,wy],[xy,My],[Sy,Ey],[Cy,Ny],[Ay,ky],[Ty,Oy]];for(let e=0;e<A.length;e++){const[r,i]=A[e],o=ny(x,r);ny(M,r,o),ny(o,i,x);const s=Ev(Sv);Qg(o,t,s);const a=Ev();Qg(o,n),Qg(s,t,s),Qg(s,n,a),Qg(a,t,s),Qg(a,n,a),ny(s,i,x),ny(a,i,x)}return ny(i,ay,v),ny(i,fy,Mv),{start:i,tokens:iv}}(Av.scanner.tokens);for(let e=0;e<Av.pluginQueue.length;e++)Av.pluginQueue[e][1]({scanner:Av.scanner,parser:Av.parser});return Av.initialized=!0,Av}function Ov(e){return Av.initialized||Tv(),function(e,t,n){let r=n.length,i=0,o=[],s=[];for(;i<r;){let a=e,l=null,c=null,u=0,d=null,p=-1;for(;i<r&&!(l=a.go(n[i].t));)s.push(n[i++]);for(;i<r&&(c=l||a.go(n[i].t));)l=null,a=c,a.accepts()?(p=0,d=a):p>=0&&p++,i++,u++;if(p<0)i-=u,i<r&&(s.push(n[i]),i++);else{s.length>0&&(o.push(Cv(xv,t,s)),s=[]),i-=p,u-=p;const e=d.t,r=n.slice(i-u,i);o.push(Cv(e,t,r))}}return s.length>0&&o.push(Cv(xv,t,s)),o}(Av.parser.start,e,pv(Av.scanner.start,e))}function _v(e,t=null,n=null){if(t&&"object"==typeof t){if(n)throw Error(`linkifyjs: Invalid link type ${t}; must be a string`);n=t,t=null}const r=new gv(n),i=Ov(e),o=[];for(let e=0;e<i.length;e++){const n=i[e];!n.isLink||t&&n.t!==t||!r.check(n)||o.push(n.toFormattedObject(r))}return o}Ov.scan=pv;var Rv="[\0-   ᠎ -\u2029  ]",Dv=new RegExp(Rv),Iv=new RegExp(`${Rv}$`),Lv=new RegExp(Rv,"g");function Bv(e,t){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return t&&t.forEach(e=>{const t="string"==typeof e?e:e.scheme;t&&n.push(t)}),!e||e.replace(Lv,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var zv=Hm.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(e=>{"string"!=typeof e?kv(e.scheme,e.optionalSlashes):kv(e)})},onDestroy(){Xg.groups={},Av.scanner=null,Av.parser=null,Av.tokenQueue=[],Av.pluginQueue=[],Av.customSchemes=[],Av.initialized=!1},inclusive(){return this.options.autolink},addOptions:()=>({openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(e,t)=>!!Bv(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>{const t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e),n=/^[a-z][a-z0-9+.-]*:/i.test(e);if(t||n&&!e.includes("@"))return!0;const r=(e.includes("@")?e.split("@").pop():e).split(/[/?#:]/)[0];return!/^\d{1,3}(\.\d{1,3}){3}$/.test(r)&&!!/\./.test(r)}}),addAttributes(){return{href:{default:null,parseHTML:e=>e.getAttribute("href")},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:e=>{const t=e.getAttribute("href");return!(!t||!this.options.isAllowedUri(t,{defaultValidate:e=>!!Bv(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}))&&null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!Bv(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",sm(this.options.HTMLAttributes,e),0]:["a",sm(this.options.HTMLAttributes,{...e,href:""}),0]},markdownTokenName:"link",parseMarkdown:(e,t)=>t.applyMark("link",t.parseInline(e.tokens||[]),{href:e.href,title:e.title||null}),renderMarkdown:(e,t)=>{var n;const r=(null==(n=e.attrs)?void 0:n.href)||"";return`[${t.renderChildren(e)}](${r})`},addCommands(){return{setLink:e=>({chain:t})=>{const{href:n}=e;return!!this.options.isAllowedUri(n,{defaultValidate:e=>!!Bv(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})&&t().setMark(this.name,e).setMeta("preventAutolink",!0).run()},toggleLink:e=>({chain:t})=>{const{href:n}=e||{};return!(n&&!this.options.isAllowedUri(n,{defaultValidate:e=>!!Bv(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}))&&t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[gg({find:e=>{const t=[];if(e){const{protocols:n,defaultProtocol:r}=this.options,i=_v(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!Bv(e,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(e=>{this.options.shouldAutoLink(e.value)&&t.push({text:e.value,data:{href:e.href},index:e.start})})}return t},type:this.type,getAttributes:e=>{var t;return{href:null==(t=e.data)?void 0:t.href}}})]},addProseMirrorPlugins(){const e=[],{protocols:t,defaultProtocol:n}=this.options;var r;return this.options.autolink&&e.push((r={type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!Bv(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink},new cs({key:new ps("autolink"),appendTransaction:(e,t,n)=>{const i=e.some(e=>e.docChanged)&&!t.doc.eq(n.doc),o=e.some(e=>e.getMeta("preventAutolink"));if(!i||o)return;const{tr:s}=n;return cm(tm(t.doc,[...e])).forEach(({newRange:e})=>{const t=function(e,t,n){const r=[];return e.nodesBetween(t.from,t.to,(e,t)=>{n(e)&&r.push({node:e,pos:t})}),r}(n.doc,e,e=>e.isTextblock);let i,o;if(t.length>1)i=t[0],o=n.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0," ");else if(t.length){const r=n.doc.textBetween(e.from,e.to," "," ");if(!Iv.test(r))return;i=t[0],o=n.doc.textBetween(i.pos,e.to,void 0," ")}if(i&&o){const e=o.split(Dv).filter(Boolean);if(e.length<=0)return!1;const t=e[e.length-1],l=i.pos+o.lastIndexOf(t);if(!t)return!1;const c=Ov(t).map(e=>e.toObject(r.defaultProtocol));if(!(1===(a=c).length?a[0].isLink:3===a.length&&a[1].isLink&&["()","[]"].includes(a[0].value+a[2].value)))return!1;c.filter(e=>e.isLink).map(e=>({...e,from:l+e.start+1,to:l+e.end+1})).filter(e=>!n.schema.marks.code||!n.doc.rangeHasMark(e.from,e.to,n.schema.marks.code)).filter(e=>r.validate(e.value)).filter(e=>r.shouldAutoLink(e.value)).forEach(e=>{um(e.from,e.to,n.doc).some(e=>e.mark.type===r.type)||s.addMark(e.from,e.to,r.type.create({href:e.href}))})}var a}),s.steps.length?s:void 0}}))),e.push(function(e){return new cs({key:new ps("handleClickLink"),props:{handleClick:(t,n,r)=>{var i,o;if(0!==r.button)return!1;if(!t.editable)return!1;let s=null;if(r.target instanceof HTMLAnchorElement)s=r.target;else{const t=r.target;if(!t)return!1;const n=e.editor.view.dom;s=t.closest("a"),s&&!n.contains(s)&&(s=null)}if(!s)return!1;let a=!1;if(e.enableClickSelection&&(a=e.editor.commands.extendMarkRange(e.type.name)),e.openOnClick){const n=am(t.state,e.type.name),r=null!=(i=s.href)?i:n.href,l=null!=(o=s.target)?o:n.target;r&&(window.open(r,l),a=!0)}return a}}})}({type:this.type,editor:this.editor,openOnClick:"whenNotEditable"===this.options.openOnClick||this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&e.push(function(e){return new cs({key:new ps("handlePasteLink"),props:{handlePaste:(t,n,r)=>{const{shouldAutoLink:i}=e,{state:o}=t,{selection:s}=o,{empty:a}=s;if(a)return!1;let l="";r.content.forEach(e=>{l+=e.textContent});const c=_v(l,{defaultProtocol:e.defaultProtocol}).find(e=>e.isLink&&e.value===l);return!(!l||!c||void 0!==i&&!i(c.value))&&e.editor.commands.setMark(e.type,{href:c.href})}}})}({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),e}}),Pv=Object.defineProperty,jv="textStyle",Fv=/^\s*([-+*])\s$/,$v=mg.create({name:"bulletList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML:()=>[{tag:"ul"}],renderHTML({HTMLAttributes:e}){return["ul",sm(this.options.HTMLAttributes,e),0]},markdownTokenName:"list",parseMarkdown:(e,t)=>"list"!==e.type||e.ordered?[]:{type:"bulletList",content:e.items?t.parseChildren(e.items):[]},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,"\n"):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(jv)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=og({find:Fv,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=og({find:Fv,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(jv),editor:this.editor})),[e]}}),Hv=mg.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:e}){return["li",sm(this.options.HTMLAttributes,e),0]},markdownTokenName:"list_item",parseMarkdown:(e,t)=>{if("list_item"!==e.type)return[];let n=[];if(e.tokens&&e.tokens.length>0){if(e.tokens.some(e=>"paragraph"===e.type))n=t.parseChildren(e.tokens);else{const r=e.tokens[0];if(r&&"text"===r.type&&r.tokens&&r.tokens.length>0){if(n=[{type:"paragraph",content:t.parseInline(r.tokens)}],e.tokens.length>1){const r=e.tokens.slice(1),i=t.parseChildren(r);n.push(...i)}}else n=t.parseChildren(e.tokens)}}return 0===n.length&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(e,t,n)=>fg(e,t,e=>"bulletList"===e.parentType?"- ":"orderedList"===e.parentType?`${e.index+1}. `:"- ",n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});((e,t)=>{for(var n in t)Pv(e,n,{get:t[n],enumerable:!0})})({},{findListItemPos:()=>Uv,getNextListDepth:()=>qv,handleBackspace:()=>Gv,handleDelete:()=>Zv,hasListBefore:()=>Vv,hasListItemAfter:()=>Xv,hasListItemBefore:()=>Wv,listItemHasSubList:()=>Kv,nextListIsDeeper:()=>Jv,nextListIsHigher:()=>Yv});var Uv=(e,t)=>{const{$from:n}=t.selection,r=rf(e,t.schema);let i=null,o=n.depth,s=n.pos,a=null;for(;o>0&&null===a;)i=n.node(o),i.type===r?a=o:(o-=1,s-=1);return null===a?null:{$pos:t.doc.resolve(s),depth:a}},qv=(e,t)=>{const n=Uv(e,t);if(!n)return!1;const[,r]=((e,t,n,r=20)=>{const i=e.doc.resolve(n);let o=r,s=null;for(;o>0&&null===s;){const e=i.node(o);(null==e?void 0:e.type.name)===t?s=e:o-=1}return[s,o]})(t,e,n.$pos.pos+4);return r},Vv=(e,t,n)=>{const{$anchor:r}=e.selection,i=Math.max(0,r.pos-2),o=e.doc.resolve(i).node();return!(!o||!n.includes(o.type.name))},Wv=(e,t)=>{var n;const{$anchor:r}=t.selection,i=t.doc.resolve(r.pos-2);return 0!==i.index()&&(null==(n=i.nodeBefore)?void 0:n.type.name)===e},Kv=(e,t,n)=>{if(!n)return!1;const r=rf(e,t.schema);let i=!1;return n.descendants(e=>{e.type===r&&(i=!0)}),i},Gv=(e,t,n)=>{if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!Pf(e.state,t)&&Vv(e.state,t,n)){const{$anchor:n}=e.state.selection,r=e.state.doc.resolve(n.before()-1),i=[];r.node().descendants((e,n)=>{e.type.name===t&&i.push({node:e,pos:n})});const o=i.at(-1);if(!o)return!1;const s=e.state.doc.resolve(r.start()+o.pos+1);return e.chain().cut({from:n.start()-1,to:n.end()+1},s.end()).joinForward().run()}if(!Pf(e.state,t))return!1;if(!(e=>{const{$from:t,$to:n}=e.selection;return!(t.parentOffset>0||t.pos!==n.pos)})(e.state))return!1;const r=Uv(t,e.state);if(!r)return!1;const i=e.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=Kv(t,e.state,i);return Wv(t,e.state)&&!o?e.commands.joinItemBackward():e.chain().liftListItem(t).run()},Jv=(e,t)=>{const n=qv(e,t),r=Uv(e,t);return!(!r||!n)&&n>r.depth},Yv=(e,t)=>{const n=qv(e,t),r=Uv(e,t);return!(!r||!n)&&n<r.depth},Zv=(e,t)=>{if(!Pf(e.state,t))return!1;if(!((e,t)=>{const{$from:n,$to:r,$anchor:i}=e.selection;if(t){const n=nm(e=>e.type.name===t)(e.selection);if(!n)return!1;const r=e.doc.resolve(n.pos+1);return i.pos+1===r.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)})(e.state,t))return!1;const{selection:n}=e.state,{$from:r,$to:i}=n;return!(!n.empty&&r.sameParent(i))&&(Jv(t,e.state)?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():Yv(t,e.state)?e.chain().joinForward().joinBackward().run():e.commands.joinItemForward())},Xv=(e,t)=>{var n;const{$anchor:r}=t.selection,i=t.doc.resolve(r.pos-r.parentOffset-2);return i.index()!==i.parent.childCount-1&&(null==(n=i.nodeAfter)?void 0:n.type.name)===e},Qv=qm.create({name:"listKeymap",addOptions:()=>({listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}),addKeyboardShortcuts(){return{Delete:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{void 0!==e.state.schema.nodes[n]&&Zv(e,n)&&(t=!0)}),t},"Mod-Delete":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{void 0!==e.state.schema.nodes[n]&&Zv(e,n)&&(t=!0)}),t},Backspace:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{void 0!==e.state.schema.nodes[n]&&Gv(e,n,r)&&(t=!0)}),t},"Mod-Backspace":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{void 0!==e.state.schema.nodes[n]&&Gv(e,n,r)&&(t=!0)}),t}}}}),eb=/^(\s*)(\d+)\.\s+(.*)$/,tb=/^\s/;function nb(e,t,n){var r;const i=[];let o=0;for(;o<e.length;){const s=e[o];if(s.indent===t){const a=s.content.split("\n"),l=(null==(r=a[0])?void 0:r.trim())||"",c=[];l&&c.push({type:"paragraph",raw:l,tokens:n.inlineTokens(l)});const u=a.slice(1).join("\n").trim();if(u){const e=n.blockTokens(u);c.push(...e)}let d=o+1;const p=[];for(;d<e.length&&e[d].indent>t;)p.push(e[d]),d+=1;if(p.length>0){const e=Math.min(...p.map(e=>e.indent)),t=nb(p,e,n);c.push({type:"list",ordered:!0,start:p[0].number,items:t,raw:p.map(e=>e.raw).join("\n")})}i.push({type:"list_item",raw:s.raw,tokens:c}),o=d}else o+=1}return i}var rb="textStyle",ib=/^(\d+)\.\s$/,ob=mg.create({name:"orderedList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes:()=>({start:{default:1,parseHTML:e=>e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1},type:{default:null,parseHTML:e=>e.getAttribute("type")}}),parseHTML:()=>[{tag:"ol"}],renderHTML({HTMLAttributes:e}){const{start:t,...n}=e;return 1===t?["ol",sm(this.options.HTMLAttributes,n),0]:["ol",sm(this.options.HTMLAttributes,e),0]},markdownTokenName:"list",parseMarkdown:(e,t)=>{if("list"!==e.type||!e.ordered)return[];const n=e.start||1,r=e.items?function(e,t){return e.map(e=>{if("list_item"!==e.type)return t.parseChildren([e])[0];const n=[];return e.tokens&&e.tokens.length>0&&e.tokens.forEach(e=>{if("paragraph"===e.type||"list"===e.type||"blockquote"===e.type||"code"===e.type)n.push(...t.parseChildren([e]));else if("text"===e.type&&e.tokens){const r=t.parseChildren([e]);n.push({type:"paragraph",content:r})}else{const r=t.parseChildren([e]);r.length>0&&n.push(...r)}}),{type:"listItem",content:n}})}(e.items,t):[];return 1!==n?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,"\n"):"",markdownTokenizer:{name:"orderedList",level:"block",start:e=>{const t=e.match(/^(\s*)(\d+)\.\s+/),n=null==t?void 0:t.index;return void 0!==n?n:-1},tokenize:(e,t,n)=>{var r;const i=e.split("\n"),[o,s]=function(e){const t=[];let n=0,r=0;for(;n<e.length;){const i=e[n],o=i.match(eb);if(!o)break;const[,s,a,l]=o,c=s.length;let u=l,d=n+1;const p=[i];for(;d<e.length;){const t=e[d];if(t.match(eb))break;if(""===t.trim())p.push(t),u+="\n",d+=1;else{if(!t.match(tb))break;p.push(t),u+=`\n${t.slice(c+2)}`,d+=1}}t.push({indent:c,number:parseInt(a,10),content:u.trim(),raw:p.join("\n")}),r=d,n=d}return[t,r]}(i);if(0===o.length)return;const a=nb(o,0,n);if(0===a.length)return;return{type:"list",ordered:!0,start:(null==(r=o[0])?void 0:r.number)||1,items:a,raw:i.slice(0,s).join("\n")}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(rb)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=og({find:ib,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=og({find:ib,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(rb)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[e]}}),sb=/^\s*(\[([( |x])?\])\s$/,ab=mg.create({name:"taskItem",addOptions:()=>({nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}),content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes:()=>({checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{const t=e.getAttribute("data-checked");return""===t||"true"===t},renderHTML:e=>({"data-checked":e.checked})}}),parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:e,HTMLAttributes:t}){return["li",sm(this.options.HTMLAttributes,t,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:e.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(e,t)=>{const n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode("paragraph",{},t.parseInline(e.tokens))):e.text?n.push(t.createNode("paragraph",{},[t.createNode("text",{text:e.text})])):n.push(t.createNode("paragraph",{},[])),e.nestedTokens&&e.nestedTokens.length>0){const r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode("taskItem",{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>{var n;return fg(e,t,`- [${(null==(n=e.attrs)?void 0:n.checked)?"x":" "}] `)},addKeyboardShortcuts(){const e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{const i=document.createElement("li"),o=document.createElement("label"),s=document.createElement("span"),a=document.createElement("input"),l=document.createElement("div"),c=e=>{var t,n;a.ariaLabel=(null==(n=null==(t=this.options.a11y)?void 0:t.checkboxLabel)?void 0:n.call(t,e,a.checked))||`Task item checkbox for ${e.textContent||"empty task item"}`};c(e),o.contentEditable="false",a.type="checkbox",a.addEventListener("mousedown",e=>e.preventDefault()),a.addEventListener("change",t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked)return void(a.checked=!a.checked);const{checked:i}=t.target;r.isEditable&&"function"==typeof n&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{const t=n();if("number"!=typeof t)return!1;const r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...null==r?void 0:r.attrs,checked:i}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,i)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{i.setAttribute(e,t)}),i.dataset.checked=e.attrs.checked,a.checked=e.attrs.checked,o.append(a,s),i.append(o,l),Object.entries(t).forEach(([e,t])=>{i.setAttribute(e,t)});let u=new Set(Object.keys(t));return{dom:i,contentDOM:l,update:e=>{if(e.type!==this.type)return!1;i.dataset.checked=e.attrs.checked,a.checked=e.attrs.checked,c(e);const t=function(e,t){return t.filter(t=>t.type===e.type.name).filter(e=>e.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:{[t.name]:e.attrs[t.name]}).reduce((e,t)=>sm(e,t),{})}(e,r.extensionManager.attributes),n=new Set(Object.keys(t)),o=this.options.HTMLAttributes;return u.forEach(e=>{n.has(e)||(e in o?i.setAttribute(e,o[e]):i.removeAttribute(e))}),Object.entries(t).forEach(([e,t])=>{null==t?e in o?i.setAttribute(e,o[e]):i.removeAttribute(e):i.setAttribute(e,t)}),u=n,!0}}}},addInputRules(){return[og({find:sb,type:this.type,getAttributes:e=>({checked:"x"===e[e.length-1]})})]}}),lb=mg.create({name:"taskList",addOptions:()=>({itemTypeName:"taskItem",HTMLAttributes:{}}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return["ul",sm(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,t)=>t.createNode("taskList",{},t.parseChildren(e.items||[])),renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,"\n"):"",markdownTokenizer:{name:"taskList",level:"block",start(e){var t;const n=null==(t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))?void 0:t.index;return void 0!==n?n:-1},tokenize(e,t,n){const r=e=>{const t=hg(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:"x"===e[3].toLowerCase()}),createToken:(e,t)=>({type:"taskItem",raw:"",mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);return t?[{type:"taskList",raw:t.raw,items:t.items}]:n.blockTokens(e)},i=hg(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:"x"===e[3].toLowerCase()}),createToken:(e,t)=>({type:"taskItem",raw:"",mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});qm.create({name:"listKit",addExtensions(){const e=[];return!1!==this.options.bulletList&&e.push($v.configure(this.options.bulletList)),!1!==this.options.listItem&&e.push(Hv.configure(this.options.listItem)),!1!==this.options.listKeymap&&e.push(Qv.configure(this.options.listKeymap)),!1!==this.options.orderedList&&e.push(ob.configure(this.options.orderedList)),!1!==this.options.taskItem&&e.push(ab.configure(this.options.taskItem)),!1!==this.options.taskList&&e.push(lb.configure(this.options.taskList)),e}});var cb=mg.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:e}){return["p",sm(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{const n=e.tokens||[];return 1===n.length&&"image"===n[0].type?t.parseChildren([n[0]]):t.createNode("paragraph",void 0,t.parseInline(n))},renderMarkdown:(e,t)=>e&&Array.isArray(e.content)?t.renderChildren(e.content):"",addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),ub=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,db=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,pb=Hm.create({name:"strike",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:e=>!!e.includes("line-through")&&{}}],renderHTML({HTMLAttributes:e}){return["s",sm(this.options.HTMLAttributes,e),0]},markdownTokenName:"del",parseMarkdown:(e,t)=>t.applyMark("strike",t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[ng({find:ub,type:this.type})]},addPasteRules(){return[gg({find:db,type:this.type})]}}),hb=mg.create({name:"text",group:"inline",parseMarkdown:e=>({type:"text",text:e.text||""}),renderMarkdown:e=>e.text||""}),fb=Hm.create({name:"underline",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:e=>!!e.includes("underline")&&{}}],renderHTML({HTMLAttributes:e}){return["u",sm(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||"underline",t.parseInline(e.tokens||[]))},renderMarkdown:(e,t)=>`++${t.renderChildren(e)}++`,markdownTokenizer:{name:"underline",level:"inline",start:e=>e.indexOf("++"),tokenize(e,t,n){const r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;const i=r[2].trim();return{type:"underline",raw:r[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function mb(e={}){return new cs({view:t=>new gb(t,e)})}class gb{constructor(e,t){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!==(n=t.width)&&void 0!==n?n:1,this.color=!1===t.color?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){null!=this.cursorPos&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,null==e?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let 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,s=i.height/r.offsetHeight;if(n){let n=t.nodeBefore,r=t.nodeAfter;if(n||r){let t=this.editorView.nodeDOM(this.cursorPos-(n?n.nodeSize:0));if(t){let i=t.getBoundingClientRect(),o=n?i.bottom:i.top;n&&r&&(o=(o+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let a=this.width/2*s;e={left:i.left,right:i.right,top:o-a,bottom:o+a}}}}if(!e){let t=this.editorView.coordsAtPos(this.cursorPos),n=this.width/2*o;e={left:t.left-n,right:t.left+n,top:t.top,bottom:t.bottom}}let a,l,c=this.editorView.dom.offsetParent;if(this.element||(this.element=c.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),!c||c==document.body&&"static"==getComputedStyle(c).position)a=-pageXOffset,l=-pageYOffset;else{let e=c.getBoundingClientRect(),t=e.width/c.offsetWidth,n=e.height/c.offsetHeight;a=e.left-c.scrollLeft*t,l=e.top-c.scrollTop*n}this.element.style.left=(e.left-a)/o+"px",this.element.style.top=(e.top-l)/s+"px",this.element.style.width=(e.right-e.left)/o+"px",this.element.style.height=(e.bottom-e.top)/s+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let 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){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=No(this.editorView.state.doc,e,this.editorView.dragging.slice);null!=t&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class yb extends Uo{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return yb.valid(n)?new yb(n):Uo.near(n)}content(){return Yr.empty}eq(e){return e instanceof yb&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new yb(e.resolve(t.pos))}getBookmark(){return new vb(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!function(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(0!=n)for(let e=r.child(n-1);;e=e.lastChild){if(0==e.childCount&&!e.inlineContent||bb(e.type))return!0;if(e.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(e)||!function(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n!=r.childCount)for(let e=r.child(n);;e=e.firstChild){if(0==e.childCount&&!e.inlineContent||bb(e.type))return!0;if(e.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(e))return!1;let n=t.type.spec.allowGapCursor;if(null!=n)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&yb.valid(e))return e;let r=e.pos,i=null;for(let n=e.depth;;n--){let o=e.node(n);if(t>0?e.indexAfter(n)<o.childCount:e.index(n)>0){i=o.child(t>0?e.indexAfter(n):e.index(n)-1);break}if(0==n)return null;r+=t;let s=e.doc.resolve(r);if(yb.valid(s))return s}for(;;){let o=t>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!Jo.isSelectable(i)){e=e.doc.resolve(r+i.nodeSize*t),n=!1;continue e}break}i=o,r+=t;let s=e.doc.resolve(r);if(yb.valid(s))return s}return null}}}yb.prototype.visible=!1,yb.findFrom=yb.findGapCursorFrom,Uo.jsonID("gapcursor",yb);class vb{constructor(e){this.pos=e}map(e){return new vb(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return yb.valid(t)?new yb(t):Uo.near(t)}}function bb(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}const wb=jc({ArrowLeft:xb("horiz",-1),ArrowRight:xb("horiz",1),ArrowUp:xb("vert",-1),ArrowDown:xb("vert",1)});function xb(e,t){const n="vert"==e?t>0?"down":"up":t>0?"right":"left";return function(e,r,i){let o=e.selection,s=t>0?o.$to:o.$from,a=o.empty;if(o instanceof Ko){if(!i.endOfTextblock(n)||0==s.depth)return!1;a=!1,s=e.doc.resolve(t>0?s.after():s.before())}let l=yb.findGapCursorFrom(s,t,a);return!!l&&(r&&r(e.tr.setSelection(new yb(l))),!0)}}function Mb(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!yb.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return!(i&&i.inside>-1&&Jo.isSelectable(e.state.doc.nodeAt(i.inside)))&&(e.dispatch(e.state.tr.setSelection(new yb(r))),!0)}function Sb(e,t){if("insertCompositionText"!=t.inputType||!(e.state.selection instanceof yb))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=qr.empty;for(let e=r.length-1;e>=0;e--)i=qr.from(r[e].createAndFill(null,i));let o=e.state.tr.replace(n.pos,n.pos,new Yr(i,0,0));return o.setSelection(Ko.near(o.doc.resolve(n.pos+1))),e.dispatch(o),!1}function Eb(e){if(!(e.selection instanceof yb))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",Xl.create(e.doc,[Jl.widget(e.selection.head,t,{key:"gapcursor"})])}var Cb=200,Nb=function(){};Nb.prototype.append=function(e){return e.length?(e=Nb.from(e),!this.length&&e||e.length<Cb&&this.leafAppend(e)||this.length<Cb&&e.leafPrepend(this)||this.appendInner(e)):this},Nb.prototype.prepend=function(e){return e.length?Nb.from(e).append(this):this},Nb.prototype.appendInner=function(e){return new kb(this,e)},Nb.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?Nb.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Nb.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Nb.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)},Nb.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},Nb.from=function(e){return e instanceof Nb?e:e&&e.length?new Ab(e):Nb.empty};var Ab=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<=Cb)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=Cb)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}(Nb);Nb.empty=new Ab([]);var kb=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}(Nb);class Tb{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(0==this.eventCount)return null;let n,r,i=this.items.length;for(;;i--){if(this.items.get(i-1).selection){--i;break}}t&&(n=this.remapping(i,this.items.length),r=n.maps.length);let o,s,a=e.tr,l=[],c=[];return this.items.forEach((e,t)=>{if(!e.step)return n||(n=this.remapping(i,t+1),r=n.maps.length),r--,void c.push(e);if(n){c.push(new Ob(e.map));let t,i=e.step.map(n.slice(r));i&&a.maybeStep(i).doc&&(t=a.mapping.maps[a.mapping.maps.length-1],l.push(new Ob(t,void 0,void 0,l.length+c.length))),r--,t&&n.appendMap(t,r)}else a.maybeStep(e.step);return e.selection?(o=n?e.selection.map(n.slice(r)):e.selection,s=new Tb(this.items.slice(0,i).append(c.reverse().concat(l)),this.eventCount-1),!1):void 0},this.items.length,0),{remaining:s,transform:a,selection:o}}addTransform(e,t,n,r){let i=[],o=this.eventCount,s=this.items,a=!r&&s.length?s.get(s.length-1):null;for(let n=0;n<e.steps.length;n++){let l,c=e.steps[n].invert(e.docs[n]),u=new Ob(e.mapping.maps[n],c,t);(l=a&&a.merge(u))&&(u=l,n?i.pop():s=s.slice(0,s.length-1)),i.push(u),t&&(o++,t=void 0),r||(a=u)}let l=o-n.depth;return l>Rb&&(s=function(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&0==t--)return n=r,!1}),e.slice(n)}(s,l),o-=l),new Tb(s.append(i),o)}remapping(e,t){let n=new no;return this.items.forEach((t,r)=>{let i=null!=t.mirrorOffset&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(e){return 0==this.eventCount?this:new Tb(this.items.append(e.map(e=>new Ob(e))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],r=Math.max(0,this.items.length-t),i=e.mapping,o=e.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},r);let a=t;this.items.forEach(t=>{let r=i.getMirror(--a);if(null==r)return;o=Math.min(o,r);let l=i.maps[r];if(t.step){let o=e.steps[r].invert(e.docs[r]),c=t.selection&&t.selection.map(i.slice(a+1,r));c&&s++,n.push(new Ob(l,o,c))}else n.push(new Ob(l))},r);let l=[];for(let e=t;e<o;e++)l.push(new Ob(i.maps[e]));let c=this.items.slice(0,r).append(l).append(n),u=new Tb(c,s);return u.emptyItemCount()>500&&(u=u.compress(this.items.length-n.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,r=[],i=0;return this.items.forEach((o,s)=>{if(s>=e)r.push(o),o.selection&&i++;else if(o.step){let e=o.step.map(t.slice(n)),s=e&&e.getMap();if(n--,s&&t.appendMap(s,n),e){let a=o.selection&&o.selection.map(t.slice(n));a&&i++;let l,c=new Ob(s.invert(),e,a),u=r.length-1;(l=r.length&&r[u].merge(c))?r[u]=l:r.push(c)}}else o.map&&n--},this.items.length,0),new Tb(Nb.from(r.reverse()),i)}}Tb.empty=new Tb(Nb.empty,0);class Ob{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Ob(t.getMap().invert(),t,this.selection)}}}class _b{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}}const Rb=20;function Db(e){let t=[];for(let n=e.length-1;n>=0&&0==t.length;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function Ib(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),o=t.map(e[r+1],-1);i<=o&&n.push(i,o)}return n}let Lb=!1,Bb=null;function zb(e){let t=e.plugins;if(Bb!=t){Lb=!1,Bb=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){Lb=!0;break}}return Lb}const Pb=new ps("history"),jb=new ps("closeHistory");function Fb(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new cs({key:Pb,state:{init:()=>new _b(Tb.empty,Tb.empty,null,0,-1),apply:(t,n,r)=>function(e,t,n,r){let i,o=n.getMeta(Pb);if(o)return o.historyState;n.getMeta(jb)&&(e=new _b(e.done,e.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(s&&s.getMeta(Pb))return s.getMeta(Pb).redo?new _b(e.done.addTransform(n,void 0,r,zb(t)),e.undone,Db(n.mapping.maps),e.prevTime,e.prevComposition):new _b(e.done,e.undone.addTransform(n,void 0,r,zb(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return(i=n.getMeta("rebased"))?new _b(e.done.rebased(n,i),e.undone.rebased(n,i),Ib(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new _b(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),Ib(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);{let i=n.getMeta("composition"),o=0==e.prevTime||!s&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}(n,e.prevRanges)),a=s?Ib(e.prevRanges,n.mapping):Db(n.mapping.maps);return new _b(e.done.addTransform(n,o?t.selection.getBookmark():void 0,r,zb(t)),Tb.empty,a,n.time,null==i?e.prevComposition:i)}}(n,r,t,e)},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r="historyUndo"==n?Hb:"historyRedo"==n?Ub:null;return!(!r||!e.editable)&&(t.preventDefault(),r(e.state,e.dispatch))}}}})}function $b(e,t){return(n,r)=>{let i=Pb.getState(n);if(!i||0==(e?i.undone:i.done).eventCount)return!1;if(r){let o=function(e,t,n){let r=zb(t),i=Pb.get(t).spec.config,o=(n?e.undone:e.done).popEvent(t,r);if(!o)return null;let s=o.selection.resolve(o.transform.doc),a=(n?e.done:e.undone).addTransform(o.transform,t.selection.getBookmark(),i,r),l=new _b(n?a:o.remaining,n?o.remaining:a,null,0,-1);return o.transform.setSelection(s).setMeta(Pb,{redo:n,historyState:l})}(i,n,e);o&&r(t?o.scrollIntoView():o)}return!0}}const Hb=$b(!1,!0),Ub=$b(!0,!0);var qb=qm.create({name:"characterCount",addOptions:()=>({limit:null,mode:"textSize",textCounter:e=>e.length,wordCounter:e=>e.split(" ").filter(e=>""!==e).length}),addStorage:()=>({characters:()=>0,words:()=>0}),onBeforeCreate(){this.storage.characters=e=>{const t=(null==e?void 0:e.node)||this.editor.state.doc;if("textSize"===((null==e?void 0:e.mode)||this.options.mode)){const e=t.textBetween(0,t.content.size,void 0," ");return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{const t=(null==e?void 0:e.node)||this.editor.state.doc,n=t.textBetween(0,t.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new cs({key:new ps("characterCount"),appendTransaction:(t,n,r)=>{if(e)return;const i=this.options.limit;if(null==i||0===i)return void(e=!0);const o=this.storage.characters({node:r.doc});if(o>i){const t=0,n=o-i;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const s=r.tr.deleteRange(t,n);return e=!0,s}e=!0},filterTransaction:(e,t)=>{const n=this.options.limit;if(!e.docChanged||0===n||null==n)return!0;const r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n)return!0;if(r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r)return!1;if(!e.getMeta("paste"))return!1;const o=e.selection.$head.pos,s=o-(i-n),a=o;e.deleteRange(s,a);return!(this.storage.characters({node:e.doc})>n)}})]}}),Vb=qm.create({name:"dropCursor",addOptions:()=>({color:"currentColor",width:1,class:void 0}),addProseMirrorPlugins(){return[mb(this.options)]}});qm.create({name:"focus",addOptions:()=>({className:"has-focus",mode:"all"}),addProseMirrorPlugins(){return[new cs({key:new ps("focus"),props:{decorations:({doc:e,selection:t})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,o=[];if(!n||!r)return Xl.create(e,[]);let s=0;"deepest"===this.options.mode&&e.descendants((e,t)=>{if(e.isText)return;if(!(i>=t&&i<=t+e.nodeSize-1))return!1;s+=1});let a=0;return e.descendants((e,t)=>{if(e.isText)return!1;if(!(i>=t&&i<=t+e.nodeSize-1))return!1;a+=1;if("deepest"===this.options.mode&&s-a>0||"shallowest"===this.options.mode&&a>1)return"deepest"===this.options.mode;o.push(Jl.node(t,t+e.nodeSize,{class:this.options.className}))}),Xl.create(e,o)}}})]}});var Wb=qm.create({name:"gapCursor",addProseMirrorPlugins:()=>[new cs({props:{decorations:Eb,createSelectionBetween:(e,t,n)=>t.pos==n.pos&&yb.valid(n)?new yb(n):null,handleClick:Mb,handleKeyDown:wb,handleDOMEvents:{beforeinput:Sb}}})],extendNodeSchema(e){var t;return{allowGapCursor:null!=(t=im(rm(e,"allowGapCursor",{name:e.name,options:e.options,storage:e.storage})))?t:null}}}),Kb=qm.create({name:"placeholder",addOptions:()=>({emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}),addProseMirrorPlugins(){return[new cs({key:new ps("placeholder"),props:{decorations:({doc:e,selection:t})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=t,i=[];if(!n)return null;const o=this.editor.isEmpty;return e.descendants((e,t)=>{const n=r>=t&&r<=t+e.nodeSize,s=!e.isLeaf&&hm(e);if((n||!this.options.showOnlyCurrent)&&s){const r=[this.options.emptyNodeClass];o&&r.push(this.options.emptyEditorClass);const s=Jl.node(t,t+e.nodeSize,{class:r.join(" "),"data-placeholder":"function"==typeof this.options.placeholder?this.options.placeholder({editor:this.editor,node:e,pos:t,hasAnchor:n}):this.options.placeholder});i.push(s)}return this.options.includeChildren}),Xl.create(e,i)}}})]}});function Gb({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||(null==t?void 0:t.type)===e}qm.create({name:"selection",addOptions:()=>({className:"selection"}),addProseMirrorPlugins(){const{editor:e,options:t}=this;return[new cs({key:new ps("selection"),props:{decorations:n=>n.selection.empty||e.isFocused||!e.isEditable||fm(n.selection)||e.view.dragging?null:Xl.create(n.doc,[Jl.inline(n.selection.from,n.selection.to,{class:t.className})])}})]}});var Jb=qm.create({name:"trailingNode",addOptions:()=>({node:void 0,notAfter:[]}),addProseMirrorPlugins(){var e;const t=new ps(this.name),n=this.options.node||(null==(e=this.editor.schema.topNodeType.contentMatch.defaultType)?void 0:e.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(n).includes(e.name));return[new cs({key:t,appendTransaction:(e,r,i)=>{const{doc:o,tr:s,schema:a}=i,l=t.getState(i),c=o.content.size,u=a.nodes[n];if(l)return s.insert(c,u.create())},state:{init:(e,t)=>!Gb({node:t.tr.doc.lastChild,types:r}),apply:(e,t)=>{if(!e.docChanged)return t;if(e.getMeta("__uniqueIDTransaction"))return t;return!Gb({node:e.doc.lastChild,types:r})}}})]}}),Yb=qm.create({name:"undoRedo",addOptions:()=>({depth:100,newGroupDelay:500}),addCommands:()=>({undo:()=>({state:e,dispatch:t})=>Hb(e,t),redo:()=>({state:e,dispatch:t})=>Ub(e,t)}),addProseMirrorPlugins(){return[Fb(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),Zb=qm.create({name:"starterKit",addExtensions(){var e,t,n,r;const i=[];return!1!==this.options.bold&&i.push(Eg.configure(this.options.bold)),!1!==this.options.blockquote&&i.push(bg.configure(this.options.blockquote)),!1!==this.options.bulletList&&i.push($v.configure(this.options.bulletList)),!1!==this.options.code&&i.push(Ag.configure(this.options.code)),!1!==this.options.codeBlock&&i.push(Og.configure(this.options.codeBlock)),!1!==this.options.document&&i.push(_g.configure(this.options.document)),!1!==this.options.dropcursor&&i.push(Vb.configure(this.options.dropcursor)),!1!==this.options.gapcursor&&i.push(Wb.configure(this.options.gapcursor)),!1!==this.options.hardBreak&&i.push(Rg.configure(this.options.hardBreak)),!1!==this.options.heading&&i.push(Dg.configure(this.options.heading)),!1!==this.options.undoRedo&&i.push(Yb.configure(this.options.undoRedo)),!1!==this.options.horizontalRule&&i.push(Ig.configure(this.options.horizontalRule)),!1!==this.options.italic&&i.push(jg.configure(this.options.italic)),!1!==this.options.listItem&&i.push(Hv.configure(this.options.listItem)),!1!==this.options.listKeymap&&i.push(Qv.configure(null==(e=this.options)?void 0:e.listKeymap)),!1!==this.options.link&&i.push(zv.configure(null==(t=this.options)?void 0:t.link)),!1!==this.options.orderedList&&i.push(ob.configure(this.options.orderedList)),!1!==this.options.paragraph&&i.push(cb.configure(this.options.paragraph)),!1!==this.options.strike&&i.push(pb.configure(this.options.strike)),!1!==this.options.text&&i.push(hb.configure(this.options.text)),!1!==this.options.underline&&i.push(fb.configure(null==(n=this.options)?void 0:n.underline)),!1!==this.options.trailingNode&&i.push(Jb.configure(null==(r=this.options)?void 0:r.trailingNode)),i}}),Xb=gd.create({name:"textStyle",priority:101,addOptions:()=>({HTMLAttributes:{},mergeNestedSpanStyles:!0}),parseHTML(){return[{tag:"span",consuming:!1,getAttrs:e=>!!e.hasAttribute("style")&&(this.options.mergeNestedSpanStyles&&(e=>{if(!e.children.length)return;const t=e.querySelectorAll("span");t&&t.forEach(e=>{var t,n;const r=e.getAttribute("style"),i=null==(n=null==(t=e.parentElement)?void 0:t.closest("span"))?void 0:n.getAttribute("style");e.setAttribute("style",`${i};${r}`)})})(e),{})}]},renderHTML({HTMLAttributes:e}){return["span",Lu(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleTextStyle:e=>({commands:t})=>t.toggleMark(this.name,e),removeEmptyTextStyle:()=>({tr:e})=>{const{selection:t}=e;return e.doc.nodesBetween(t.from,t.to,(t,n)=>{if(t.isTextblock)return!0;t.marks.filter(e=>e.type===this.type).some(e=>Object.values(e.attrs).some(e=>!!e))||e.removeMark(n,n+t.nodeSize,this.type)}),!0}}}}),Qb=xd.create({name:"backgroundColor",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:e=>{var t;return null==(t=e.style.backgroundColor)?void 0:t.replace(/['"]+/g,"")},renderHTML:e=>e.backgroundColor?{style:`background-color: ${e.backgroundColor}`}:{}}}}]},addCommands:()=>({setBackgroundColor:e=>({chain:t})=>t().setMark("textStyle",{backgroundColor:e}).run(),unsetBackgroundColor:()=>({chain:e})=>e().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()})}),ew=xd.create({name:"color",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:e=>{var t;return null==(t=e.style.color)?void 0:t.replace(/['"]+/g,"")},renderHTML:e=>e.color?{style:`color: ${e.color}`}:{}}}}]},addCommands:()=>({setColor:e=>({chain:t})=>t().setMark("textStyle",{color:e}).run(),unsetColor:()=>({chain:e})=>e().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()})}),tw=xd.create({name:"fontFamily",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:e=>e.style.fontFamily,renderHTML:e=>e.fontFamily?{style:`font-family: ${e.fontFamily}`}:{}}}}]},addCommands:()=>({setFontFamily:e=>({chain:t})=>t().setMark("textStyle",{fontFamily:e}).run(),unsetFontFamily:()=>({chain:e})=>e().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()})}),nw=xd.create({name:"fontSize",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:e=>e.style.fontSize,renderHTML:e=>e.fontSize?{style:`font-size: ${e.fontSize}`}:{}}}}]},addCommands:()=>({setFontSize:e=>({chain:t})=>t().setMark("textStyle",{fontSize:e}).run(),unsetFontSize:()=>({chain:e})=>e().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()})}),rw=xd.create({name:"lineHeight",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:e=>e.style.lineHeight,renderHTML:e=>e.lineHeight?{style:`line-height: ${e.lineHeight}`}:{}}}}]},addCommands:()=>({setLineHeight:e=>({chain:t})=>t().setMark("textStyle",{lineHeight:e}).run(),unsetLineHeight:()=>({chain:e})=>e().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()})}),iw=xd.create({name:"textStyleKit",addExtensions(){const e=[];return!1!==this.options.backgroundColor&&e.push(Qb.configure(this.options.backgroundColor)),!1!==this.options.color&&e.push(ew.configure(this.options.color)),!1!==this.options.fontFamily&&e.push(tw.configure(this.options.fontFamily)),!1!==this.options.fontSize&&e.push(nw.configure(this.options.fontSize)),!1!==this.options.lineHeight&&e.push(rw.configure(this.options.lineHeight)),!1!==this.options.textStyle&&e.push(Xb.configure(this.options.textStyle)),e}}),ow=gd.create({name:"superscript",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"sup"},{style:"vertical-align",getAttrs:e=>"super"===e&&null}],renderHTML({HTMLAttributes:e}){return["sup",Lu(this.options.HTMLAttributes,e),0]},addCommands(){return{setSuperscript:()=>({commands:e})=>e.setMark(this.name),toggleSuperscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSuperscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),sw=gd.create({name:"subscript",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"sub"},{style:"vertical-align",getAttrs:e=>"sub"===e&&null}],renderHTML({HTMLAttributes:e}){return["sub",Lu(this.options.HTMLAttributes,e),0]},addCommands(){return{setSubscript:()=>({commands:e})=>e.setMark(this.name),toggleSubscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSubscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),aw=xd.create({name:"textAlign",addOptions:()=>({types:[],alignments:["left","center","right","justify"],defaultAlignment:null}),addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>{const t=e.style.textAlign;return this.options.alignments.includes(t)?t:this.options.defaultAlignment},renderHTML:e=>e.textAlign?{style:`text-align: ${e.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>!!this.options.alignments.includes(e)&&this.options.types.map(n=>t.updateAttributes(n,{textAlign:e})).every(e=>e),unsetTextAlign:()=>({commands:e})=>this.options.types.map(t=>e.resetAttributes(t,"textAlign")).every(e=>e),toggleTextAlign:e=>({editor:t,commands:n})=>!!this.options.alignments.includes(e)&&(t.isActive({textAlign:e})?n.unsetTextAlign():n.setTextAlign(e))}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),lw=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,cw=Kp.create({name:"image",addOptions:()=>({inline:!1,allowBase64:!1,HTMLAttributes:{}}),inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes:()=>({src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}),parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:e}){return["img",Lu(this.options.HTMLAttributes,e)]},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[Wp({find:lw,type:this.type,getAttributes:e=>{const[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}}),uw=cw,dw=Kb;const pw=e=>{const t=String((n=e,r=()=>"",null!=n?n:r())).trim();var n,r;if(!t)return"<div></div>";return/<[^>]+>/.test(t)?t:`<div>${i=t,String(i).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}</div>`;var i};let hw,fw;if("undefined"!=typeof WeakMap){let e=new WeakMap;hw=t=>e.get(t),fw=(t,n)=>(e.set(t,n),n)}else{const e=[],t=10;let n=0;hw=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},fw=(r,i)=>(n==t&&(n=0),e[n++]=r,e[n++]=i)}var mw=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){const n=this.map[t];if(n!=e)continue;const r=t%this.width,i=t/this.width|0;let o=r+1,s=i+1;for(let e=1;o<this.width&&this.map[t+e]==n;e++)o++;for(let e=1;s<this.height&&this.map[t+this.width*e]==n;e++)s++;return{left:r,top:i,right:o,bottom:s}}throw new RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){const{left:r,right:i,top:o,bottom:s}=this.findCell(e);return"horiz"==t?(n<0?0==r:i==this.width)?null:this.map[o*this.width+(n<0?r-1:i)]:(n<0?0==o:s==this.height)?null:this.map[r+this.width*(n<0?o-1:s)]}rectBetween(e,t){const{left:n,right:r,top:i,bottom:o}=this.findCell(e),{left:s,right:a,top:l,bottom:c}=this.findCell(t);return{left:Math.min(n,s),top:Math.min(i,l),right:Math.max(r,a),bottom:Math.max(o,c)}}cellsInRect(e){const t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let i=e.left;i<e.right;i++){const o=r*this.width+i,s=this.map[o];n[s]||(n[s]=!0,i==e.left&&i&&this.map[o-1]==s||r==e.top&&r&&this.map[o-this.width]==s||t.push(s))}return t}positionAt(e,t,n){for(let r=0,i=0;;r++){const o=i+n.child(r).nodeSize;if(r==e){let n=t+e*this.width;const r=(e+1)*this.width;for(;n<r&&this.map[n]<i;)n++;return n==r?o-1:this.map[n]}i=o}}static get(e){return hw(e)||fw(e,function(e){if("table"!=e.type.spec.tableRole)throw new RangeError("Not a table node: "+e.type.name);const t=function(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){const i=e.child(r);let o=0;if(n)for(let t=0;t<r;t++){const n=e.child(t);for(let e=0;e<n.childCount;e++){const i=n.child(e);t+i.attrs.rowspan>r&&(o+=i.attrs.colspan)}}for(let e=0;e<i.childCount;e++){const t=i.child(e);o+=t.attrs.colspan,t.attrs.rowspan>1&&(n=!0)}-1==t?t=o:t!=o&&(t=Math.max(t,o))}return t}(e),n=e.childCount,r=[];let i=0,o=null;const s=[];for(let e=0,i=t*n;e<i;e++)r[e]=0;for(let a=0,l=0;a<n;a++){const c=e.child(a);l++;for(let e=0;;e++){for(;i<r.length&&0!=r[i];)i++;if(e==c.childCount)break;const u=c.child(e),{colspan:d,rowspan:p,colwidth:h}=u.attrs;for(let e=0;e<p;e++){if(e+a>=n){(o||(o=[])).push({type:"overlong_rowspan",pos:l,n:p-e});break}const c=i+e*t;for(let e=0;e<d;e++){0==r[c+e]?r[c+e]=l:(o||(o=[])).push({type:"collision",row:a,pos:l,n:d-e});const n=h&&h[e];if(n){const r=(c+e)%t*2,i=s[r];null==i||i!=n&&1==s[r+1]?(s[r]=n,s[r+1]=1):i==n&&s[r+1]++}}}i+=d,l+=u.nodeSize}const u=(a+1)*t;let d=0;for(;i<u;)0==r[i++]&&d++;d&&(o||(o=[])).push({type:"missing",row:a,n:d}),l++}0!==t&&0!==n||(o||(o=[])).push({type:"zero_sized"});const a=new mw(t,n,r,o);let l=!1;for(let e=0;!l&&e<s.length;e+=2)null!=s[e]&&s[e+1]<n&&(l=!0);l&&function(e,t,n){e.problems||(e.problems=[]);const r={};for(let i=0;i<e.map.length;i++){const o=e.map[i];if(r[o])continue;r[o]=!0;const s=n.nodeAt(o);if(!s)throw new RangeError(`No cell with offset ${o} found`);let a=null;const l=s.attrs;for(let n=0;n<l.colspan;n++){const r=t[(i+n)%e.width*2];null==r||l.colwidth&&l.colwidth[n]==r||((a||(a=gw(l)))[n]=r)}a&&e.problems.unshift({type:"colwidth mismatch",pos:o,colwidth:a})}}(a,s,e);return a}(e))}};function gw(e){if(e.colwidth)return e.colwidth.slice();const t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function yw(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(const n in e.nodes){const r=e.nodes[n],i=r.spec.tableRole;i&&(t[i]=r)}}return t}const vw=new ps("selectingCells");function bw(e){for(let t=e.depth-1;t>0;t--)if("row"==e.node(t).type.spec.tableRole)return e.node(0).resolve(e.before(t+1));return null}function ww(e){const t=e.selection.$head;for(let e=t.depth;e>0;e--)if("row"==t.node(e).type.spec.tableRole)return!0;return!1}function xw(e){const t=e.selection;if("$anchorCell"in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if("node"in t&&t.node&&"cell"==t.node.type.spec.tableRole)return t.$anchor;const n=bw(t.$head)||function(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){const r=t.type.spec.tableRole;if("cell"==r||"header_cell"==r)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){const r=t.type.spec.tableRole;if("cell"==r||"header_cell"==r)return e.doc.resolve(n-t.nodeSize)}}(t.$head);if(n)return n;throw new RangeError(`No cell found around position ${t.head}`)}function Mw(e){return"row"==e.parent.type.spec.tableRole&&!!e.nodeAfter}function Sw(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function Ew(e,t,n){const r=e.node(-1),i=mw.get(r),o=e.start(-1),s=i.nextCell(e.pos-o,t,n);return null==s?null:e.node(0).resolve(o+s)}function Cw(e,t,n=1){const r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}function Nw(e,t,n=1){const r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;e<n;e++)r.colwidth.splice(t,0,0)}return r}var Aw=class e extends Uo{constructor(e,t=e){const n=e.node(-1),r=mw.get(n),i=e.start(-1),o=r.rectBetween(e.pos-i,t.pos-i),s=e.node(0),a=r.cellsInRect(o).filter(e=>e!=t.pos-i);a.unshift(t.pos-i);const l=a.map(e=>{const t=n.nodeAt(e);if(!t)throw new RangeError(`No cell with offset ${e} found`);const r=i+e+1;return new qo(s.resolve(r),s.resolve(r+t.content.size))});super(l[0].$from,l[0].$to,l),this.$anchorCell=e,this.$headCell=t}map(t,n){const r=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(Mw(r)&&Mw(i)&&Sw(r,i)){const t=this.$anchorCell.node(-1)!=r.node(-1);return t&&this.isRowSelection()?e.rowSelection(r,i):t&&this.isColSelection()?e.colSelection(r,i):new e(r,i)}return Ko.between(r,i)}content(){const e=this.$anchorCell.node(-1),t=mw.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},o=[];for(let n=r.top;n<r.bottom;n++){const s=[];for(let o=n*t.width+r.left,a=r.left;a<r.right;a++,o++){const n=t.map[o];if(i[n])continue;i[n]=!0;const a=t.findCell(n);let l=e.nodeAt(n);if(!l)throw new RangeError(`No cell with offset ${n} found`);const c=r.left-a.left,u=a.right-r.right;if(c>0||u>0){let e=l.attrs;if(c>0&&(e=Cw(e,0,c)),u>0&&(e=Cw(e,e.colspan-u,u)),a.left<r.left){if(l=l.type.createAndFill(e),!l)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(e)}`)}else l=l.type.create(e,l.content)}if(a.top<r.top||a.bottom>r.bottom){const e={...l.attrs,rowspan:Math.min(a.bottom,r.bottom)-Math.max(a.top,r.top)};l=a.top<r.top?l.type.createAndFill(e):l.type.create(e,l.content)}s.push(l)}o.push(e.child(n).copy(qr.from(s)))}const s=this.isColSelection()&&this.isRowSelection()?e:o;return new Yr(qr.from(s),1,1)}replace(e,t=Yr.empty){const n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){const{$from:o,$to:s}=r[i],a=e.mapping.slice(n);e.replace(a.map(o.pos),a.map(s.pos),i?Yr.empty:t)}const i=Uo.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new Yr(qr.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),n=mw.get(t),r=this.$anchorCell.start(-1),i=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let n=0;n<i.length;n++)e(t.nodeAt(i[n]),r+i[n])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){const r=t.node(-1),i=mw.get(r),o=t.start(-1),s=i.findCell(t.pos-o),a=i.findCell(n.pos-o),l=t.node(0);return s.top<=a.top?(s.top>0&&(t=l.resolve(o+i.map[s.left])),a.bottom<i.height&&(n=l.resolve(o+i.map[i.width*(i.height-1)+a.right-1]))):(a.top>0&&(n=l.resolve(o+i.map[a.left])),s.bottom<i.height&&(t=l.resolve(o+i.map[i.width*(i.height-1)+s.right-1]))),new e(t,n)}isRowSelection(){const e=this.$anchorCell.node(-1),t=mw.get(e),n=this.$anchorCell.start(-1),r=t.colCount(this.$anchorCell.pos-n),i=t.colCount(this.$headCell.pos-n);if(Math.min(r,i)>0)return!1;const o=r+this.$anchorCell.nodeAfter.attrs.colspan,s=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,s)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){const r=t.node(-1),i=mw.get(r),o=t.start(-1),s=i.findCell(t.pos-o),a=i.findCell(n.pos-o),l=t.node(0);return s.left<=a.left?(s.left>0&&(t=l.resolve(o+i.map[s.top*i.width])),a.right<i.width&&(n=l.resolve(o+i.map[i.width*(a.top+1)-1]))):(a.left>0&&(n=l.resolve(o+i.map[a.top*i.width])),s.right<i.width&&(t=l.resolve(o+i.map[i.width*(s.top+1)-1]))),new e(t,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new e(t.resolve(n),t.resolve(r))}getBookmark(){return new kw(this.$anchorCell.pos,this.$headCell.pos)}};Aw.prototype.visible=!1,Uo.jsonID("cell",Aw);var kw=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){const t=e.resolve(this.anchor),n=e.resolve(this.head);return"row"==t.parent.type.spec.tableRole&&"row"==n.parent.type.spec.tableRole&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&Sw(t,n)?new Aw(t,n):Uo.near(n,1)}};function Tw(e){if(!(e.selection instanceof Aw))return null;const t=[];return e.selection.forEachCell((e,n)=>{t.push(Jl.node(n,n+e.nodeSize,{class:"selectedCell"}))}),Xl.create(e.doc,t)}const Ow=new ps("fix-tables");function _w(e,t,n,r){const i=e.childCount,o=t.childCount;e:for(let s=0,a=0;s<o;s++){const o=t.child(s);for(let t=a,r=Math.min(i,s+3);t<r;t++)if(e.child(t)==o){a=t+1,n+=o.nodeSize;continue e}r(o,n),a<i&&e.child(a).sameMarkup(o)?_w(e.child(a),o,n+1,r):o.nodesBetween(0,o.content.size,r,n+1),n+=o.nodeSize}}function Rw(e,t){let n;const r=(t,r)=>{"table"==t.type.spec.tableRole&&(n=function(e,t,n,r){const i=mw.get(t);if(!i.problems)return r;r||(r=e.tr);const o=[];for(let e=0;e<i.height;e++)o.push(0);for(let e=0;e<i.problems.length;e++){const s=i.problems[e];if("collision"==s.type){const e=t.nodeAt(s.pos);if(!e)continue;const i=e.attrs;for(let e=0;e<i.rowspan;e++)o[s.row+e]+=s.n;r.setNodeMarkup(r.mapping.map(n+1+s.pos),null,Cw(i,i.colspan-s.n,s.n))}else if("missing"==s.type)o[s.row]+=s.n;else if("overlong_rowspan"==s.type){const e=t.nodeAt(s.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+s.pos),null,{...e.attrs,rowspan:e.attrs.rowspan-s.n})}else if("colwidth mismatch"==s.type){const e=t.nodeAt(s.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+s.pos),null,{...e.attrs,colwidth:s.colwidth})}else if("zero_sized"==s.type){const e=r.mapping.map(n);r.delete(e,e+t.nodeSize)}}let s,a;for(let e=0;e<o.length;e++)o[e]&&(null==s&&(s=e),a=e);for(let l=0,c=n+1;l<i.height;l++){const n=t.child(l),i=c+n.nodeSize,u=o[l];if(u>0){let t="cell";n.firstChild&&(t=n.firstChild.type.spec.tableRole);const o=[];for(let n=0;n<u;n++){const n=yw(e.schema)[t].createAndFill();n&&o.push(n)}const d=0!=l&&s!=l-1||a!=l?i-1:c+1;r.insert(r.mapping.map(d),o)}c=i}return r.setMeta(Ow,{fixTables:!0})}(e,t,r,n))};return t?t.doc!=e.doc&&_w(t.doc,e.doc,0,r):e.doc.descendants(r),n}function Dw(e){const t=e.selection,n=xw(e),r=n.node(-1),i=n.start(-1),o=mw.get(r);return{...t instanceof Aw?o.rectBetween(t.$anchorCell.pos-i,t.$headCell.pos-i):o.findCell(n.pos-i),tableStart:i,map:o,table:r}}function Iw(e,{map:t,tableStart:n,table:r},i){let o=i>0?-1:0;(function(e,t,n){const r=yw(t.type.schema).header_cell;for(let i=0;i<e.height;i++)if(t.nodeAt(e.map[n+i*e.width]).type!=r)return!1;return!0})(t,r,i+o)&&(o=0==i||i==t.width?null:0);for(let s=0;s<t.height;s++){const a=s*t.width+i;if(i>0&&i<t.width&&t.map[a-1]==t.map[a]){const o=t.map[a],l=r.nodeAt(o);e.setNodeMarkup(e.mapping.map(n+o),null,Nw(l.attrs,i-t.colCount(o))),s+=l.attrs.rowspan-1}else{const l=null==o?yw(r.type.schema).cell:r.nodeAt(t.map[a+o]).type,c=t.positionAt(s,i,r);e.insert(e.mapping.map(n+c),l.createAndFill())}}return e}function Lw(e,t){if(!ww(e))return!1;if(t){const n=Dw(e);t(Iw(e.tr,n,n.left))}return!0}function Bw(e,t){if(!ww(e))return!1;if(t){const n=Dw(e);t(Iw(e.tr,n,n.right))}return!0}function zw(e,{map:t,table:n,tableStart:r},i){const o=e.mapping.maps.length;for(let s=0;s<t.height;){const a=s*t.width+i,l=t.map[a],c=n.nodeAt(l),u=c.attrs;if(i>0&&t.map[a-1]==l||i<t.width-1&&t.map[a+1]==l)e.setNodeMarkup(e.mapping.slice(o).map(r+l),null,Cw(u,i-t.colCount(l)));else{const t=e.mapping.slice(o).map(r+l);e.delete(t,t+c.nodeSize)}s+=u.rowspan}}function Pw(e,t){if(!ww(e))return!1;if(t){const n=Dw(e),r=e.tr;if(0==n.left&&n.right==n.map.width)return!1;for(let e=n.right-1;zw(r,n,e),e!=n.left;e--){const e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw new RangeError("No table found");n.table=e,n.map=mw.get(e)}t(r)}return!0}function jw(e,{map:t,tableStart:n,table:r},i){let o=n;for(let e=0;e<i;e++)o+=r.child(e).nodeSize;const s=[];let a=i>0?-1:0;(function(e,t,n){var r;const i=yw(t.type.schema).header_cell;for(let o=0;o<e.width;o++)if((null===(r=t.nodeAt(e.map[o+n*e.width]))||void 0===r?void 0:r.type)!=i)return!1;return!0})(t,r,i+a)&&(a=0==i||i==t.height?null:0);for(let o=0,c=t.width*i;o<t.width;o++,c++)if(i>0&&i<t.height&&t.map[c]==t.map[c-t.width]){const i=t.map[c],s=r.nodeAt(i).attrs;e.setNodeMarkup(n+i,null,{...s,rowspan:s.rowspan+1}),o+=s.colspan-1}else{var l;const e=null==a?yw(r.type.schema).cell:null===(l=r.nodeAt(t.map[c+a*t.width]))||void 0===l?void 0:l.type,n=null==e?void 0:e.createAndFill();n&&s.push(n)}return e.insert(o,yw(r.type.schema).row.create(null,s)),e}function Fw(e,t){if(!ww(e))return!1;if(t){const n=Dw(e);t(jw(e.tr,n,n.top))}return!0}function $w(e,t){if(!ww(e))return!1;if(t){const n=Dw(e);t(jw(e.tr,n,n.bottom))}return!0}function Hw(e,{map:t,table:n,tableStart:r},i){let o=0;for(let e=0;e<i;e++)o+=n.child(e).nodeSize;const s=o+n.child(i).nodeSize,a=e.mapping.maps.length;e.delete(o+r,s+r);const l=new Set;for(let o=0,s=i*t.width;o<t.width;o++,s++){const c=t.map[s];if(!l.has(c))if(l.add(c),i>0&&c==t.map[s-t.width]){const t=n.nodeAt(c).attrs;e.setNodeMarkup(e.mapping.slice(a).map(c+r),null,{...t,rowspan:t.rowspan-1}),o+=t.colspan-1}else if(i<t.height&&c==t.map[s+t.width]){const s=n.nodeAt(c),l=s.attrs,u=s.type.create({...l,rowspan:s.attrs.rowspan-1},s.content),d=t.positionAt(i+1,o,n);e.insert(e.mapping.slice(a).map(r+d),u),o+=l.colspan-1}}}function Uw(e,t){if(!ww(e))return!1;if(t){const n=Dw(e),r=e.tr;if(0==n.top&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;Hw(r,n,e),e!=n.top;e--){const e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw new RangeError("No table found");n.table=e,n.map=mw.get(n.table)}t(r)}return!0}function qw(e){const t=e.content;return 1==t.childCount&&t.child(0).isTextblock&&0==t.child(0).childCount}function Vw(e,t){const n=e.selection;if(!(n instanceof Aw)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=Dw(e),{map:i}=r;if(function({width:e,height:t,map:n},r){let i=r.top*e+r.left,o=i,s=(r.bottom-1)*e+r.left,a=i+(r.right-r.left-1);for(let t=r.top;t<r.bottom;t++){if(r.left>0&&n[o]==n[o-1]||r.right<e&&n[a]==n[a+1])return!0;o+=e,a+=e}for(let o=r.left;o<r.right;o++){if(r.top>0&&n[i]==n[i-e]||r.bottom<t&&n[s]==n[s+e])return!0;i++,s++}return!1}(i,r))return!1;if(t){const n=e.tr,o={};let s,a,l=qr.empty;for(let e=r.top;e<r.bottom;e++)for(let t=r.left;t<r.right;t++){const c=i.map[e*i.width+t],u=r.table.nodeAt(c);if(!o[c]&&u)if(o[c]=!0,null==s)s=c,a=u;else{qw(u)||(l=l.append(u.content));const e=n.mapping.map(c+r.tableStart);n.delete(e,e+u.nodeSize)}}if(null==s||null==a)return!0;if(n.setNodeMarkup(s+r.tableStart,null,{...Nw(a.attrs,a.attrs.colspan,r.right-r.left-a.attrs.colspan),rowspan:r.bottom-r.top}),l.size>0){const e=s+1+a.content.size,t=qw(a)?s+1:e;n.replaceWith(t+r.tableStart,e+r.tableStart,l)}n.setSelection(new Aw(n.doc.resolve(s+r.tableStart))),t(n)}return!0}function Ww(e,t){const n=yw(e.schema);return(r=({node:e})=>n[e.type.spec.tableRole],(e,t)=>{const n=e.selection;let i,o;if(n instanceof Aw){if(n.$anchorCell.pos!=n.$headCell.pos)return!1;i=n.$anchorCell.nodeAfter,o=n.$anchorCell.pos}else{var s;if(i=function(e){for(let t=e.depth;t>0;t--){const n=e.node(t).type.spec.tableRole;if("cell"===n||"header_cell"===n)return e.node(t)}return null}(n.$from),!i)return!1;o=null===(s=bw(n.$from))||void 0===s?void 0:s.pos}if(null==i||null==o)return!1;if(1==i.attrs.colspan&&1==i.attrs.rowspan)return!1;if(t){let s=i.attrs;const a=[],l=s.colwidth;s.rowspan>1&&(s={...s,rowspan:1}),s.colspan>1&&(s={...s,colspan:1});const c=Dw(e),u=e.tr;for(let e=0;e<c.right-c.left;e++)a.push(l?{...s,colwidth:l&&l[e]?[l[e]]:null}:s);let d;for(let e=c.top;e<c.bottom;e++){let t=c.map.positionAt(e,c.left,c.table);e==c.top&&(t+=i.nodeSize);for(let n=c.left,o=0;n<c.right;n++,o++)n==c.left&&e==c.top||u.insert(d=u.mapping.map(t+c.tableStart,1),r({node:i,row:e,col:n}).createAndFill(a[o]))}u.setNodeMarkup(o,r({node:i,row:c.top,col:c.left}),a[0]),n instanceof Aw&&u.setSelection(new Aw(u.doc.resolve(n.$anchorCell.pos),d?u.doc.resolve(d):void 0)),t(u)}return!0})(e,t);var r}function Kw(e,t){return function(n,r){if(!ww(n))return!1;const i=xw(n);if(i.nodeAfter.attrs[e]===t)return!1;if(r){const o=n.tr;n.selection instanceof Aw?n.selection.forEachCell((n,r)=>{n.attrs[e]!==t&&o.setNodeMarkup(r,null,{...n.attrs,[e]:t})}):o.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),r(o)}return!0}}function Gw(e,t,n){const r=t.map.cellsInRect({left:0,top:0,right:"row"==e?t.map.width:1,bottom:"column"==e?t.map.height:1});for(let e=0;e<r.length;e++){const i=t.table.nodeAt(r[e]);if(i&&i.type!==n.header_cell)return!1}return!0}function Jw(e,t){return(t=t||{useDeprecatedLogic:!1}).useDeprecatedLogic?function(e){return function(t,n){if(!ww(t))return!1;if(n){const r=yw(t.schema),i=Dw(t),o=t.tr,s=i.map.cellsInRect("column"==e?{left:i.left,top:0,right:i.right,bottom:i.map.height}:"row"==e?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),a=s.map(e=>i.table.nodeAt(e));for(let e=0;e<s.length;e++)a[e].type==r.header_cell&&o.setNodeMarkup(i.tableStart+s[e],r.cell,a[e].attrs);if(0===o.steps.length)for(let e=0;e<s.length;e++)o.setNodeMarkup(i.tableStart+s[e],r.header_cell,a[e].attrs);n(o)}return!0}}(e):function(t,n){if(!ww(t))return!1;if(n){const r=yw(t.schema),i=Dw(t),o=t.tr,s=Gw("row",i,r),a=Gw("column",i,r),l=("column"===e?s:"row"===e&&a)?1:0,c="column"==e?{left:0,top:l,right:1,bottom:i.map.height}:"row"==e?{left:l,top:0,right:i.map.width,bottom:1}:i,u="column"==e?a?r.cell:r.header_cell:"row"==e?s?r.cell:r.header_cell:r.cell;i.map.cellsInRect(c).forEach(e=>{const t=e+i.tableStart,n=o.doc.nodeAt(t);n&&o.setNodeMarkup(t,u,n.attrs)}),n(o)}return!0}}Jw("row",{useDeprecatedLogic:!0}),Jw("column",{useDeprecatedLogic:!0});const Yw=Jw("cell",{useDeprecatedLogic:!0});function Zw(e){return function(t,n){if(!ww(t))return!1;const r=function(e,t){if(t<0){const t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){const r=e.node(-1).child(t),i=r.lastChild;if(i)return n-1-i.nodeSize;n-=r.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;const t=e.node(-1);for(let n=e.indexAfter(-1),r=e.after();n<t.childCount;n++){const e=t.child(n);if(e.childCount)return r+1;r+=e.nodeSize}}return null}(xw(t),e);if(null==r)return!1;if(n){const e=t.doc.resolve(r);n(t.tr.setSelection(Ko.between(e,(i=e,i.node(0).resolve(i.pos+i.nodeAfter.nodeSize)))).scrollIntoView())}var i;return!0}}function Xw(e,t){const n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if("table"==n.node(r).type.spec.tableRole)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Qw(e,t){const n=e.selection;if(!(n instanceof Aw))return!1;if(t){const r=e.tr,i=yw(e.schema).cell.createAndFill().content;n.forEachCell((e,t)=>{e.content.eq(i)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new Yr(i,0,0))}),r.docChanged&&t(r)}return!0}function ex(e){if(0===e.size)return null;let{content:t,openStart:n,openEnd:r}=e;for(;1==t.childCount&&(n>0&&r>0||"table"==t.child(0).type.spec.tableRole);)n--,r--,t=t.child(0).content;const i=t.child(0),o=i.type.spec.tableRole,s=i.type.schema,a=[];if("row"==o)for(let e=0;e<t.childCount;e++){let i=t.child(e).content;const o=e?0:Math.max(0,n-1),l=e<t.childCount-1?0:Math.max(0,r-1);(o||l)&&(i=tx(yw(s).row,new Yr(i,o,l)).content),a.push(i)}else{if("cell"!=o&&"header_cell"!=o)return null;a.push(n||r?tx(yw(s).row,new Yr(t,n,r)).content:t)}return function(e,t){const n=[];for(let e=0;e<t.length;e++){const r=t[e];for(let t=r.childCount-1;t>=0;t--){const{rowspan:i,colspan:o}=r.child(t).attrs;for(let t=e;t<e+i;t++)n[t]=(n[t]||0)+o}}let r=0;for(let e=0;e<n.length;e++)r=Math.max(r,n[e]);for(let i=0;i<n.length;i++)if(i>=t.length&&t.push(qr.empty),n[i]<r){const o=yw(e).cell.createAndFill(),s=[];for(let e=n[i];e<r;e++)s.push(o);t[i]=t[i].append(qr.from(s))}return{height:t.length,width:r,rows:t}}(s,a)}function tx(e,t){const n=e.createAndFill();return new $o(n).replace(0,n.content.size,t).doc}function nx(e,t,n,r,i,o,s,a){if(0==s||s==t.height)return!1;let l=!1;for(let c=i;c<o;c++){const i=s*t.width+c,o=t.map[i];if(t.map[i-t.width]==o){l=!0;const i=n.nodeAt(o),{top:u,left:d}=t.findCell(o);e.setNodeMarkup(e.mapping.slice(a).map(o+r),null,{...i.attrs,rowspan:s-u}),e.insert(e.mapping.slice(a).map(t.positionAt(s,d,n)),i.type.createAndFill({...i.attrs,rowspan:u+i.attrs.rowspan-s})),c+=i.attrs.colspan-1}}return l}function rx(e,t,n,r,i,o,s,a){if(0==s||s==t.width)return!1;let l=!1;for(let c=i;c<o;c++){const i=c*t.width+s,o=t.map[i];if(t.map[i-1]==o){l=!0;const i=n.nodeAt(o),u=t.colCount(o),d=e.mapping.slice(a).map(o+r);e.setNodeMarkup(d,null,Cw(i.attrs,s-u,i.attrs.colspan-(s-u))),e.insert(d+i.nodeSize,i.type.createAndFill(Cw(i.attrs,0,s-u))),c+=i.attrs.rowspan-1}}return l}function ix(e,t,n,r,i){let o=n?e.doc.nodeAt(n-1):e.doc;if(!o)throw new Error("No table found");let s=mw.get(o);const{top:a,left:l}=r,c=l+i.width,u=a+i.height,d=e.tr;let p=0;function h(){if(o=n?d.doc.nodeAt(n-1):d.doc,!o)throw new Error("No table found");s=mw.get(o),p=d.mapping.maps.length}(function(e,t,n,r,i,o,s){const a=yw(e.doc.type.schema);let l,c;if(i>t.width)for(let o=0,u=0;o<t.height;o++){const d=n.child(o);u+=d.nodeSize;const p=[];let h;h=null==d.lastChild||d.lastChild.type==a.cell?l||(l=a.cell.createAndFill()):c||(c=a.header_cell.createAndFill());for(let e=t.width;e<i;e++)p.push(h);e.insert(e.mapping.slice(s).map(u-1+r),p)}if(o>t.height){const u=[];for(let e=0,r=(t.height-1)*t.width;e<Math.max(t.width,i);e++){const i=!(e>=t.width)&&n.nodeAt(t.map[r+e]).type==a.header_cell;u.push(i?c||(c=a.header_cell.createAndFill()):l||(l=a.cell.createAndFill()))}const d=a.row.create(null,qr.from(u)),p=[];for(let e=t.height;e<o;e++)p.push(d);e.insert(e.mapping.slice(s).map(r+n.nodeSize-2),p)}return!(!l&&!c)})(d,s,o,n,c,u,p)&&h(),nx(d,s,o,n,l,c,a,p)&&h(),nx(d,s,o,n,l,c,u,p)&&h(),rx(d,s,o,n,a,u,l,p)&&h(),rx(d,s,o,n,a,u,c,p)&&h();for(let e=a;e<u;e++){const t=s.positionAt(e,l,o),r=s.positionAt(e,c,o);d.replace(d.mapping.slice(p).map(t+n),d.mapping.slice(p).map(r+n),new Yr(i.rows[e-a],0,0))}h(),d.setSelection(new Aw(d.doc.resolve(n+s.positionAt(a,l,o)),d.doc.resolve(n+s.positionAt(u-1,c-1,o)))),t(d)}const ox=jc({ArrowLeft:ax("horiz",-1),ArrowRight:ax("horiz",1),ArrowUp:ax("vert",-1),ArrowDown:ax("vert",1),"Shift-ArrowLeft":lx("horiz",-1),"Shift-ArrowRight":lx("horiz",1),"Shift-ArrowUp":lx("vert",-1),"Shift-ArrowDown":lx("vert",1),Backspace:Qw,"Mod-Backspace":Qw,Delete:Qw,"Mod-Delete":Qw});function sx(e,t,n){return!n.eq(e.selection)&&(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function ax(e,t){return(n,r,i)=>{if(!i)return!1;const o=n.selection;if(o instanceof Aw)return sx(n,r,Uo.near(o.$headCell,t));if("horiz"!=e&&!o.empty)return!1;const s=px(i,e,t);if(null==s)return!1;if("horiz"==e)return sx(n,r,Uo.near(n.doc.resolve(o.head+t),t));{const i=n.doc.resolve(s),o=Ew(i,e,t);let a;return a=o?Uo.near(o,1):t<0?Uo.near(n.doc.resolve(i.before(-1)),-1):Uo.near(n.doc.resolve(i.after(-1)),1),sx(n,r,a)}}}function lx(e,t){return(n,r,i)=>{if(!i)return!1;const o=n.selection;let s;if(o instanceof Aw)s=o;else{const r=px(i,e,t);if(null==r)return!1;s=new Aw(n.doc.resolve(r))}const a=Ew(s.$headCell,e,t);return!!a&&sx(n,r,new Aw(s.$anchorCell,a))}}function cx(e,t){const n=bw(e.state.doc.resolve(t));return!!n&&(e.dispatch(e.state.tr.setSelection(new Aw(n))),!0)}function ux(e,t,n){if(!ww(e.state))return!1;let r=ex(n);const i=e.state.selection;if(i instanceof Aw){r||(r={width:1,height:1,rows:[qr.from(tx(yw(e.state.schema).cell,n))]});const t=i.$anchorCell.node(-1),o=i.$anchorCell.start(-1),s=mw.get(t).rectBetween(i.$anchorCell.pos-o,i.$headCell.pos-o);return r=function({width:e,height:t,rows:n},r,i){if(e!=r){const t=[],i=[];for(let e=0;e<n.length;e++){const o=n[e],s=[];for(let n=t[e]||0,i=0;n<r;i++){let a=o.child(i%o.childCount);n+a.attrs.colspan>r&&(a=a.type.createChecked(Cw(a.attrs,a.attrs.colspan,n+a.attrs.colspan-r),a.content)),s.push(a),n+=a.attrs.colspan;for(let n=1;n<a.attrs.rowspan;n++)t[e+n]=(t[e+n]||0)+a.attrs.colspan}i.push(qr.from(s))}n=i,e=r}if(t!=i){const e=[];for(let r=0,o=0;r<i;r++,o++){const s=[],a=n[o%t];for(let e=0;e<a.childCount;e++){let t=a.child(e);r+t.attrs.rowspan>i&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,i-t.attrs.rowspan)},t.content)),s.push(t)}e.push(qr.from(s))}n=e,t=i}return{width:e,height:t,rows:n}}(r,s.right-s.left,s.bottom-s.top),ix(e.state,e.dispatch,o,s,r),!0}if(r){const t=xw(e.state),n=t.start(-1);return ix(e.state,e.dispatch,n,mw.get(t.node(-1)).findCell(t.pos-n),r),!0}return!1}function dx(e,t){var n;if(0!=t.button)return;if(t.ctrlKey||t.metaKey)return;const r=hx(e,t.target);let i;if(t.shiftKey&&e.state.selection instanceof Aw)o(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&r&&null!=(i=bw(e.state.selection.$anchor))&&(null===(n=fx(e,t))||void 0===n?void 0:n.pos)!=i.pos)o(i,t),t.preventDefault();else if(!r)return;function o(t,n){let r=fx(e,n);const i=null==vw.getState(e.state);if(!r||!Sw(t,r)){if(!i)return;r=t}const o=new Aw(t,r);if(i||!e.state.selection.eq(o)){const n=e.state.tr.setSelection(o);i&&n.setMeta(vw,t.pos),e.dispatch(n)}}function s(){e.root.removeEventListener("mouseup",s),e.root.removeEventListener("dragstart",s),e.root.removeEventListener("mousemove",a),null!=vw.getState(e.state)&&e.dispatch(e.state.tr.setMeta(vw,-1))}function a(n){const i=n,a=vw.getState(e.state);let l;if(null!=a)l=e.state.doc.resolve(a);else if(hx(e,i.target)!=r&&(l=fx(e,t),!l))return s();l&&o(l,i)}e.root.addEventListener("mouseup",s),e.root.addEventListener("dragstart",s),e.root.addEventListener("mousemove",a)}function px(e,t,n){if(!(e.state.selection instanceof Ko))return null;const{$head:r}=e.state.selection;for(let i=r.depth-1;i>=0;i--){const o=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:o.childCount))return null;if("cell"==o.type.spec.tableRole||"header_cell"==o.type.spec.tableRole){const o=r.before(i),s="vert"==t?n>0?"down":"up":n>0?"right":"left";return e.endOfTextblock(s)?o:null}}return null}function hx(e,t){for(;t&&t!=e.dom;t=t.parentNode)if("TD"==t.nodeName||"TH"==t.nodeName)return t;return null}function fx(e,t){const n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&bw(e.state.doc.resolve(r))||bw(e.state.doc.resolve(i))}var mx=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${t}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),gx(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type==this.node.type&&(this.node=e,gx(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return"attributes"==e.type&&(e.target==this.table||this.colgroup.contains(e.target))}};function gx(e,t,n,r,i,o){let s=0,a=!0,l=t.firstChild;const c=e.firstChild;if(c){for(let e=0,n=0;e<c.childCount;e++){const{colspan:u,colwidth:d}=c.child(e).attrs;for(let e=0;e<u;e++,n++){const c=i==n?o:d&&d[e],u=c?c+"px":"";if(s+=c||r,c||(a=!1),l)l.style.width!=u&&(l.style.width=u),l=l.nextSibling;else{const e=document.createElement("col");e.style.width=u,t.appendChild(e)}}}for(;l;){var u;const e=l.nextSibling;null===(u=l.parentNode)||void 0===u||u.removeChild(l),l=e}a?(n.style.width=s+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=s+"px")}}const yx=new ps("tableColumnResizing");function vx({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=mx,lastColumnResizable:i=!0}={}){const o=new cs({key:yx,state:{init(e,t){var i;const s=null===(i=o.spec)||void 0===i||null===(i=i.props)||void 0===i?void 0:i.nodeViews,a=yw(t.schema).table.name;return r&&s&&(s[a]=(e,t)=>new r(e,n,t)),new bx(-1,!1)},apply:(e,t)=>t.apply(e)},props:{attributes:e=>{const t=yx.getState(e);return t&&t.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(t,n)=>{!function(e,t,n,r){if(!e.editable)return;const i=yx.getState(e.state);if(!i)return;if(!i.dragging){const o=function(e){for(;e&&"TD"!=e.nodeName&&"TH"!=e.nodeName;)e=e.classList&&e.classList.contains("ProseMirror")?null:e.parentNode;return e}(t.target);let s=-1;if(o){const{left:r,right:i}=o.getBoundingClientRect();t.clientX-r<=n?s=wx(e,t,"left",n):i-t.clientX<=n&&(s=wx(e,t,"right",n))}if(s!=i.activeHandle){if(!r&&-1!==s){const t=e.state.doc.resolve(s),n=t.node(-1),r=mw.get(n),i=t.start(-1);if(r.colCount(t.pos-i)+t.nodeAfter.attrs.colspan-1==r.width-1)return}Mx(e,s)}}}(t,n,e,i)},mouseleave:e=>{!function(e){if(!e.editable)return;const t=yx.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&Mx(e,-1)}(e)},mousedown:(e,r)=>{!function(e,t,n,r){var i;if(!e.editable)return!1;const o=null!==(i=e.dom.ownerDocument.defaultView)&&void 0!==i?i:window,s=yx.getState(e.state);if(!s||-1==s.activeHandle||s.dragging)return!1;const a=e.state.doc.nodeAt(s.activeHandle),l=function(e,t,{colspan:n,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const o=e.domAtPos(t);let s=o.node.childNodes[o.offset].offsetWidth,a=n;if(r)for(let e=0;e<n;e++)r[e]&&(s-=r[e],a--);return s/a}(e,s.activeHandle,a.attrs);function c(t){o.removeEventListener("mouseup",c),o.removeEventListener("mousemove",u);const r=yx.getState(e.state);(null==r?void 0:r.dragging)&&(!function(e,t,n){const r=e.state.doc.resolve(t),i=r.node(-1),o=mw.get(i),s=r.start(-1),a=o.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,l=e.state.tr;for(let e=0;e<o.height;e++){const t=e*o.width+a;if(e&&o.map[t]==o.map[t-o.width])continue;const r=o.map[t],c=i.nodeAt(r).attrs,u=1==c.colspan?0:a-o.colCount(r);if(c.colwidth&&c.colwidth[u]==n)continue;const d=c.colwidth?c.colwidth.slice():Ex(c.colspan);d[u]=n,l.setNodeMarkup(s+r,null,{...c,colwidth:d})}l.docChanged&&e.dispatch(l)}(e,r.activeHandle,xx(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(yx,{setDragging:null})))}function u(t){if(!t.which)return c(t);const i=yx.getState(e.state);if(i&&i.dragging){const o=xx(i.dragging,t,n);Sx(e,i.activeHandle,o,r)}}e.dispatch(e.state.tr.setMeta(yx,{setDragging:{startX:t.clientX,startWidth:l}})),Sx(e,s.activeHandle,l,r),o.addEventListener("mouseup",c),o.addEventListener("mousemove",u),t.preventDefault()}(e,r,t,n)}},decorations:e=>{const t=yx.getState(e);if(t&&t.activeHandle>-1)return function(e,t){const n=[],r=e.doc.resolve(t),i=r.node(-1);if(!i)return Xl.empty;const o=mw.get(i),s=r.start(-1),a=o.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;for(let t=0;t<o.height;t++){const r=a+t*o.width;if(!(a!=o.width-1&&o.map[r]==o.map[r+1]||0!=t&&o.map[r]==o.map[r-o.width])){var l;const t=o.map[r],a=s+t+i.nodeAt(t).nodeSize-1,c=document.createElement("div");c.className="column-resize-handle",(null===(l=yx.getState(e))||void 0===l?void 0:l.dragging)&&n.push(Jl.node(s+t,s+t+i.nodeAt(t).nodeSize,{class:"column-resize-dragging"})),n.push(Jl.widget(a,c))}}return Xl.create(e.doc,n)}(e,t.activeHandle)},nodeViews:{}}});return o}var bx=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){const n=this,r=t.getMeta(yx);if(r&&null!=r.setHandle)return new e(r.setHandle,!1);if(r&&void 0!==r.setDragging)return new e(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let r=t.mapping.map(n.activeHandle,-1);return Mw(t.doc.resolve(r))||(r=-1),new e(r,n.dragging)}return n}};function wx(e,t,n,r){const i="right"==n?-r:r,o=e.posAtCoords({left:t.clientX+i,top:t.clientY});if(!o)return-1;const{pos:s}=o,a=bw(e.state.doc.resolve(s));if(!a)return-1;if("right"==n)return a.pos;const l=mw.get(a.node(-1)),c=a.start(-1),u=l.map.indexOf(a.pos-c);return u%l.width==0?-1:c+l.map[u-1]}function xx(e,t,n){const r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function Mx(e,t){e.dispatch(e.state.tr.setMeta(yx,{setHandle:t}))}function Sx(e,t,n,r){const i=e.state.doc.resolve(t),o=i.node(-1),s=i.start(-1),a=mw.get(o).colCount(i.pos-s)+i.nodeAfter.attrs.colspan-1;let l=e.domAtPos(i.start(-1)).node;for(;l&&"TABLE"!=l.nodeName;)l=l.parentNode;l&&gx(o,l.firstChild,l,r,a,n)}function Ex(e){return Array(e).fill(0)}function Cx({allowTableNodeSelection:e=!1}={}){return new cs({key:vw,state:{init:()=>null,apply(e,t){const n=e.getMeta(vw);if(null!=n)return-1==n?null:n;if(null==t||!e.docChanged)return t;const{deleted:r,pos:i}=e.mapping.mapResult(t);return r?null:i}},props:{decorations:Tw,handleDOMEvents:{mousedown:dx},createSelectionBetween:e=>null!=vw.getState(e.state)?e.state.selection:null,handleTripleClick:cx,handleKeyDown:ox,handlePaste:ux},appendTransaction:(t,n,r)=>function(e,t,n){const r=(t||e).selection,i=(t||e).doc;let o,s;if(r instanceof Jo&&(s=r.node.type.spec.tableRole)){if("cell"==s||"header_cell"==s)o=Aw.create(i,r.from);else if("row"==s){const e=i.resolve(r.from+1);o=Aw.rowSelection(e,e)}else if(!n){const e=mw.get(r.node),t=r.from+1,n=t+e.map[e.width*e.height-1];o=Aw.create(i,t+1,n)}}else r instanceof Ko&&function({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,i=e.depth;for(;i>=0&&!(e.after(i+1)<e.end(i));i--,n++);for(let e=t.depth;e>=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}(r)?o=Ko.create(i,r.from):r instanceof Ko&&function({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){const r=e.node(t);if("cell"===r.type.spec.tableRole||"header_cell"===r.type.spec.tableRole){n=r;break}}for(let e=t.depth;e>0;e--){const n=t.node(e);if("cell"===n.type.spec.tableRole||"header_cell"===n.type.spec.tableRole){r=n;break}}return n!==r&&0===t.parentOffset}(r)&&(o=Ko.create(i,r.$from.start(),r.$from.end()));return o&&(t||(t=e.tr)).setSelection(o),t}(r,Rw(r,n),e)})}var Nx=Kp.create({name:"tableCell",addOptions:()=>({HTMLAttributes:{}}),content:"block+",addAttributes:()=>({colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?t.split(",").map(e=>parseInt(e,10)):null}}}),tableRole:"cell",isolating:!0,parseHTML:()=>[{tag:"td"}],renderHTML({HTMLAttributes:e}){return["td",Lu(this.options.HTMLAttributes,e),0]}}),Ax=Kp.create({name:"tableHeader",addOptions:()=>({HTMLAttributes:{}}),content:"block+",addAttributes:()=>({colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?t.split(",").map(e=>parseInt(e,10)):null}}}),tableRole:"header_cell",isolating:!0,parseHTML:()=>[{tag:"th"}],renderHTML({HTMLAttributes:e}){return["th",Lu(this.options.HTMLAttributes,e),0]}}),kx=Kp.create({name:"tableRow",addOptions:()=>({HTMLAttributes:{}}),content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML:()=>[{tag:"tr"}],renderHTML({HTMLAttributes:e}){return["tr",Lu(this.options.HTMLAttributes,e),0]}});function Tx(e,t){return t?["width",`${Math.max(t,e)}px`]:["min-width",`${e}px`]}function Ox(e,t,n,r,i,o){var s;let a=0,l=!0,c=t.firstChild;const u=e.firstChild;if(null!==u)for(let e=0,n=0;e<u.childCount;e+=1){const{colspan:s,colwidth:d}=u.child(e).attrs;for(let e=0;e<s;e+=1,n+=1){const s=i===n?o:d&&d[e],u=s?`${s}px`:"";if(a+=s||r,s||(l=!1),c){if(c.style.width!==u){const[e,t]=Tx(r,s);c.style.setProperty(e,t)}c=c.nextSibling}else{const e=document.createElement("col"),[n,i]=Tx(r,s);e.style.setProperty(n,i),t.appendChild(e)}}}for(;c;){const e=c.nextSibling;null==(s=c.parentNode)||s.removeChild(c),c=e}l?(n.style.width=`${a}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${a}px`)}var _x=class{constructor(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Ox(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type===this.node.type&&(this.node=e,Ox(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return"attributes"===e.type&&(e.target===this.table||this.colgroup.contains(e.target))}};function Rx(e,t){return t?e.createChecked(null,t):e.createAndFill()}function Dx(e,t,n,r,i){const o=function(e){if(e.cached.tableNodeTypes)return e.cached.tableNodeTypes;const t={};return Object.keys(e.nodes).forEach(n=>{const r=e.nodes[n];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}(e),s=[],a=[];for(let e=0;e<n;e+=1){const e=Rx(o.cell,i);if(e&&a.push(e),r){const e=Rx(o.header_cell,i);e&&s.push(e)}}const l=[];for(let e=0;e<t;e+=1)l.push(o.row.createChecked(null,r&&0===e?s:a));return o.table.createChecked(null,l)}var Ix=({editor:e})=>{const{selection:t}=e.state;if(!(t instanceof Aw))return!1;let n=0;const r=Nu(t.ranges[0].$from,e=>"table"===e.type.name);null==r||r.node.descendants(e=>{if("table"===e.type.name)return!1;["tableCell","tableHeader"].includes(e.type.name)&&(n+=1)});return n===t.ranges.length&&(e.commands.deleteTable(),!0)},Lx=Kp.create({name:"table",addOptions:()=>({HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:_x,lastColumnResizable:!0,allowTableNodeSelection:!1}),content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML:()=>[{tag:"table"}],renderHTML({node:e,HTMLAttributes:t}){const{colgroup:n,tableWidth:r,tableMinWidth:i}=function(e,t,n,r){let i=0,o=!0;const s=[],a=e.firstChild;if(!a)return{};for(let e=0,l=0;e<a.childCount;e+=1){const{colspan:c,colwidth:u}=a.child(e).attrs;for(let e=0;e<c;e+=1,l+=1){const a=n===l?r:u&&u[e];i+=a||t,a||(o=!1);const[c,d]=Tx(t,a);s.push(["col",{style:`${c}: ${d}`}])}}const l=o?`${i}px`:"",c=o?"":`${i}px`;return{colgroup:["colgroup",{},...s],tableWidth:l,tableMinWidth:c}}(e,this.options.cellMinWidth);return["table",Lu(this.options.HTMLAttributes,t,{style:r?`width: ${r}`:`min-width: ${i}`}),n,["tbody",0]]},addCommands:()=>({insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:o})=>{const s=Dx(o.schema,e,t,n);if(i){const e=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(Ko.near(r.doc.resolve(e)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>Lw(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>Bw(e,t),deleteColumn:()=>({state:e,dispatch:t})=>Pw(e,t),addRowBefore:()=>({state:e,dispatch:t})=>Fw(e,t),addRowAfter:()=>({state:e,dispatch:t})=>$w(e,t),deleteRow:()=>({state:e,dispatch:t})=>Uw(e,t),deleteTable:()=>({state:e,dispatch:t})=>Xw(e,t),mergeCells:()=>({state:e,dispatch:t})=>Vw(e,t),splitCell:()=>({state:e,dispatch:t})=>Ww(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>Jw("column")(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>Jw("row")(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>Yw(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>!!Vw(e,t)||Ww(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>Kw(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>Zw(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>Zw(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&Rw(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){const n=Aw.create(t.doc,e.anchorCell,e.headCell);t.setSelection(n)}return!0}}),addKeyboardShortcuts(){return{Tab:()=>!!this.editor.commands.goToNextCell()||!!this.editor.can().addRowAfter()&&this.editor.chain().addRowAfter().goToNextCell().run(),"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Ix,"Mod-Backspace":Ix,Delete:Ix,"Mod-Delete":Ix}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[vx({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Cx({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema:e=>({tableRole:Ru(ku(e,"tableRole",{name:e.name,options:e.options,storage:e.storage}))})});xd.create({name:"tableKit",addExtensions(){const e=[];return!1!==this.options.table&&e.push(Lx.configure(this.options.table)),!1!==this.options.tableCell&&e.push(Nx.configure(this.options.tableCell)),!1!==this.options.tableHeader&&e.push(Ax.configure(this.options.tableHeader)),!1!==this.options.tableRow&&e.push(kx.configure(this.options.tableRow)),e}});const Bx=Lx.extend({addAttributes:()=>({border:{default:"1"}}),renderHTML(e){const t=this.parent(e),{border:n}=e.HTMLAttributes,r=`${t[1].style}${t[1].style.match(/.*; */)?"":";"}`;return t[1].style=`${r}\n color: var(--pie-text, black);\n background-color: var(--pie-background, rgba(255, 255, 255))`,t[1].border=n||"1",t}});var zx=Object.defineProperty,Px=(e,t)=>{for(var n in t)zx(e,n,{get:t[n],enumerable:!0})};function jx(e){const{state:t,transaction:n}=e;let{selection:r}=n,{doc:i}=n,{storedMarks:o}=n;return{...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 Fx=class{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:n}=this,{view:r}=t,{tr:i}=n,o=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,(...e)=>{const n=t(...e)(o);return i.getMeta("preventDispatch")||this.hasCustomState||r.dispatch(i),n}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:n,editor:r,state:i}=this,{view:o}=r,s=[],a=!!e,l=e||i.tr,c={...Object.fromEntries(Object.entries(n).map(([e,n])=>[e,(...e)=>{const r=this.buildProps(l,t),i=n(...e)(r);return s.push(i),c}])),run:()=>(a||!t||l.getMeta("preventDispatch")||this.hasCustomState||o.dispatch(l),s.every(e=>!0===e))};return c}createCan(e){const{rawCommands:t,state:n}=this,r=!1,i=e||n.tr,o=this.buildProps(i,r),s=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,(...e)=>t(...e)({...o,dispatch:void 0})]));return{...s,chain:()=>this.createChain(i,r)}}buildProps(e,t=!0){const{rawCommands:n,editor:r,state:i}=this,{view:o}=r,s={tr:e,editor:r,view:o,state:jx({state:i,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,(...e)=>t(...e)(s)]))}};return s}};var $x=e=>{const t=e.childNodes;for(let n=t.length-1;n>=0;n-=1){const r=t[n];3===r.nodeType&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):1===r.nodeType&&$x(r)}return e};function Hx(e){if("undefined"==typeof window)throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const t=`<body>${e}</body>`,n=(new window.DOMParser).parseFromString(t,"text/html").body;return $x(n)}function Ux(e,t,n){if(e instanceof fi||e instanceof qr)return e;n={slice:!0,parseOptions:{},...n};const r="string"==typeof e;if("object"==typeof e&&null!==e)try{if(Array.isArray(e)&&e.length>0)return qr.fromArray(e.map(e=>t.nodeFromJSON(e)));const r=t.nodeFromJSON(e);return n.errorOnInvalidContent&&r.check(),r}catch(r){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:r});return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",r),Ux("",t,n)}if(r){if(n.errorOnInvalidContent){let r=!1,i="";const o=new Di({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:e=>(r=!0,i="string"==typeof e?e:e.outerHTML,null)}]}})});if(n.slice?Li.fromSchema(o).parseSlice(Hx(e),n.parseOptions):Li.fromSchema(o).parse(Hx(e),n.parseOptions),n.errorOnInvalidContent&&r)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${i}`)})}const r=Li.fromSchema(t);return n.slice?r.parseSlice(Hx(e),n.parseOptions).content:r.parse(Hx(e),n.parseOptions)}return Ux("",t,n)}function qx(e,t){for(let n=e.depth;n>0;n-=1){const r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}function Vx(e){return t=>qx(t.$from,e)}function Wx(e,t,n){if(void 0===e.config[t]&&e.parent)return Wx(e.parent,t,n);if("function"==typeof e.config[t]){return e.config[t].bind({...n,parent:e.parent?Wx(e.parent,t,n):null})}return e.config[t]}function Kx(e,t=void 0,...n){return function(e){return"function"==typeof e}(e)?t?e.bind(t)(...n):e(...n):e}function Gx(...e){return e.filter(e=>!!e).reduce((e,t)=>{const n={...e};return Object.entries(t).forEach(([e,t])=>{if(n[e])if("class"===e){const r=t?String(t).split(" "):[],i=n[e]?n[e].split(" "):[],o=r.filter(e=>!i.includes(e));n[e]=[...i,...o].join(" ")}else if("style"===e){const r=t?t.split(";").map(e=>e.trim()).filter(Boolean):[],i=n[e]?n[e].split(";").map(e=>e.trim()).filter(Boolean):[],o=new Map;i.forEach(e=>{const[t,n]=e.split(":").map(e=>e.trim());o.set(t,n)}),r.forEach(e=>{const[t,n]=e.split(":").map(e=>e.trim());o.set(t,n)}),n[e]=Array.from(o.entries()).map(([e,t])=>`${e}: ${t}`).join("; ")}else n[e]=t;else n[e]=t}),n},{})}function Jx(e,t){if("string"==typeof e){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}function Yx(e,t){if("string"==typeof e){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}function Zx(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function Xx(e){const t=function(e,t=JSON.stringify){const n={};return e.filter(e=>{const r=t(e);return!Object.prototype.hasOwnProperty.call(n,r)&&(n[r]=!0)})}(e);return 1===t.length?t:t.filter((e,n)=>{const r=t.filter((e,t)=>t!==n);return!r.some(t=>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 Qx(e,t,n={strict:!0}){const r=Object.keys(t);return!r.length||r.every(r=>{return n.strict?t[r]===e[r]:(i=t[r],"[object RegExp]"===Object.prototype.toString.call(i)?t[r].test(e[r]):t[r]===e[r]);var i})}function eM(e,t,n={}){return e.find(e=>e.type===t&&Qx(Object.fromEntries(Object.keys(n).map(t=>[t,e.attrs[t]])),n))}function tM(e,t,n={}){return!!eM(e,t,n)}function nM(e,t,n){var r;if(!e||!t)return;let i=e.parent.childAfter(e.parentOffset);if(i.node&&i.node.marks.some(e=>e.type===t)||(i=e.parent.childBefore(e.parentOffset)),!i.node||!i.node.marks.some(e=>e.type===t))return;n=n||(null==(r=i.node.marks[0])?void 0:r.attrs);if(!eM([...i.node.marks],t,n))return;let o=i.index,s=e.start()+i.offset,a=o+1,l=s+i.node.nodeSize;for(;o>0&&tM([...e.parent.child(o-1).marks],t,n);)o-=1,s-=e.parent.child(o).nodeSize;for(;a<e.parent.childCount&&tM([...e.parent.child(a).marks],t,n);)l+=e.parent.child(a).nodeSize,a+=1;return{from:s,to:l}}function rM(e,t,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{const r=e.find(e=>e.type===t&&e.name===n);return!!r&&r.attribute.keepOnSplit}))}function iM(e,t,n={}){const{from:r,to:i,empty:o}=e.selection,s=t?Yx(t,e.schema):null,a=[];e.doc.nodesBetween(r,i,(e,t)=>{if(e.isText)return;const n=Math.max(r,t),o=Math.min(i,t+e.nodeSize);a.push({node:e,from:n,to:o})});const l=i-r,c=a.filter(e=>!s||s.name===e.node.type.name).filter(e=>Qx(e.node.attrs,n,{strict:!1}));if(o)return!!c.length;const u=c.reduce((e,t)=>e+t.to-t.from,0);return u>=l}function oM(e,t){const{nodeExtensions:n}=function(e){return{baseExtensions:e.filter(e=>"extension"===e.type),nodeExtensions:e.filter(e=>"node"===e.type),markExtensions:e.filter(e=>"mark"===e.type)}}(t),r=n.find(t=>t.name===e);if(!r)return!1;const i=Kx(Wx(r,"group",{name:r.name,options:r.options,storage:r.storage}));return"string"==typeof i&&i.split(" ").includes("list")}function sM(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if("hardBreak"===e.type.name)return!0;if(e.isText)return/^\s*$/m.test(null!=(r=e.text)?r:"")}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(0===e.content.childCount)return!0;if(t){let r=!0;return e.content.forEach(e=>{!1!==r&&(sM(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function aM(e){return e instanceof Ko}function lM(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function cM(e){return"Object"===function(e){return Object.prototype.toString.call(e).slice(8,-1)}(e)&&(e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype)}function uM(e,t){const n={...e};return cM(e)&&cM(t)&&Object.keys(t).forEach(r=>{cM(t[r])&&cM(e[r])?n[r]=uM(e[r],t[r]):n[r]=t[r]}),n}var dM=class{constructor(e={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...e},this.name=this.config.name}get options(){return{...Kx(Wx(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Kx(Wx(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(e={}){const t=this.extend({...this.config,addOptions:()=>uM(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new this.constructor({...this.config,...e});return t.parent=this,this.child=t,t.name="name"in e?e.name:t.parent.name,t}};Px({},{ClipboardTextSerializer:()=>hM,Commands:()=>CS,Delete:()=>NS,Drop:()=>AS,Editable:()=>kS,FocusEvents:()=>OS,Keymap:()=>_S,Paste:()=>RS,Tabindex:()=>DS,focusEventsPluginKey:()=>TS});var pM=class e extends dM{constructor(){super(...arguments),this.type="extension"}static create(t={}){const n="function"==typeof t?t():t;return new e(n)}configure(e){return super.configure(e)}extend(e){const t="function"==typeof e?e():e;return super.extend(t)}},hM=pM.create({name:"clipboardTextSerializer",addOptions:()=>({blockSeparator:void 0}),addProseMirrorPlugins(){return[new cs({key:new ps("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:i}=t,{ranges:o}=i,s=Math.min(...o.map(e=>e.$from.pos)),a=Math.max(...o.map(e=>e.$to.pos)),l=function(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}(n);return function(e,t,n){const{from:r,to:i}=t,{blockSeparator:o="\n\n",textSerializers:s={}}=n||{};let a="";return e.nodesBetween(r,i,(e,n,l,c)=>{var u;e.isBlock&&n>r&&(a+=o);const d=null==s?void 0:s[e.type.name];if(d)return l&&(a+=d({node:e,pos:n,parent:l,index:c,range:t})),!1;e.isText&&(a+=null==(u=null==e?void 0:e.text)?void 0:u.slice(Math.max(r,n)-n,i-n))}),a}(r,{from:s,to:a},{...void 0!==this.options.blockSeparator?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),fM={};Px(fM,{blur:()=>mM,clearContent:()=>gM,clearNodes:()=>yM,command:()=>vM,createParagraphNear:()=>bM,cut:()=>wM,deleteCurrentNode:()=>xM,deleteNode:()=>MM,deleteRange:()=>SM,deleteSelection:()=>EM,enter:()=>CM,exitCode:()=>NM,extendMarkRange:()=>AM,first:()=>kM,focus:()=>OM,forEach:()=>_M,insertContent:()=>RM,insertContentAt:()=>DM,joinBackward:()=>BM,joinDown:()=>LM,joinForward:()=>zM,joinItemBackward:()=>PM,joinItemForward:()=>jM,joinTextblockBackward:()=>FM,joinTextblockForward:()=>$M,joinUp:()=>IM,keyboardShortcut:()=>UM,lift:()=>qM,liftEmptyBlock:()=>VM,liftListItem:()=>WM,newlineInCode:()=>KM,resetAttributes:()=>JM,scrollIntoView:()=>YM,selectAll:()=>ZM,selectNodeBackward:()=>XM,selectNodeForward:()=>QM,selectParentNode:()=>eS,selectTextblockEnd:()=>tS,selectTextblockStart:()=>nS,setContent:()=>rS,setMark:()=>iS,setMeta:()=>oS,setNode:()=>sS,setNodeSelection:()=>aS,setTextSelection:()=>lS,sinkListItem:()=>cS,splitBlock:()=>dS,splitListItem:()=>pS,toggleList:()=>mS,toggleMark:()=>gS,toggleNode:()=>yS,toggleWrap:()=>vS,undoInputRule:()=>bS,unsetAllMarks:()=>wS,unsetMark:()=>xS,updateAttributes:()=>MS,wrapIn:()=>SS,wrapInList:()=>ES});var mM=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(t.dom.blur(),null==(n=null==window?void 0:window.getSelection())||n.removeAllRanges())}),!0),gM=(e=!0)=>({commands:t})=>t.setContent("",{emitUpdate:e}),yM=()=>({state:e,tr:t,dispatch:n})=>{const{selection:r}=t,{ranges:i}=r;return!n||(i.forEach(({$from:n,$to:r})=>{e.doc.nodesBetween(n.pos,r.pos,(e,n)=>{if(e.type.isText)return;const{doc:r,mapping:i}=t,o=r.resolve(i.map(n)),s=r.resolve(i.map(n+e.nodeSize)),a=o.blockRange(s);if(!a)return;const l=yo(a);if(e.type.isTextblock){const{defaultType:e}=o.parent.contentMatchAt(o.index());t.setNodeMarkup(a.start,e)}(l||0===l)&&t.lift(a,l)})}),!0)},vM=e=>t=>e(t),bM=()=>({state:e,dispatch:t})=>ou(e,t),wM=(e,t)=>({editor:n,tr:r})=>{const{state:i}=n,o=i.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);const s=r.mapping.map(t);return r.insert(s,o.content),r.setSelection(new Ko(r.doc.resolve(Math.max(s-1,0)))),!0},xM=()=>({tr:e,dispatch:t})=>{const{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;const i=e.selection.$anchor;for(let n=i.depth;n>0;n-=1){if(i.node(n).type===r.type){if(t){const t=i.before(n),r=i.after(n);e.delete(t,r).scrollIntoView()}return!0}}return!1},MM=e=>({tr:t,state:n,dispatch:r})=>{const i=Yx(e,n.schema),o=t.selection.$anchor;for(let e=o.depth;e>0;e-=1){if(o.node(e).type===i){if(r){const n=o.before(e),r=o.after(e);t.delete(n,r).scrollIntoView()}return!0}}return!1},SM=e=>({tr:t,dispatch:n})=>{const{from:r,to:i}=e;return n&&t.delete(r,i),!0},EM=()=>({state:e,dispatch:t})=>Fc(e,t),CM=()=>({commands:e})=>e.keyboardShortcut("Enter"),NM=()=>({state:e,dispatch:t})=>iu(e,t),AM=(e,t={})=>({tr:n,state:r,dispatch:i})=>{const o=Jx(e,r.schema),{doc:s,selection:a}=n,{$from:l,from:c,to:u}=a;if(i){const e=nM(l,o,t);if(e&&e.from<=c&&e.to>=u){const t=Ko.create(s,e.from,e.to);n.setSelection(t)}}return!0},kM=e=>t=>{const n="function"==typeof e?e(t):e;for(let e=0;e<n.length;e+=1)if(n[e](t))return!0;return!1};function TM(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var OM=(e=null,t={})=>({editor:n,view:r,tr:i,dispatch:o})=>{t={scrollIntoView:!0,...t};const s=()=>{(TM()||"Android"===navigator.platform||/android/i.test(navigator.userAgent))&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),(null==t?void 0:t.scrollIntoView)&&n.commands.scrollIntoView())})};if(r.hasFocus()&&null===e||!1===e)return!0;if(o&&null===e&&!aM(n.state.selection))return s(),!0;const a=function(e,t=null){if(!t)return null;const n=Uo.atStart(e),r=Uo.atEnd(e);if("start"===t||!0===t)return n;if("end"===t)return r;const i=n.from,o=r.to;return"all"===t?Ko.create(e,lM(0,i,o),lM(e.content.size,i,o)):Ko.create(e,lM(t,i,o),lM(t,i,o))}(i.doc,e)||n.state.selection,l=n.state.selection.eq(a);return o&&(l||i.setSelection(a),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),s()),!0},_M=(e,t)=>n=>e.every((e,r)=>t(e,{...n,index:r})),RM=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),DM=(e,t,n)=>({tr:r,dispatch:i,editor:o})=>{var s;if(i){let i;n={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};const{selection:a}=o.state,l=e=>{o.emit("contentError",{editor:o,error:e,disableCollaboration:()=>{"collaboration"in o.storage&&"object"==typeof o.storage.collaboration&&o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{Ux(t,o.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(e){l(e)}try{i=Ux(t,o.schema,{parseOptions:c,errorOnInvalidContent:null!=(s=n.errorOnInvalidContent)?s:o.options.enableContentCheck})}catch(e){return l(e),!1}let{from:u,to:d}="number"==typeof e?{from:e,to:e}:{from:e.from,to:e.to},p=!0,h=!0;if(("type"in i?[i]:i).forEach(e=>{e.check(),p=!!p&&(e.isText&&0===e.marks.length),h=!!h&&e.isBlock}),u===d&&h){const{parent:e}=r.doc.resolve(u);e.isTextblock&&!e.type.spec.code&&!e.childCount&&(u-=1,d+=1)}let f;if(p){if(Array.isArray(t))f=t.map(e=>e.text||"").join("");else if(t instanceof qr){let e="";t.forEach(t=>{t.text&&(e+=t.text)}),f=e}else f="object"==typeof t&&t&&t.text?t.text:t;r.insertText(f,u,d)}else{f=i;const e=0===a.$from.parentOffset,t=a.$from.node().isText||a.$from.node().isTextblock,n=a.$from.node().content.size>0;e&&t&&n&&(u=Math.max(0,u-1)),r.replaceWith(u,d,f)}n.updateSelection&&function(e,t,n){const r=e.steps.length-1;if(r<t)return;const i=e.steps[r];if(!(i instanceof po||i instanceof ho))return;const o=e.mapping.maps[r];let s=0;o.forEach((e,t,n,r)=>{0===s&&(s=r)}),e.setSelection(Uo.near(e.doc.resolve(s),n))}(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:f}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:f})}return!0},IM=()=>({state:e,dispatch:t})=>Qc(e,t),LM=()=>({state:e,dispatch:t})=>eu(e,t),BM=()=>({state:e,dispatch:t})=>Hc(e,t),zM=()=>({state:e,dispatch:t})=>Yc(e,t),PM=()=>({state:e,dispatch:t,tr:n})=>{try{const r=Co(e.doc,e.selection.$from.pos,-1);return null!=r&&(n.join(r,2),t&&t(n),!0)}catch(e){return!1}},jM=()=>({state:e,dispatch:t,tr:n})=>{try{const r=Co(e.doc,e.selection.$from.pos,1);return null!=r&&(n.join(r,2),t&&t(n),!0)}catch(e){return!1}},FM=()=>({state:e,dispatch:t})=>Uc(e,t),$M=()=>({state:e,dispatch:t})=>qc(e,t);function HM(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}var UM=e=>({editor:t,view:n,tr:r,dispatch:i})=>{const o=function(e){const t=e.split(/-(?!$)/);let n,r,i,o,s=t[t.length-1];"Space"===s&&(s=" ");for(let e=0;e<t.length-1;e+=1){const s=t[e];if(/^(cmd|meta|m)$/i.test(s))o=!0;else if(/^a(lt)?$/i.test(s))n=!0;else if(/^(c|ctrl|control)$/i.test(s))r=!0;else if(/^s(hift)?$/i.test(s))i=!0;else{if(!/^mod$/i.test(s))throw new Error(`Unrecognized modifier name: ${s}`);TM()||HM()?o=!0:r=!0}}return n&&(s=`Alt-${s}`),r&&(s=`Ctrl-${s}`),o&&(s=`Meta-${s}`),i&&(s=`Shift-${s}`),s}(e).split(/-(?!$)/),s=o.find(e=>!["Alt","Ctrl","Meta","Shift"].includes(e)),a=new KeyboardEvent("keydown",{key:"Space"===s?" ":s,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),l=t.captureTransaction(()=>{n.someProp("handleKeyDown",e=>e(n,a))});return null==l||l.steps.forEach(e=>{const t=e.map(r.mapping);t&&i&&r.maybeStep(t)}),!0},qM=(e,t={})=>({state:n,dispatch:r})=>!!iM(n,Yx(e,n.schema),t)&&tu(n,r),VM=()=>({state:e,dispatch:t})=>su(e,t),WM=e=>({state:t,dispatch:n})=>mu(Yx(e,t.schema))(t,n),KM=()=>({state:e,dispatch:t})=>nu(e,t);function GM(e,t){const n="string"==typeof t?[t]:t;return Object.keys(e).reduce((t,r)=>(n.includes(r)||(t[r]=e[r]),t),{})}var JM=(e,t)=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null;const a=Zx("string"==typeof e?e:e.name,r.schema);return!!a&&("node"===a&&(o=Yx(e,r.schema)),"mark"===a&&(s=Jx(e,r.schema)),i&&n.selection.ranges.forEach(e=>{r.doc.nodesBetween(e.$from.pos,e.$to.pos,(e,r)=>{o&&o===e.type&&n.setNodeMarkup(r,void 0,GM(e.attrs,t)),s&&e.marks.length&&e.marks.forEach(i=>{s===i.type&&n.addMark(r,r+e.nodeSize,s.create(GM(i.attrs,t)))})})}),!0)},YM=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),ZM=()=>({tr:e,dispatch:t})=>{if(t){const t=new Zo(e.doc);e.setSelection(t)}return!0},XM=()=>({state:e,dispatch:t})=>Kc(e,t),QM=()=>({state:e,dispatch:t})=>Zc(e,t),eS=()=>({state:e,dispatch:t})=>au(e,t),tS=()=>({state:e,dispatch:t})=>du(e,t),nS=()=>({state:e,dispatch:t})=>uu(e,t),rS=(e,{errorOnInvalidContent:t,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:o,dispatch:s,commands:a})=>{const{doc:l}=o;if("full"!==r.preserveWhitespace){const a=function(e,t,n={},r={}){return Ux(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}(e,i.schema,r,{errorOnInvalidContent:null!=t?t:i.options.enableContentCheck});return s&&o.replaceWith(0,l.content.size,a).setMeta("preventUpdate",!n),!0}return s&&o.setMeta("preventUpdate",!n),a.insertContentAt({from:0,to:l.content.size},e,{parseOptions:r,errorOnInvalidContent:null!=t?t:i.options.enableContentCheck})};var iS=(e,t={})=>({tr:n,state:r,dispatch:i})=>{const{selection:o}=n,{empty:s,ranges:a}=o,l=Jx(e,r.schema);if(i)if(s){const e=function(e,t){const n=Jx(t,e.schema),{from:r,to:i,empty:o}=e.selection,s=[];o?(e.storedMarks&&s.push(...e.storedMarks),s.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,i,e=>{s.push(...e.marks)});const a=s.find(e=>e.type.name===n.name);return a?{...a.attrs}:{}}(r,l);n.addStoredMark(l.create({...e,...t}))}else a.forEach(e=>{const i=e.$from.pos,o=e.$to.pos;r.doc.nodesBetween(i,o,(e,r)=>{const s=Math.max(r,i),a=Math.min(r+e.nodeSize,o);e.marks.find(e=>e.type===l)?e.marks.forEach(e=>{l===e.type&&n.addMark(s,a,l.create({...e.attrs,...t}))}):n.addMark(s,a,l.create(t))})});return function(e,t,n){var r;const{selection:i}=t;let o=null;if(aM(i)&&(o=i.$cursor),o){const t=null!=(r=e.storedMarks)?r:o.marks();return!!n.isInSet(t)||!t.some(e=>e.type.excludes(n))}const{ranges:s}=i;return s.some(({$from:t,$to:r})=>{let i=0===t.depth&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(t.pos,r.pos,(e,t,r)=>{if(i)return!1;if(e.isInline){const t=!r||r.type.allowsMarkType(n),o=!!n.isInSet(e.marks)||!e.marks.some(e=>e.type.excludes(n));i=t&&o}return!i}),i})}(r,n,l)},oS=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),sS=(e,t={})=>({state:n,dispatch:r,chain:i})=>{const o=Yx(e,n.schema);let s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),o.isTextblock?i().command(({commands:e})=>!!hu(o,{...s,...t})(n)||e.clearNodes()).command(({state:e})=>hu(o,{...s,...t})(e,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},aS=e=>({tr:t,dispatch:n})=>{if(n){const{doc:n}=t,r=lM(e,0,n.content.size),i=Jo.create(n,r);t.setSelection(i)}return!0},lS=e=>({tr:t,dispatch:n})=>{if(n){const{doc:n}=t,{from:r,to:i}="number"==typeof e?{from:e,to:e}:e,o=Ko.atStart(n).from,s=Ko.atEnd(n).to,a=lM(r,o,s),l=lM(i,o,s),c=Ko.create(n,a,l);t.setSelection(c)}return!0},cS=e=>({state:t,dispatch:n})=>gu(Yx(e,t.schema))(t,n);function uS(e,t){const n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){const r=n.filter(e=>null==t?void 0:t.includes(e.type.name));e.tr.ensureMarks(r)}}var dS=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:i})=>{const{selection:o,doc:s}=t,{$from:a,$to:l}=o,c=rM(i.extensionManager.attributes,a.node().type.name,a.node().attrs);if(o instanceof Jo&&o.node.isBlock)return!(!a.parentOffset||!Mo(s,a.pos))&&(r&&(e&&uS(n,i.extensionManager.splittableMarks),t.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const u=l.parentOffset===l.parent.content.size,d=0===a.depth?void 0:function(e){for(let t=0;t<e.edgeCount;t+=1){const{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}(a.node(-1).contentMatchAt(a.indexAfter(-1)));let p=u&&d?[{type:d,attrs:c}]:void 0,h=Mo(t.doc,t.mapping.map(a.pos),1,p);if(p||h||!Mo(t.doc,t.mapping.map(a.pos),1,d?[{type:d}]:void 0)||(h=!0,p=d?[{type:d,attrs:c}]:void 0),r){if(h&&(o instanceof Ko&&t.deleteSelection(),t.split(t.mapping.map(a.pos),1,p),d&&!u&&!a.parentOffset&&a.parent.type!==d)){const e=t.mapping.map(a.before()),n=t.doc.resolve(e);a.node(-1).canReplaceWith(n.index(),n.index()+1,d)&&t.setNodeMarkup(t.mapping.map(a.before()),d)}e&&uS(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return h},pS=(e,t={})=>({tr:n,state:r,dispatch:i,editor:o})=>{var s;const a=Yx(e,r.schema),{$from:l,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||l.depth<2||!l.sameParent(c))return!1;const d=l.node(-1);if(d.type!==a)return!1;const p=o.extensionManager.attributes;if(0===l.parent.content.size&&l.node(-1).childCount===l.indexAfter(-1)){if(2===l.depth||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(i){let e=qr.empty;const r=l.index(-1)?1:l.index(-2)?2:3;for(let t=l.depth-r;t>=l.depth-3;t-=1)e=qr.from(l.node(t).copy(e));const i=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,o={...rM(p,l.node().type.name,l.node().attrs),...t},c=(null==(s=a.contentMatch.defaultType)?void 0:s.createAndFill(o))||void 0;e=e.append(qr.from(a.createAndFill(null,c)||void 0));const u=l.before(l.depth-(r-1));n.replace(u,l.after(-i),new Yr(e,4-r,0));let d=-1;n.doc.nodesBetween(u,n.doc.content.size,(e,t)=>{if(d>-1)return!1;e.isTextblock&&0===e.content.size&&(d=t+1)}),d>-1&&n.setSelection(Ko.near(n.doc.resolve(d))),n.scrollIntoView()}return!0}const h=c.pos===l.end()?d.contentMatchAt(0).defaultType:null,f={...rM(p,d.type.name,d.attrs),...t},m={...rM(p,l.node().type.name,l.node().attrs),...t};n.delete(l.pos,c.pos);const g=h?[{type:a,attrs:f},{type:h,attrs:m}]:[{type:a,attrs:f}];if(!Mo(n.doc,l.pos,2))return!1;if(i){const{selection:e,storedMarks:t}=r,{splittableMarks:s}=o.extensionManager,a=t||e.$to.parentOffset&&e.$from.marks();if(n.split(l.pos,2,g).scrollIntoView(),!a||!i)return!0;const c=a.filter(e=>s.includes(e.type.name));n.ensureMarks(c)}return!0},hS=(e,t)=>{const n=Vx(e=>e.type===t)(e.selection);if(!n)return!0;const r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===r)return!0;const i=e.doc.nodeAt(r);return n.node.type!==(null==i?void 0:i.type)||!So(e.doc,n.pos)||(e.join(n.pos),!0)},fS=(e,t)=>{const n=Vx(e=>e.type===t)(e.selection);if(!n)return!0;const r=e.doc.resolve(n.start).after(n.depth);if(void 0===r)return!0;const i=e.doc.nodeAt(r);return n.node.type!==(null==i?void 0:i.type)||!So(e.doc,r)||(e.join(r),!0)},mS=(e,t,n,r={})=>({editor:i,tr:o,state:s,dispatch:a,chain:l,commands:c,can:u})=>{const{extensions:d,splittableMarks:p}=i.extensionManager,h=Yx(e,s.schema),f=Yx(t,s.schema),{selection:m,storedMarks:g}=s,{$from:y,$to:v}=m,b=y.blockRange(v),w=g||m.$to.parentOffset&&m.$from.marks();if(!b)return!1;const x=Vx(e=>oM(e.type.name,d))(m);if(b.depth>=1&&x&&b.depth-x.depth<=1){if(x.node.type===h)return c.liftListItem(f);if(oM(x.node.type.name,d)&&h.validContent(x.node.content)&&a)return l().command(()=>(o.setNodeMarkup(x.pos,h),!0)).command(()=>hS(o,h)).command(()=>fS(o,h)).run()}return n&&w&&a?l().command(()=>{const e=u().wrapInList(h,r),t=w.filter(e=>p.includes(e.type.name));return o.ensureMarks(t),!!e||c.clearNodes()}).wrapInList(h,r).command(()=>hS(o,h)).command(()=>fS(o,h)).run():l().command(()=>!!u().wrapInList(h,r)||c.clearNodes()).wrapInList(h,r).command(()=>hS(o,h)).command(()=>fS(o,h)).run()},gS=(e,t={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:o=!1}=n,s=Jx(e,r.schema),a=function(e,t,n={}){const{empty:r,ranges:i}=e.selection,o=t?Jx(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>!o||o.name===e.type.name).find(e=>Qx(e.attrs,n,{strict:!1}));let s=0;const a=[];if(i.forEach(({$from:t,$to:n})=>{const r=t.pos,i=n.pos;e.doc.nodesBetween(r,i,(e,t)=>{if(!e.isText&&!e.marks.length)return;const n=Math.max(r,t),o=Math.min(i,t+e.nodeSize);s+=o-n,a.push(...e.marks.map(e=>({mark:e,from:n,to:o})))})}),0===s)return!1;const l=a.filter(e=>!o||o.name===e.mark.type.name).filter(e=>Qx(e.mark.attrs,n,{strict:!1})).reduce((e,t)=>e+t.to-t.from,0),c=a.filter(e=>!o||e.mark.type!==o&&e.mark.type.excludes(o)).reduce((e,t)=>e+t.to-t.from,0);return(l>0?l+c:l)>=s}(r,s,t);return a?i.unsetMark(s,{extendEmptyMarkRange:o}):i.setMark(s,t)},yS=(e,t,n={})=>({state:r,commands:i})=>{const o=Yx(e,r.schema),s=Yx(t,r.schema),a=iM(r,o,n);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),a?i.setNode(s,l):i.setNode(o,{...l,...n})},vS=(e,t={})=>({state:n,commands:r})=>{const i=Yx(e,n.schema);return iM(n,i,t)?r.lift(i):r.wrapIn(i,t)},bS=()=>({state:e,dispatch:t})=>{const n=e.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let o;if(i.spec.isInputRules&&(o=i.getState(e))){if(t){const t=e.tr,n=o.transform;for(let e=n.steps.length-1;e>=0;e-=1)t.step(n.steps[e].invert(n.docs[e]));if(o.text){const n=t.doc.resolve(o.from).marks();t.replaceWith(o.from,o.to,e.schema.text(o.text,n))}else t.delete(o.from,o.to)}return!0}}return!1},wS=()=>({tr:e,dispatch:t})=>{const{selection:n}=e,{empty:r,ranges:i}=n;return r||t&&i.forEach(t=>{e.removeMark(t.$from.pos,t.$to.pos)}),!0},xS=(e,t={})=>({tr:n,state:r,dispatch:i})=>{var o;const{extendEmptyMarkRange:s=!1}=t,{selection:a}=n,l=Jx(e,r.schema),{$from:c,empty:u,ranges:d}=a;if(!i)return!0;if(u&&s){let{from:e,to:t}=a;const r=null==(o=c.marks().find(e=>e.type===l))?void 0:o.attrs,i=nM(c,l,r);i&&(e=i.from,t=i.to),n.removeMark(e,t,l)}else d.forEach(e=>{n.removeMark(e.$from.pos,e.$to.pos,l)});return n.removeStoredMark(l),!0},MS=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null;const a=Zx("string"==typeof e?e:e.name,r.schema);return!!a&&("node"===a&&(o=Yx(e,r.schema)),"mark"===a&&(s=Jx(e,r.schema)),i&&n.selection.ranges.forEach(e=>{const i=e.$from.pos,a=e.$to.pos;let l,c,u,d;n.selection.empty?r.doc.nodesBetween(i,a,(e,t)=>{o&&o===e.type&&(u=Math.max(t,i),d=Math.min(t+e.nodeSize,a),l=t,c=e)}):r.doc.nodesBetween(i,a,(e,r)=>{r<i&&o&&o===e.type&&(u=Math.max(r,i),d=Math.min(r+e.nodeSize,a),l=r,c=e),r>=i&&r<=a&&(o&&o===e.type&&n.setNodeMarkup(r,void 0,{...e.attrs,...t}),s&&e.marks.length&&e.marks.forEach(o=>{if(s===o.type){const l=Math.max(r,i),c=Math.min(r+e.nodeSize,a);n.addMark(l,c,s.create({...o.attrs,...t}))}}))}),c&&(void 0!==l&&n.setNodeMarkup(l,void 0,{...c.attrs,...t}),s&&c.marks.length&&c.marks.forEach(e=>{s===e.type&&n.addMark(u,d,s.create({...e.attrs,...t}))}))}),!0)},SS=(e,t={})=>({state:n,dispatch:r})=>pu(Yx(e,n.schema),t)(n,r),ES=(e,t={})=>({state:n,dispatch:r})=>fu(Yx(e,n.schema),t)(n,r),CS=pM.create({name:"commands",addCommands:()=>({...fM})}),NS=pM.create({name:"delete",onUpdate({transaction:e,appendedTransactions:t}){var n,r,i;const o=()=>{var n,r,i,o;if(null!=(o=null==(i=null==(r=null==(n=this.editor.options.coreExtensionOptions)?void 0:n.delete)?void 0:r.filterTransaction)?void 0:i.call(r,e))?o:e.getMeta("y-sync$"))return;const s=function(e,t){const n=new $o(e);return t.forEach(e=>{e.steps.forEach(e=>{n.step(e)})}),n}(e.before,[e,...t]),a=function(e){const{mapping:t,steps:n}=e,r=[];return t.maps.forEach((e,i)=>{const o=[];if(e.ranges.length)e.forEach((e,t)=>{o.push({from:e,to:t})});else{const{from:e,to:t}=n[i];if(void 0===e||void 0===t)return;o.push({from:e,to:t})}o.forEach(({from:e,to:n})=>{const o=t.slice(i).map(e,-1),s=t.slice(i).map(n),a=t.invert().map(o,-1),l=t.invert().map(s);r.push({oldRange:{from:a,to:l},newRange:{from:o,to:s}})})}),Xx(r)}(s);a.forEach(t=>{s.mapping.mapResult(t.oldRange.from).deletedAfter&&s.mapping.mapResult(t.oldRange.to).deletedBefore&&s.before.nodesBetween(t.oldRange.from,t.oldRange.to,(n,r)=>{const i=r+n.nodeSize-2,o=t.oldRange.from<=r&&i<=t.oldRange.to;this.editor.emit("delete",{type:"node",node:n,from:r,to:i,newFrom:s.mapping.map(r),newTo:s.mapping.map(i),deletedRange:t.oldRange,newRange:t.newRange,partial:!o,editor:this.editor,transaction:e,combinedTransform:s})})});const l=s.mapping;s.steps.forEach((t,n)=>{var r,i;if(t instanceof lo){const o=l.slice(n).map(t.from,-1),a=l.slice(n).map(t.to),c=l.invert().map(o,-1),u=l.invert().map(a),d=null==(r=s.doc.nodeAt(o-1))?void 0:r.marks.some(e=>e.eq(t.mark)),p=null==(i=s.doc.nodeAt(a))?void 0:i.marks.some(e=>e.eq(t.mark));this.editor.emit("delete",{type:"mark",mark:t.mark,from:t.from,to:t.to,deletedRange:{from:c,to:u},newRange:{from:o,to:a},partial:Boolean(p||d),editor:this.editor,transaction:e,combinedTransform:s})}})};null==(i=null==(r=null==(n=this.editor.options.coreExtensionOptions)?void 0:n.delete)?void 0:r.async)||i?setTimeout(o,0):o()}}),AS=pM.create({name:"drop",addProseMirrorPlugins(){return[new cs({key:new ps("tiptapDrop"),props:{handleDrop:(e,t,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),kS=pM.create({name:"editable",addProseMirrorPlugins(){return[new cs({key:new ps("editable"),props:{editable:()=>this.editor.options.editable}})]}}),TS=new ps("focusEvents"),OS=pM.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:e}=this;return[new cs({key:TS,props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;const r=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;const r=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1}}}})]}}),_S=pM.create({name:"keymap",addKeyboardShortcuts(){const e=()=>this.editor.commands.first(({commands:e})=>[()=>e.undoInputRule(),()=>e.command(({tr:t})=>{const{selection:n,doc:r}=t,{empty:i,$anchor:o}=n,{pos:s,parent:a}=o,l=o.parent.isTextblock&&s>0?t.doc.resolve(s-1):o,c=l.parent.type.spec.isolating,u=o.pos-o.parentOffset,d=c&&1===l.parent.childCount?u===o.pos:Uo.atStart(r).from===s;return!(!i||!a.type.isTextblock||a.textContent.length||!d||d&&"paragraph"===o.parent.type.name)&&e.clearNodes()}),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:e})=>[()=>e.deleteSelection(),()=>e.deleteCurrentNode(),()=>e.joinForward(),()=>e.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},i={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return TM()||HM()?i:r},addProseMirrorPlugins(){return[new cs({key:new ps("clearDocument"),appendTransaction:(e,t,n)=>{if(e.some(e=>e.getMeta("composition")))return;const r=e.some(e=>e.docChanged)&&!t.doc.eq(n.doc),i=e.some(e=>e.getMeta("preventClearDocument"));if(!r||i)return;const{empty:o,from:s,to:a}=t.selection,l=Uo.atStart(t.doc).from,c=Uo.atEnd(t.doc).to;if(o||!(s===l&&a===c))return;if(!sM(n.doc))return;const u=n.tr,d=jx({state:n,transaction:u}),{commands:p}=new Fx({editor:this.editor,state:d});return p.clearNodes(),u.steps.length?u:void 0}})]}}),RS=pM.create({name:"paste",addProseMirrorPlugins(){return[new cs({key:new ps("tiptapPaste"),props:{handlePaste:(e,t,n)=>{this.editor.emit("paste",{editor:this.editor,event:t,slice:n})}}})]}}),DS=pM.create({name:"tabindex",addProseMirrorPlugins(){return[new cs({key:new ps("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),IS=class e extends dM{constructor(){super(...arguments),this.type="node"}static create(t={}){const n="function"==typeof t?t():t;return new e(n)}configure(e){return super.configure(e)}extend(e){const t="function"==typeof e?e():e;return super.extend(t)}},LS=IS.create({name:"tableCell",addOptions:()=>({HTMLAttributes:{}}),content:"block+",addAttributes:()=>({colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?t.split(",").map(e=>parseInt(e,10)):null}}}),tableRole:"cell",isolating:!0,parseHTML:()=>[{tag:"td"}],renderHTML({HTMLAttributes:e}){return["td",Gx(this.options.HTMLAttributes,e),0]}}),BS=IS.create({name:"tableHeader",addOptions:()=>({HTMLAttributes:{}}),content:"block+",addAttributes:()=>({colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?t.split(",").map(e=>parseInt(e,10)):null}}}),tableRole:"header_cell",isolating:!0,parseHTML:()=>[{tag:"th"}],renderHTML({HTMLAttributes:e}){return["th",Gx(this.options.HTMLAttributes,e),0]}}),zS=IS.create({name:"tableRow",addOptions:()=>({HTMLAttributes:{}}),content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML:()=>[{tag:"tr"}],renderHTML({HTMLAttributes:e}){return["tr",Gx(this.options.HTMLAttributes,e),0]}});function PS(e,t){return t?["width",`${Math.max(t,e)}px`]:["min-width",`${e}px`]}function jS(e,t,n,r,i,o){var s;let a=0,l=!0,c=t.firstChild;const u=e.firstChild;if(null!==u)for(let e=0,n=0;e<u.childCount;e+=1){const{colspan:s,colwidth:d}=u.child(e).attrs;for(let e=0;e<s;e+=1,n+=1){const s=i===n?o:d&&d[e],u=s?`${s}px`:"";if(a+=s||r,s||(l=!1),c){if(c.style.width!==u){const[e,t]=PS(r,s);c.style.setProperty(e,t)}c=c.nextSibling}else{const e=document.createElement("col"),[n,i]=PS(r,s);e.style.setProperty(n,i),t.appendChild(e)}}}for(;c;){const e=c.nextSibling;null==(s=c.parentNode)||s.removeChild(c),c=e}l?(n.style.width=`${a}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${a}px`)}var FS=class{constructor(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),jS(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type===this.node.type&&(this.node=e,jS(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return"attributes"===e.type&&(e.target===this.table||this.colgroup.contains(e.target))}};function $S(e,t){return t?e.createChecked(null,t):e.createAndFill()}function HS(e,t,n,r,i){const o=function(e){if(e.cached.tableNodeTypes)return e.cached.tableNodeTypes;const t={};return Object.keys(e.nodes).forEach(n=>{const r=e.nodes[n];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}(e),s=[],a=[];for(let e=0;e<n;e+=1){const e=$S(o.cell,i);if(e&&a.push(e),r){const e=$S(o.header_cell,i);e&&s.push(e)}}const l=[];for(let e=0;e<t;e+=1)l.push(o.row.createChecked(null,r&&0===e?s:a));return o.table.createChecked(null,l)}var US=({editor:e})=>{const{selection:t}=e.state;if(!(t instanceof Aw))return!1;let n=0;const r=qx(t.ranges[0].$from,e=>"table"===e.type.name);null==r||r.node.descendants(e=>{if("table"===e.type.name)return!1;["tableCell","tableHeader"].includes(e.type.name)&&(n+=1)});return n===t.ranges.length&&(e.commands.deleteTable(),!0)},qS=IS.create({name:"table",addOptions:()=>({HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:FS,lastColumnResizable:!0,allowTableNodeSelection:!1}),content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML:()=>[{tag:"table"}],renderHTML({node:e,HTMLAttributes:t}){const{colgroup:n,tableWidth:r,tableMinWidth:i}=function(e,t,n,r){let i=0,o=!0;const s=[],a=e.firstChild;if(!a)return{};for(let e=0,l=0;e<a.childCount;e+=1){const{colspan:c,colwidth:u}=a.child(e).attrs;for(let e=0;e<c;e+=1,l+=1){const a=n===l?r:u&&u[e];i+=a||t,a||(o=!1);const[c,d]=PS(t,a);s.push(["col",{style:`${c}: ${d}`}])}}const l=o?`${i}px`:"",c=o?"":`${i}px`;return{colgroup:["colgroup",{},...s],tableWidth:l,tableMinWidth:c}}(e,this.options.cellMinWidth);return["table",Gx(this.options.HTMLAttributes,t,{style:r?`width: ${r}`:`min-width: ${i}`}),n,["tbody",0]]},addCommands:()=>({insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:o})=>{const s=HS(o.schema,e,t,n);if(i){const e=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(Ko.near(r.doc.resolve(e)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>Lw(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>Bw(e,t),deleteColumn:()=>({state:e,dispatch:t})=>Pw(e,t),addRowBefore:()=>({state:e,dispatch:t})=>Fw(e,t),addRowAfter:()=>({state:e,dispatch:t})=>$w(e,t),deleteRow:()=>({state:e,dispatch:t})=>Uw(e,t),deleteTable:()=>({state:e,dispatch:t})=>Xw(e,t),mergeCells:()=>({state:e,dispatch:t})=>Vw(e,t),splitCell:()=>({state:e,dispatch:t})=>Ww(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>Jw("column")(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>Jw("row")(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>Yw(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>!!Vw(e,t)||Ww(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>Kw(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>Zw(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>Zw(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&Rw(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){const n=Aw.create(t.doc,e.anchorCell,e.headCell);t.setSelection(n)}return!0}}),addKeyboardShortcuts(){return{Tab:()=>!!this.editor.commands.goToNextCell()||!!this.editor.can().addRowAfter()&&this.editor.chain().addRowAfter().goToNextCell().run(),"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:US,"Mod-Backspace":US,Delete:US,"Mod-Delete":US}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[vx({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Cx({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema:e=>({tableRole:Kx(Wx(e,"tableRole",{name:e.name,options:e.options,storage:e.storage}))})});pM.create({name:"tableKit",addExtensions(){const e=[];return!1!==this.options.table&&e.push(qS.configure(this.options.table)),!1!==this.options.tableCell&&e.push(LS.configure(this.options.tableCell)),!1!==this.options.tableHeader&&e.push(BS.configure(this.options.tableHeader)),!1!==this.options.tableRow&&e.push(zS.configure(this.options.tableRow)),e}});const VS="(div | paragraph | heading | bulletList | orderedList | blockquote | codeBlock | horizontalRule | image | imageUploadNode)+",WS=LS.extend({content:VS}),KS=BS.extend({content:VS}),GS=Kp.create({name:"div",group:"block",content:"inline*",parseHTML:()=>[{tag:"div"}],renderHTML:({HTMLAttributes:e})=>["div",e,0],addKeyboardShortcuts(){return{Enter:()=>{const{state:e}=this.editor,{$from:t}=e.selection;return"div"===t.parent.type.name&&this.editor.chain().focus().setNode("paragraph").splitBlock().run()},Backspace:()=>{const{state:e}=this.editor,{$from:t,empty:n}=e.selection;if("div"!==t.parent.type.name)return!1;if(!n)return!1;const r=t.parent.textContent;if(0===r.length)return 1===e.doc.childCount;if(1===r.length&&1===t.parentOffset){const{tr:n}=e;return n.delete(t.pos-1,t.pos),this.editor.view.dispatch(n),!0}return!1}}}}),JS=xd.create({name:"ensureEmptyRootIsDiv",addProseMirrorPlugins(){const e=new ps(this.name);return[new cs({key:e,appendTransaction(e,t,n){if(!e.some(e=>e.docChanged))return null;const{doc:r}=n;if(1!==r.childCount)return null;const i=r.firstChild;if("paragraph"!==i.type.name||i.content.size>0)return null;const o=n.schema.nodes.div;if(!o)return null;const s=i.nodeSize;return n.tr.replaceWith(0,s,o.create())}})]}}),YS="pie-toolbar",ZS=e,{IconButton:XS}=n,{Check:QS}=o,{styled:eE}=r,tE=i,nE=eE(XS)({verticalAlign:"top",width:"28px",height:"28px",color:"var(--editable-html-toolbar-check, #00bb00)",padding:"4px"}),rE=({onClick:e,doneButtonRef:t})=>ZS.createElement(nE,{"aria-label":"Done",buttonRef:t,onClick:e},ZS.createElement(QS,null));rE.propTypes={onClick:tE.func,doneButtonRef:tE.func};const iE=rE,oE=e,{IconButton:sE}=n,{Delete:aE}=o,{styled:lE}=r;const cE=lE("div",{shouldForwardProp:e=>!["showDone","toolbarAlignment","isFocused","autoWidth","isHidden"].includes(e)})(({showDone:e,toolbarAlignment:t,isFocused:n,autoWidth:r,isHidden:i})=>({position:"absolute",zIndex:10,cursor:"pointer",justifyContent:"space-between",background:"var(--editable-html-toolbar-bg, #efefef)",minWidth:e?"280px":"265px",margin:"5px 0 0 0",padding:"2px",boxShadow:"0px 1px 5px 0px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 3px 1px -2px rgba(0, 0, 0, 0.12)",boxSizing:"border-box",display:"flex",opacity:1,..."right"===t&&{right:0},...r?{width:"auto"}:{width:"100%"},...i&&{visibility:"hidden"}})),uE=lE(sE)({width:"28px",height:"28px",padding:"4px",verticalAlign:"top"}),dE=lE("div")({display:"flex"});function pE(e){const{children:t,deletable:n,toolbarOpts:r,autoWidth:i,isFocused:o,doneButtonRef:s,onDelete:a,showDone:l,onDone:c,style:u}=e,d=void 0!==r.minWidth?{minWidth:r.minWidth}:{};return oE.createElement(cE,{className:YS,showDone:l,toolbarAlignment:r.alignment,isFocused:r.alwaysVisible||o,autoWidth:i,isHidden:!0===r.isHidden,style:{...d,...u}},t,oE.createElement(dE,null,n&&oE.createElement(uE,{"aria-label":"Delete",onMouseDown:e=>function(e){let t,n=e[0],r=1;for(;r<e.length;){const i=e[r],o=e[r+1];if(r+=2,("optionalAccess"===i||"optionalCall"===i)&&null==n)return;"access"===i||"optionalAccess"===i?(t=n,n=o(n)):"call"!==i&&"optionalCall"!==i||(n=o((...e)=>n.call(t,...e)),t=void 0)}return n}([a,"optionalCall",t=>t(e)])},oE.createElement(aE,null)),l&&oE.createElement(iE,{doneButtonRef:s,onClick:c})))}const hE=e,{useEffect:fE}=e,{useRef:mE}=e,{useState:gE}=e,yE=t,vE=i;const bE=e=>{const{editor:t,node:n,getPos:r,options:i,selected:o}=e,{attrs:s}=n,{value:a}=s,{respAreaToolbar:l,error:c}=i,u=r(),[d,p]=gE(!1),h=l([n,u],t,()=>{}),f=mE(null);let m;if(c){const e=c(),t=parseInt(s.index,10);m=!!function(e){let t,n=e[0],r=1;for(;r<e.length;){const i=e[r],o=e[r+1];if(r+=2,("optionalAccess"===i||"optionalCall"===i)&&null==n)return;"access"===i||"optionalAccess"===i?(t=n,n=o(n)):"call"!==i&&"optionalCall"!==i||(n=o((...e)=>n.call(t,...e)),t=void 0)}return n}([e,"optionalAccess",e=>e[t],"optionalAccess",e=>e[0]])}return fE(()=>{const{selection:e}=t.state,r=e.from+n.nodeSize===e.to;o?r&&p(o):p(o)},[t,n,o]),fE(()=>{const e=e=>{e.target.closest(".insert-character-dialog")||e.target.closest("[data-toolbar-for]")||!f.current||f.current.contains(e.target)||e.target.closest("[data-inline-node]")||p(!1)};return d?document.addEventListener("mousedown",e):document.removeEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[d]),hE.createElement(jh,{className:"drag-in-the-blank","data-selected":o,style:{display:"inline-flex",minHeight:"55px",position:"relative",cursor:"pointer"}},hE.createElement("div",{...s,style:{display:"inline-flex",width:"100%",minHeight:"46px",height:"46px",backgroundColor:"#FFF",border:"1px solid "+(m?"red":"#C0C3CF"),boxSizing:"border-box",borderRadius:"4px",overflow:"hidden",padding:"12px 21px",margin:"0 4px",minWidth:"178px",visibility:d?"hidden":"visible"},onClick:()=>p(!0),dangerouslySetInnerHTML:{__html:a||"<div>&nbsp;</div>"}}),d&&hE.createElement("div",{ref:f,className:"absolute z-50 bg-white shadow-lg rounded p-2",style:{zIndex:1}},hE.createElement(h,null)),d&&t._tiptapContainerEl&&yE.createPortal(hE.createElement(pE,{deletable:!0,toolbarOpts:{minWidth:"auto"},autoWidth:!0,style:{top:-40,left:0,right:0},onDelete:()=>{const{tr:e}=t.state;e.delete(u,u+n.nodeSize),t._toolbarOpened=!1,t.view.dispatch(e),p(!1),t.commands.focus()},showDone:!1}),t._tiptapContainerEl))};bE.propTypes={attributes:vE.object,error:vE.any,value:vE.string,isFocused:vE.bool};const{useMemo:wE}=e,{useLayoutEffect:xE}=e,{useEffect:ME}=e,{useRef:SE}=e,{useCallback:EE}=e,CE="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement;function NE(e){const t=Object.prototype.toString.call(e);return"[object Window]"===t||"[object global]"===t}function AE(e){return"nodeType"in e}function kE(e){var t,n;return e?NE(e)?e:AE(e)&&null!=(t=null==(n=e.ownerDocument)?void 0:n.defaultView)?t:window:window}function TE(e){const{Document:t}=kE(e);return e instanceof t}function OE(e){return!NE(e)&&e instanceof kE(e).HTMLElement}function _E(e){return e instanceof kE(e).SVGElement}function RE(e){return e?NE(e)?e.document:AE(e)?TE(e)?e:OE(e)||_E(e)?e.ownerDocument:document:document:document}const DE=CE?xE:ME;function IE(e){const t=SE(e);return DE(()=>{t.current=e}),EE(function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return null==t.current?void 0:t.current(...n)},[])}function LE(e,t){void 0===t&&(t=[e]);const n=SE(e);return DE(()=>{n.current!==e&&(n.current=e)},t),n}function BE(e,t){const n=SE();return wE(()=>{const t=e(n.current);return n.current=t,t},[...t])}function zE(e){const t=IE(e),n=SE(null),r=EE(e=>{e!==n.current&&(null==t||t(e,n.current)),n.current=e},[]);return[n,r]}function PE(e){const t=SE();return ME(()=>{t.current=e},[e]),t.current}let jE={};function FE(e,t){return wE(()=>{if(t)return t;const n=null==jE[e]?0:jE[e]+1;return jE[e]=n,e+"-"+n},[e,t])}function $E(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((t,n)=>{const r=Object.entries(n);for(const[n,i]of r){const r=t[n];null!=r&&(t[n]=r+e*i)}return t},{...t})}}const HE=$E(1),UE=$E(-1);function qE(e){if(!e)return!1;const{KeyboardEvent:t}=kE(e.target);return t&&e instanceof t}function VE(e){if(function(e){if(!e)return!1;const{TouchEvent:t}=kE(e.target);return t&&e instanceof t}(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return function(e){return"clientX"in e&&"clientY"in e}(e)?{x:e.clientX,y:e.clientY}:null}const WE=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[WE.Translate.toString(e),WE.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),KE="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function GE(e){return e.matches(KE)?e:e.querySelector(KE)}const JE=e,{useState:YE}=e,{useCallback:ZE}=e,XE={display:"none"};function QE(e){let{id:t,value:n}=e;return JE.createElement("div",{id:t,style:XE},n)}function eC(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;return JE.createElement("div",{id:t,style:{position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"},role:"status","aria-live":r,"aria-atomic":!0},n)}const tC=e,{createContext:nC}=e,{useContext:rC}=e,{useEffect:iC}=e,{useState:oC}=e,{useCallback:sC}=e,{useMemo:aC}=e,{useRef:lC}=e,{memo:cC}=e,{useReducer:uC}=e,{cloneElement:dC}=e,{forwardRef:pC}=e,{createPortal:hC}=t,{unstable_batchedUpdates:fC}=t,mC=nC(null);const gC={draggable:"\n To pick up a draggable item, press the space bar.\n While dragging, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n "},yC={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function vC(e){let{announcements:t=yC,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=gC}=e;const{announce:o,announcement:s}=function(){const[e,t]=YE("");return{announce:ZE(e=>{null!=e&&t(e)},[]),announcement:e}}(),a=FE("DndLiveRegion"),[l,c]=oC(!1);if(iC(()=>{c(!0)},[]),function(e){const t=rC(mC);iC(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}(aC(()=>({onDragStart(e){let{active:n}=e;o(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&o(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;o(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;o(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;o(t.onDragCancel({active:n,over:r}))}}),[o,t])),!l)return null;const u=tC.createElement(tC.Fragment,null,tC.createElement(QE,{id:r,value:i.draggable}),tC.createElement(eC,{id:a,announcement:s}));return n?hC(u,n):u}var bC;function wC(){}!function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"}(bC||(bC={}));const xC=Object.freeze({x:0,y:0});function MC(e,t){const n=VE(e);if(!n)return"0 0";return(n.x-t.left)/t.width*100+"% "+(n.y-t.top)/t.height*100+"%"}function SC(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function EC(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),o=Math.min(t.top+t.height,e.top+e.height),s=i-r,a=o-n;if(r<i&&n<o){const n=t.width*t.height,r=e.width*e.height,i=s*a;return Number((i/(n+r-i)).toFixed(4))}return 0}const CC=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const i=[];for(const e of r){const{id:r}=e,o=n.get(r);if(o){const n=EC(o,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(SC)};function NC(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:xC}const AC=(kC=1,function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return n.reduce((e,t)=>({...e,top:e.top+kC*t.y,bottom:e.bottom+kC*t.y,left:e.left+kC*t.x,right:e.right+kC*t.x}),{...e})});var kC;function TC(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}const OC={ignoreTransform:!1};function _C(e,t){void 0===t&&(t=OC);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:t,transformOrigin:r}=kE(e).getComputedStyle(e);t&&(n=function(e,t,n){const r=TC(t);if(!r)return e;const{scaleX:i,scaleY:o,x:s,y:a}=r,l=e.left-s-(1-i)*parseFloat(n),c=e.top-a-(1-o)*parseFloat(n.slice(n.indexOf(" ")+1)),u=i?e.width/i:e.width,d=o?e.height/o:e.height;return{width:u,height:d,top:c,right:l+u,bottom:c+d,left:l}}(n,t,r))}const{top:r,left:i,width:o,height:s,bottom:a,right:l}=n;return{top:r,left:i,width:o,height:s,bottom:a,right:l}}function RC(e){return _C(e,{ignoreTransform:!0})}function DC(e,t){const n=[];return e?function r(i){if(null!=t&&n.length>=t)return n;if(!i)return n;if(TE(i)&&null!=i.scrollingElement&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!OE(i)||_E(i))return n;if(n.includes(i))return n;const o=kE(e).getComputedStyle(i);return i!==e&&function(e,t){void 0===t&&(t=kE(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(e=>{const r=t[e];return"string"==typeof r&&n.test(r)})}(i,o)&&n.push(i),function(e,t){return void 0===t&&(t=kE(e).getComputedStyle(e)),"fixed"===t.position}(i,o)?n:r(i.parentNode)}(e):n}function IC(e){const[t]=DC(e,1);return null!=t?t:null}function LC(e){return CE&&e?NE(e)?e:AE(e)?TE(e)||e===RE(e).scrollingElement?window:OE(e)?e:null:null:null}function BC(e){return NE(e)?e.scrollX:e.scrollLeft}function zC(e){return NE(e)?e.scrollY:e.scrollTop}function PC(e){return{x:BC(e),y:zC(e)}}var jC;function FC(e){return!(!CE||!e)&&e===document.scrollingElement}function $C(e){const t={x:0,y:0},n=FC(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}!function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"}(jC||(jC={}));const HC={x:.2,y:.2};function UC(e,t,n,r,i){let{top:o,left:s,right:a,bottom:l}=n;void 0===r&&(r=10),void 0===i&&(i=HC);const{isTop:c,isBottom:u,isLeft:d,isRight:p}=$C(e),h={x:0,y:0},f={x:0,y:0},m=t.height*i.y,g=t.width*i.x;return!c&&o<=t.top+m?(h.y=jC.Backward,f.y=r*Math.abs((t.top+m-o)/m)):!u&&l>=t.bottom-m&&(h.y=jC.Forward,f.y=r*Math.abs((t.bottom-m-l)/m)),!p&&a>=t.right-g?(h.x=jC.Forward,f.x=r*Math.abs((t.right-g-a)/g)):!d&&s<=t.left+g&&(h.x=jC.Backward,f.x=r*Math.abs((t.left+g-s)/g)),{direction:h,speed:f}}function qC(e){if(e===document.scrollingElement){const{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}const{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function VC(e){return e.reduce((e,t)=>HE(e,PC(t)),xC)}function WC(e,t){if(void 0===t&&(t=_C),!e)return;const{top:n,left:r,bottom:i,right:o}=t(e);IC(e)&&(i<=0||o<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const KC=[["x",["left","right"],function(e){return e.reduce((e,t)=>e+BC(t),0)}],["y",["top","bottom"],function(e){return e.reduce((e,t)=>e+zC(t),0)}]];class GC{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const n=DC(t),r=VC(n);this.rect={...e},this.width=e.width,this.height=e.height;for(const[e,t,i]of KC)for(const o of t)Object.defineProperty(this,o,{get:()=>{const t=i(n),s=r[e]-t;return this.rect[o]+s},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class JC{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>{var t;return null==(t=this.target)?void 0:t.removeEventListener(...e)})},this.target=e}add(e,t,n){var r;null==(r=this.target)||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}}function YC(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return"number"==typeof t?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t&&r>t.y}var ZC,XC;function QC(e){e.preventDefault()}function eN(e){e.stopPropagation()}!function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"}(ZC||(ZC={})),function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"}(XC||(XC={}));const tN={start:[XC.Space,XC.Enter],cancel:[XC.Esc],end:[XC.Space,XC.Enter,XC.Tab]},nN=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case XC.Right:return{...n,x:n.x+25};case XC.Left:return{...n,x:n.x-25};case XC.Down:return{...n,y:n.y+25};case XC.Up:return{...n,y:n.y-25}}};class rN{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:t}}=e;this.props=e,this.listeners=new JC(RE(t)),this.windowListeners=new JC(kE(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(ZC.Resize,this.handleCancel),this.windowListeners.add(ZC.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(ZC.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&WC(n),t(xC)}handleKeyDown(e){if(qE(e)){const{active:t,context:n,options:r}=this.props,{keyboardCodes:i=tN,coordinateGetter:o=nN,scrollBehavior:s="smooth"}=r,{code:a}=e;if(i.end.includes(a))return void this.handleEnd(e);if(i.cancel.includes(a))return void this.handleCancel(e);const{collisionRect:l}=n.current,c=l?{x:l.left,y:l.top}:xC;this.referenceCoordinates||(this.referenceCoordinates=c);const u=o(e,{active:t,context:n.current,currentCoordinates:c});if(u){const t=UE(u,c),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(const n of i){const i=e.code,{isTop:o,isRight:a,isLeft:l,isBottom:c,maxScroll:d,minScroll:p}=$C(n),h=qC(n),f={x:Math.min(i===XC.Right?h.right-h.width/2:h.right,Math.max(i===XC.Right?h.left:h.left+h.width/2,u.x)),y:Math.min(i===XC.Down?h.bottom-h.height/2:h.bottom,Math.max(i===XC.Down?h.top:h.top+h.height/2,u.y))},m=i===XC.Right&&!a||i===XC.Left&&!l,g=i===XC.Down&&!c||i===XC.Up&&!o;if(m&&f.x!==u.x){const e=n.scrollLeft+t.x,o=i===XC.Right&&e<=d.x||i===XC.Left&&e>=p.x;if(o&&!t.y)return void n.scrollTo({left:e,behavior:s});r.x=o?n.scrollLeft-e:i===XC.Right?n.scrollLeft-d.x:n.scrollLeft-p.x,r.x&&n.scrollBy({left:-r.x,behavior:s});break}if(g&&f.y!==u.y){const e=n.scrollTop+t.y,o=i===XC.Down&&e<=d.y||i===XC.Up&&e>=p.y;if(o&&!t.x)return void n.scrollTo({top:e,behavior:s});r.y=o?n.scrollTop-e:i===XC.Down?n.scrollTop-d.y:n.scrollTop-p.y,r.y&&n.scrollBy({top:-r.y,behavior:s});break}}this.handleMove(e,HE(UE(u,this.referenceCoordinates),r))}}}handleMove(e,t){const{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){const{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){const{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}function iN(e){return Boolean(e&&"distance"in e)}function oN(e){return Boolean(e&&"delay"in e)}rN.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=tN,onActivation:i}=t,{active:o}=n;const{code:s}=e.nativeEvent;if(r.start.includes(s)){const t=o.activatorNode.current;return(!t||e.target===t)&&(e.preventDefault(),null==i||i({event:e.nativeEvent}),!0)}return!1}}];class sN{constructor(e,t,n){var r;void 0===n&&(n=function(e){const{EventTarget:t}=kE(e);return e instanceof t?e:RE(e)}(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;const{event:i}=e,{target:o}=i;this.props=e,this.events=t,this.document=RE(o),this.documentListeners=new JC(this.document),this.listeners=new JC(n),this.windowListeners=new JC(kE(o)),this.initialCoordinates=null!=(r=VE(i))?r:xC,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(ZC.Resize,this.handleCancel),this.windowListeners.add(ZC.DragStart,QC),this.windowListeners.add(ZC.VisibilityChange,this.handleCancel),this.windowListeners.add(ZC.ContextMenu,QC),this.documentListeners.add(ZC.Keydown,this.handleKeydown),t){if(null!=n&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(oN(t))return this.timeoutId=setTimeout(this.handleStart,t.delay),void this.handlePending(t);if(iN(t))return void this.handlePending(t)}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),null!==this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){const{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){const{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(ZC.Click,eN,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(ZC.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){var t;const{activated:n,initialCoordinates:r,props:i}=this,{onMove:o,options:{activationConstraint:s}}=i;if(!r)return;const a=null!=(t=VE(e))?t:xC,l=UE(r,a);if(!n&&s){if(iN(s)){if(null!=s.tolerance&&YC(l,s.tolerance))return this.handleCancel();if(YC(l,s.distance))return this.handleStart()}return oN(s)&&YC(l,s.tolerance)?this.handleCancel():void this.handlePending(s,l)}e.cancelable&&e.preventDefault(),o(a)}handleEnd(){const{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){const{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===XC.Esc&&this.handleCancel()}removeTextSelection(){var e;null==(e=this.document.getSelection())||e.removeAllRanges()}}const aN={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class lN extends sN{constructor(e){const{event:t}=e,n=RE(t.target);super(e,aN,n)}}lN.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!(!n.isPrimary||0!==n.button)&&(null==r||r({event:n}),!0)}}];const cN={move:{name:"mousemove"},end:{name:"mouseup"}};var uN;!function(e){e[e.RightClick=2]="RightClick"}(uN||(uN={}));(class extends sN{constructor(e){super(e,cN,RE(e.event.target))}}).activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button!==uN.RightClick&&(null==r||r({event:n}),!0)}}];const dN={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};var pN,hN;function fN(e){let{acceleration:t,activator:n=pN.Pointer,canScroll:r,draggingRect:i,enabled:o,interval:s=5,order:a=hN.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:u,delta:d,threshold:p}=e;const h=function(e){let{delta:t,disabled:n}=e;const r=PE(t);return BE(e=>{if(n||!r||!e)return mN;const i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[jC.Backward]:e.x[jC.Backward]||-1===i.x,[jC.Forward]:e.x[jC.Forward]||1===i.x},y:{[jC.Backward]:e.y[jC.Backward]||-1===i.y,[jC.Forward]:e.y[jC.Forward]||1===i.y}}},[n,t,r])}({delta:d,disabled:!o}),[f,m]=function(){const e=SE(null);return[EE((t,n)=>{e.current=setInterval(t,n)},[]),EE(()=>{null!==e.current&&(clearInterval(e.current),e.current=null)},[])]}(),g=lC({x:0,y:0}),y=lC({x:0,y:0}),v=aC(()=>{switch(n){case pN.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case pN.DraggableRect:return i}},[n,i,l]),b=lC(null),w=sC(()=>{const e=b.current;if(!e)return;const t=g.current.x*y.current.x,n=g.current.y*y.current.y;e.scrollBy(t,n)},[]),x=aC(()=>a===hN.TreeOrder?[...c].reverse():c,[a,c]);iC(()=>{if(o&&c.length&&v){for(const e of x){if(!1===(null==r?void 0:r(e)))continue;const n=c.indexOf(e),i=u[n];if(!i)continue;const{direction:o,speed:a}=UC(e,i,v,t,p);for(const e of["x","y"])h[e][o[e]]||(a[e]=0,o[e]=0);if(a.x>0||a.y>0)return m(),b.current=e,f(w,s),g.current=a,void(y.current=o)}g.current={x:0,y:0},y.current={x:0,y:0},m()}else m()},[t,w,r,m,o,s,JSON.stringify(v),JSON.stringify(h),f,c,x,u,JSON.stringify(p)])}(class extends sN{constructor(e){super(e,dN)}static setup(){return window.addEventListener(dN.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(dN.move.name,e)};function e(){}}}).activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:i}=n;return!(i.length>1)&&(null==r||r({event:n}),!0)}}],function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"}(pN||(pN={})),function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"}(hN||(hN={}));const mN={x:{[jC.Backward]:!1,[jC.Forward]:!1},y:{[jC.Backward]:!1,[jC.Forward]:!1}};var gN,yN;!function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"}(gN||(gN={})),function(e){e.Optimized="optimized"}(yN||(yN={}));const vN=new Map;function bN(e,t){return BE(n=>e?n||("function"==typeof t?t(e):e):null,[t,e])}function wN(e){let{callback:t,disabled:n}=e;const r=IE(t),i=aC(()=>{if(n||"undefined"==typeof window||void 0===window.ResizeObserver)return;const{ResizeObserver:e}=window;return new e(r)},[n]);return iC(()=>()=>null==i?void 0:i.disconnect(),[i]),i}function xN(e){return new GC(_C(e),e)}function MN(e,t,n){void 0===t&&(t=xN);const[r,i]=oC(null);function o(){i(r=>{if(!e)return null;var i;if(!1===e.isConnected)return null!=(i=null!=r?r:n)?i:null;const o=t(e);return JSON.stringify(r)===JSON.stringify(o)?r:o})}const s=function(e){let{callback:t,disabled:n}=e;const r=IE(t),i=aC(()=>{if(n||"undefined"==typeof window||void 0===window.MutationObserver)return;const{MutationObserver:e}=window;return new e(r)},[r,n]);return iC(()=>()=>null==i?void 0:i.disconnect(),[i]),i}({callback(t){if(e)for(const n of t){const{type:t,target:r}=n;if("childList"===t&&r instanceof HTMLElement&&r.contains(e)){o();break}}}}),a=wN({callback:o});return DE(()=>{o(),e?(null==a||a.observe(e),null==s||s.observe(document.body,{childList:!0,subtree:!0})):(null==a||a.disconnect(),null==s||s.disconnect())},[e]),r}const SN=[];function EN(e,t){void 0===t&&(t=[]);const n=lC(null);return iC(()=>{n.current=null},t),iC(()=>{const t=e!==xC;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?UE(e,n.current):xC}function CN(e){return aC(()=>e?function(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}(e):null,[e])}const NN=[];function AN(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return OE(t)?t:e}const kN=[{sensor:lN,options:{}},{sensor:rN,options:{}}],TN={current:{}},ON={draggable:{measure:RC},droppable:{measure:RC,strategy:gN.WhileDragging,frequency:yN.Optimized},dragOverlay:{measure:_C}};class _N extends Map{get(e){var t;return null!=e&&null!=(t=super.get(e))?t:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){var t,n;return null!=(t=null==(n=this.get(e))?void 0:n.node.current)?t:void 0}}const RN={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new _N,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:wC},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:ON,measureDroppableContainers:wC,windowRect:null,measuringScheduled:!1},DN={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:wC,draggableNodes:new Map,over:null,measureDroppableContainers:wC},IN=nC(DN),LN=nC(RN);function BN(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new _N}}}function zN(e,t){switch(t.type){case bC.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case bC.DragMove:return null==e.draggable.active?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case bC.DragEnd:case bC.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case bC.RegisterDroppable:{const{element:n}=t,{id:r}=n,i=new _N(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case bC.SetDroppableDisabled:{const{id:n,key:r,disabled:i}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const s=new _N(e.droppable.containers);return s.set(n,{...o,disabled:i}),{...e,droppable:{...e.droppable,containers:s}}}case bC.UnregisterDroppable:{const{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;const o=new _N(e.droppable.containers);return o.delete(n),{...e,droppable:{...e.droppable,containers:o}}}default:return e}}function PN(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:i}=rC(IN),o=PE(r),s=PE(null==n?void 0:n.id);return iC(()=>{if(!t&&!r&&o&&null!=s){if(!qE(o))return;if(document.activeElement===o.target)return;const e=i.get(s);if(!e)return;const{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(const e of[t.current,n.current]){if(!e)continue;const t=GE(e);if(t){t.focus();break}}})}},[r,t,i,s,o]),null}function jN(e,t){let{transform:n,...r}=t;return null!=e&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}const FN=nC({...xC,scaleX:1,scaleY:1});var $N;!function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"}($N||($N={})),cC(function(e){var t,n,r,i;let{id:o,accessibility:s,autoScroll:a=!0,children:l,sensors:c=kN,collisionDetection:u=CC,measuring:d,modifiers:p,...h}=e;const f=uC(zN,void 0,BN),[m,g]=f,[y,v]=function(){const[e]=oC(()=>new Set),t=sC(t=>(e.add(t),()=>e.delete(t)),[e]);return[sC(t=>{let{type:n,event:r}=t;e.forEach(e=>{var t;return null==(t=e[n])?void 0:t.call(e,r)})},[e]),t]}(),[b,w]=oC($N.Uninitialized),x=b===$N.Initialized,{draggable:{active:M,nodes:S,translate:E},droppable:{containers:C}}=m,N=null!=M?S.get(M):null,A=lC({initial:null,translated:null}),k=aC(()=>{var e;return null!=M?{id:M,data:null!=(e=null==N?void 0:N.data)?e:TN,rect:A}:null},[M,N]),T=lC(null),[O,_]=oC(null),[R,D]=oC(null),I=LE(h,Object.values(h)),L=FE("DndDescribedBy",o),B=aC(()=>C.getEnabled(),[C]),z=function(e){return aC(()=>({draggable:{...ON.draggable,...null==e?void 0:e.draggable},droppable:{...ON.droppable,...null==e?void 0:e.droppable},dragOverlay:{...ON.dragOverlay,...null==e?void 0:e.dragOverlay}}),[null==e?void 0:e.draggable,null==e?void 0:e.droppable,null==e?void 0:e.dragOverlay])}(d),{droppableRects:P,measureDroppableContainers:j,measuringScheduled:F}=function(e,t){let{dragging:n,dependencies:r,config:i}=t;const[o,s]=oC(null),{frequency:a,measure:l,strategy:c}=i,u=lC(e),d=function(){switch(c){case gN.Always:return!1;case gN.BeforeDragging:return n;default:return!n}}(),p=LE(d),h=sC(function(e){void 0===e&&(e=[]),p.current||s(t=>null===t?e:t.concat(e.filter(e=>!t.includes(e))))},[p]),f=lC(null),m=BE(t=>{if(d&&!n)return vN;if(!t||t===vN||u.current!==e||null!=o){const t=new Map;for(let n of e){if(!n)continue;if(o&&o.length>0&&!o.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}const e=n.node.current,r=e?new GC(l(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,o,n,d,l]);return iC(()=>{u.current=e},[e]),iC(()=>{d||h()},[n,d]),iC(()=>{o&&o.length>0&&s(null)},[JSON.stringify(o)]),iC(()=>{d||"number"!=typeof a||null!==f.current||(f.current=setTimeout(()=>{h(),f.current=null},a))},[a,d,h,...r]),{droppableRects:m,measureDroppableContainers:h,measuringScheduled:null!=o}}(B,{dragging:x,dependencies:[E.x,E.y],config:z.droppable}),$=function(e,t){const n=null!=t?e.get(t):void 0,r=n?n.node.current:null;return BE(e=>{var n;return null==t?null:null!=(n=null!=r?r:e)?n:null},[r,t])}(S,M),H=aC(()=>R?VE(R):null,[R]),U=function(){const e=!1===(null==O?void 0:O.autoScrollEnabled),t="object"==typeof a?!1===a.enabled:!1===a,n=x&&!e&&!t;if("object"==typeof a)return{...a,enabled:n};return{enabled:n}}(),q=function(e,t){return bN(e,t)}($,z.draggable.measure);!function(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e;const o=lC(!1),{x:s,y:a}="boolean"==typeof i?{x:i,y:i}:i;DE(()=>{if(!s&&!a||!t)return void(o.current=!1);if(o.current||!r)return;const e=null==t?void 0:t.node.current;if(!e||!1===e.isConnected)return;const i=NC(n(e),r);if(s||(i.x=0),a||(i.y=0),o.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){const t=IC(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,s,a,r,n])}({activeNode:null!=M?S.get(M):null,config:U.layoutShiftCompensation,initialRect:q,measure:z.draggable.measure});const V=MN($,z.draggable.measure,q),W=MN($?$.parentElement:null),K=lC({activatorEvent:null,active:null,activeNode:$,collisionRect:null,collisions:null,droppableRects:P,draggableNodes:S,draggingNode:null,draggingNodeRect:null,droppableContainers:C,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),G=C.getNodeFor(null==(t=K.current.over)?void 0:t.id),J=function(e){let{measure:t}=e;const[n,r]=oC(null),i=wN({callback:sC(e=>{for(const{target:n}of e)if(OE(n)){r(e=>{const r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),o=sC(e=>{const n=AN(e);null==i||i.disconnect(),n&&(null==i||i.observe(n)),r(n?t(n):null)},[t,i]),[s,a]=zE(o);return aC(()=>({nodeRef:s,rect:n,setRef:a}),[n,s,a])}({measure:z.dragOverlay.measure}),Y=null!=(n=J.nodeRef.current)?n:$,Z=x?null!=(r=J.rect)?r:V:null,X=Boolean(J.nodeRef.current&&J.rect),Q=NC(ee=X?null:V,bN(ee));var ee;const te=CN(Y?kE(Y):null),ne=function(e){const t=lC(e),n=BE(n=>e?n&&n!==SN&&e&&t.current&&e.parentNode===t.current.parentNode?n:DC(e):SN,[e]);return iC(()=>{t.current=e},[e]),n}(x?null!=G?G:$:null),re=function(e,t){void 0===t&&(t=_C);const[n]=e,r=CN(n?kE(n):null),[i,o]=oC(NN);function s(){o(()=>e.length?e.map(e=>FC(e)?r:new GC(t(e),e)):NN)}const a=wN({callback:s});return DE(()=>{null==a||a.disconnect(),s(),e.forEach(e=>null==a?void 0:a.observe(e))},[e]),i}(ne),ie=jN(p,{transform:{x:E.x-Q.x,y:E.y-Q.y,scaleX:1,scaleY:1},activatorEvent:R,active:k,activeNodeRect:V,containerNodeRect:W,draggingNodeRect:Z,over:K.current.over,overlayNodeRect:J.rect,scrollableAncestors:ne,scrollableAncestorRects:re,windowRect:te}),oe=H?HE(H,E):null,se=function(e){const[t,n]=oC(null),r=lC(e),i=sC(e=>{const t=LC(e.target);t&&n(e=>e?(e.set(t,PC(t)),new Map(e)):null)},[]);return iC(()=>{const t=r.current;if(e!==t){o(t);const s=e.map(e=>{const t=LC(e);return t?(t.addEventListener("scroll",i,{passive:!0}),[t,PC(t)]):null}).filter(e=>null!=e);n(s.length?new Map(s):null),r.current=e}return()=>{o(e),o(t)};function o(e){e.forEach(e=>{const t=LC(e);null==t||t.removeEventListener("scroll",i)})}},[i,e]),aC(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>HE(e,t),xC):VC(e):xC,[e,t])}(ne),ae=EN(se),le=EN(se,[V]),ce=HE(ie,ae),ue=Z?AC(Z,ie):null,de=k&&ue?u({active:k,collisionRect:ue,droppableRects:P,droppableContainers:B,pointerCoordinates:oe}):null,pe=function(e,t){if(!e||0===e.length)return null;const[n]=e;return t?n[t]:n}(de,"id"),[he,fe]=oC(null),me=function(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}(X?ie:HE(ie,le),null!=(i=null==he?void 0:he.rect)?i:null,V),ge=lC(null),ye=sC((e,t)=>{let{sensor:n,options:r}=t;if(null==T.current)return;const i=S.get(T.current);if(!i)return;const o=e.nativeEvent,s=new n({active:T.current,activeNode:i,event:o,options:r,context:K,onAbort(e){if(!S.get(e))return;const{onDragAbort:t}=I.current,n={id:e};null==t||t(n),y({type:"onDragAbort",event:n})},onPending(e,t,n,r){if(!S.get(e))return;const{onDragPending:i}=I.current,o={id:e,constraint:t,initialCoordinates:n,offset:r};null==i||i(o),y({type:"onDragPending",event:o})},onStart(e){const t=T.current;if(null==t)return;const n=S.get(t);if(!n)return;const{onDragStart:r}=I.current,i={activatorEvent:o,active:{id:t,data:n.data,rect:A}};fC(()=>{null==r||r(i),w($N.Initializing),g({type:bC.DragStart,initialCoordinates:e,active:t}),y({type:"onDragStart",event:i}),_(ge.current),D(o)})},onMove(e){g({type:bC.DragMove,coordinates:e})},onEnd:a(bC.DragEnd),onCancel:a(bC.DragCancel)});function a(e){return async function(){const{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=K.current;let s=null;if(t&&i){const{cancelDrop:a}=I.current;if(s={activatorEvent:o,active:t,collisions:n,delta:i,over:r},e===bC.DragEnd&&"function"==typeof a){await Promise.resolve(a(s))&&(e=bC.DragCancel)}}T.current=null,fC(()=>{g({type:e}),w($N.Uninitialized),fe(null),_(null),D(null),ge.current=null;const t=e===bC.DragEnd?"onDragEnd":"onDragCancel";if(s){const e=I.current[t];null==e||e(s),y({type:t,event:s})}})}}ge.current=s},[S]),ve=sC((e,t)=>(n,r)=>{const i=n.nativeEvent,o=S.get(r);if(null!==T.current||!o||i.dndKit||i.defaultPrevented)return;const s={active:o};!0===e(n,t.options,s)&&(i.dndKit={capturedBy:t.sensor},T.current=r,ye(n,t))},[S,ye]),be=function(e,t){return aC(()=>e.reduce((e,n)=>{const{sensor:r}=n;return[...e,...r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}))]},[]),[e,t])}(c,ve);!function(e){iC(()=>{if(!CE)return;const t=e.map(e=>{let{sensor:t}=e;return null==t.setup?void 0:t.setup()});return()=>{for(const e of t)null==e||e()}},e.map(e=>{let{sensor:t}=e;return t}))}(c),DE(()=>{V&&b===$N.Initializing&&w($N.Initialized)},[V,b]),iC(()=>{const{onDragMove:e}=I.current,{active:t,activatorEvent:n,collisions:r,over:i}=K.current;if(!t||!n)return;const o={active:t,activatorEvent:n,collisions:r,delta:{x:ce.x,y:ce.y},over:i};fC(()=>{null==e||e(o),y({type:"onDragMove",event:o})})},[ce.x,ce.y]),iC(()=>{const{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=K.current;if(!e||null==T.current||!t||!i)return;const{onDragOver:o}=I.current,s=r.get(pe),a=s&&s.rect.current?{id:s.id,rect:s.rect.current,data:s.data,disabled:s.disabled}:null,l={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:a};fC(()=>{fe(a),null==o||o(l),y({type:"onDragOver",event:l})})},[pe]),DE(()=>{K.current={activatorEvent:R,active:k,activeNode:$,collisionRect:ue,collisions:de,droppableRects:P,draggableNodes:S,draggingNode:Y,draggingNodeRect:Z,droppableContainers:C,over:he,scrollableAncestors:ne,scrollAdjustedTranslate:ce},A.current={initial:Z,translated:ue}},[k,$,de,ue,S,Y,Z,P,C,he,ne,ce]),fN({...U,delta:E,draggingRect:ue,pointerCoordinates:oe,scrollableAncestors:ne,scrollableAncestorRects:re});const we=aC(()=>({active:k,activeNode:$,activeNodeRect:V,activatorEvent:R,collisions:de,containerNodeRect:W,dragOverlay:J,draggableNodes:S,droppableContainers:C,droppableRects:P,over:he,measureDroppableContainers:j,scrollableAncestors:ne,scrollableAncestorRects:re,measuringConfiguration:z,measuringScheduled:F,windowRect:te}),[k,$,V,R,de,W,J,S,C,P,he,j,ne,re,z,F,te]),xe=aC(()=>({activatorEvent:R,activators:be,active:k,activeNodeRect:V,ariaDescribedById:{draggable:L},dispatch:g,draggableNodes:S,over:he,measureDroppableContainers:j}),[R,be,k,V,g,L,S,he,j]);return tC.createElement(mC.Provider,{value:v},tC.createElement(IN.Provider,{value:xe},tC.createElement(LN.Provider,{value:we},tC.createElement(FN.Provider,{value:me},l)),tC.createElement(PN,{disabled:!1===(null==s?void 0:s.restoreFocus)})),tC.createElement(vC,{...s,hiddenTextDescribedById:L}))});const HN=nC(null),UN="button";function qN(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e;const o=FE("Draggable"),{activators:s,activatorEvent:a,active:l,activeNodeRect:c,ariaDescribedById:u,draggableNodes:d,over:p}=rC(IN),{role:h=UN,roleDescription:f="draggable",tabIndex:m=0}=null!=i?i:{},g=(null==l?void 0:l.id)===t,y=rC(g?FN:HN),[v,b]=zE(),[w,x]=zE(),M=function(e,t){return aC(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}(s,t),S=LE(n);DE(()=>(d.set(t,{id:t,key:o,node:v,activatorNode:w,data:S}),()=>{const e=d.get(t);e&&e.key===o&&d.delete(t)}),[d,t]);return{active:l,activatorEvent:a,activeNodeRect:c,attributes:aC(()=>({role:h,tabIndex:m,"aria-disabled":r,"aria-pressed":!(!g||h!==UN)||void 0,"aria-roledescription":f,"aria-describedby":u.draggable}),[r,h,m,g,f,u.draggable]),isDragging:g,listeners:r?void 0:M,node:v,over:p,setNodeRef:b,setActivatorNodeRef:x,transform:y}}const VN={timeout:25};function WN(e){let{animation:t,children:n}=e;const[r,i]=oC(null),[o,s]=oC(null),a=PE(n);return n||r||!a||i(a),DE(()=>{if(!o)return;const e=null==r?void 0:r.key,n=null==r?void 0:r.props.id;null!=e&&null!=n?Promise.resolve(t(n,o)).then(()=>{i(null)}):i(null)},[t,r,o]),tC.createElement(tC.Fragment,null,n,r?dC(r,{ref:s}):null)}const KN={x:0,y:0,scaleX:1,scaleY:1};function GN(e){let{children:t}=e;return tC.createElement(IN.Provider,{value:DN},tC.createElement(FN.Provider,{value:KN},t))}const JN={position:"fixed",touchAction:"none"},YN=e=>qE(e)?"transform 250ms ease":void 0,ZN=pC((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:o,className:s,rect:a,style:l,transform:c,transition:u=YN}=e;if(!a)return null;const d=i?c:{...c,scaleX:1,scaleY:1},p={...JN,width:a.width,height:a.height,top:a.top,left:a.left,transform:WE.Transform.toString(d),transformOrigin:i&&r?MC(r,a):void 0,transition:"function"==typeof u?u(r):u,...l};return tC.createElement(n,{className:s,style:p,ref:t},o)}),XN={duration:250,easing:"ease",keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:WE.Transform.toString(t)},{transform:WE.Transform.toString(n)}]},sideEffects:(QN={styles:{active:{opacity:"0"}}},e=>{let{active:t,dragOverlay:n}=e;const r={},{styles:i,className:o}=QN;if(null!=i&&i.active)for(const[e,n]of Object.entries(i.active))void 0!==n&&(r[e]=t.node.style.getPropertyValue(e),t.node.style.setProperty(e,n));if(null!=i&&i.dragOverlay)for(const[e,t]of Object.entries(i.dragOverlay))void 0!==t&&n.node.style.setProperty(e,t);return null!=o&&o.active&&t.node.classList.add(o.active),null!=o&&o.dragOverlay&&n.node.classList.add(o.dragOverlay),function(){for(const[e,n]of Object.entries(r))t.node.style.setProperty(e,n);null!=o&&o.active&&t.node.classList.remove(o.active)}})};var QN;function eA(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return IE((e,o)=>{if(null===t)return;const s=n.get(e);if(!s)return;const a=s.node.current;if(!a)return;const l=AN(o);if(!l)return;const{transform:c}=kE(o).getComputedStyle(o),u=TC(c);if(!u)return;const d="function"==typeof t?t:function(e){const{duration:t,easing:n,sideEffects:r,keyframes:i}={...XN,...e};return e=>{let{active:o,dragOverlay:s,transform:a,...l}=e;if(!t)return;const c={x:s.rect.left-o.rect.left,y:s.rect.top-o.rect.top},u={scaleX:1!==a.scaleX?o.rect.width*a.scaleX/s.rect.width:1,scaleY:1!==a.scaleY?o.rect.height*a.scaleY/s.rect.height:1},d={x:a.x-c.x,y:a.y-c.y,...u},p=i({...l,active:o,dragOverlay:s,transform:{initial:a,final:d}}),[h]=p,f=p[p.length-1];if(JSON.stringify(h)===JSON.stringify(f))return;const m=null==r?void 0:r({active:o,dragOverlay:s,...l}),g=s.node.animate(p,{duration:t,easing:n,fill:"forwards"});return new Promise(e=>{g.onfinish=()=>{null==m||m(),e()}})}}(t);return WC(a,i.draggable.measure),d({active:{id:e,data:s.data,node:a,rect:i.draggable.measure(a)},draggableNodes:n,dragOverlay:{node:o,rect:i.dragOverlay.measure(l)},droppableContainers:r,measuringConfiguration:i,transform:u})})}let tA=0;function nA(e){return aC(()=>{if(null!=e)return tA++,tA},[e])}tC.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:i,transition:o,modifiers:s,wrapperElement:a="div",className:l,zIndex:c=999}=e;const{activatorEvent:u,active:d,activeNodeRect:p,containerNodeRect:h,draggableNodes:f,droppableContainers:m,dragOverlay:g,over:y,measuringConfiguration:v,scrollableAncestors:b,scrollableAncestorRects:w,windowRect:x}=rC(LN),M=rC(FN),S=nA(null==d?void 0:d.id),E=jN(s,{activatorEvent:u,active:d,activeNodeRect:p,containerNodeRect:h,draggingNodeRect:g.rect,over:y,overlayNodeRect:g.rect,scrollableAncestors:b,scrollableAncestorRects:w,transform:M,windowRect:x}),C=bN(p),N=eA({config:r,draggableNodes:f,droppableContainers:m,measuringConfiguration:v}),A=C?g.setRef:void 0;return tC.createElement(GN,null,tC.createElement(WN,{animation:N},d&&S?tC.createElement(ZN,{key:S,id:d.id,ref:A,as:a,activatorEvent:u,adjustScale:t,className:l,transition:o,rect:C,style:{zIndex:c,...i},transform:E},n):null))});const rA=e,iA=i,{ChevronRight:oA}=o,{MoreVert:sA}=o,{styled:aA}=r,lA=e=>{const{direction:t,style:n}=e,r=(e=>{switch(e){case"down":return 90;case"up":return-90;case"left":return 180;default:return 0}})(t);return rA.createElement(oA,{style:{transform:`rotate(${r}deg)`,...n}})};lA.propTypes={direction:iA.string,style:iA.object};const cA=({style:e})=>rA.createElement("span",{style:e},rA.createElement(sA,{style:{margin:"0 -16px"}}),rA.createElement(sA,null));cA.propTypes={style:iA.object},aA("div")(({theme:e})=>({fontFamily:"Cerebri Sans !important",fontSize:e.typography.fontSize,fontWeight:"bold",lineHeight:"14px",position:"relative",top:"7px",width:"110px",height:"28px",whiteSpace:"nowrap"}));const uA=e,{useEffect:dA}=e,{useRef:pA}=e,{useState:hA}=e,fA=i,{color:mA}=a,{styled:gA}=r,yA=s,{renderMath:vA}=u;function bA(e){let t,n=e[0],r=1;for(;r<e.length;){const i=e[r],o=e[r+1];if(r+=2,("optionalAccess"===i||"optionalCall"===i)&&null==n)return;"access"===i||"optionalAccess"===i?(t=n,n=o(n)):"call"!==i&&"optionalCall"!==i||(n=o((...e)=>n.call(t,...e)),t=void 0)}return n}const wA=gA("span")(({theme:e})=>({border:`solid 0px ${e.palette.primary.main}`,"& mjx-frac":{fontSize:"120% !important"}}));function xA({n:e,children:t,isDragging:n,isOver:r,dragItem:i,value:o,selected:s}){const[a,l]=hA(null),c=pA(null),u=e=>{c.current&&(c.current.contains(e.target)?c.current.classList.add("selected"):c.current.classList.remove("selected"))};dA(()=>(document.addEventListener("click",u),()=>{document.removeEventListener("click",u)}),[]),dA(()=>{c.current&&"function"==typeof vA&&vA(c.current)},[bA([o,"optionalAccess",e=>e.value]),r,bA([i,"optionalAccess",e=>e.value,"optionalAccess",e=>e.value])]),dA(()=>{if(r&&c.current&&!a){const e=c.current;l({width:e.offsetWidth,height:e.offsetHeight})}else!r&&a&&l(null)},[r,a]);const d=i&&r?i.value.value:o.value||" ",p=n?" ":d,h=" "!==p,f=i&&r,m=s?`2px solid ${mA.primaryDark()}`:f?`1px solid ${mA.defaults.BORDER_DARK}`:`1px solid ${mA.defaults.BORDER_LIGHT}`;return uA.createElement("div",{ref:c,className:s?"selected":void 0,style:{display:"inline-flex",minWidth:"178px",minHeight:"36px",background:f?`${mA.defaults.BORDER_LIGHT}`:`${mA.defaults.WHITE}`,border:m,boxSizing:"border-box",borderRadius:"3px",overflow:"hidden",position:"relative",padding:"8px 8px 8px 35px",width:a?a.width:void 0,height:a?a.height:void 0,touchAction:"none"},"data-key":e.index,contentEditable:!1},h&&uA.createElement(cA,{style:{position:"absolute",top:"6px",left:"15px",color:"#9B9B9B"},contentEditable:!1}),uA.createElement("span",{dangerouslySetInnerHTML:{__html:p}}),t)}function MA({value:e,disabled:t,instanceId:n,children:r,n:i,onChange:o,removeResponse:s,duplicates:a,pos:l,selected:c}){const{attributes:u,listeners:d,setNodeRef:p,isDragging:h}=qN({id:`drag-${i.index}`,disabled:t||!bA([e,"optionalAccess",e=>e.value]),data:{id:`drag-${i.index}`,value:e,instanceId:n,n:i,pos:l,opts:{duplicates:a},type:"drag-in-the-blank-placed-choice",fromChoice:!e,onRemove:e=>s(e),onDrop:(e,t)=>{"drag-in-the-blank-drop-choice"===bA([t,"optionalAccess",e=>e.type])&&(o(e),!a&&e.fromChoice&&s(e))}}}),{setNodeRef:f,isOver:m,active:g}=function(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e;const o=FE("Droppable"),{active:s,dispatch:a,over:l,measureDroppableContainers:c}=rC(IN),u=lC({disabled:n}),d=lC(!1),p=lC(null),h=lC(null),{disabled:f,updateMeasurementsFor:m,timeout:g}={...VN,...i},y=LE(null!=m?m:r),v=wN({callback:sC(()=>{d.current?(null!=h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{c(Array.isArray(y.current)?y.current:[y.current]),h.current=null},g)):d.current=!0},[g]),disabled:f||!s}),b=sC((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v]),[w,x]=zE(b),M=LE(t);return iC(()=>{v&&w.current&&(v.disconnect(),d.current=!1,v.observe(w.current))},[w,v]),iC(()=>(a({type:bC.RegisterDroppable,element:{id:r,key:o,disabled:n,node:w,rect:p,data:M}}),()=>a({type:bC.UnregisterDroppable,key:o,id:r})),[r]),iC(()=>{n!==u.current.disabled&&(a({type:bC.SetDroppableDisabled,id:r,key:o,disabled:n}),u.current.disabled=n)},[r,o,n,a]),{active:s,rect:p,isOver:(null==l?void 0:l.id)===r,node:w,over:l,setNodeRef:x}}({id:`drop-${i.index}`,data:{type:"drag-in-the-blank-drop-choice",accepts:["drag-in-the-blank-choice","drag-in-the-blank-placed-choice"],instanceId:n,value:e,id:`drop-${i.index}`,pos:l,n:i,opts:{duplicates:a},onDrop:(e,t)=>{if("drag-in-the-blank-drop-choice"===bA([t,"optionalAccess",e=>e.type])&&e.value.id!==t.value.id)return"drag-in-the-blank-choice"===e.type?(o(e),void(!a&&e.fromChoice&&s(e))):void("drag-in-the-blank-placed-choice"===e.type&&(s(t),o(e),setTimeout(()=>s(e),10)))}}}),y=uA.createElement(xA,{n:i,isDragging:h,isOver:m,dragItem:bA([g,"optionalAccess",e=>e.data,"optionalAccess",e=>e.current]),value:e,selected:c},r),v=e?uA.createElement("span",{ref:e=>{p(e),f(e)},...u,...d},y):uA.createElement("span",{ref:f},y);return uA.createElement(wA,{className:yA(m&&"over")},v)}xA.propTypes={n:fA.object,children:fA.node,isDragging:fA.bool,isOver:fA.bool,dragItem:fA.object,value:fA.object,selected:fA.bool},MA.propTypes={value:fA.object,disabled:fA.bool,instanceId:fA.string,children:fA.node,n:fA.object.isRequired,onChange:fA.func.isRequired,removeResponse:fA.func.isRequired,duplicates:fA.bool,selected:fA.bool};const SA=e,EA=i,CA=e=>{const{editor:t,node:n,getPos:r,options:i,selected:o}=e,{attrs:s}=n,{inTable:a}=s,l=r();return SA.createElement(jh,{className:"drag-in-the-blank","data-selected":o,style:{display:"inline",whiteSpace:"normal"}},SA.createElement("span",{...s,style:{display:"inline-flex",minHeight:"50px",minWidth:"178px",position:"relative",margin:a?"10px":"0 10px",cursor:"pointer"}},SA.createElement(MA,{n:s,dragKey:s.id,targetId:"0",pos:l,value:s,duplicates:i.duplicates,selected:o,onChange:e=>((e,t,n,r)=>{const{tr:i}=e.state;i.setNodeMarkup(n,void 0,{...t.attrs,...r.value}),i.isDone=!0,e.view.dispatch(i)})(t,n,l,e),removeResponse:e=>((e,t,n)=>{const{tr:r}=e.state;r.setNodeMarkup(n.pos,void 0,yr(t.attrs,["value","id"])),r.isDone=!0,e.view.dispatch(r)})(t,n,e)})))};CA.propTypes={attributes:EA.object,data:EA.object,n:EA.object,nodeProps:EA.object,opts:EA.object};const NA=e,{useEffect:AA}=e,{useRef:kA}=e,{useState:TA}=e,OA=i,_A=t,RA=e=>{const{editor:t,node:n,getPos:r,options:i,selected:o}=e,{attrs:s}=n,{value:a,error:l}=s,c=a||"<div>&nbsp</div>",u=r(),d=kA(null),p=kA(null),[h,f]=TA(!1),[m,g]=TA({top:0,left:0}),y=i.respAreaToolbar([n,u],t,()=>{});return AA(()=>{const{selection:e}=t.state,r=e.from+n.nodeSize===e.to;o?r&&f(o):f(o)},[t,n,o]),AA(()=>{const e=document.body.getBoundingClientRect(),{from:n}=t.state.selection,r=t.view.coordsAtPos(n);g({top:r.top+Math.abs(e.top)+40,left:r.left});const i=e=>{const n=e.target.closest("[data-toolbar-for]");n&&n.dataset.toolbarFor===p.current.instanceId||t._toolbarOpened||!d.current||d.current.contains(e.target)||e.target.closest("[data-inline-node]")||f(!1)};return h?document.addEventListener("mousedown",i):document.removeEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[h]),NA.createElement(jh,{className:"inline-dropdown","data-selected":o,style:{display:"inline-flex",height:"50px",cursor:"pointer"}},NA.createElement("div",{style:{display:"inline-flex",minWidth:"178px",height:"36px",background:"#FFF",border:"1px solid #C0C3CF",boxSizing:"border-box",borderRadius:"3px",margin:"0 2px",position:"relative",alignItems:"center"},onClick:()=>f(!0)},NA.createElement("div",{style:{flex:1,overflow:"hidden",padding:"0 25px 0 8px",whiteSpace:"nowrap",textOverflow:"ellipsis"}},NA.createElement("span",{style:{display:"inline-block",verticalAlign:"middle"},dangerouslySetInnerHTML:{__html:c}})),NA.createElement(lA,{direction:"down",style:{position:"absolute",top:"5px",right:"5px"}})),h&&_A.createPortal(NA.createElement("div",{ref:d,style:{zIndex:1}},NA.createElement(y,{editorCallback:e=>{p.current=e}})),document.body))};RA.propTypes={attributes:OA.object,selectedItem:OA.oneOfType([OA.string,OA.object])};const DA=e,IA=i,{styled:LA}=r,{mq:BA}=d,zA=LA("span")(()=>({display:"inline-flex",border:"1px solid #C0C3CF",margin:"1px 5px",cursor:"pointer",alignItems:"center",justifyContent:"center",minWidth:"50px",minHeight:"36px",height:"fit-content"})),PA=LA("div")(({theme:e})=>({background:e.palette.grey.A100,color:e.palette.grey.A700,display:"inline-flex",borderRight:"2px solid #C0C3CF",boxSizing:"border-box",overflow:"hidden",fontSize:"12px",minHeight:"36px",height:"100%",alignItems:"center",fontFamily:"Symbola, Times New Roman, serif",padding:"0 2px"})),jA=LA("div")(()=>({flex:8,color:"var(--pie-text, black)",padding:"4px !important",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"var(--pie-background, rgba(255, 255, 255, 0))","& > .mq-math-mode sup.mq-nthroot":{fontSize:"70% !important",verticalAlign:"1em !important"},"& > .mq-math-mode .mq-sqrt-stem":{borderTop:"0.07em solid",marginLeft:"-1.5px",marginTop:"-2px !important",paddingTop:"5px !important"},"& .mq-overarrow-inner":{paddingTop:"0 !important",border:"none !important"},"& .mq-overarrow.mq-arrow-both":{marginTop:"0px",minWidth:"1.23em","& *":{lineHeight:"1 !important"},"&:before":{top:"-0.4em",left:"-1px"},"&:after":{top:"0px !important",position:"absolute !important",right:"-2px"},"&.mq-empty:after":{top:"-0.45em"}},"& .mq-overarrow.mq-arrow-right":{"&:before":{top:"-0.4em",right:"-1px"}},"& .mq-overarrow-inner-right":{display:"none !important"},"& .mq-overarrow-inner-left":{display:"none !important"}})),FA=e=>{const{node:t,options:n,selected:r}=e,{attrs:i}=t,{value:o,index:s}=i,a=`R ${parseInt(s)+1}`;return DA.createElement(jh,{className:"math-templated","data-selected":r,style:{display:"inline-flex",minHeight:"36px",minWidth:"50px",cursor:"pointer"}},DA.createElement(zA,{...i},DA.createElement(PA,null,a),DA.createElement(jA,null,DA.createElement(BA.Static,{latex:o}))))};FA.propTypes={attributes:IA.object,value:IA.string,keyToDisplay:IA.string};const $A=e;function HA(e){let t,n=e[0],r=1;for(;r<e.length;){const i=e[r],o=e[r+1];if(r+=2,("optionalAccess"===i||"optionalCall"===i)&&null==n)return;"access"===i||"optionalAccess"===i?(t=n,n=o(n)):"call"!==i&&"optionalCall"!==i||(n=o((...e)=>n.call(t,...e)),t=void 0)}return n}const UA={},qA=e=>String(e||"").replace(/-/g,"_"),VA=e=>e&&e.attrs&&null!=e.attrs.index?String(e.attrs.index):null,WA=(e,t)=>{const n=[];return e.descendants((e,r)=>{if(e.type&&e.type.name===t){const t=VA(e);null!=t&&n.push({index:t,pos:r,node:e})}return!0}),n},KA=xd.create({name:"responseArea",addOptions:()=>({maxResponseAreas:null,error:null,options:null,respAreaToolbar:null,onHandleAreaChange:null}),addProseMirrorPlugins(){if(!this.options.type)return[];const e=qA(this.options.type),t=new ps(`response-area-watcher:${e}`);return[new cs({key:t,view:t=>(void 0===UA[e]&&(UA[e]=0,t.state.doc.descendants(t=>{if(t.type&&t.type.name===e){const n=VA(t);if(null!=n){const t=parseInt(n,10);!Number.isNaN(t)&&t>UA[e]&&(UA[e]=t)}}return!0})),{update:(t,n)=>{const r=t.state;if(n.doc.eq(r.doc))return;const i=WA(r.doc,e),o=WA(n.doc,e);if(this.options.toolbar&&(this.options.toolbar.disabled=i.length>=this.options.maxResponseAreas),o.length>i.length){const e=new Set(i.map(e=>e.index)),t=o.filter(t=>!e.has(t.index));t.length&&"function"==typeof this.options.onHandleAreaChange&&this.options.onHandleAreaChange(t)}}})})]},addCommands(){return{insertResponseArea:e=>({tr:t,state:n,dispatch:r,commands:i})=>{const o=qA(e),s=((e,t)=>{let n=0;return e.descendants(e=>(e.type&&e.type.name===t&&(n+=1),!0)),n})(n.doc,o);if(s>=this.options.maxResponseAreas)return!1;void 0===UA[o]&&(UA[o]=0);const a=UA[o]+1;UA[o]+=1;const l=(({schema:e,typeName:t,index:n})=>{const r=e.nodes[t];return r?r.create({index:String(n),id:String(n),value:""}):null})({schema:n.schema,typeName:o,index:a});if(!l)return!1;const{selection:c}=n;const u=e=>{try{return t.insert(e,l),e}catch(e){return null}};let d=u(c.from);if(null==d&&(d=u(t.doc.content.size)),null==d)return!1;if(["math_templated","inline_dropdown","explicit_constructed_response"].includes(o))t.setSelection(Jo.create(t.doc,d));else{const e=d+l.nodeSize;t.setSelection(((e,t)=>{const n=e.resolve(Math.min(t,e.content.size));return Ko.near(n,1)})(t.doc,e))}return r&&(i.focus(),r(t)),!0},refreshResponseArea:()=>({tr:e,state:t,commands:n,dispatch:r})=>{const{selection:i}=t,o=i.$from.nodeAfter,s=i.from;return e.setNodeMarkup(s,void 0,{...HA([o,"optionalAccess",e=>e.attrs]),updated:`${Date.now()}`}),e.setSelection(Jo.create(e.doc,s)),r&&(n.focus(),r(e)),!0}}}}),GA=Kp.create({name:"explicit_constructed_response",group:"inline",inline:!0,atom:!0,addAttributes:()=>({index:{default:null},value:{default:""},updated:{default:""}}),parseHTML:()=>[{tag:'span[data-type="explicit_constructed_response"]',getAttrs:e=>({index:e.dataset.index,value:e.dataset.value})}],renderHTML:({HTMLAttributes:e})=>["span",{"data-type":"explicit_constructed_response","data-index":e.index,"data-value":e.value}],addNodeView(){return qh(e=>$A.createElement(bE,{...{...e,options:this.options}}))}}),JA=Kp.create({name:"math_templated",group:"inline",inline:!0,atom:!0,addAttributes:()=>({index:{default:null},value:{default:""},updated:{default:""}}),parseHTML:()=>[{tag:'span[data-type="math_templated"]',getAttrs:e=>({index:e.dataset.index,value:e.dataset.value})}],renderHTML:({HTMLAttributes:e})=>["span",{"data-type":"math_templated","data-index":e.index,"data-value":e.value}],addNodeView(){return qh(e=>$A.createElement(FA,{...{...e,options:this.options}}))}}),YA=Kp.create({name:"drag_in_the_blank",group:"inline",inline:!0,atom:!0,addAttributes:()=>({index:{default:null},id:{default:null},value:{default:""},inTable:{default:null},updated:{default:""}}),parseHTML:()=>[{tag:'span[data-type="drag_in_the_blank"]',getAttrs:e=>({index:e.dataset.index,id:e.dataset.id,value:e.dataset.value,inTable:e.dataset.inTable})}],renderHTML:({HTMLAttributes:e})=>["span",{"data-type":"drag_in_the_blank","data-index":e.index,"data-id":e.id,"data-value":e.value,"data-in-table":e.inTable}],addNodeView(){return qh(e=>$A.createElement(CA,{...{...e,options:this.options}}))}}),ZA=Kp.create({name:"inline_dropdown",group:"inline",inline:!0,atom:!0,addAttributes:()=>({index:{default:null},value:{default:""},updated:{default:""}}),parseHTML:()=>[{tag:'span[data-type="inline_dropdown"]',getAttrs:e=>({index:e.dataset.index,value:e.dataset.value})}],renderHTML:({HTMLAttributes:e})=>["span",{"data-type":"inline_dropdown","data-index":e.index,"data-value":e.value}],addNodeView(){return qh(e=>$A.createElement(RA,{...{...e,options:this.options}}))}}),XA=e,{useEffect:QA}=e,{useRef:ek}=e,{useState:tk}=e,nk=t,{MathPreview:rk}=p,{MathToolbar:ik}=p,{wrapMath:ok}=u;function sk(e){let t,n=e[0],r=1;for(;r<e.length;){const i=e[r],o=e[r+1];if(r+=2,("optionalAccess"===i||"optionalCall"===i)&&null==n)return;"access"===i||"optionalAccess"===i?(t=n,n=o(n)):"call"!==i&&"optionalCall"!==i||(n=o((...e)=>n.call(t,...e)),t=void 0)}return n}const ak=new ps("ensureTextAfterMath"),lk=(e=[])=>e.map(e=>({name:e,latex:e,write:e,label:e})),ck=new cs({key:new ps("zeroWidthSpaceHandling"),props:{handleKeyDown(e,t){const{state:n,dispatch:r}=e,{selection:i,doc:o}=n,{from:s,empty:a}=i;if(a&&"Backspace"===t.key&&s>0){if("​"===o.textBetween(s-1,s,"","")){return r(n.tr.delete(s-2,s)),!0}}if(a&&"ArrowLeft"===t.key&&s>0){if("​"===o.textBetween(s-1,s,"","")){const e=s-1,t=n.doc.resolve(e-1),i=t.nodeAfter||t.nodeBefore;if(i){const t=e-i.nodeSize,o=n.doc.resolve(t);return r(n.tr.setSelection(Jo.create(n.doc,o.pos))),!0}return r(n.tr.setSelection(Ko.create(n.doc,s-2))),!0}}return!1}}}),uk=Kp.create({name:"math",group:"inline",inline:!0,atom:!0,addAttributes:()=>({latex:{default:""},wrapper:{default:null},html:{default:null}}),addProseMirrorPlugins(){return[(e=this.name,new cs({key:ak,appendTransaction:(t,n,r)=>{if(!t.some(e=>e.docChanged))return null;const i=r.tr;let o=!1;return r.doc.descendants((t,n)=>{if(t.type.name===e){const e=n+t.nodeSize,s=r.doc.nodeAt(e);s&&"text"===s.type.name||(i.insert(e,r.schema.text("​")),o=!0)}}),o?i:null}})),ck];var e},parseHTML:()=>[{tag:"span[data-latex]",getAttrs:e=>({latex:e.getAttribute("data-raw")||e.textContent})},{tag:'span[data-type="mathml"]',getAttrs:e=>({html:e.innerHTML})}],addCommands(){return{insertMath:(e="")=>({tr:t,editor:n,dispatch:r})=>{const{state:i}=n.view,o=i.schema.nodes.math.create({latex:e}),{selection:s}=i,a=s.$from.pos;if(t.insert(a,o),sk([o,"optionalAccess",e=>e.type,"optionalAccess",e=>e.name])===this.name){const e=Jo.create(t.doc,s.$from.pos);t.setSelection(e)}return r(t),!0}}},renderHTML:({HTMLAttributes:e})=>e.html?["span",{"data-type":"mathml",dangerouslySetInnerHTML:{__html:e.html}}]:["span",{"data-latex":"","data-raw":e.latex},ok(e.latex,e.wrapper)],addNodeView(){return qh(e=>XA.createElement(dk,{...{...e,options:this.options}}))}}),dk=e=>{const{node:t,updateAttributes:n,editor:r,selected:i,options:o}=e,[s,a]=tk(i),l=ek(null),[c,u]=tk({top:0,left:0}),{math:d={}}=o||{},{keypadMode:p,controlledKeypadMode:h=!0,customKeys:f=[],keyPadCharacterRef:m,setKeypadInteraction:g}=d,y=t.attrs.latex||"";QA(()=>{i&&a(!0)},[i]),QA(()=>{r._toolbarOpened=!!s},[s]),QA(()=>{const e=document.body.getBoundingClientRect(),{from:t}=r.state.selection,n=r.view.coordsAtPos(t);u({top:n.top+Math.abs(e.top)+40,left:n.left});const i=e=>{const t=sk([e,"optionalAccess",e=>e.target]),n=(sk([document,"access",e=>e.querySelectorAll,"optionalCall",e=>e('[id^="equation-editor-select"][id*="listbox"], [aria-labelledby="equation-editor-label"][role="listbox"]')])||[]).length>0,r=!(!sk([t,"optionalAccess",e=>e.id])||!t.id.includes("equation-editor-select"))||!!sk([t,"optionalAccess",e=>e.closest,"optionalCall",e=>e('[id*="equation-editor-select"]')]),i=!!sk([t,"optionalAccess",e=>e.closest,"optionalCall",e=>e(".math-node")]);!l.current||l.current.contains(t)||sk([t,"optionalAccess",e=>e.closest,"optionalCall",e=>e("[data-inline-node]")])||n||r||i||a(!1)};return s?document.addEventListener("click",i):document.removeEventListener("click",i),()=>document.removeEventListener("click",i)},[r,s]);return XA.createElement(jh,{className:"math-node",style:{display:"inline-flex",cursor:"pointer",margin:"0 4px"},"data-selected":i},XA.createElement("div",{onClick:()=>a(!0),contentEditable:!1},XA.createElement(rk,{latex:y})),s&&nk.createPortal(XA.createElement("div",{ref:l,"data-toolbar-for":r.instanceId,style:{marginTop:"6px",zIndex:20,background:"var(--editable-html-toolbar-bg, #efefef)",boxShadow:"0px 1px 5px 0px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 3px 1px -2px rgba(0, 0, 0, 0.12)"}},XA.createElement(ik,{latex:y,autoFocus:!0,onChange:e=>{n({latex:e})},onDone:e=>{n({latex:e}),a(!1),r._toolbarOpened=!1;const{selection:t,tr:i,doc:o}=r.state,s=Ko.create(o,t.from+1);i.setSelection(s),r.view.dispatch(i),r.commands.focus()},keypadMode:p,controlledKeypadMode:h,additionalKeys:lk(f),keyPadCharacterRef:m,setKeypadInteraction:g})),sk([r,"optionalAccess",e=>e._tiptapContainerEl])||document.body))},pk=l("@pie-lib:editable-html:image:insert-image-handler");class hk{constructor(e,t,n,r=!1){let i;this.editor=e,this.node=t,e.state.doc.descendants((e,t)=>{if(e===this.node)return i=t,!1}),this.nodePos=i,this.onFinish=n,this.isPasted=r,this.chosenFile=null}cancel(){pk("insert cancelled");try{this.deleteNode(),this.onFinish(!1)}catch(e){}}updateNode(e){const{state:t,view:n}=this.editor,{tr:r}=t,i=t.doc.nodeAt(this.nodePos);if(i){const t=r.setNodeMarkup(this.nodePos,void 0,{...i.attrs,...e});n.dispatch(t)}}deleteNode(){const{state:e,view:t}=this.editor,{tr:n}=e,r=n.delete(this.nodePos,this.nodePos+this.node.nodeSize);t.dispatch(r)}done(e,t){pk("done: err:",e),e?(console.log(e),this.onFinish(!1)):(this.updateNode({loaded:!0,src:t,percent:100}),this.onFinish(!0))}fileChosen(e){if(!e)return;this.chosenFile=e,pk("[fileChosen] file: ",e);const t=new FileReader;t.onload=()=>{const e=t.result;this.updateNode({src:e})},t.readAsDataURL(e)}progress(e,t,n){pk("progress: ",e,t,n),this.updateNode({percent:e})}getChosenFile(){return this.chosenFile}}const fk=e,{DialogContent:mk}=n,{TextField:gk}=n,{DialogActions:yk}=n,{Button:vk}=n,{Dialog:bk}=n,{ArrowBackIos:wk}=o,xk=i;class Mk extends fk.Component{static __initStatic(){this.propTypes={onDone:xk.func.isRequired,alt:xk.string}}constructor(e){super(e),Mk.prototype.__init.call(this),Mk.prototype.__init2.call(this),Mk.prototype.__init3.call(this);const{alt:t}=e;this.state={value:t}}__init(){this.closeDialog=()=>{document.querySelectorAll("#text-dialog").forEach(function(e){return e.remove()})}}__init2(){this.onDone=()=>{const{onDone:e}=this.props,{value:t}=this.state;e(t),this.closeDialog()}}__init3(){this.handleOverflow=()=>{document.body.style.removeProperty("overflow")}}render(){const{value:e}=this.state;return fk.createElement(bk,{open:!0,disablePortal:!0,onClose:this.closeDialog,id:"text-dialog",hideBackdrop:!0,disableScrollLock:!0,onEntered:this.handleOverflow},fk.createElement(mk,null,fk.createElement("div",{style:{display:"flex"}},fk.createElement(wk,{style:{paddingTop:"6px"}}),fk.createElement(gk,{multiline:!0,placeholder:"Enter an Alt Text description of this image",helperText:"Users with visual limitations rely on Alt Text, since screen readers cannot otherwise describe the contents of an image.",value:e,onChange:e=>this.setState({value:e.target.value}),FormHelperTextProps:{style:{fontSize:14}}}))),fk.createElement(yk,null,fk.createElement(vk,{onClick:this.onDone},"Done")))}}Mk.__initStatic();const Sk=e,Ek=l,{styled:Ck}=r,Nk=i,Ak=Ck("button",{shouldForwardProp:e=>!["active","disabled","extraStyles"].includes(e)})(({theme:e,active:t,disabled:n})=>({color:t?"black":"grey",display:"inline-flex",padding:"2px",background:"none",border:"none",cursor:n?"not-allowed":"pointer","&:hover":{color:n?"grey":"black"},"&:focus":{outline:`2px solid ${e.palette.grey[700]}`},...n&&{opacity:.7}})),kk=Ek("pie-elements:editable-html:raw-button");class Tk extends Sk.Component{static __initStatic(){this.propTypes={onClick:Nk.func.isRequired,children:Nk.oneOfType([Nk.arrayOf(Nk.node),Nk.node]).isRequired,active:Nk.bool,disabled:Nk.bool,extraStyles:Nk.object}}constructor(e){super(e),Tk.prototype.__init.call(this),Tk.prototype.__init2.call(this)}__init(){this.onClick=e=>{kk("[onClick]"),e.preventDefault();const{onClick:t}=this.props;t(e)}}__init2(){this.onKeyDown=e=>{if("Enter"===e.key||" "===e.key){kk("[onKeyDown]"),e.preventDefault();const{onClick:t}=this.props;t(e)}}}render(){const{active:e,children:t,disabled:n,extraStyles:r,ariaLabel:i}=this.props;return Sk.createElement(Ak,{style:r,active:e,disabled:n,onMouseDown:this.onClick,onKeyDown:this.onKeyDown,"aria-label":i,"aria-pressed":e,tabIndex:0},t)}}Tk.__initStatic();class Ok extends Sk.Component{static __initStatic2(){this.propTypes={onToggle:Nk.func.isRequired,mark:Nk.string,label:Nk.string.isRequired,children:Nk.oneOfType([Nk.arrayOf(Nk.node),Nk.node]).isRequired,active:Nk.bool}}constructor(e){super(e),Ok.prototype.__init3.call(this),Ok.prototype.__init4.call(this)}__init3(){this.onToggle=e=>{e.preventDefault(),this.props.onToggle(this.props.mark)}}__init4(){this.onKeyDown=e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this.props.onToggle(this.props.mark))}}render(){const{children:e,active:t,label:n}=this.props;return Sk.createElement(Ak,{active:t,onMouseDown:this.onToggle,"aria-pressed":t,onKeyDown:this.onKeyDown,"aria-label":n,tabIndex:0},e)}}Ok.__initStatic2();const _k=Ok,Rk=i,Dk=e,Ik=l,Lk=t,{styled:Bk}=r,zk=Ik("@pie-lib:editable-html:plugins:image:image-toolbar"),Pk=Bk("div")(({theme:e})=>({paddingLeft:e.spacing.unit,display:"flex",alignItems:"center"})),jk=Bk("span",{shouldForwardProp:e=>!["disabled","hasAlignmentButtons"].includes(e)})(({disabled:e,hasAlignmentButtons:t})=>({...e&&{opacity:.5},...t&&{borderLeft:"1px solid grey",paddingLeft:8,marginLeft:4}})),Fk=({alignment:e,active:t,onClick:n})=>Dk.createElement(_k,{active:t,onToggle:()=>n(e),label:e},e);Fk.propTypes={alignment:Rk.string.isRequired,active:Rk.bool.isRequired,onClick:Rk.func.isRequired};class $k extends Dk.Component{constructor(...e){super(...e),$k.prototype.__init.call(this),$k.prototype.__init2.call(this),$k.prototype.__init3.call(this)}static __initStatic(){this.propTypes={onChange:Rk.func.isRequired,alignment:Rk.string,alt:Rk.string,imageLoaded:Rk.bool,disableImageAlignmentButtons:Rk.bool}}__init(){this.onAltTextDone=e=>{zk("[onAltTextDone]: alt:",e),this.props.onChange({alt:e},!0)}}__init2(){this.onAlignmentClick=e=>{zk("[onAlignmentClick]: alignment:",e),this.props.onChange({alignment:e})}}__init3(){this.renderDialog=()=>{const{alt:e}=this.props,t=document.createElement("div"),n=Dk.createElement(Mk,{alt:e,onDone:this.onAltTextDone});Lk.render(n,t),document.body.appendChild(t)}}render(){const{alignment:e,imageLoaded:t,disableImageAlignmentButtons:n}=this.props;return Dk.createElement(Pk,null,!n&&Dk.createElement(Dk.Fragment,null,Dk.createElement(Fk,{alignment:"left",active:"left"===e,onClick:this.onAlignmentClick}),Dk.createElement(Fk,{alignment:"center",active:"center"===e,onClick:this.onAlignmentClick}),Dk.createElement(Fk,{alignment:"right",active:"right"===e,onClick:this.onAlignmentClick})),Dk.createElement(jk,{disabled:!t,hasAlignmentButtons:!n,onMouseDown:e=>t&&this.renderDialog(e)},"Alt text"))}}$k.__initStatic();const Hk=e,{useCallback:Uk}=e,{useEffect:qk}=e,{useRef:Vk}=e,{useState:Wk}=e,Kk=i,Gk=l,{LinearProgress:Jk}=n,{styled:Yk}=r,Zk=t;function Xk(e){let t,n=e[0],r=1;for(;r<e.length;){const i=e[r],o=e[r+1];if(r+=2,("optionalAccess"===i||"optionalCall"===i)&&null==n)return;"access"===i||"optionalAccess"===i?(t=n,n=o(n)):"call"!==i&&"optionalCall"!==i||(n=o((...e)=>n.call(t,...e)),t=void 0)}return n}Gk("@pie-lib:editable-html:plugins:image:component");const Qk=Yk(Jk,{shouldForwardProp:e=>"hideProgress"!==e})(({hideProgress:e})=>({position:"absolute",left:"0",width:"fit-content",top:"0%",transition:"opacity 200ms linear",...e&&{opacity:0}})),eT=Yk("div",{shouldForwardProp:e=>!["active","loading","pendingDelete"].includes(e)})(({loading:e,pendingDelete:t})=>({position:"relative",display:"flex",transition:"opacity 200ms linear",...e&&{opacity:.3},...t&&{opacity:.3}})),tT=Yk("div")(({theme:e})=>({position:"relative",width:"fit-content",display:"flex",alignItems:"center","&&:hover > .resize":{display:"block"}})),nT=Yk("img",{shouldForwardProp:e=>"active"!==e})(({theme:e,active:t})=>({border:t?`solid 1px ${e.palette.primary.main}`:"solid 1px transparent"})),rT=Yk("div")(({theme:e})=>({backgroundColor:e.palette.primary.main,cursor:"col-resize",height:"35px",width:"5px",borderRadius:8,marginLeft:"5px",marginRight:"10px",display:"none"})),iT=e=>e?`${e}px`:"calc(20px)";function oT(e){const{node:t,editor:n,attributes:r,onFocus:i,selected:o,options:s,maxImageWidth:a=700,maxImageHeight:l=900,latex:c,handleChange:u,handleDone:d}=e;t.attrs;const[p,h]=Wk(!1),f=Vk(t),m=Vk(null),g=Vk(null),y=Vk(null),v=Uk(e=>{const t=e/m.current.naturalWidth*4;return parseInt(25*t.toFixed(0),10)},[]),b=Uk(()=>{if(!t.attrs.width||!m.current)return;const e={...t.attrs,resizePercent:v(t.attrs.width)};ar(e,t.attrs)||n.commands.updateAttributes("imageUploadNode",e)},[n,t.attrs,v]);qk(()=>{f.current=t},[t]),qk(()=>{const{selection:e}=n.state,r=e.from+t.nodeSize===e.to;o?r&&h(o):h(o)},[n,t,o]),qk(()=>{s.imageHandling.insertImageRequested(t,e=>new hk(n,t,e)),b();const e=g.current;return e&&e.addEventListener("mousedown",C,!1),()=>{e&&e.removeEventListener("mousedown",C,!1)}},[]),qk(()=>{b()});const w=Uk(()=>{const e=m.current;if(e&&(!e.style.width||"calc(20px)"===e.style.width)){const r=Math.min(e.naturalWidth,a),i=Math.min(e.naturalHeight,l);e.style.width=`${r}px`,e.style.height=`${i}px`;const o={width:r,height:i};ar(o,t.attrs)||n.commands.updateAttributes("imageUploadNode",o)}},[n,t.attrs,a,l]),x=Uk(e=>{const r=m.current;if(!r)return;const i=e.target.getBoundingClientRect(),o=((e,t,n=!0,r)=>{if(n){const n=e.width/e.height;return"height"===r?{width:t.height*n,height:t.height}:{width:t.width,height:t.width/n}}return t})({width:r.naturalWidth,height:r.naturalHeight},{width:e.clientX-i.left,height:e.clientY-i.top});if(o.width>50&&o.height>50&&o.width<=700&&o.height<=900){r.style.width=`${o.width}px`,r.style.height=`${o.height}px`;const e={width:o.width,height:o.height};ar(e,t.attrs)||n.commands.updateAttributes("imageUploadNode",e)}},[n,t.attrs]),M=Uk(()=>{let e=null;const t=f.current.attrs.src;return n.state.doc.descendants((n,r)=>null===e&&("imageUploadNode"===n.type.name&&n.attrs.src===t?(e=r,!1):void 0)),e},[n]),S=Uk(e=>{n.commands.updateAttributes("imageUploadNode",e)},[n]),E=Uk(()=>{window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",E)},[x]),C=Uk(()=>{window.addEventListener("mousemove",x),window.addEventListener("mouseup",E)},[x,E]),N={width:iT(t.attrs.width),height:iT(t.attrs.height),objectFit:"contain"},A={left:"flex-start",center:"center",right:"flex-end"}[t.attrs.alignment]||"flex-start";return Hk.createElement(jh,null,Hk.createElement(eT,{onFocus:i,loading:!t.attrs.loaded,pendingDelete:"pending"===t.attrs.deleteStatus,style:{justifyContent:A}},Hk.createElement(Qk,{mode:"determinate",value:t.attrs.percent||0,hideProgress:t.attrs.loaded}),Hk.createElement(tT,{onDragStart:e=>e.preventDefault()},Hk.createElement(nT,{...r,active:o&&t.attrs.loaded,draggable:!1,ref:m,src:t.attrs.src,style:N,onLoad:w,alt:t.attrs.alt}),Hk.createElement(rT,{ref:g,className:"resize"}))),p&&n._tiptapContainerEl&&Zk.createPortal(Hk.createElement("div",{ref:y,style:{zIndex:20,background:"var(--editable-html-toolbar-bg, #efefef)",boxShadow:"0px 1px 5px 0px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 3px 1px -2px rgba(0, 0, 0, 0.12)",width:"100%"}},Hk.createElement(pE,{showDone:!0,deletable:!0,toolbarOpts:s.toolbarOpts||{},onDelete:()=>{const e=M();null!==e&&(Xk([s,"access",e=>e.imageHandling,"optionalAccess",e=>e.onDelete,"optionalCall",e=>e(f.current)]),n.view.dispatch(n.state.tr.delete(e,e+n.state.doc.nodeAt(e).nodeSize)),h(!1),n.commands.focus())},onDone:()=>{h(!1),Xk([s,"access",e=>e.imageHandling,"optionalAccess",e=>e.onDone,"optionalCall",e=>e()]),n.commands.focus("end")}},Hk.createElement($k,{disableImageAlignmentButtons:s.disableImageAlignmentButtons,alt:t.attrs.alt,imageLoaded:t.attrs.loaded,alignment:t.attrs.alignment||"left",onChange:S}))),n._tiptapContainerEl))}oT.propTypes={node:Kk.object.isRequired,editor:Kk.object.isRequired,attributes:Kk.object,onFocus:Kk.func,maxImageWidth:Kk.number,maxImageHeight:Kk.number};const sT=e,aT=Kp.create({name:"imageUploadNode",group:"block",atom:!0,selectable:!0,draggable:!0,addAttributes:()=>({loaded:{default:!1},deleteStatus:{default:null},alignment:{default:null},percent:{default:null},width:{default:null},height:{default:null},src:{default:null},alt:{default:null}}),parseHTML:()=>[{tag:'div[data-type="image-upload-node"]'}],renderHTML:({HTMLAttributes:e})=>["img",Lu(e,{"data-type":"image-upload-node"})],addNodeView(){return qh(e=>sT.createElement(oT,{...{...e,options:this.options}}))},addCommands(){return{setImageUploadNode:()=>({commands:e})=>e.insertContent({type:this.name})}}}),lT=e,cT=i,uT=l,{styled:dT}=r,{Button:pT}=n,{Dialog:hT}=n,{Tabs:fT}=n,{Tab:mT}=n,{DialogTitle:gT}=n,{DialogContent:yT}=n,{DialogContentText:vT}=n,{DialogActions:bT}=n,{TextField:wT}=n,{Typography:xT}=n,{IconButton:MT}=n,{Delete:ST}=o;function ET(e){let t,n=e[0],r=1;for(;r<e.length;){const i=e[r],o=e[r+1];if(r+=2,("optionalAccess"===i||"optionalCall"===i)&&null==n)return;"access"===i||"optionalAccess"===i?(t=n,n=o(n)):"call"!==i&&"optionalCall"!==i||(n=o((...e)=>n.call(t,...e)),t=void 0)}return n}const CT=uT("@pie-lib:editable-html:plugins:media:dialog"),NT=e=>{if(!e)return!1;const t=/^(?:https?:\/\/)?(?:m\.|www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/;return!!e.match(t)&&e.match(t)[1]},AT=e=>e&&/(http|https)?:\/\/(www\.)?(player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^/]*)\/videos\/|)(video\/)?(\d+)(?:|\/\?)/.test(e),kT={video:"Video",audio:"Audio"},TT="upload-file",OT="insert-url",_T=dT(hT)(({theme:e})=>({"& .MuiDialog-paper":{minWidth:"500px"}})),RT=dT(yT)(({theme:e})=>({padding:0})),DT=dT("div")(({theme:e})=>({display:"flex",flexDirection:"space-between"})),IT=dT("div")(({theme:e})=>({marginTop:e.spacing(1.5)})),LT=dT("input")(({theme:e})=>({})),BT=dT(xT)(({theme:e})=>({marginTop:e.spacing(1.5),color:e.palette.error.main})),zT=dT(MT)(({theme:e})=>({marginLeft:e.spacing(1.5)}));class PT extends lT.Component{static __initStatic(){this.propTypes={open:cT.bool,edit:cT.bool,disablePortal:cT.bool,handleClose:cT.func,uploadSoundSupport:cT.shape({add:cT.func,delete:cT.func}),type:cT.string,src:cT.string,url:cT.string,urlToUse:cT.string,starts:cT.number,ends:cT.number,height:cT.number,width:cT.number}}constructor(e){super(e),PT.prototype.__init.call(this),PT.prototype.__init2.call(this),PT.prototype.__init3.call(this),PT.prototype.__init4.call(this),PT.prototype.__init5.call(this),PT.prototype.__init6.call(this),PT.prototype.__init7.call(this),PT.prototype.__init8.call(this),PT.prototype.__init9.call(this);const{ends:t,height:n,src:r,starts:i,type:o,uploadSoundSupport:s,url:a,urlToUse:l,width:c}=e,u=ET([s,"optionalAccess",e=>e.add])&&ET([s,"optionalAccess",e=>e.delete])&&"video"!==o&&!r;this.state={ends:t||0,url:a,urlToUse:l,formattedUrl:r,height:n||315,invalid:!1,starts:i||0,width:c||560,tabValue:u?TT:OT,fileUpload:{error:null,loading:!1,scheduled:!1,url:"",mimeType:""}}}componentDidMount(){this.props.url&&this.urlChange({target:{value:this.props.url}})}__init(){this.formatUrl=()=>{const{url:e,urlToUse:t,starts:n,ends:r}=this.state,i=NT(e),o=AT(e);let s=t;if((i||o)&&t){const e=[];let i,a;if(!0===o)i="t",a="#";else i="start",a="?";n&&e.push(`${i}=${n}`),r&&e.push(`end=${r}`),s=`${t}${e.length?a:""}${e.join("&")}`}this.setState({formattedUrl:null,updating:!0},()=>this.setState({formattedUrl:s,updating:!1}))}}__init2(){this.handleStateChange=e=>this.setState(e,this.formatUrl)}__init3(){this.checkAudio=e=>{var t;(e=>{if(!e)return!1;const t=/^https?:\/\/(soundcloud\.com|snd\.sc)\/(.*)$/;return e.match(t)&&e.match(t)[2]})(e)&&(t=e,new Promise(e=>{try{fetch(`https://soundcloud.com/oembed?format=json&url=${t}`).then(e=>e.json()).then(t=>{const n=document.createElement("div");n.innerHTML=t.html;const r=n.querySelector("iframe");e(r.src)}).catch(t=>{e(""),CT(t)})}catch(t){e("")}})).then(t=>{this.handleStateChange({urlToUse:t,invalid:!t,url:e})}).catch(CT)}}__init4(){this.checkVideo=e=>{if(NT(e)){const t=/^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/,n=`https://youtube.com/embed/${e.match(t)[2]}`;CT("is youtube"),this.handleStateChange({urlToUse:n,url:e,invalid:!1})}if(AT(e)){const t=`https://player.vimeo.com/video/${e.replace(/.*vimeo.com\/(.*)/g,"$1")}`;CT("is vimeo"),this.handleStateChange({urlToUse:t,url:e,ends:null,invalid:!1})}if((t=e)&&/^https:\/\/drive\.google\.com\/(?:file\/d\/|drive\/(?:u\/\d+\/)?folders\/|uc\?id=)([a-zA-Z0-9_-]+)/.test(t)){const t=`https://drive.google.com/file/d/${e.replace(/^https:\/\/drive\.google\.com\/(?:file\/d\/|drive\/(?:u\/\d+\/)?folders\/|uc\?id=)([a-zA-Z0-9_-]+)\/.*/,"$1")}/preview`;CT("is google drive"),this.handleStateChange({urlToUse:t,url:e,ends:null,invalid:!1})}var t}}__init5(){this.urlChange=e=>{const{value:t}=e.target||{},{type:n}=this.props;n&&"audio"===n?this.checkAudio(t):n&&"video"===n?this.checkVideo(t):this.handleStateChange({urlToUse:null,url:null,invalid:!0})}}__init6(){this.changeHandler=e=>t=>this.handleStateChange({[e]:t.target.value})}__init7(){this.handleDone=e=>{const{handleClose:t}=this.props,{tabValue:n,fileUpload:r}=this.state,i=n===OT;if(!e)return r.url&&this.handleRemoveFile(),void t(e);if(i){const{ends:n,height:r,url:i,urlToUse:o,formattedUrl:s,starts:a,width:l}=this.state;return void t(e,{tag:"iframe",ends:n,height:r,starts:a,width:l,url:i,urlToUse:o,src:s})}r.loading?this.setState({fileUpload:{...r,scheduled:!0}}):t(e,{tag:"audio",src:r.url})}}__init8(){this.handleUploadFile=async e=>{e.preventDefault(),this.setState({fileUpload:{...this.state.fileUpload,error:null,loading:!0}});const t=e.target.files[0],n=new FileReader;n.onload=()=>{const e=n.result;this.setState({fileUpload:{...this.state.fileUpload,url:e,mimeType:t.type}})},n.readAsDataURL(t),this.props.uploadSoundSupport.add({fileChosen:t,done:(e,t)=>{if(CT("done: err:",e),e)return console.log(e),void this.setState({fileUpload:{...this.state.fileUpload,scheduled:!1,loading:!1,error:e}});const{fileUpload:n}=this.state,r=n&&n.scheduled?this.handleDone.bind(this,!0):void 0;this.setState({fileUpload:{...n,scheduled:!1,loading:!1,url:t}},r)}})}}__init9(){this.handleRemoveFile=async()=>{this.props.uploadSoundSupport.delete(this.state.fileUpload.url,e=>{e&&(console.log(e),this.setState({fileUpload:{...this.state.fileUpload,error:e}}))}),this.setState({fileUpload:{...this.state.fileUpload,loading:!1,url:"",mimeType:""}})}}render(){const{open:e,disablePortal:t,type:n,edit:r,uploadSoundSupport:i}=this.props,{ends:o,height:s,invalid:a,starts:l,width:c,url:u,mimeType:d,formattedUrl:p,updating:h,tabValue:f,fileUpload:m}=this.state,g=NT(u),y=f===OT,v=f===TT,b=y?a||null==u:!m.url||m.scheduled,w=ET([i,"optionalAccess",e=>e.add])&&ET([i,"optionalAccess",e=>e.delete])&&"video"!==n;return lT.createElement(_T,{disablePortal:t,open:e,onClose:()=>this.handleDone(!1),"aria-labelledby":"form-dialog-title"},lT.createElement(gT,{id:"form-dialog-title"},"Insert ",kT[n]),lT.createElement(yT,null,lT.createElement("div",null,lT.createElement(DT,null,lT.createElement(fT,{indicatorColor:"primary",value:f,onChange:(e,t)=>{this.setState({tabValue:t})}},w?lT.createElement(mT,{value:TT,label:"Upload file"}):null,lT.createElement(mT,{value:OT,label:"video"===n?"Insert YouTube, Vimeo, or Google Drive URL":"Insert SoundCloud URL"}))),y&&lT.createElement("div",null,lT.createElement(wT,{autoFocus:!0,error:a,helperText:a?"Invalid URL":"",margin:"dense",id:"name",label:"URL",placeholder:`Paste URL of ${n}...`,type:"text",onChange:this.urlChange,value:u,fullWidth:!0}),"video"===n&&lT.createElement(RT,null,lT.createElement(vT,null,"Video Properties"),lT.createElement(wT,{autoFocus:!0,margin:"dense",id:"width",label:"Width",type:"number",placeholder:"Width",value:c,onChange:this.changeHandler("width")}),lT.createElement(wT,{autoFocus:!0,margin:"dense",id:"height",label:"Height",type:"number",placeholder:"Height",value:s,onChange:this.changeHandler("height")})),p&&lT.createElement("iframe",{width:c,height:s,src:p,frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0}),"video"===n&&(p||h)&&!a&&lT.createElement(lT.Fragment,null,lT.createElement(RT,null,lT.createElement(wT,{autoFocus:!0,margin:"dense",id:"starts",label:"Starts",type:"number",placeholder:"Starts",value:l,onChange:this.changeHandler("starts")}),g&&lT.createElement(wT,{autoFocus:!0,margin:"dense",id:"ends",label:"Ends",type:"number",placeholder:"Ends",value:o,onChange:this.changeHandler("ends")})))),v&&lT.createElement(IT,null,lT.createElement("div",null,m.url?lT.createElement(lT.Fragment,null,lT.createElement(DT,null,lT.createElement("audio",{controls:"controls",controlsList:"nodownload"},lT.createElement("source",{type:d,src:m.url})),lT.createElement(zT,{"aria-label":"delete",onClick:this.handleRemoveFile},lT.createElement(ST,null))),!m.scheduled&&m.loading?lT.createElement(xT,{variant:"subheading"},"Loading..."):null,m.scheduled?lT.createElement(xT,{variant:"subheading"},"Waiting for Upload to finish, then inserting item..."):null):m.loading?null:lT.createElement(LT,{accept:"audio/*",onChange:this.handleUploadFile,type:"file"}),!!m.error&&lT.createElement(BT,{variant:"caption"},m.error))))),lT.createElement(bT,null,lT.createElement(pT,{onClick:()=>this.handleDone(!1),color:"primary"},"Cancel"),lT.createElement(pT,{disabled:b,onClick:()=>this.handleDone(!0),color:"primary"},r?"Update":"Insert")))}}PT.__initStatic();const jT=e,FT=i,{styled:$T}=r,HT=$T("span")(({theme:e})=>({position:"relative",bottom:"5px",left:0,width:"100%",background:e.palette.common.white,display:"inline-flex",padding:"5px",boxShadow:"0px 4px 4px rgba(0, 0, 0, 0.25)"})),UT=$T("span")(({theme:e})=>({cursor:"pointer",flex:3,border:`solid ${e.palette.common.black}`,textAlign:"right",borderWidth:"0 2px 0 0",marginRight:"5px",paddingRight:"5px"})),qT=$T("span")({cursor:"pointer"});class VT extends jT.Component{static __initStatic(){this.propTypes={onEdit:FT.func,hideEdit:FT.bool,onRemove:FT.func}}render(){const{hideEdit:e,onEdit:t,onRemove:n}=this.props;return jT.createElement(HT,null,e?null:jT.createElement(UT,{onClick:t},"Edit Settings"),jT.createElement(qT,{onClick:n},"Remove"))}}VT.__initStatic();const WT=e,{useEffect:KT}=e,GT=t;function JT(e){let t,n=e[0],r=1;for(;r<e.length;){const i=e[r],o=e[r+1];if(r+=2,("optionalAccess"===i||"optionalCall"===i)&&null==n)return;"access"===i||"optionalAccess"===i?(t=n,n=o(n)):"call"!==i&&"optionalCall"!==i||(n=o((...e)=>n.call(t,...e)),t=void 0)}return n}const YT=Kp.create({name:"media",group:"inline",inline:!0,atom:!0,addAttributes:()=>({type:{default:"video"},src:{default:null},width:{default:null},height:{default:null},title:{default:null},starts:{default:null},ends:{default:null},editing:{default:!1},tag:{default:"iframe"},url:{default:null}}),parseHTML:()=>[{tag:'iframe[data-type="video"]',getAttrs:e=>({type:"video",tag:"iframe",src:e.getAttribute("src"),width:e.getAttribute("width"),height:e.getAttribute("height"),title:e.dataset.title,starts:e.dataset.starts,ends:e.dataset.ends,url:e.dataset.url})},{tag:"audio",getAttrs:e=>({type:"audio",tag:"audio",src:JT([e,"access",e=>e.querySelector,"call",e=>e("source"),"optionalAccess",e=>e.getAttribute,"call",e=>e("src")])})}],renderHTML({HTMLAttributes:e}){const{tag:t,src:n,width:r,height:i}=e;return"audio"===t?["audio",{controls:"controls",controlsList:"nodownload"},["source",{src:n,type:"audio/mp3"}]]:["iframe",Lu({"data-type":"video",frameborder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowfullscreen:"",src:n},r?{width:r}:{},i?{height:i}:{})]},addCommands(){return{insertMedia:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e}),updateMedia:e=>({commands:t})=>t.updateAttributes(this.name,e)}},addNodeView(){return qh(e=>WT.createElement(XT,{...{...e,options:this.options}}))}}),ZT=e=>{const t=document.createElement("div"),{type:n,callback:r,options:i,...o}=e,s=document.body.style.overflow;document.querySelectorAll(".insert-media-dialog").forEach(e=>e.remove()),t.className="insert-media-dialog",document.body.style.overflow="hidden";const a=WT.createElement(PT,{...o,uploadSoundSupport:i.uploadSoundSupport,type:n,disablePortal:!0,open:!0,handleClose:(e,n)=>{r(e,n),t.remove(),document.body.style.overflow=s}});GT.render(a,t),document.body.appendChild(t)};function XT({editor:e,node:t,updateAttributes:n,deleteNode:r,options:i}){const{type:o,src:s,width:a,height:l,tag:c}=t.attrs;return KT(()=>{s||ZT({...t.attrs,options:i,edit:!0,callback:(t,i)=>{t?n(i):r(),e.chain().focus().run()}})},[]),WT.createElement(jh,{"data-type":o,style:{width:a,height:l}},"audio"===c?WT.createElement("audio",{controls:!0,controlsList:"nodownload"},WT.createElement("source",{type:"audio/mp3",src:s})):WT.createElement("iframe",{src:s,allowFullScreen:!0,frameBorder:"0"}),WT.createElement(VT,{onEdit:()=>{ZT({...t.attrs,options:i,edit:!0,callback:(t,r)=>{t&&n(r),e.chain().focus().run()}})},onRemove:r}))}const QT=e,eO=t,{List:tO}=n,{ListItem:nO}=n;function rO(e){let t,n=e[0],r=1;for(;r<e.length;){const i=e[r],o=e[r+1];if(r+=2,("optionalAccess"===i||"optionalCall"===i)&&null==n)return;"access"===i||"optionalAccess"===i?(t=n,n=o(n)):"call"!==i&&"optionalCall"!==i||(n=o((...e)=>n.call(t,...e)),t=void 0)}return n}const iO=({editor:e,callback:t,opts:n,selectedText:r,parentNode:i})=>{const o=e.options.element,s=document.createElement("div"),{selection:a}=e.state;document.querySelectorAll(".insert-css-dialog").forEach(e=>e.remove()),s.className="insert-css-dialog";let l=!1;const c=e=>{if(l){const t=s.contains(e.target)||undefined,n=o.contains(e.target);t||n||u()}else l=!0},u=()=>{t(void 0,!0),s.remove(),document.body.removeEventListener("click",c)},d=rO([i,"optionalAccess",e=>e.attrs,"access",e=>e.class]),p=e=>{let t=`<span class="${e}">${r}</span>`;if(i){let e="span";"inline"===rO([i,"optionalAccess",e=>e.object])&&(e="span"),"block"===rO([i,"optionalAccess",e=>e.object])&&(e="div"),t=`<${e} class="${d}">${i.text.slice(0,a.$anchor.textOffset)}${t}${i.text.slice(a.$head.textOffset)}</${e}>`}return t},h=QT.createElement("div",{style:{background:"white",height:500,padding:20,overflow:"hidden",display:"flex",flexFlow:"column"}},QT.createElement("h2",null,"Please choose a css class"),d&&QT.createElement("div",null,"The current parent has this class ",d),QT.createElement(tO,{component:"nav",style:{overflow:"scroll"}},n.names.map((e,n)=>QT.createElement(nO,{key:`rule-${n}`,button:!0,onClick:()=>(e=>{t(e,!0),s.remove(),document.body.removeEventListener("click",c)})(e)},QT.createElement("div",{style:{marginRight:20}},e),QT.createElement("div",{dangerouslySetInnerHTML:{__html:p(e)}})))));eO.render(h,s,()=>{const t=rO([e.view.nodeDOM(e.state.selection.from),"optionalAccess",e=>e.parentNode]);if(t){const e=o.parentElement.parentElement.parentElement.getBoundingClientRect(),n=t.getBoundingClientRect();o.parentElement.parentElement.parentElement.appendChild(s),s.style.maxWidth="500px",s.style.position="absolute",s.style.top=0,s.style.zIndex=99999;const r=`${n.left+Math.abs(e.left)+t.offsetWidth+10}px`,i=`${n.x}px`;s.style.left=r;const a=s.offsetWidth;s.style.left="unset",s.style.right=i;const l=s.offsetWidth;s.style.left="unset",s.style.right="unset",a>=l?s.style.left=r:s.style.right=i,document.body.addEventListener("click",c)}})},oO=gd.create({name:"cssmark",addOptions:()=>({classes:[]}),addAttributes:()=>({class:{default:null,parseHTML:e=>e.getAttribute("class"),renderHTML:e=>e.class?{class:e.class}:{}}}),parseHTML(){return[{tag:"span[class]",getAttrs:e=>{const t=e.getAttribute("class")||"",n=this.options.classes.find(e=>t.includes(e));return!!n&&{class:n}}}]},renderHTML:({HTMLAttributes:e})=>["span",Lu(e),0],addCommands(){return{setCSSClass:e=>({commands:t})=>t.setMark(this.name,{class:e}),unsetCSSClass:()=>({commands:e})=>e.unsetMark(this.name),openCSSClassDialog:()=>({editor:e})=>{iO({editor:e,selectedText:e.state.doc.textBetween(e.state.selection.from,e.state.selection.to),parentNode:e.state.selection.$from.nodeAfter,opts:this.options.extraCSSRules,callback:t=>{t&&e.chain().focus().setCSSClass(t).run()}})}}}}),sO=e=>{if(!e)return;const t=/^calc\((.*)\)$/;if("string"==typeof e){if(e.endsWith("%"))return;if(e.endsWith("px")||e.endsWith("vh")||e.endsWith("vw")||e.endsWith("ch")||e.endsWith("em")||e.match(t))return e;const n=parseInt(e,10);return Number.isNaN(n)?n:`${n}px`}return"number"==typeof e?`${e}px`:void 0},aO=e,{styled:lO}=r,cO=lO("div")(({theme:e})=>({fontFamily:"Cerebri Sans !important",fontSize:e.typography.fontSize,fontWeight:"bold",lineHeight:"14px",position:"relative",top:"7px",width:"110px",height:"28px",whiteSpace:"nowrap"})),uO=()=>aO.createElement(cO,null,"+ Response Area"),dO={characters:[["á","é","í","ó","ú"],["Á","É","Í","Ó","Ú"],["—","«","»","ñ","ü"],["-","¿","¡","Ñ","Ü"]]},pO={hasPreview:!0,characters:[[{unicode:"U+00A2",description:"CENT SIGN",write:"¢",label:"¢"},{unicode:"U+00BF",description:"INVERTED QUESTION MARK",write:"¿",label:"¿"},{unicode:"U+00B4",description:"ACUTE ACCENT",write:"´",label:"´",extraProps:{style:{gridRow:"span 2"}}},{unicode:"U+00E1",description:"LATIN SMALL LETTER A WITH ACUTE",write:"á",label:"á"},{unicode:"U+00E9",description:"LATIN SMALL LETTER E WITH ACUTE",write:"é",label:"é"},{unicode:"U+00ED",description:"LATIN SMALL LETTER I WITH ACUTE",write:"í",label:"í"},{unicode:"U+00F3",description:"LATIN SMALL LETTER O WITH ACUTE",write:"ó",label:"ó"},{unicode:"U+00FA",description:"LATIN SMALL LETTER U WITH ACUTE",write:"ú",label:"ú"},{unicode:"U+00F1",description:"LATIN SMALL LETTER N WITH TILDE",write:"ñ",label:"ñ"}],[{unicode:"U+20AC",description:"EURO SIGN",write:"€",label:"€"},{unicode:"U+00A1",description:"INVERTED EXCLAMATION MARK",write:"¡",label:"¡"},{unicode:"U+00C1",description:"LATIN CAPITAL LETTER A WITH ACUTE",write:"Á",label:"Á"},{unicode:"U+00C9",description:"LATIN CAPITAL LETTER E WITH ACUTE",write:"É",label:"É"},{unicode:"U+00CD",description:"LATIN CAPITAL LETTER I WITH ACUTE",write:"Í",label:"Í"},{unicode:"U+00D3",description:"LATIN CAPITAL LETTER O WITH ACUTE",write:"Ó",label:"Ó"},{unicode:"U+00DA",description:"LATIN CAPITAL LETTER U WITH ACUTE",write:"Ú",label:"Ú"},{unicode:"U+00D1",description:"LATIN CAPITAL LETTER N WITH TILDE",write:"Ñ",label:"Ñ"}],[{unicode:"U+00A3",description:"POUND SIGN",write:"£",label:"£"},{unicode:"U+00AB",description:"LEFT-POINTING DOUBLE ANGLE QUOTATION MARK",write:"«",label:"«"},{unicode:"U+005E",description:"CIRCUMFLEX ACCENT",write:"^",label:"^",extraProps:{style:{gridRow:"span 2"}}},{unicode:"U+00E2",description:"LATIN SMALL LETTER A WITH CIRCUMFLEX",write:"â",label:"â"},{unicode:"U+00EA",description:"LATIN SMALL LETTER E WITH CIRCUMFLEX",write:"ê",label:"ê"},{unicode:"U+00EE",description:"LATIN SMALL LETTER I WITH CIRCUMFLEX",write:"î",label:"î"},{unicode:"U+00F4",description:"LATIN SMALL LETTER O WITH CIRCUMFLEX",write:"ô",label:"ô"},{unicode:"U+00FB",description:"LATIN SMALL LETTER U WITH CIRCUMFLEX",write:"û",label:"û"},{unicode:"U+00E7",description:"LATIN SMALL LETTER C WITH CEDILLA",write:"ç",label:"ç"}],[{unicode:"U+00A5",description:"YEN SIGN",write:"¥",label:"¥"},{unicode:"U+00BB",description:"RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK",write:"»",label:"»"},{unicode:"U+00C2",description:"LATIN CAPITAL LETTER A WITH CIRCUMFLEX",write:"Â",label:"Â"},{unicode:"U+00CA",description:"LATIN CAPITAL LETTER E WITH CIRCUMFLEX",write:"Ê",label:"Ê"},{unicode:"U+00CE",description:"LATIN CAPITAL LETTER I WITH CIRCUMFLEX",write:"Î",label:"Î"},{unicode:"U+00D4",description:"LATIN CAPITAL LETTER O WITH CIRCUMFLEX",write:"Ô",label:"Ô"},{unicode:"U+00DB",description:"LATIN CAPITAL LETTER U WITH CIRCUMFLEX",write:"Û",label:"Û"},{unicode:"U+00C7",description:"LATIN CAPITAL LETTER C WITH CEDILLA",write:"Ç",label:"Ç"}],[{unicode:"U+200A",description:"HAIR SPACE",write:String.fromCodePoint("0x200A"),label:"&hairsp;"},{unicode:"U+00A7",description:"SECTION SIGN",write:"§",label:"§"},{unicode:"U+00A8",description:"DIAERESIS",write:"¨",label:"¨",extraProps:{style:{gridRow:"span 2"}}},{unicode:"U+00E4",description:"LATIN SMALL LETTER A WITH DIAERESIS",write:"ä",label:"ä"},{unicode:"U+00EB",description:"LATIN SMALL LETTER E WITH DIAERESIS",write:"ë",label:"ë"},{unicode:"U+00EF",description:"LATIN SMALL LETTER I WITH DIAERESIS",write:"ï",label:"ï"},{unicode:"U+00F6",description:"LATIN SMALL LETTER O WITH DIAERESIS",write:"ö",label:"ö"},{unicode:"U+00FC",description:"LATIN SMALL LETTER U WITH DIAERESIS",write:"ü",label:"ü"},{unicode:"U+00DF",description:"LATIN SMALL LETTER SHARP S",write:"ß",label:"ß"}],[{unicode:"U+2009",description:"THIN SPACE",write:String.fromCodePoint("0x2009"),label:"&thinsp;"},{unicode:"U+2026",description:"HORIZONTAL ELLIPSIS",write:"…",label:"…"},{unicode:"U+00C4",description:"LATIN CAPITAL LETTER A WITH DIAERESIS",write:"Ä",label:"Ä"},{unicode:"U+00CB",description:"LATIN CAPITAL LETTER E WITH DIAERESIS",write:"Ë",label:"Ë"},{unicode:"U+00CF",description:"LATIN CAPITAL LETTER I WITH DIAERESIS",write:"Ï",label:"Ï"},{unicode:"U+00D6",description:"LATIN CAPITAL LETTER O WITH DIAERESIS",write:"Ö",label:"Ö"},{unicode:"U+00DC",description:"LATIN CAPITAL LETTER U WITH DIAERESIS",write:"Ü",label:"Ü"},{unicode:"U+2212",description:"MINUS SIGN",write:"−",label:"−"}],[{unicode:"U+00A0",description:"NO-BREAK SPACE",write:String.fromCodePoint("0x00A0"),label:"&nbsp;"},{unicode:"U+2022",description:"BULLET",write:"•",label:"•"},{unicode:"U+0060",description:"GRAVE ACCENT",write:"`",label:"`",extraProps:{style:{gridRow:"span 2"}}},{unicode:"U+00E0",description:"LATIN SMALL LETTER A WITH GRAVE",write:"à",label:"à"},{unicode:"U+00E8",description:"LATIN SMALL LETTER E WITH GRAVE",write:"è",label:"è"},{unicode:"U+00EC",description:"LATIN SMALL LETTER I WITH GRAVE",write:"ì",label:"ì"},{unicode:"U+00F2",description:"LATIN SMALL LETTER O WITH GRAVE",write:"ò",label:"ò"},{unicode:"U+00F9",description:"LATIN SMALL LETTER U WITH GRAVE",write:"ù",label:"ù"},{unicode:"U+2013",description:"EN DASH",write:"–",label:"–"}],[{unicode:"U+2003",description:"EM SPACE",write:String.fromCodePoint("0x2003"),label:"&emsp;"},{unicode:"U+25E6",description:"WHITE BULLET",write:"◦",label:"◦"},{unicode:"U+00C0",description:"LATIN CAPITAL LETTER A WITH GRAVE",write:"À",label:"À"},{unicode:"U+00C8",description:"LATIN CAPITAL LETTER E WITH GRAVE",write:"È",label:"È"},{unicode:"U+00CC",description:"LATIN CAPITAL LETTER I WITH GRAVE",write:"Ì",label:"Ì"},{unicode:"U+00D2",description:"LATIN CAPITAL LETTER O WITH GRAVE",write:"Ò",label:"Ò"},{unicode:"U+00D9",description:"LATIN CAPITAL LETTER U WITH GRAVE",write:"Ù",label:"Ù"},{unicode:"U+2014",description:"EM DASH",write:"—",label:"—"}]]},hO=e,{useState:fO}=e,mO=c,{List:gO}=n,{ListItem:yO}=n;const vO=()=>hO.createElement("svg",{width:"20",height:"20",viewBox:"0 0 66 66",fill:"none",xmlns:"http://www.w3.org/2000/svg"},hO.createElement("path",{d:"M42.1875 4.75C42.1875 7.38672 39.9902 9.4375 37.5 9.4375H4.6875C2.05078 9.4375 0 7.38672 0 4.75C0 2.25977 2.05078 0.0625 4.6875 0.0625H37.5C39.9902 0.0625 42.1875 2.25977 42.1875 4.75ZM42.1875 42.25C42.1875 44.8867 39.9902 46.9375 37.5 46.9375H4.6875C2.05078 46.9375 0 44.8867 0 42.25C0 39.7598 2.05078 37.5625 4.6875 37.5625H37.5C39.9902 37.5625 42.1875 39.7598 42.1875 42.25ZM0 23.5C0 21.0098 2.05078 18.8125 4.6875 18.8125H60.9375C63.4277 18.8125 65.625 21.0098 65.625 23.5C65.625 26.1367 63.4277 28.1875 60.9375 28.1875H4.6875C2.05078 28.1875 0 26.1367 0 23.5ZM65.625 61C65.625 63.6367 63.4277 65.6875 60.9375 65.6875H4.6875C2.05078 65.6875 0 63.6367 0 61C0 58.5098 2.05078 56.3125 4.6875 56.3125H60.9375C63.4277 56.3125 65.625 58.5098 65.625 61Z",fill:"currentColor"})),bO=()=>hO.createElement("svg",{width:"20",height:"20",viewBox:"0 0 66 66",fill:"none",xmlns:"http://www.w3.org/2000/svg"},hO.createElement("path",{d:"M65.625 4.75C65.625 7.38672 63.4277 9.4375 60.9375 9.4375H28.125C25.4883 9.4375 23.4375 7.38672 23.4375 4.75C23.4375 2.25977 25.4883 0.0625 28.125 0.0625H60.9375C63.4277 0.0625 65.625 2.25977 65.625 4.75ZM65.625 42.25C65.625 44.8867 63.4277 46.9375 60.9375 46.9375H28.125C25.4883 46.9375 23.4375 44.8867 23.4375 42.25C23.4375 39.7598 25.4883 37.5625 28.125 37.5625H60.9375C63.4277 37.5625 65.625 39.7598 65.625 42.25ZM0 23.5C0 21.0098 2.05078 18.8125 4.6875 18.8125H60.9375C63.4277 18.8125 65.625 21.0098 65.625 23.5C65.625 26.1367 63.4277 28.1875 60.9375 28.1875H4.6875C2.05078 28.1875 0 26.1367 0 23.5ZM65.625 61C65.625 63.6367 63.4277 65.6875 60.9375 65.6875H4.6875C2.05078 65.6875 0 63.6367 0 61C0 58.5098 2.05078 56.3125 4.6875 56.3125H60.9375C63.4277 56.3125 65.625 58.5098 65.625 61Z",fill:"currentColor"})),wO=()=>hO.createElement("svg",{width:"20",height:"20",viewBox:"0 0 66 66",fill:"none",xmlns:"http://www.w3.org/2000/svg"},hO.createElement("path",{d:"M51.5625 4.75C51.5625 7.38672 49.3652 9.4375 46.875 9.4375H18.75C16.1133 9.4375 14.0625 7.38672 14.0625 4.75C14.0625 2.25977 16.1133 0.0625 18.75 0.0625H46.875C49.3652 0.0625 51.5625 2.25977 51.5625 4.75ZM65.625 23.5C65.625 26.1367 63.4277 28.1875 60.9375 28.1875H4.6875C2.05078 28.1875 0 26.1367 0 23.5C0 21.0098 2.05078 18.8125 4.6875 18.8125H60.9375C63.4277 18.8125 65.625 21.0098 65.625 23.5ZM0 61C0 58.5098 2.05078 56.3125 4.6875 56.3125H60.9375C63.4277 56.3125 65.625 58.5098 65.625 61C65.625 63.6367 63.4277 65.6875 60.9375 65.6875H4.6875C2.05078 65.6875 0 63.6367 0 61ZM51.5625 42.25C51.5625 44.8867 49.3652 46.9375 46.875 46.9375H18.75C16.1133 46.9375 14.0625 44.8867 14.0625 42.25C14.0625 39.7598 16.1133 37.5625 18.75 37.5625H46.875C49.3652 37.5625 51.5625 39.7598 51.5625 42.25Z",fill:"currentColor"})),xO=()=>hO.createElement("svg",{width:"20",height:"20",viewBox:"0 0 66 66",fill:"none",xmlns:"http://www.w3.org/2000/svg"},hO.createElement("path",{d:"M65.625 4.75C65.625 7.38672 63.4277 9.4375 60.9375 9.4375H4.6875C2.05078 9.4375 0 7.38672 0 4.75C0 2.25977 2.05078 0.0625 4.6875 0.0625H60.9375C63.4277 0.0625 65.625 2.25977 65.625 4.75ZM65.625 42.25C65.625 44.8867 63.4277 46.9375 60.9375 46.9375H4.6875C2.05078 46.9375 0 44.8867 0 42.25C0 39.7598 2.05078 37.5625 4.6875 37.5625H60.9375C63.4277 37.5625 65.625 39.7598 65.625 42.25ZM0 23.5C0 21.0098 2.05078 18.8125 4.6875 18.8125H60.9375C63.4277 18.8125 65.625 21.0098 65.625 23.5C65.625 26.1367 63.4277 28.1875 60.9375 28.1875H4.6875C2.05078 28.1875 0 26.1367 0 23.5ZM65.625 61C65.625 63.6367 63.4277 65.6875 60.9375 65.6875H4.6875C2.05078 65.6875 0 63.6367 0 61C0 58.5098 2.05078 56.3125 4.6875 56.3125H60.9375C63.4277 56.3125 65.625 58.5098 65.625 61Z",fill:"currentColor"}));var MO=({editor:e,onChange:t})=>{const[n,r]=fO(!1);let i;switch(!0){case e.isActive({textAlign:"right"}):i=hO.createElement(bO,null);break;case e.isActive({textAlign:"center"}):i=hO.createElement(wO,null);break;case e.isActive({textAlign:"justify"}):i=hO.createElement(xO,null);break;default:i=hO.createElement(vO,null)}const o=t=>{const n=function(e){let t,n=e[0],r=1;for(;r<e.length;){const i=e[r],o=e[r+1];if(r+=2,("optionalAccess"===i||"optionalCall"===i)&&null==n)return;"access"===i||"optionalAccess"===i?(t=n,n=o(n)):"call"!==i&&"optionalCall"!==i||(n=o((...e)=>n.call(t,...e)),t=void 0)}return n}([t,"access",e=>e.currentTarget,"optionalAccess",e=>e.getAttribute,"call",e=>e("value")]);n&&e.commands.setTextAlign(n),r(!1)};return hO.createElement("div",null,hO.createElement("div",{style:{display:"flex",alignItems:"center"},onClick:e=>{e.preventDefault(),e.stopPropagation(),r(!n)}},i,hO.createElement("span",{style:{marginLeft:"5px",fontSize:"8px"}},"▼")),hO.createElement(mO,{in:n,timeout:"auto",unmountOnExit:!0,style:{position:"absolute"}},hO.createElement(gO,{component:"div",disablePadding:!0,style:{background:"#fff",display:"flex",flexDirection:"row",padding:0}},hO.createElement(yO,{button:!0,type:"submit",value:"left","aria-label":"Align text left",onClick:o},hO.createElement(vO,null)),hO.createElement(yO,{button:!0,type:"submit",value:"center","aria-label":"Align text center",onClick:o},hO.createElement(wO,null)),hO.createElement(yO,{button:!0,type:"submit",value:"right","aria-label":"Align text right",onClick:o},hO.createElement(bO,null)),hO.createElement(yO,{button:!0,type:"submit",value:"justify","aria-label":"Justify text",onClick:o},hO.createElement(xO,null)))))};const SO=e,{styled:EO}=r,CO=EO("div")(({theme:e})=>({fontFamily:"Cerebri Sans, Arial, sans-serif",fontSize:e.typography.fontSize,fontWeight:"bold",lineHeight:"14px",position:"relative",whiteSpace:"nowrap"})),NO=()=>SO.createElement(CO,null,"CSS"),AO=e,{styled:kO}=r,TO=kO("path")({fill:"grey","&:hover":{fill:"black"}}),OO=e=>t=>AO.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",version:"1.1",width:"24",height:"24",viewBox:"0 0 24 24"},AO.createElement(e,{...t})),_O=OO(e=>AO.createElement(TO,{...e,d:"M22,10A2,2 0 0,1 20,12H4A2,2 0 0,1 2,10V3H4V5H8V3H10V5H14V3H16V5H20V3H22V10M4,10H8V7H4V10M10,10H14V7H10V10M20,10V7H16V10H20M11,14H13V17H16V19H13V22H11V19H8V17H11V14Z"})),RO=OO(e=>AO.createElement(TO,{...e,d:"M9.41,13L12,15.59L14.59,13L16,14.41L13.41,17L16,19.59L14.59,21L12,18.41L9.41,21L8,19.59L10.59,17L8,14.41L9.41,13M22,9A2,2 0 0,1 20,11H4A2,2 0 0,1 2,9V6A2,2 0 0,1 4,4H20A2,2 0 0,1 22,6V9M4,9H8V6H4V9M10,9H14V6H10V9M16,9H20V6H16V9Z"})),DO=OO(e=>AO.createElement(TO,{...e,d:"M11,2A2,2 0 0,1 13,4V20A2,2 0 0,1 11,22H2V2H11M4,10V14H11V10H4M4,16V20H11V16H4M4,4V8H11V4H4M15,11H18V8H20V11H23V13H20V16H18V13H15V11Z"})),IO=OO(e=>AO.createElement(TO,{...e,d:"M4,2H11A2,2 0 0,1 13,4V20A2,2 0 0,1 11,22H4A2,2 0 0,1 2,20V4A2,2 0 0,1 4,2M4,10V14H11V10H4M4,16V20H11V16H4M4,4V8H11V4H4M17.59,12L15,9.41L16.41,8L19,10.59L21.59,8L23,9.41L20.41,12L23,14.59L21.59,16L19,13.41L16.41,16L15,14.59L17.59,12Z"})),LO=OO(e=>AO.createElement(TO,{...e,d:"M15.46,15.88L16.88,14.46L19,16.59L21.12,14.46L22.54,15.88L20.41,18L22.54,20.12L21.12,21.54L19,19.41L16.88,21.54L15.46,20.12L17.59,18L15.46,15.88M4,3H18A2,2 0 0,1 20,5V12.08C18.45,11.82 16.92,12.18 15.68,13H12V17H13.08C12.97,17.68 12.97,18.35 13.08,19H4A2,2 0 0,1 2,17V5A2,2 0 0,1 4,3M4,7V11H10V7H4M12,7V11H18V7H12M4,13V17H10V13H4Z"})),BO=e,{styled:zO}=r,{Popper:PO}=n,{Typography:jO}=n,FO=zO(PO)({background:"#fff",padding:"10px",pointerEvents:"none",zIndex:99999}),$O=zO(jO)({fontSize:50,textAlign:"center"}),HO=({children:e,...t})=>BO.createElement(FO,{id:"mouse-over-popover",open:!0,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},disableRestoreFocus:!0,disableAutoFocus:!0,...t},BO.createElement($O,null,e)),UO=e,{useEffect:qO}=e,{useMemo:VO}=e,{useRef:WO}=e,{useState:KO}=e,GO=t,JO=i,{PureToolbar:YO}=p;const ZO=({letter:e})=>UO.createElement("div",{style:{fontSize:"24px",lineHeight:"24px"}},e);function XO({editor:e,opts:t,onClose:n}){if(!function(e){let t,n=e[0],r=1;for(;r<e.length;){const i=e[r],o=e[r+1];if(r+=2,("optionalAccess"===i||"optionalCall"===i)&&null==n)return;"access"===i||"optionalAccess"===i?(t=n,n=o(n)):"call"!==i&&"optionalCall"!==i||(n=o((...e)=>n.call(t,...e)),t=void 0)}return n}([t,"optionalAccess",e=>e.characters,"optionalAccess",e=>e.length]))return null;const r=WO(null),[i,o]=KO({top:0,left:0}),[s,a]=KO(null),l=VO(()=>{if(!t)return dO;switch(!0){case"spanish"===t.language:return dO;case"special"===t.language:return pO;default:return t}},[t]),c=VO(()=>l.characters.reduce((e,t)=>(t.length>=e.columns&&(e.columns=t.length),e),{rows:l.characters.length,columns:0}),[l]),u=()=>a(null);qO(()=>()=>{u()},[]),qO(()=>{if(!e)return;const t=e.options.element.getBoundingClientRect(),i=document.body.getBoundingClientRect(),{from:s}=e.state.selection,a=e.view.coordsAtPos(s);let l=t.top+Math.abs(i.top)+t.height+60;t.y>r.current.offsetHeight&&(l=l-(r.current.offsetHeight+t.height)-80),o({top:l,left:a.left});const c=t=>{!r.current||r.current.contains(t.target)||e.view.dom.contains(t.target)||n()},u=setTimeout(()=>{document.addEventListener("click",c)});return()=>{clearTimeout(u),document.removeEventListener("click",c)}},[e,n]);return UO.createElement(UO.Fragment,null,GO.createPortal(UO.createElement("div",{ref:r,className:"insert-character-dialog","data-toolbar-for":e.instanceId,style:{visibility:0===i.top&&0===i.left?"hidden":"initial",position:"absolute",top:`${i.top}px`,left:`${i.left}px`,maxWidth:"500px",zIndex:99}},UO.createElement("div",null,UO.createElement(YO,{keyPadCharacterRef:t.keyPadCharacterRef,setKeypadInteraction:t.setKeypadInteraction,autoFocus:!0,noDecimal:!0,hideInput:!0,noLatexHandling:!0,hideDoneButtonBackground:!0,layoutForKeyPad:c,additionalKeys:l.characters.reduce((e,t)=>(e=[...e,...t.map(e=>({name:Et(e,"name")||e,write:Et(e,"write")||e,label:Et(e,"label")||e,category:"character",extraClass:"character",extraProps:{...e.extraProps||{},style:{...(e.extraProps||{}).style,border:"1px solid #000"}},...l.hasPreview?{actions:{onMouseEnter:t=>{return n=e,a({anchorEl:t.currentTarget,el:n});var n},onMouseLeave:u}}:{}}))],e),[]),keypadMode:"language",onChange:t=>{"string"==typeof t&&e.chain().focus().insertContent(t).run()},onDone:n}))),document.body),s&&GO.createPortal(UO.createElement(HO,{onClose:u,anchorEl:s.anchorEl},UO.createElement("div",null,s.el.label),UO.createElement("div",{style:{fontSize:20,lineHeight:"20px"}},s.el.description),UO.createElement("div",{style:{fontSize:20,lineHeight:"20px"}},s.el.unicode)),document.body))}ZO.propTypes={letter:JO.string},XO.propTypes={editor:JO.object,opts:JO.object,onClose:JO.func.isRequired};const QO=e,{useMemo:e_}=e,{useState:t_}=e,n_=s,{styled:r_}=r,{useTheme:i_}=r,{FormatBold:o_}=o,{FormatItalic:s_}=o,{FormatStrikethrough:a_}=o,{Code:l_}=o,{GridOn:c_}=o,{FormatListBulleted:u_}=o,{FormatListNumbered:d_}=o,{FormatUnderlined:p_}=o,{Functions:h_}=o,{Image:f_}=o,{Redo:m_}=o,{Undo:g_}=o,{FormatQuote:y_}=o,{Theaters:v_}=o,{VolumeUp:b_}=o,{BorderAll:w_}=o,{Delete:x_}=o;function M_(e,t){return null!=e?e:t()}function S_(e){let t,n=e[0],r=1;for(;r<e.length;){const i=e[r],o=e[r+1];if(r+=2,("optionalAccess"===i||"optionalCall"===i)&&null==n)return;"access"===i||"optionalAccess"===i?(t=n,n=o(n)):"call"!==i&&"optionalCall"!==i||(n=o((...e)=>n.call(t,...e)),t=void 0)}return n}const E_=()=>QO.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"none"},QO.createElement("path",{d:"M22,7h-2v1h3v1h-4V7c0-0.55,0.45-1,1-1h2V5h-3V4h3c0.55,0,1,0.45,1,1v1C23,6.55,22.55,7,22,7z M5.88,20h2.66l3.4-5.42h0.12 l3.4,5.42h2.66l-4.65-7.27L17.81,6h-2.68l-3.07,4.99h-0.12L8.85,6H6.19l4.32,6.73L5.88,20z",fill:"currentColor"})),C_=()=>QO.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"none"},QO.createElement("path",{d:"M22,18h-2v1h3v1h-4v-2c0-0.55,0.45-1,1-1h2v-1h-3v-1h3c0.55,0,1,0.45,1,1v1C23,17.55,22.55,18,22,18z M5.88,18h2.66 l3.4-5.42h0.12l3.4,5.42h2.66l-4.65-7.27L17.81,4h-2.68l-3.07,4.99h-0.12L8.85,4H6.19l4.32,6.73L5.88,18z",fill:"currentColor"})),N_=()=>QO.createElement("svg",{width:"30",height:"28",viewBox:"0 0 30 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{width:"20px",height:"18px"}},QO.createElement("path",{d:"M27 4V24H29C29.5 24 30 24.5 30 25V27C30 27.5625 29.5 28 29 28H19C18.4375 28 18 27.5625 18 27V25C18 24.5 18.4375 24 19 24H21V16H9V24H11C11.5 24 12 24.5 12 25V27C12 27.5625 11.5 28 11 28H1C0.4375 28 0 27.5625 0 27V25C0 24.5 0.4375 24 1 24H3V4H1C0.4375 4 0 3.5625 0 3V1C0 0.5 0.4375 0 1 0H11C11.5 0 12 0.5 12 1V3C12 3.5625 11.5 4 11 4H9V12H21V4H19C18.4375 4 18 3.5625 18 3V1C18 0.5 18.4375 0 19 0H29C29.5 0 30 0.5 30 1V3C30 3.5625 29.5 4 29 4H27Z",fill:"currentColor"}));function A_({editor:e,classes:t,activePlugins:n,toolbarOpts:r,responseAreaProps:i,onChange:o,autoWidthToolbar:s}){const[a,l]=t_(!1),c=M_(r,()=>({})),u=Ih({editor:e,selector:e=>{const{selection:t}=S_([e,"access",e=>e.editor,"optionalAccess",e=>e.state])||{};let n;t instanceof Jo&&(n=t.node);return{currentNode:n,hideDefaultToolbar:S_([e,"access",e=>e.editor,"optionalAccess",e=>e.isActive,"call",e=>e("math")])||S_([e,"access",e=>e.editor,"optionalAccess",e=>e.isActive,"call",e=>e("explicit_constructed_response")])||S_([e,"access",e=>e.editor,"optionalAccess",e=>e.isActive,"call",e=>e("imageUploadNode")])||S_([e,"access",e=>e.editor,"optionalAccess",e=>e.isActive,"call",e=>e("drag_in_the_blank")]),hasTextSelectionInTable:t&&!1===t.empty&&e.editor.isActive("table"),isFocused:S_([e,"access",e=>e.editor,"optionalAccess",e=>e.isFocused]),isBold:M_(e.editor.isActive("bold"),()=>!1),canBold:M_(e.editor.can().chain().toggleBold().run(),()=>!1),isTable:M_(e.editor.isActive("table"),()=>!1),tableHasBorder:M_("1"===S_([e,"access",e=>e.editor,"access",e=>e.getAttributes,"call",e=>e("table"),"optionalAccess",e=>e.border]),()=>!1),canTable:M_(e.editor.can().chain().insertTable().run(),()=>!1),isItalic:M_(e.editor.isActive("italic"),()=>!1),canItalic:M_(e.editor.can().chain().toggleItalic().run(),()=>!1),isStrike:M_(e.editor.isActive("strike"),()=>!1),canStrike:M_(e.editor.can().chain().toggleStrike().run(),()=>!1),isCode:M_(e.editor.isActive("code"),()=>!1),canCode:M_(e.editor.can().chain().toggleCode().run(),()=>!1),canClearMarks:M_(e.editor.can().chain().unsetAllMarks().run(),()=>!1),isUnderline:M_(e.editor.isActive("underline"),()=>!1),isSubScript:M_(e.editor.isActive("subscript"),()=>!1),isSuperScript:M_(e.editor.isActive("superscript"),()=>!1),isParagraph:M_(e.editor.isActive("paragraph"),()=>!1),isHeading1:M_(e.editor.isActive("heading",{level:1}),()=>!1),isHeading2:M_(e.editor.isActive("heading",{level:2}),()=>!1),isHeading3:M_(e.editor.isActive("heading",{level:3}),()=>!1),isHeading4:M_(e.editor.isActive("heading",{level:4}),()=>!1),isHeading5:M_(e.editor.isActive("heading",{level:5}),()=>!1),isHeading6:M_(e.editor.isActive("heading",{level:6}),()=>!1),isBulletList:M_(e.editor.isActive("bulletList"),()=>!1),isOrderedList:M_(e.editor.isActive("orderedList"),()=>!1),isCodeBlock:M_(e.editor.isActive("codeBlock"),()=>!1),isBlockquote:M_(e.editor.isActive("blockquote"),()=>!1),canUndo:M_(e.editor.can().chain().undo().run(),()=>!1),canRedo:M_(e.editor.can().chain().redo().run(),()=>!1)}}}),d=!!s,p=n_(t.toolbar,YS,{[t.toolbarWithNoDone]:!0,[t.toolbarTop]:"top"===c.position,[t.toolbarRight]:"right"===c.alignment,[t.focused]:c.alwaysVisible||u.isFocused&&!e._toolbarOpened&&!u.hideDefaultToolbar,[t.autoWidth]:d,[t.fullWidth]:!d,[t.hidden]:!0===c.isHidden}),h=void 0!==c.minWidth?{minWidth:c.minWidth}:{},f=e_(()=>[{icon:QO.createElement(c_,null),onClick:e=>e.chain().focus().insertTable({rows:2,cols:2,withHeaderRow:!1}).run(),hidden:e=>!S_([n,"optionalAccess",e=>e.includes,"call",e=>e("table")])||e.isTable,isActive:e=>e.isTable,isDisabled:e=>!e.canTable},{icon:QO.createElement(_O,null),onClick:e=>e.chain().focus().addRowAfter().run(),hidden:e=>!(e.isTable&&!e.hasTextSelectionInTable),isActive:e=>e.isTable,isDisabled:e=>!e.canTable},{icon:QO.createElement(RO,null),onClick:e=>e.chain().focus().deleteRow().run(),hidden:e=>!(e.isTable&&!e.hasTextSelectionInTable),isActive:e=>e.isTable,isDisabled:e=>!e.canTable},{icon:QO.createElement(DO,null),onClick:e=>e.chain().focus().addColumnAfter().run(),hidden:e=>!(e.isTable&&!e.hasTextSelectionInTable),isActive:e=>e.isTable,isDisabled:e=>!e.canTable},{icon:QO.createElement(IO,null),onClick:e=>e.chain().focus().deleteColumn().run(),hidden:e=>!(e.isTable&&!e.hasTextSelectionInTable),isActive:e=>e.isTable,isDisabled:e=>!e.canTable},{icon:QO.createElement(LO,null),onClick:e=>e.chain().focus().deleteTable().run(),hidden:e=>!(e.isTable&&!e.hasTextSelectionInTable),isActive:e=>e.isTable,isDisabled:e=>!e.canTable},{icon:QO.createElement(w_,null),onClick:e=>{const t=e.getAttributes("table"),n={...t,border:"0"!==t.border?"0":"1"};e.commands.updateAttributes("table",n)},hidden:e=>!(e.isTable&&!e.hasTextSelectionInTable),isActive:e=>e.tableHasBorder,isDisabled:e=>!e.canTable},{icon:QO.createElement(o_,null),onClick:e=>e.chain().focus().toggleBold().run(),hidden:()=>!S_([n,"optionalAccess",e=>e.includes,"call",e=>e("bold")]),isActive:e=>e.isBold,isDisabled:e=>!e.canBold},{icon:QO.createElement(s_,null),onClick:e=>e.chain().focus().toggleItalic().run(),hidden:()=>!S_([n,"optionalAccess",e=>e.includes,"call",e=>e("italic")]),isActive:e=>e.isItalic,isDisabled:e=>!e.canItalic},{icon:QO.createElement(a_,null),onClick:e=>e.chain().focus().toggleStrike().run(),hidden:()=>!S_([n,"optionalAccess",e=>e.includes,"call",e=>e("strikethrough")]),isActive:e=>e.isStrike,isDisabled:e=>!e.canStrike},{icon:QO.createElement(l_,null),onClick:e=>e.chain().focus().toggleCode().run(),hidden:()=>!S_([n,"optionalAccess",e=>e.includes,"call",e=>e("code")]),isActive:e=>e.isCode,isDisabled:e=>!e.canCode},{icon:QO.createElement(p_,null),onClick:e=>e.chain().focus().toggleUnderline().run(),hidden:()=>!S_([n,"optionalAccess",e=>e.includes,"call",e=>e("underline")]),isActive:e=>e.isUnderline},{icon:QO.createElement(C_,null),onClick:e=>e.chain().focus().toggleSubscript().run(),hidden:()=>!S_([n,"optionalAccess",e=>e.includes,"call",e=>e("subscript")]),isActive:e=>e.isSubScript},{icon:QO.createElement(E_,null),onClick:e=>e.chain().focus().toggleSuperscript().run(),hidden:()=>!S_([n,"optionalAccess",e=>e.includes,"call",e=>e("superscript")]),isActive:e=>e.isSuperScript},{icon:QO.createElement(f_,null),hidden:()=>!S_([n,"optionalAccess",e=>e.includes,"call",e=>e("image")]),onClick:e=>e.chain().focus().setImageUploadNode().run()},{icon:QO.createElement(v_,null),hidden:()=>!S_([n,"optionalAccess",e=>e.includes,"call",e=>e("video")]),onClick:e=>e.chain().focus().insertMedia({type:"video"}).run()},{icon:QO.createElement(b_,null),hidden:()=>!S_([n,"optionalAccess",e=>e.includes,"call",e=>e("audio")]),onClick:e=>e.chain().focus().insertMedia({type:"audio",tag:"audio"}).run()},{icon:QO.createElement(NO,null),hidden:()=>!S_([n,"optionalAccess",e=>e.includes,"call",e=>e("css")]),onClick:e=>e.commands.openCSSClassDialog()},{icon:QO.createElement(y_,null),hidden:()=>!S_([n,"optionalAccess",e=>e.includes,"call",e=>e("blockquote")]),onClick:e=>e.chain().focus().toggleBlockquote().run(),isActive:e=>e.isBlockquote},{icon:QO.createElement(N_,null),hidden:()=>!S_([n,"optionalAccess",e=>e.includes,"call",e=>e("h3")]),onClick:e=>e.chain().focus().toggleHeading({level:3}).run(),isActive:e=>e.isHeading3},{icon:QO.createElement(h_,null),hidden:()=>!S_([n,"optionalAccess",e=>e.includes,"call",e=>e("math")]),onClick:e=>e.chain().focus().insertMath("").run()},{icon:QO.createElement(ZO,{letter:"ñ"}),hidden:()=>!S_([n,"optionalAccess",e=>e.includes,"call",e=>e("languageCharacters")]),onClick:()=>l(dO)},{icon:QO.createElement(ZO,{letter:"€"}),hidden:()=>2!==S_([n,"optionalAccess",e=>e.filter,"call",e=>e(e=>"languageCharacters"===e),"access",e=>e.length]),onClick:()=>l(pO)},{icon:QO.createElement(MO,{editor:e}),hidden:()=>!S_([n,"optionalAccess",e=>e.includes,"call",e=>e("text-align")]),onClick:()=>{}},{icon:QO.createElement(u_,null),hidden:()=>!S_([n,"optionalAccess",e=>e.includes,"call",e=>e("bulleted-list")]),onClick:e=>e.chain().focus().toggleBulletList().run(),isActive:e=>e.isBulletList},{icon:QO.createElement(d_,null),hidden:()=>!S_([n,"optionalAccess",e=>e.includes,"call",e=>e("numbered-list")]),onClick:e=>e.chain().focus().toggleOrderedList().run(),isActive:e=>e.isOrderedList},{icon:QO.createElement(g_,null),hidden:()=>!S_([n,"optionalAccess",e=>e.includes,"call",e=>e("undo")]),onClick:e=>e.chain().focus().undo().run(),isDisabled:e=>!e.canUndo},{icon:QO.createElement(m_,null),hidden:()=>!S_([n,"optionalAccess",e=>e.includes,"call",e=>e("redo")]),onClick:e=>e.chain().focus().redo().run(),isDisabled:e=>!e.canRedo}],[n,e]),m=u.hideDefaultToolbar&&"drag_in_the_blank"===S_([u,"access",e=>e.currentNode,"optionalAccess",e=>e.type,"optionalAccess",e=>e.name]);return QO.createElement("div",{className:p,style:{...h},onMouseDown:e=>{e.preventDefault()}},m&&QO.createElement("div",{className:t.defaultToolbar,tabIndex:"1"},QO.createElement("div",{className:t.buttonsContainer},QO.createElement("button",{type:"button",className:t.button,onClick:t=>{t.preventDefault(),e.chain().focus().deleteSelection().run(),S_([o,"optionalCall",t=>t(e.getHTML())])},"aria-label":"Delete response area"},QO.createElement(x_,null)))),!u.hideDefaultToolbar&&QO.createElement("div",{className:t.defaultToolbar,tabIndex:"1"},QO.createElement("div",{className:t.buttonsContainer},f.filter(e=>!S_([e,"access",e=>e.hidden,"optionalCall",e=>e(u)])).map((n,r)=>{const i=S_([n,"access",e=>e.isDisabled,"optionalCall",e=>e(u)]),o=S_([n,"access",e=>e.isActive,"optionalCall",e=>e(u)]);return QO.createElement("button",{key:r,disabled:i,onClick:t=>{t.preventDefault(),n.onClick(e)},className:n_(t.button,{[t.active]:o})},n.icon)})),S_([n,"optionalAccess",e=>e.includes,"call",e=>e("responseArea")])&&QO.createElement("button",{onClick:()=>{e.chain().focus().insertResponseArea(i.type).run()},className:t.button},QO.createElement(uO,null)),c.showDone&&QO.createElement(iE,{onClick:()=>{S_([o,"optionalCall",t=>t(e.getHTML())]),e.commands.blur()}})),a&&QO.createElement(XO,{editor:e,opts:{...a,renderPopOver:(e,t)=>console.log("Show popover",t),closePopOver:()=>console.log("Close popover")},onClose:()=>l(!1)}))}const k_=e=>{i_();return QO.createElement(T_,null,QO.createElement(A_,{...e,classes:{defaultToolbar:"defaultToolbar",buttonsContainer:"buttonsContainer",button:"button",active:"active",disabled:"disabled",isActive:"isActive",toolbar:"toolbar",toolbarWithNoDone:"toolbarWithNoDone",toolbarTop:"toolbarTop",toolbarRight:"toolbarRight",fullWidth:"fullWidth",hidden:"hidden",autoWidth:"autoWidth",focused:"focused",iconRoot:"iconRoot",label:"label",shared:"shared"}}))},T_=r_("div")(({theme:e})=>({"& .defaultToolbar":{display:"flex",width:"100%",justifyContent:"space-between"},"& .buttonsContainer":{alignItems:"center",display:"flex",width:"100%"},"& .button":{color:"grey",display:"inline-flex",padding:"2px",background:"none",border:"none",cursor:"pointer","&:hover":{color:"black"},"&:focus":{outline:`2px solid ${e.palette.grey[700]}`}},"& .active":{color:"black"},"& .disabled":{opacity:.7,cursor:"not-allowed","& :hover":{color:"grey"}},"& .isActive":{background:"var(--purple)",color:"var(--white)"},"& .toolbar":{position:"absolute",zIndex:20,cursor:"pointer",justifyContent:"space-between",background:"var(--editable-html-toolbar-bg, #efefef)",minWidth:"280px",margin:"5px 0 0 0",padding:"2px",boxShadow:"0px 1px 5px 0px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 3px 1px -2px rgba(0, 0, 0, 0.12)",boxSizing:"border-box",display:"flex",opacity:0,pointerEvents:"none"},"& .toolbarWithNoDone":{minWidth:"265px"},"& .toolbarTop":{top:"-45px"},"& .toolbarRight":{right:0},"& .fullWidth":{width:"100%"},"& .hidden":{visibility:"hidden"},"& .autoWidth":{width:"auto"},"& .focused":{opacity:1,pointerEvents:"auto"},"& .iconRoot":{width:"28px",height:"28px",padding:"4px",verticalAlign:"top"},"& .label":{color:"var(--editable-html-toolbar-check, #00bb00)"},"& .shared":{display:"flex"}})),O_=e,{useEffect:__}=e,{useMemo:R_}=e,{useState:D_}=e,{useRef:I_}=e,{styled:L_}=r,{color:B_}=a,z_=L_("div",{shouldForwardProp:e=>!["noBorder","error"].includes(e)})(({theme:e,noBorder:t,error:n})=>({position:"relative",padding:"0px",border:t?"none":"1px solid #ccc",borderRadius:"4px",cursor:"text",'& [data-slate-editor="true"]':{wordBreak:"break-word",overflow:"visible",maxHeight:"500px",padding:"5px"},"&:first-child":{marginTop:0},"& ul, & ol":{padding:"0 1rem",margin:"1.25rem 1rem 1.25rem 0.4rem"},"& ul li p, & ol li p":{marginTop:"0.25em",marginBottom:"0.25em"},"& h1, & h2, & h3, & h4, & h5, & h6":{lineHeight:1.1,marginTop:"2.5rem",textWrap:"pretty"},"& h1, & h2":{marginTop:"3.5rem",marginBottom:"1.5rem"},"& h1":{fontSize:"1.4rem"},"& h2":{fontSize:"1.2rem"},"& h3":{fontSize:"1.1rem"},"& h4, & h5, & h6":{fontSize:"1rem"},"& code":{backgroundColor:"var(--purple-light)",borderRadius:"0.4rem",color:"var(--black)",fontSize:"0.85rem",padding:"0.25em 0.3em"},"& pre":{background:"var(--black)",borderRadius:"0.5rem",color:"var(--white)",fontFamily:"'JetBrainsMono', monospace",margin:"1.5rem 0",padding:"0.75rem 1rem","& code":{background:"none",color:"inherit",fontSize:"0.8rem",padding:0}},"& blockquote":{background:"#f9f9f9",borderLeft:"5px solid #ccc",margin:"1.5em 10px",padding:".5em 10px"},"& p":{margin:"0"},"& table":{tableLayout:"fixed",width:"100%",borderCollapse:"collapse",color:B_.text(),backgroundColor:B_.background()},'& table:not([border="1"]) tr':{borderTop:"1px solid #dfe2e5"},"& td, th":{padding:".6em 1em",textAlign:"center"},'& table:not([border="1"]) td, th':{border:"1px solid #dfe2e5"},...n&&{border:`2px solid ${e.palette.error.main} !important`}})),P_=L_("div",{shouldForwardProp:e=>!["disableScrollbar","highlightShape"].includes(e)})(({theme:e,disableScrollbar:t,highlightShape:n})=>({position:"relative",padding:"0px",overflowY:"auto",color:B_.text(),backgroundColor:n?e.palette.action.selected:B_.background(),...t&&{"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none","-ms-overflow-style":"none"}})),j_=L_("div",{shouldForwardProp:e=>"noPadding"!==e})(({noPadding:e})=>({padding:e?0:"10px 8px"}));function F_(e){const[t,n]=D_(null),r=I_(null),{editor:i,disabled:o,children:s,disableScrollbar:a,activePlugins:l,toolbarOpts:c,responseAreaProps:u,autoFocus:d,minWidth:p,width:h,maxWidth:f,minHeight:m,height:g,maxHeight:y,highlightShape:v,ref:b}=e;__(()=>{i&&r.current&&(i._tiptapContainerEl=r.current)},[i,r.current]),__(()=>{i&&d&&Promise.resolve().then(()=>{i.commands.focus("end")})},[i,d]),__(()=>{if(e.adjustWidthForLimit){const t=document.createElement("p");t.style.visibility="hidden",t.style.position="absolute",t.textContent="W".repeat(e.charactersLimit),r.current.appendChild(t),n(`${t.offsetWidth+27}px`),t.remove()}},[e.adjustWidthForLimit,e.charactersLimit]);const w=R_(()=>({width:sO(t||h),minWidth:sO(p),maxWidth:sO(f),height:sO(g),minHeight:sO(m),maxHeight:sO(y)}),[t,p,h,f,m,g,y]);return O_.createElement(z_,{noBorder:c&&c.noBorder,error:c&&c.error,className:e.className,style:{width:w.width,minWidth:w.minWidth,maxWidth:w.maxWidth},ref:r},O_.createElement(P_,{disableScrollbar:a,highlightShape:v},O_.createElement(j_,{noPadding:c&&c.noPadding},s)),i&&O_.createElement(k_,{editor:i,responseAreaProps:u,toolbarOpts:c,activePlugins:l,onChange:e.onChange,autoWidthToolbar:e.autoWidthToolbar}))}const $_=l("@pie-lib:editable-html:plugins"),H_={"text-align":"textAlign","bulleted-list":"ul_list","numbered-list":"ol_list"},U_=["bold","html","extraCSSRules","italic","underline","strikethrough","bulleted-list","numbered-list","image","math","languageCharacters","text-align","blockquote","h3","table","video","audio","responseArea","redo","undo","superscript","subscript"].filter(e=>!["responseArea","h3","blockquote"].includes(e)),q_=(e,t,n)=>{$_("[buildPlugins] opts: ",n),e=e||U_;const r=(t,n=!0)=>e.includes(t)&&n&&t,i=n.image&&n.image.delete,o=n.math,s=n.responseArea&&n.responseArea.type,a=!function(e){if(null==e)return!0;if(Ae(e)&&(T(e)||"string"==typeof e||"function"==typeof e.splice||Pe(e)||Ke(e)||Ie(e)))return!e.length;var t=hn(e);if("[object Map]"==t||"[object Set]"==t)return!e.size;if(Te(e))return!Qe(e).length;for(var n in e)if(sr.call(e,n))return!1;return!0}(n.extraCSSRules),l=function(e){let t,n=e[0],r=1;for(;r<e.length;){const i=e[r],o=e[r+1];if(r+=2,("optionalAccess"===i||"optionalCall"===i)&&null==n)return;"access"===i||"optionalAccess"===i?(t=n,n=o(n)):"call"!==i&&"optionalCall"!==i||(n=o((...e)=>n.call(t,...e)),t=void 0)}return n}([n,"optionalAccess",e=>e.languageCharacters])||[];return function(e){for(var t=-1,n=null==e?0:e.length,r=0,i=[];++t<n;){var o=e[t];o&&(i[r++]=o)}return i}([r("table"),r("bold"),r("italic"),r("strikethrough"),r("underline"),r("superscript"),r("subscript"),r("image",!!i),r("video"),r("audio"),r("math",!!o),...l.map(e=>r("languageCharacters",e)),r("text-align"),r("blockquote"),r("h3"),r("bulleted-list"),r("numbered-list"),r("undo"),r("redo"),r("responseArea",!!s),r("css",!!a),r("html",!!n.html)])},V_=e,{useEffect:W_}=e,{useMemo:K_}=e,{useState:G_}=e,{styled:J_}=r;function Y_(e){let t,n=e[0],r=1;for(;r<e.length;){const i=e[r],o=e[r+1];if(r+=2,("optionalAccess"===i||"optionalCall"===i)&&null==n)return;"access"===i||"optionalAccess"===i?(t=n,n=o(n)):"call"!==i&&"optionalCall"!==i||(n=o((...e)=>n.call(t,...e)),t=void 0)}return n}const Z_={position:"bottom",alignment:"left",alwaysVisible:!1,showDone:!0,doneOn:"blur"},X_=["bold","italic","underline","strikethrough","code","bulleted-list","numbered-list","image","math","languageCharacters","text-align","table","video","audio","responseArea","superscript","subscript","css","h3","undo","redo"],Q_={"--white":"#fff","--black":"#2e2b29","--black-contrast":"#110f0e","--gray-1":"rgba(61, 37, 20, .05)","--gray-2":"rgba(61, 37, 20, .08)","--gray-3":"rgba(61, 37, 20, .12)","--gray-4":"rgba(53, 38, 28, .3)","--gray-5":"rgba(28, 25, 23, .6)","--green":"#22c55e","--purple":"#6a00f5","--purple-contrast":"#5800cc","--purple-light":"rgba(88, 5, 255, .05)","--yellow-contrast":"#facc15","--yellow":"rgba(250, 204, 21, .4)","--yellow-light":"#fffae5","--red":"#ff5c33","--red-light":"#ffebe5","--shadow":"0px 12px 33px 0px rgba(0, 0, 0, .06),\n 0px 3.618px 9.949px 0px rgba(0, 0, 0, .04)"},eR=e=>{const{showParagraphs:t,separateParagraphs:n}=e.pluginProps||{},[r,i]=G_([]),[o,s]=G_(!1),{toolbarOpts:a}=e,l={...Z_,...a},c=K_(()=>{let{customPlugins:t,...n}=e.pluginProps||{};t=t||[];const r=Y_([e.activePlugins||X_,"optionalAccess",e=>e.filter,"call",e=>e(e=>{const t=n[H_[e]||e]||{};return!t||!t.disabled})]);return q_(r,0,{math:{},textAlign:e.textAlign,html:{},extraCSSRules:e.extraCSSRules||{},image:{...e.imageSupport},toolbar:{},table:{},responseArea:{type:Y_([e,"access",e=>e.responseAreaProps,"optionalAccess",e=>e.type])},languageCharacters:e.languageCharactersProps,keyPadCharacterRef:{},setKeypadInteraction:{},media:{}})},[e]),u=function(e={},t=[]){const n=hh(e);n.current=e;const[r]=fh(()=>new zh(n)),i=Mr.exports.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return dh(i),ph(r.onRender(t)),Ih({editor:i,selector:({transactionNumber:t})=>!1===e.shouldRerenderOnTransaction||void 0===e.shouldRerenderOnTransaction?null:e.immediatelyRender&&0===t?0:t+1}),i}({extensions:[aw.configure({types:["heading","paragraph","div","h1","h2","h3","h4","h5","h6","td","th"],alignments:["left","right","center","justify"]}),iw,qb.configure({limit:e.charactersLimit||1e6}),Zb.configure({trailingNode:{node:"paragraph",notAfter:["paragraph","div"]}}),GS,JS,dw.configure({placeholder:e.placeholder,showOnlyWhenEditable:!0,showOnlyCurrent:!1,includeChildren:!0}),Bx,zS,KS,WS,KA.configure(e.responseAreaProps),GA.configure(e.responseAreaProps),YA.configure(e.responseAreaProps),ZA.configure(e.responseAreaProps),JA.configure(e.responseAreaProps),uk.configure({toolbarOpts:l,math:Y_([e,"access",e=>e.pluginProps,"optionalAccess",e=>e.math])||{}}),sw,ow,uw,aT.configure({toolbarOpts:l,imageHandling:{disableImageAlignmentButtons:e.disableImageAlignmentButtons,onDone:()=>Y_([e,"access",e=>e.onDone,"optionalCall",e=>e(u.getHTML())]),onDelete:e.imageSupport&&e.imageSupport.delete&&(t=>{const{src:n}=t.attrs;e.imageSupport.delete(n,e=>{const n=r.filter(e=>e.key!==t.key),a={pendingImages:n,scheduled:(!o||0!==n.length)&&o};i(a.pendingImages),s(a.scheduled)})}),insertImageRequested:e.imageSupport&&((t,n)=>{const a=n=>{let a;o&&n&&(a=e.onChange);const l=r.filter(e=>e.key!==t.key),c={pendingImages:l};0===l.length&&(c.scheduled=!1),i(c.pendingImages),s(c.scheduled),Y_([a,"optionalCall",e=>e(u.getHTML())])};i([...r,t]),(()=>{const t=n(a);e.imageSupport.add(t)})()}),maxImageWidth:e.maxImageWidth,maxImageHeight:e.maxImageHeight},limit:3}),YT.configure({uploadSoundSupport:e.uploadSoundSupport}),oO.configure({extraCSSRules:e.extraCSSRules})],immediatelyRender:!1,editorProps:{handleKeyDown:(t,n)=>!!e.onKeyDown&&e.onKeyDown(n)},editable:!e.disabled,content:pw(e.markup),onUpdate:({editor:t,transaction:n})=>{n.isDone&&Y_([e,"access",e=>e.onChange,"optionalCall",e=>e(t.getHTML())])},onBlur:Qn(({editor:t})=>{t._toolbarOpened||t.isActive("inline_dropdown")||t.isActive("explicit_constructed_response")||(e.markup!==t.getHTML()&&Y_([e,"access",e=>e.onChange,"optionalCall",e=>e(t.getHTML())]),"blur"===l.doneOn&&Y_([e,"access",e=>e.onDone,"optionalCall",e=>e(t.getHTML())]))},200)},[e.charactersLimit]);W_(()=>{e.editorRef&&e.editorRef(u)},[e.editorRef,u]),W_(()=>{Y_([u,"optionalAccess",e=>e.setEditable,"call",t=>t(!e.disabled)])},[e.disabled,u]),W_(()=>{if(!u)return;const t=pw(e.markup);t!==u.getHTML()&&u.commands.setContent(t,!1)},[e.markup,u]),W_(()=>{Object.entries(Q_).forEach(([e,t])=>{document.documentElement.style.setProperty(e,t)})},[]);const d=Ih({editor:u,selector:e=>({isFocused:Y_([e,"access",e=>e.editor,"optionalAccess",e=>e.isFocused])})}),p=K_(()=>{const{minWidth:t,width:n,maxWidth:r,minHeight:i,height:o,maxHeight:s}=e;return{width:sO(n),minWidth:sO(t),maxWidth:sO(r),height:sO(o),minHeight:sO(i),maxHeight:sO(s)}},[e]);return V_.createElement(F_,{...{...e,activePlugins:c,toolbarOpts:l},editorState:d,editor:u},u&&V_.createElement(tR,{style:{minHeight:p.minHeight,height:p.height,maxHeight:p.maxHeight},showParagraph:t&&!t.disabled,separateParagraph:n&&!n.disabled,editor:u}))},tR=J_(_h,{shouldForwardProp:e=>!["showParagraph","separateParagraph"].includes(e)})(({showParagraph:e,separateParagraph:t})=>({display:"flex",outline:"none !important","& .ProseMirror":{flex:1,padding:"5px",maxHeight:"500px",outline:"none !important",position:"initial","& > p, & > div":{margin:"0"},"& p.is-editor-empty, & div.is-editor-empty":{position:"relative"},"& p.is-editor-empty::before, & div.is-editor-empty::before":{content:"attr(data-placeholder)",position:"absolute",left:0,top:0,color:"#9CA3AF",pointerEvents:"none",whiteSpace:"pre-wrap"},...e&&{"& > p:has(+ p)::after, & > div:has(+ div)::after":{display:"block",content:'"¶"',fontSize:"1em",color:"#146EB3"}},...t&&{"& > div:has(+ div)":{marginBottom:"1em"}}}})),nR=(e,t,n)=>{const r=n||[],i=r.reduce((e,t)=>e+t.textContent.length,0);let o=!0;if(i>t)return!1;for(e&&(3===e.nodeType&&e.parentNode&&!e.parentNode.hasAttribute("data-ann-id")&&r.push(e),e=e.firstChild);e&&o;)o=nR(e,t,r),e=e.nextSibling;return r},rR=e=>{const{commonAncestorContainer:t,startContainer:n,endContainer:r,startOffset:i,endOffset:o}=e,s=[];let a=!1,l=!1,c="";const u=e=>{const{nodeValue:t,childNodes:d}=e;e===n&&e===r?(t&&(c+=t.substring(i,o)),a=l=!0):e===n?(t&&(c+=t.substring(i)),a=!0):e===r?(t&&(c+=t.substring(0,o)),l=!0):e&&3===e.nodeType&&e.parentNode&&!e.parentNode.hasAttribute("data-ann-id")&&t&&a&&!l&&(c+=t,s.push(e)),d.forEach(e=>{l||u(e)})};return u(t),[s,c]},iR=e=>{const t=document.createElement("SPAN");return e.surroundContents(t),t},oR=e=>{if(e.startContainer===e.endContainer)return[iR(e)];const[t]=rR(e),n=document.createRange();n.selectNodeContents(e.startContainer),n.setStart(e.startContainer,e.startOffset);const r=iR(n),i=document.createRange();i.selectNode(e.endContainer),i.setEnd(e.endContainer,e.endOffset);const o=iR(i);return[r,...t.map(e=>{const t=document.createElement("SPAN");return e.parentNode.insertBefore(t,e),t.appendChild(e),t}),o]},sR=(e,t)=>{(e||[]).forEach(e=>{const t=e.parentNode,n=e.childNodes,r=n.length;if(r>0)for(let i=0;i<r;i++)t.insertBefore(n[0],e);else t.insertBefore(document.createTextNode(e.textContent),e);t.removeChild(e)}),t.normalize()},aR=()=>{document.getSelection?(document.getSelection().removeAllRanges(),document.getSelection().addRange(document.createRange())):window.getSelection?window.getSelection().removeAllRanges?(window.getSelection().removeAllRanges(),window.getSelection().addRange(document.createRange())):window.getSelection().empty&&window.getSelection().empty():document.selection&&document.selection.empty()},lR=e=>e.length>=20||-1!==e.search(/\n|\r|\r\n/),cR=e=>Array.from(document.querySelectorAll(`[data-id='${e}']`)),uR=e=>document.querySelector(`[data-ann-id='${e}']`),dR=e,pR=i,{Popover:hR}=n,{TextField:fR}=n,{styled:mR}=r,gR=mR(hR)(({theme:e,annotationType:t})=>({"& .MuiPaper-root":{overflowX:"unset",overflowY:"unset",marginLeft:"16px","&::before":{position:"absolute",right:"100%",top:"13px",border:"solid transparent",content:'""',height:0,width:0,pointerEvents:"none",borderWidth:"7px",borderRightColor:e.palette.grey[100]},..."negative"===t&&{"&::before":{borderRightColor:"rgb(255, 204, 238) !important"}},..."positive"===t&&{"&::before":{borderRightColor:"rgb(153, 255, 153) !important"}}}})),yR=mR("div")(({theme:e,annotationType:t})=>({width:"200px",overflow:"hidden",borderRadius:"4px",backgroundColor:"#ffffff",border:`4px solid ${e.palette.grey[100]}`,..."negative"===t&&{borderColor:"rgb(255, 204, 238) !important"},..."positive"===t&&{borderColor:"rgb(153, 255, 153) !important"}})),vR=mR("div")(({theme:e})=>({display:"flex",flexWrap:"wrap",borderTop:`2px solid ${e.palette.grey[100]}`})),bR=mR("div")(({theme:e,variant:t,annotationType:n})=>({flexGrow:1,width:"28%",textAlign:"center",padding:"4px",cursor:"pointer","&:not(:nth-child(3n))":{borderRight:`1px solid ${e.palette.grey[100]}`},"&:hover":{backgroundColor:e.palette.grey[100]},..."positive"===t&&{backgroundColor:"rgb(153, 255, 153) !important","&:hover":{filter:"brightness(85%)"}},..."negative"===t&&{backgroundColor:"rgb(255, 204, 238) !important","&:hover":{filter:"brightness(85%)"}},..."typeChange"===t&&"negative"===n&&{"&:hover":{backgroundColor:"rgb(153, 255, 153) !important"}},..."typeChange"===t&&"positive"===n&&{"&:hover":{backgroundColor:"rgb(255, 204, 238) !important"}}}));class wR extends dR.Component{static __initStatic(){this.propTypes={anchorEl:pR.object,open:pR.bool,offset:pR.number,value:pR.string,type:pR.string,onClose:pR.func,onDelete:pR.func,onSave:pR.func,onTypeChange:pR.func}}constructor(e){super(e),wR.prototype.__init.call(this),wR.prototype.__init2.call(this),wR.prototype.__init3.call(this),this.state={value:e.value}}UNSAFE_componentWillReceiveProps(e){const{value:t}=e,{value:n}=this.props;t!==n&&this.setState({value:t})}__init(){this.onValueChange=e=>this.setState({value:e.target.value})}__init2(){this.handleSave=()=>{const{value:e,onSave:t,onClose:n,onDelete:r}=this.props,{value:i}=this.state;""===i&&r(),e!==i&&t(e,i),this.setState({value:""}),n()}}__init3(){this.handleTypeChange=()=>{const{onTypeChange:e,onDelete:t}=this.props,{value:n}=this.state;""===n?t():e(n),this.setState({value:""})}}render(){const{anchorEl:e,offset:t,onDelete:n,open:r,type:i}=this.props,{value:o}=this.state;return dR.createElement(gR,{anchorEl:e,elevation:2,open:r,onClose:this.handleSave,annotationType:i,style:{marginTop:`${t}px`,transition:"margin-top 2s ease-out"},transitionDuration:{enter:225,exit:195},anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"}},dR.createElement(yR,{annotationType:i},dR.createElement(fR,{id:"annotation-editor",style:{padding:"2px 5px",width:"95%"},autoFocus:!0,multiline:!0,rows:1,maxRows:4,value:o,onChange:this.onValueChange,InputProps:{disableUnderline:!0}}),dR.createElement(vR,null,dR.createElement(bR,{onClick:n},"Delete"),dR.createElement(bR,{variant:"typeChange",annotationType:i,onClick:this.handleTypeChange},"negative"===i?"Green":"Pink"),dR.createElement(bR,{onClick:this.handleSave},"Save"))))}}wR.__initStatic();const xR=e,MR=i,{styled:SR}=r,{Popover:ER}=n,CR=SR(ER)({"& .MuiPaper-root":{overflowX:"unset",overflowY:"unset",marginTop:"-16px","&::after":{position:"absolute",left:"calc(50% - 7px)",border:"solid transparent",content:'""',height:0,width:0,pointerEvents:"none",borderWidth:"7px",borderTopColor:"black"}}}),NR=SR("div")(({theme:e})=>({width:"300px",overflow:"hidden",borderRadius:"4px",backgroundColor:e.palette.common.white,border:`2px solid ${e.palette.grey[100]}`})),AR=SR("div")({display:"flex",flexWrap:"wrap"}),kR=SR("div")(({theme:e})=>({display:"flex",flexWrap:"wrap",borderTop:`2px solid ${e.palette.grey[100]}`})),TR=SR("div")(({theme:e,variant:t})=>({width:"22%",textAlign:"center",padding:"4px",cursor:"pointer",borderBottom:`1px solid ${e.palette.grey[100]}`,"&:not(:nth-child(4n))":{borderRight:`1px solid ${e.palette.grey[100]}`},"&:nth-child(4n)":{flexGrow:1},"&:hover":{backgroundColor:e.palette.grey[100]},..."positive"===t&&{backgroundColor:"rgb(153, 255, 153) !important","&:hover":{filter:"brightness(85%)"}},..."negative"===t&&{backgroundColor:"rgb(255, 204, 238) !important","&:hover":{filter:"brightness(85%)"}}}));class OR extends xR.Component{static __initStatic(){this.propTypes={anchorEl:MR.object,open:MR.bool,annotations:MR.array,isNewAnnotation:MR.bool,onClose:MR.func,onDelete:MR.func,onEdit:MR.func,onWrite:MR.func,onAnnotate:MR.func}}render(){const{anchorEl:e,annotations:t,isNewAnnotation:n,onAnnotate:r,onClose:i,onEdit:o,onDelete:s,onWrite:a,open:l}=this.props;return xR.createElement(CR,{anchorEl:e,open:l,onClose:i,elevation:5,transitionDuration:{enter:225,exit:195},anchorOrigin:{vertical:"top",horizontal:"center"},transformOrigin:{vertical:"bottom",horizontal:"center"}},xR.createElement(NR,null,xR.createElement(AR,null,t.map((e,t)=>xR.createElement(TR,{key:`annotation-${t}`,variant:e.type,onClick:()=>r(e)},e.label))),xR.createElement(kR,null,xR.createElement(TR,{onClick:i},"Cancel"),xR.createElement(TR,{style:{pointerEvents:"none"}}),n?xR.createElement(xR.Fragment,null,xR.createElement(TR,{variant:"positive",onClick:()=>a("positive")},"Write"),xR.createElement(TR,{variant:"negative",onClick:()=>a("negative")},"Write")):xR.createElement(xR.Fragment,null,xR.createElement(TR,{onClick:s},"Delete"),xR.createElement(TR,{onClick:o},"Edit")))))}}OR.__initStatic();const _R=i,{DialogContentText:RR}=n,{DialogTitle:DR}=n,{styled:IR}=r;IR(DR)(()=>({fontSize:"max(1.25rem, 18px)"})),IR(RR)(()=>({fontSize:"max(1rem, 14px)"})),_R.oneOfType([_R.string,_R.object]),_R.string,_R.func,_R.func,_R.bool,_R.string,_R.string,_R.bool,_R.bool,_R.bool;const{FormControlLabel:LR}=n,{Radio:BR}=n,zR=e,PR=i,{styled:jR}=r,{color:FR}=a,$R=jR(LR)(()=>({"& .MuiFormControlLabel-label":{left:"-5px",position:"relative"}})),HR=jR(BR)(()=>({color:`${FR.tertiary()} !important`})),UR=({label:e,value:t,checked:n,onChange:r})=>zR.createElement($R,{value:t,control:zR.createElement(HR,{checked:n,onChange:r}),label:e});UR.propTypes={label:PR.string,value:PR.string,checked:PR.bool,onChange:PR.func};const qR=i,VR=e,{styled:WR}=r,KR=WR("div")(()=>({display:"flex",alignItems:"center"})),GR=WR("div")(()=>({display:"flex",alignItems:"center"})),JR=WR(UR)(({theme:e})=>({"& .MuiFormControlLabel-label":{fontSize:e.typography.fontSize-2}})),YR=e=>{const{feedbackLabels:t,value:n,className:r,onChange:i,keys:o}=e;return VR.createElement(KR,{className:r},o.map(e=>VR.createElement(GR,{key:e},VR.createElement(JR,{value:e,checked:n===e,onChange:e=>i(e.currentTarget.value),label:t[e]}))))};YR.propTypes={className:qR.string,feedbackLabels:qR.object.isRequired,value:qR.string.isRequired,keys:qR.arrayOf(qR.string),onChange:qR.func};const{InputContainer:ZR}=a,XR=i,QR=e,{styled:eD}=r;let tD,nD;"undefined"!=typeof window&&(tD=require("@pie-lib/editable-html-tip-tap").default,nD=eD(tD)(({theme:e})=>({fontFamily:e.typography.fontFamily})));const rD={default:"Simple Feedback",none:"No Feedback",custom:"Customized Feedback"},iD=eD("div")(({theme:e})=>({marginBottom:e.spacing(1)})),oD=eD(ZR)(()=>({paddingBottom:0})),sD=eD("div")(({theme:e})=>({marginTop:"0px",background:e.palette.grey[300],padding:0,marginBottom:e.spacing(2),borderRadius:"4px"})),aD=eD("div")(({theme:e})=>({marginTop:"0px",background:e.palette.grey[300],padding:e.spacing(2),marginBottom:e.spacing(2),borderRadius:"4px",fontFamily:e.typography.fontFamily,cursor:"default"})),lD=eD(YR)(({theme:e})=>({paddingTop:e.spacing(1)})),cD={type:XR.oneOf(["default","custom","none"]),default:XR.string,custom:XR.string};class uD extends QR.Component{constructor(...e){super(...e),uD.prototype.__init.call(this),uD.prototype.__init2.call(this)}static __initStatic(){this.propTypes={keys:XR.arrayOf(XR.string),label:XR.string.isRequired,feedback:XR.shape(cD).isRequired,onChange:XR.func.isRequired,toolbarOpts:XR.object,mathMlOptions:XR.object}}__init(){this.changeType=e=>{const{onChange:t,feedback:n}=this.props;t({...n,type:e})}}__init2(){this.changeCustom=e=>{const{onChange:t,feedback:n}=this.props;t({...n,type:"custom",custom:e})}}render(){const{keys:e,label:t,feedback:n,toolbarOpts:r,mathMlOptions:i={}}=this.props,o=e||Object.keys(rD);return QR.createElement(iD,null,QR.createElement(oD,{label:t,extraClasses:{label:{transform:"translateY(-20%)"}}},QR.createElement(lD,{keys:o,label:t,value:n.type,onChange:this.changeType,feedbackLabels:rD})),"custom"===n.type&&QR.createElement(sD,null,QR.createElement(nD,{onChange:this.changeCustom,markup:n.custom||"",toolbarOpts:r,languageCharactersProps:[{language:"spanish"},{language:"special"}],mathMlOptions:i})),"default"===n.type&&QR.createElement(aD,null," ",n.default))}}uD.__initStatic();const dD=i,pD=e,{styled:hD}=r,{Accordion:fD}=n,{AccordionSummary:mD}=n,{AccordionDetails:gD}=n,{Typography:yD}=n,{ExpandMore:vD}=o,bD=hD("div")(()=>({display:"flex",flex:1,flexDirection:"column"})),wD=hD(gD)(()=>({paddingTop:0,paddingBottom:0}));class xD extends pD.Component{constructor(...e){super(...e),xD.prototype.__init.call(this),xD.prototype.__init2.call(this),xD.prototype.__init3.call(this)}static __initStatic(){this.propTypes={allowPartial:dD.bool,className:dD.string,feedback:dD.shape({correct:dD.shape(cD),incorrect:dD.shape(cD),partial:dD.shape(cD)}),onChange:dD.func.isRequired,toolbarOpts:dD.object}}static __initStatic2(){var e;this.defaultProps={allowPartial:!0,feedback:pr({},{correct:{type:"default",default:"Correct"},incorrect:{type:"default",default:"Incorrect"},partial:{type:"default",default:"Nearly"}},e)}}onChange(e,t){const{feedback:n,onChange:r}=this.props;r({...n,[e]:t})}__init(){this.onCorrectChange=this.onChange.bind(this,"correct")}__init2(){this.onIncorrectChange=this.onChange.bind(this,"incorrect")}__init3(){this.onPartialChange=this.onChange.bind(this,"partial")}render(){const{className:e,allowPartial:t,feedback:n,toolbarOpts:r}=this.props;return pD.createElement("div",{className:e},pD.createElement(fD,{slotProps:{transition:{timeout:{enter:225,exit:195}}}},pD.createElement(mD,{expandIcon:pD.createElement(vD,null)},pD.createElement(yD,null,"Feedback")),pD.createElement(wD,null,pD.createElement(bD,null,pD.createElement(uD,{label:"If correct, show",feedback:n.correct,onChange:this.onCorrectChange,toolbarOpts:r}),t&&pD.createElement(uD,{label:"If partially correct, show",feedback:n.partial,onChange:this.onPartialChange,toolbarOpts:r}),pD.createElement(uD,{label:"If incorrect, show",feedback:n.incorrect,onChange:this.onIncorrectChange,toolbarOpts:r})))))}}xD.__initStatic(),xD.__initStatic2();const{Checkbox:MD}=n,{Radio:SD}=n,{Switch:ED}=n,{color:CD}=a,{InputContainer:ND}=a,AD=i,kD=e,{styled:TD}=r,OD={className:AD.string,label:AD.string,checked:AD.bool,onChange:AD.func,disabled:AD.bool,error:AD.string};TD(ED)(()=>({justifyContent:"inherit",transform:"translate(-20%, 20%)"}));const _D=TD(MD)(({theme:e,error:t})=>({transform:"translate(-25%, 20%)",color:`${CD.tertiary()} !important`,...t&&{color:`${e.palette.error.main} !important`}})),RD=({className:e,label:t,checked:n,onChange:r,disabled:i,error:o})=>kD.createElement(ND,{className:e,label:t},kD.createElement(_D,{disabled:i,checked:n,onChange:r,"aria-label":t,error:o}));RD.propTypes={...OD};const DD=TD(SD)(({theme:e,error:t})=>({transform:"translate(-20%, 20%)",color:`${CD.tertiary()} !important`,...t&&{color:`${e.palette.error.main} !important`}})),ID=({className:e,label:t,checked:n,onChange:r,disabled:i,error:o})=>kD.createElement(ND,{className:e,label:t},kD.createElement(DD,{disabled:i,checked:n,onChange:r,"aria-label":t,error:o}));ID.propTypes={...OD};const{Input:LD}=n,{InputLabel:BD}=n,{Select:zD}=n,{MenuItem:PD}=n,{FormControl:jD}=n,FD=i,$D=e,{styled:HD}=r,UD=l("pie-elements:config-ui:langs"),qD=HD("div")(()=>({flexDirection:"column",alignItems:"start",display:"flex",position:"relative",paddingTop:"0px",paddingRight:"0px"})),VD=HD(jD)(()=>({position:"initial"})),WD=HD(BD)(({theme:e})=>({paddingBottom:e.spacing(1)}));class KD extends $D.Component{static __initStatic(){this.propTypes={onChange:FD.func,langs:FD.array,selected:FD.string,label:FD.string,uid:FD.string}}constructor(e){super(e),KD.prototype.__init.call(this),this.uid=e.uid||(1e4*Math.random()).toFixed()}__init(){this.choose=e=>{UD("[choose] event: ",e),this.props.onChange&&this.props.onChange(e.target.value)}}render(){let{langs:e,selected:t,label:n}=this.props;return UD("[render] selected:",t),$D.createElement(qD,null,$D.createElement(VD,null,$D.createElement(WD,{htmlFor:this.uid},n),$D.createElement(zD,{value:t,onChange:this.choose,input:$D.createElement(LD,{id:this.uid})},e.map((e,t)=>$D.createElement(PD,{key:t,value:e},e)))))}}KD.__initStatic(),HD("div")(()=>({display:"grid",gridAutoFlow:"column",gridAutoColumns:"1fr",gridGap:"8px"})),FD.array,FD.string.isRequired,FD.string.isRequired,FD.func.isRequired,FD.func.isRequired,FD.string;const GD=e,{Tabs:JD}=n,{Tab:YD}=n,ZD=i,{styled:XD}=r,QD=XD(YD)(()=>({}));class eI extends GD.Component{static __initStatic(){this.propTypes={className:ZD.string,contentClassName:ZD.string,contentStyle:ZD.object,children:ZD.oneOfType([ZD.arrayOf(ZD.node),ZD.node]).isRequired}}constructor(e){super(e),eI.prototype.__init.call(this),this.state={value:0}}__init(){this.handleChange=(e,t)=>{this.setState({value:t})}}render(){const{value:e}=this.state,{children:t,className:n,contentClassName:r,contentStyle:i={}}=this.props;return GD.createElement("div",{className:n},GD.createElement(JD,{indicatorColor:"primary",value:e,onChange:this.handleChange},GD.Children.map(t,(e,t)=>e&&e.props.title?GD.createElement(QD,{key:t,label:e.props.title}):null)),GD.createElement("div",{className:r,style:i},t[e]))}}eI.__initStatic();const{FormControlLabel:tI}=n,{Checkbox:nI}=n,rI=i,iI=e,{styled:oI}=r,{color:sI}=a,aI=oI(tI)(({theme:e,mini:t})=>({margin:0,marginLeft:0,padding:0,"& .MuiFormControlLabel-label":{fontSize:e.typography.fontSize-1,transform:"translate(-4%, 2%)",color:"rgba(0,0,0,1.0)",...t&&{marginLeft:e.spacing(1),color:h[700],fontSize:e.typography.fontSize-3}}})),lI=oI(nI)(({theme:e,mini:t,error:n})=>({color:`${sI.tertiary()} !important`,...t&&{margin:0,padding:0,width:e.spacing(3),height:e.spacing(3)},...n&&{color:`${e.palette.error.main} !important`}})),cI=({mini:e,checked:t,onChange:n,value:r,label:i,error:o})=>iI.createElement(aI,{mini:e,control:iI.createElement(lI,{checked:t,onChange:n,value:r,mini:e,error:o}),label:i});cI.propTypes={mini:rI.bool,checked:rI.bool.isRequired,onChange:rI.func.isRequired,value:rI.string,label:rI.string.isRequired,error:rI.bool},cI.defaultProps={value:"",mini:!1,error:!1};const uI=i,{Typography:dI}=n,{styled:pI}=r;pI("div")(({theme:e})=>({marginTop:e.spacing(2),marginBottom:e.spacing(2)})),pI(dI)(({theme:e})=>({marginBottom:e.spacing(1)})),uI.string,uI.string,uI.node,uI.object;const{Dialog:hI}=n,{DialogTitle:fI}=n,{DialogContentText:mI}=n,{DialogContent:gI}=n,{DialogActions:yI}=n,{Button:vI}=n,{IconButton:bI}=n,wI=i,{Help:xI}=o,MI=e,{styled:SI}=r,EI=SI(bI)(({theme:e})=>({"&:hover":{color:e.palette.grey[300]}})),CI=({onClick:e})=>MI.createElement(EI,{onClick:e,size:"large"},MI.createElement(xI,null));CI.propTypes={onClick:wI.func};const NI=({open:e,onClose:t,children:n,title:r})=>MI.createElement(hI,{open:e,onClose:t},MI.createElement(fI,null,r),MI.createElement(gI,null,MI.createElement(mI,null,n)),MI.createElement(yI,null,MI.createElement(vI,{onClick:t,color:"primary"},"OK")));NI.propTypes={open:wI.bool,onClose:wI.func,children:wI.oneOfType([wI.arrayOf(wI.node),wI.node]).isRequired,title:wI.string.isRequired};class AI extends MI.Component{static __initStatic(){this.propTypes={children:wI.oneOfType([wI.arrayOf(wI.node),wI.node]).isRequired,title:wI.string}}constructor(e){super(e),this.state={open:!1}}render(){const{children:e,title:t}=this.props;return MI.createElement("div",null,MI.createElement(CI,{color:"accent",onClick:()=>this.setState({open:!0})}),MI.createElement(NI,{open:this.state.open,title:t,onClose:()=>this.setState({open:!1})},e))}}AI.__initStatic();const kI=e,TI=i,{InputContainer:OI}=a;class _I extends kI.Component{static __initStatic(){this.propTypes={value:TI.oneOfType([TI.string,TI.number]),onChange:TI.func.isRequired,label:TI.string,type:TI.string.isRequired,error:TI.func,noModelUpdateOnError:TI.bool}}static __initStatic2(){this.defaultProps={type:"text",error:(e,t)=>"number"===t?!e||isNaN(e):!e,noModelUpdateOnError:!1}}constructor(e){super(e),_I.prototype.__init.call(this),this.state={value:e.value}}UNSAFE_componentWillReceiveProps(e){this.setState({value:e.value})}__init(){this.onChange=e=>{const{type:t,onChange:n,error:r}=this.props;r(e.target.value,t)?this.setState({error:!0,value:e.target.value}):(this.setState({error:!1,value:e.target.value}),n(e))}}render(){const{label:e,type:t,noModelUpdateOnError:n,...r}=this.props,{value:i,error:o}=this.state;return e?kI.createElement(OI,{label:e},kI.createElement(f,{type:t,...r,value:i,onChange:this.onChange,error:o})):kI.createElement(f,{type:t,...r,value:i,onChange:this.onChange,error:o})}}_I.__initStatic(),_I.__initStatic2();const RI=i,DI=e,{TextField:II}=n,{InputAdornment:LI}=n,{styled:BI}=r,zI=l("@pie-lib:config-ui:number-text-field"),PI=BI(II)(({theme:e})=>({marginRight:e.spacing(1),"& .MuiInputLabel-root":{width:"auto",minWidth:"max-content",maxWidth:"none",whiteSpace:"nowrap",overflow:"visible",transform:"translate(0, 8px) scale(0.75)",transformOrigin:"top left",position:"relative"},"& .MuiInputBase-root, & .MuiInput-root, & .MuiFilledInput-root, & .MuiOutlinedInput-root":{height:"auto",minHeight:"auto"},"& .MuiInputBase-input":{height:"auto",minHeight:"auto",padding:"6px 0 7px"},"& .MuiInput-root, & .MuiFilledInput-root":{"&:before, &:after, &:hover:not(.Mui-disabled):before":{display:"none"}}}));class jI extends DI.Component{static __initStatic(){this.propTypes={disabled:RI.bool,className:RI.string,inputClassName:RI.string,onChange:RI.func.isRequired,value:RI.number,min:RI.number,max:RI.number,label:RI.string,suffix:RI.string,showErrorWhenOutsideRange:RI.bool,disableUnderline:RI.bool,variant:RI.string}}static __initStatic2(){this.defaultProps={showErrorWhenOutsideRange:!1}}constructor(e){super(e),jI.prototype.__init.call(this),jI.prototype.__init2.call(this),jI.prototype.__init3.call(this);const t=this.clamp(e.value);this.state={value:t},t!==e.value&&this.props.onChange({},t),this.onChange=this.onChange.bind(this)}UNSAFE_componentWillReceiveProps(e){const t=this.clamp(e.value,e.min,e.max);this.setState({value:t})}clamp(e,t=this.props.min,n=this.props.max){return cr(e)?(cr(n)&&(e=Math.min(e,n)),cr(t)&&(e=Math.max(e,t)),e):((e,t)=>cr(e)||cr(t)?!cr(e)&&cr(t)?t:cr(e)?e:void 0:0)(t,n)}__init(){this.onBlur=e=>{const t=e.target.value,n=parseFloat(t);zI("rawNumber: ",n);const r=this.clamp(n);zI("number: ",r),r!==this.state.value&&(zI("trigger update..."),this.setState({value:r.toString()},()=>{this.props.onChange(e,r)}))}}onChange(e){const t=e.target.value;this.setState({value:t})}__init2(){this.errorMessage=()=>{const{min:e,max:t}=this.props;return e&&t?`The value must be between ${e} and ${t}`:e?`The value must be greater than ${e}`:t?`The value must be less than ${t}`:void 0}}__init3(){this.getError=()=>{const{value:e}=this.state,t=parseFloat(e);if(this.clamp(t)!==t)return this.errorMessage()}}render(){const{className:e,label:t,disabled:n,suffix:r,min:i,max:o,inputClassName:s,disableUnderline:a,showErrorWhenOutsideRange:l,variant:c}=this.props,u=l&&this.getError();return DI.createElement(PI,{variant:a?"filled":c||"standard",inputRef:e=>{this.inputRef=e},disabled:n,label:t,InputLabelProps:{shrink:!0},value:this.state.value,error:!!u,helperText:u,onChange:this.onChange,onBlur:this.onBlur,onKeyDown:e=>{"Enter"===e.key&&this.inputRef&&this.inputRef.blur()},type:"number",className:e,slotProps:{input:{endAdornment:r&&DI.createElement(LI,{position:"end"},r),className:s,inputProps:{min:i,max:o}}},margin:"normal"})}}jI.__initStatic(),jI.__initStatic2();var FI={epsilon:1e-12,matrix:"Matrix",number:"number",precision:64,predictable:!1,randomSeed:null};function $I(e){return $I="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},$I(e)}function HI(e){return"number"==typeof e}function UI(e){return e&&!0===e.constructor.prototype.isBigNumber||!1}function qI(e){return e&&"object"===$I(e)&&!0===Object.getPrototypeOf(e).isComplex||!1}function VI(e){return e&&"object"===$I(e)&&!0===Object.getPrototypeOf(e).isFraction||!1}function WI(e){return e&&!0===e.constructor.prototype.isUnit||!1}function KI(e){return"string"==typeof e}var GI=Array.isArray;function JI(e){return e&&!0===e.constructor.prototype.isMatrix||!1}function YI(e){return Array.isArray(e)||JI(e)}function ZI(e){return e&&e.isDenseMatrix&&!0===e.constructor.prototype.isMatrix||!1}function XI(e){return e&&e.isSparseMatrix&&!0===e.constructor.prototype.isMatrix||!1}function QI(e){return e&&!0===e.constructor.prototype.isRange||!1}function eL(e){return e&&!0===e.constructor.prototype.isIndex||!1}function tL(e){return"boolean"==typeof e}function nL(e){return e&&!0===e.constructor.prototype.isResultSet||!1}function rL(e){return e&&!0===e.constructor.prototype.isHelp||!1}function iL(e){return"function"==typeof e}function oL(e){return e instanceof Date}function sL(e){return e instanceof RegExp}function aL(e){return!(!e||"object"!==$I(e)||e.constructor!==Object||qI(e)||VI(e))}function lL(e){return null===e}function cL(e){return void 0===e}function uL(e){return e&&!0===e.isAccessorNode&&!0===e.constructor.prototype.isNode||!1}function dL(e){return e&&!0===e.isArrayNode&&!0===e.constructor.prototype.isNode||!1}function pL(e){return e&&!0===e.isAssignmentNode&&!0===e.constructor.prototype.isNode||!1}function hL(e){return e&&!0===e.isBlockNode&&!0===e.constructor.prototype.isNode||!1}function fL(e){return e&&!0===e.isConditionalNode&&!0===e.constructor.prototype.isNode||!1}function mL(e){return e&&!0===e.isConstantNode&&!0===e.constructor.prototype.isNode||!1}function gL(e){return e&&!0===e.isFunctionAssignmentNode&&!0===e.constructor.prototype.isNode||!1}function yL(e){return e&&!0===e.isFunctionNode&&!0===e.constructor.prototype.isNode||!1}function vL(e){return e&&!0===e.isIndexNode&&!0===e.constructor.prototype.isNode||!1}function bL(e){return e&&!0===e.isNode&&!0===e.constructor.prototype.isNode||!1}function wL(e){return e&&!0===e.isObjectNode&&!0===e.constructor.prototype.isNode||!1}function xL(e){return e&&!0===e.isOperatorNode&&!0===e.constructor.prototype.isNode||!1}function ML(e){return e&&!0===e.isParenthesisNode&&!0===e.constructor.prototype.isNode||!1}function SL(e){return e&&!0===e.isRangeNode&&!0===e.constructor.prototype.isNode||!1}function EL(e){return e&&!0===e.isSymbolNode&&!0===e.constructor.prototype.isNode||!1}function CL(e){return e&&!0===e.constructor.prototype.isChain||!1}function NL(e){var t=$I(e);return"object"===t?null===e?"null":Array.isArray(e)?"Array":e instanceof Date?"Date":e instanceof RegExp?"RegExp":UI(e)?"BigNumber":qI(e)?"Complex":VI(e)?"Fraction":JI(e)?"Matrix":WI(e)?"Unit":eL(e)?"Index":QI(e)?"Range":nL(e)?"ResultSet":bL(e)?e.type:CL(e)?"Chain":rL(e)?"Help":"Object":"function"===t?"Function":t}function AL(e){return AL="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},AL(e)}function kL(e){var t=AL(e);if("number"===t||"string"===t||"boolean"===t||null==e)return e;if("function"==typeof e.clone)return e.clone();if(Array.isArray(e))return e.map(function(e){return kL(e)});if(e instanceof Date)return new Date(e.valueOf());if(UI(e))return e;if(e instanceof RegExp)throw new TypeError("Cannot clone "+e);return function(e,t){var n={};for(var r in e)_L(e,r)&&(n[r]=t(e[r]));return n}(e,kL)}function TL(e,t){for(var n in t)_L(t,n)&&(e[n]=t[n]);return e}function OL(e,t){var n,r,i;if(Array.isArray(e)){if(!Array.isArray(t))return!1;if(e.length!==t.length)return!1;for(r=0,i=e.length;r<i;r++)if(!OL(e[r],t[r]))return!1;return!0}if("function"==typeof e)return e===t;if(e instanceof Object){if(Array.isArray(t)||!(t instanceof Object))return!1;for(n in e)if(!(n in t)||!OL(e[n],t[n]))return!1;for(n in t)if(!(n in e)||!OL(e[n],t[n]))return!1;return!0}return e===t}function _L(e,t){return e&&Object.hasOwnProperty.call(e,t)}function RL(){return RL=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},RL.apply(this,arguments)}var DL=function(e){if(e)throw new Error("The global config is readonly. \nPlease create a mathjs instance if you want to change the default configuration. \nExample:\n\n import { create, all } from 'mathjs';\n const mathjs = create(all);\n mathjs.config({ number: 'BigNumber' });\n");return Object.freeze(FI)};RL(DL,FI,{MATRIX_OPTIONS:["Matrix","Array"],NUMBER_OPTIONS:["number","BigNumber","Fraction"]});var IL={exports:{}};IL.exports=function(){function e(){return!0}function t(){return!1}function n(){}function r(){var i=[{name:"number",test:function(e){return"number"==typeof e}},{name:"string",test:function(e){return"string"==typeof e}},{name:"boolean",test:function(e){return"boolean"==typeof e}},{name:"Function",test:function(e){return"function"==typeof e}},{name:"Array",test:Array.isArray},{name:"Date",test:function(e){return e instanceof Date}},{name:"RegExp",test:function(e){return e instanceof RegExp}},{name:"Object",test:function(e){return"object"==typeof e&&null!==e&&e.constructor===Object}},{name:"null",test:function(e){return null===e}},{name:"undefined",test:function(e){return void 0===e}}],o={name:"any",test:e},s=[],a=[],l={types:i,conversions:a,ignore:s};function c(e){var t=J(l.types,function(t){return t.name===e});if(t)return t;if("any"===e)return o;var n=J(l.types,function(t){return t.name.toLowerCase()===e.toLowerCase()});throw new TypeError('Unknown type "'+e+'"'+(n?'. Did you mean "'+n.name+'"?':""))}function u(e){return e===o?999:l.types.indexOf(e)}function d(e){var t=J(l.types,function(t){return t.test(e)});if(t)return t.name;throw new TypeError("Value has unknown type. Value: "+e)}function p(e,t){if(!e.signatures)throw new TypeError("Function is no typed-function");var n;if("string"==typeof t){n=t.split(",");for(var r=0;r<n.length;r++)n[r]=n[r].trim()}else{if(!Array.isArray(t))throw new TypeError("String array or a comma separated string expected");n=t}var i=n.join(","),o=e.signatures[i];if(o)return o;throw new TypeError("Signature not found (signature: "+(e.name||"unnamed")+"("+n.join(", ")+"))")}function h(e,t){var n=d(e);if(t===n)return e;for(var r=0;r<l.conversions.length;r++){var i=l.conversions[r];if(i.from===n&&i.to===t)return i.convert(e)}throw new Error("Cannot convert from "+n+" to "+t)}function f(e){return e.map(function(e){var t=e.types.map(S);return(e.restParam?"...":"")+t.join("|")}).join(",")}function m(e,t){var n=0===e.indexOf("..."),r=(n?e.length>3?e.slice(3):"any":e).split("|").map(F).filter($).filter(j),i=_(t,r),o=r.map(function(e){var t=c(e);return{name:e,typeIndex:u(t),test:t.test,conversion:null,conversionIndex:-1}}),s=i.map(function(e){var n=c(e.from);return{name:e.from,typeIndex:u(n),test:n.test,conversion:e,conversionIndex:t.indexOf(e)}});return{types:o.concat(s),restParam:n}}function g(e,t,n){var r=[];return""!==e.trim()&&(r=e.split(",").map(F).map(function(e,t,r){var i=m(e,n);if(i.restParam&&t!==r.length-1)throw new SyntaxError('Unexpected rest parameter "'+e+'": only allowed for the last parameter');return i})),r.some(U)?null:{params:r,fn:t}}function y(e){var t=V(e);return!!t&&t.restParam}function v(e){return e.types.some(function(e){return null!=e.conversion})}function b(t){if(t&&0!==t.types.length){if(1===t.types.length)return c(t.types[0].name).test;if(2===t.types.length){var n=c(t.types[0].name).test,r=c(t.types[1].name).test;return function(e){return n(e)||r(e)}}var i=t.types.map(function(e){return c(e.name).test});return function(e){for(var t=0;t<i.length;t++)if(i[t](e))return!0;return!1}}return e}function w(e){var t,n,r;if(y(e)){var i=(t=q(e).map(b)).length,o=b(V(e)),s=function(e){for(var t=i;t<e.length;t++)if(!o(e[t]))return!1;return!0};return function(e){for(var n=0;n<t.length;n++)if(!t[n](e[n]))return!1;return s(e)&&e.length>=i+1}}return 0===e.length?function(e){return 0===e.length}:1===e.length?(n=b(e[0]),function(e){return n(e[0])&&1===e.length}):2===e.length?(n=b(e[0]),r=b(e[1]),function(e){return n(e[0])&&r(e[1])&&2===e.length}):(t=e.map(b),function(e){for(var n=0;n<t.length;n++)if(!t[n](e[n]))return!1;return e.length===t.length})}function x(e,t){return t<e.params.length?e.params[t]:y(e.params)?V(e.params):null}function M(e,t,n){var r=x(e,t);return(r?n?r.types.filter(E):r.types:[]).map(S)}function S(e){return e.name}function E(e){return null===e.conversion||void 0===e.conversion}function C(e,t){var n=Y(Z(e,function(e){return M(e,t,!1)}));return-1!==n.indexOf("any")?["any"]:n}function N(e,t,n){var r,i,o,s=e||"unnamed",a=n;for(o=0;o<t.length;o++){var l=a.filter(function(e){var n=b(x(e,o));return(o<e.params.length||y(e.params))&&n(t[o])});if(0===l.length){if((i=C(a,o)).length>0){var c=d(t[o]);return(r=new TypeError("Unexpected type of argument in function "+s+" (expected: "+i.join(" or ")+", actual: "+c+", index: "+o+")")).data={category:"wrongType",fn:s,index:o,actual:c,expected:i},r}}else a=l}var u=a.map(function(e){return y(e.params)?1/0:e.params.length});if(t.length<Math.min.apply(null,u))return i=C(a,o),(r=new TypeError("Too few arguments in function "+s+" (expected: "+i.join(" or ")+", index: "+t.length+")")).data={category:"tooFewArgs",fn:s,index:t.length,expected:i},r;var p=Math.max.apply(null,u);return t.length>p?((r=new TypeError("Too many arguments in function "+s+" (expected: "+p+", actual: "+t.length+")")).data={category:"tooManyArgs",fn:s,index:t.length,expectedLength:p},r):((r=new TypeError('Arguments of type "'+t.join(", ")+'" do not match any of the defined signatures of function '+s+".")).data={category:"mismatch",actual:t.map(d)},r)}function A(e){for(var t=999,n=0;n<e.types.length;n++)E(e.types[n])&&(t=Math.min(t,e.types[n].typeIndex));return t}function k(e){for(var t=999,n=0;n<e.types.length;n++)E(e.types[n])||(t=Math.min(t,e.types[n].conversionIndex));return t}function T(e,t){var n;return 0!==(n=e.restParam-t.restParam)||0!==(n=v(e)-v(t))||0!==(n=A(e)-A(t))?n:k(e)-k(t)}function O(e,t){var n,r,i=Math.min(e.params.length,t.params.length);if(0!==(r=e.params.some(v)-t.params.some(v)))return r;for(n=0;n<i;n++)if(0!==(r=v(e.params[n])-v(t.params[n])))return r;for(n=0;n<i;n++)if(0!==(r=T(e.params[n],t.params[n])))return r;return e.params.length-t.params.length}function _(e,t){var n={};return e.forEach(function(e){-1!==t.indexOf(e.from)||-1===t.indexOf(e.to)||n[e.from]||(n[e.from]=e)}),Object.keys(n).map(function(e){return n[e]})}function R(e,t){var n=t;if(e.some(v)){var r=y(e),i=e.map(D);n=function(){for(var e=[],n=r?arguments.length-1:arguments.length,o=0;o<n;o++)e[o]=i[o](arguments[o]);return r&&(e[n]=arguments[n].map(i[n])),t.apply(this,e)}}var o=n;if(y(e)){var s=e.length-1;o=function(){return n.apply(this,W(arguments,0,s).concat([W(arguments,s)]))}}return o}function D(e){var t,n,r,i,o=[],s=[];switch(e.types.forEach(function(e){e.conversion&&(o.push(c(e.conversion.from).test),s.push(e.conversion.convert))}),s.length){case 0:return function(e){return e};case 1:return t=o[0],r=s[0],function(e){return t(e)?r(e):e};case 2:return t=o[0],n=o[1],r=s[0],i=s[1],function(e){return t(e)?r(e):n(e)?i(e):e};default:return function(e){for(var t=0;t<s.length;t++)if(o[t](e))return s[t](e);return e}}}function I(e){var t={};return e.forEach(function(e){e.params.some(v)||L(e.params,!0).forEach(function(n){t[f(n)]=e.fn})}),t}function L(e,t){function n(e,r,i){if(r<e.length){var o,s=e[r],a=t?s.types.filter(E):s.types;if(s.restParam){var l=a.filter(E);o=l.length<a.length?[l,a]:[a]}else o=a.map(function(e){return[e]});return Z(o,function(t){return n(e,r+1,i.concat([t]))})}return[i.map(function(t,n){return{types:t,restParam:n===e.length-1&&y(e)}})]}return n(e,0,[])}function B(e,t){for(var n=Math.max(e.params.length,t.params.length),r=0;r<n;r++)if(!G(M(e,r,!0),M(t,r,!0)))return!1;var i=e.params.length,o=t.params.length,s=y(e.params),a=y(t.params);return s?a?i===o:o>=i:a?i>=o:i===o}function z(e,r){if(0===Object.keys(r).length)throw new SyntaxError("No signatures provided");var i=[];Object.keys(r).map(function(e){return g(e,r[e],l.conversions)}).filter(H).forEach(function(e){var t=J(i,function(t){return B(t,e)});if(t)throw new TypeError('Conflicting signatures "'+f(t.params)+'" and "'+f(e.params)+'".');i.push(e)});var o=Z(i,function(e){return(e?L(e.params,!1):[]).map(function(t){return{params:t,fn:e.fn}})}).filter(H);o.sort(O);var s=o[0]&&o[0].params.length<=2&&!y(o[0].params),a=o[1]&&o[1].params.length<=2&&!y(o[1].params),c=o[2]&&o[2].params.length<=2&&!y(o[2].params),u=o[3]&&o[3].params.length<=2&&!y(o[3].params),d=o[4]&&o[4].params.length<=2&&!y(o[4].params),p=o[5]&&o[5].params.length<=2&&!y(o[5].params),h=s&&a&&c&&u&&d&&p,m=o.map(function(e){return w(e.params)}),v=s?b(o[0].params[0]):t,x=a?b(o[1].params[0]):t,M=c?b(o[2].params[0]):t,S=u?b(o[3].params[0]):t,E=d?b(o[4].params[0]):t,C=p?b(o[5].params[0]):t,N=s?b(o[0].params[1]):t,A=a?b(o[1].params[1]):t,k=c?b(o[2].params[1]):t,T=u?b(o[3].params[1]):t,_=d?b(o[4].params[1]):t,D=p?b(o[5].params[1]):t,z=o.map(function(e){return R(e.params,e.fn)}),P=s?z[0]:n,j=a?z[1]:n,F=c?z[2]:n,$=u?z[3]:n,U=d?z[4]:n,q=p?z[5]:n,V=s?o[0].params.length:-1,W=a?o[1].params.length:-1,K=c?o[2].params.length:-1,G=u?o[3].params.length:-1,Y=d?o[4].params.length:-1,X=p?o[5].params.length:-1,Q=h?6:0,ee=o.length,te=function(){for(var t=Q;t<ee;t++)if(m[t](arguments))return z[t].apply(this,arguments);return l.onMismatch(e,arguments,o)},ne=function e(t,n){return arguments.length===V&&v(t)&&N(n)?P.apply(e,arguments):arguments.length===W&&x(t)&&A(n)?j.apply(e,arguments):arguments.length===K&&M(t)&&k(n)?F.apply(e,arguments):arguments.length===G&&S(t)&&T(n)?$.apply(e,arguments):arguments.length===Y&&E(t)&&_(n)?U.apply(e,arguments):arguments.length===X&&C(t)&&D(n)?q.apply(e,arguments):te.apply(e,arguments)};try{Object.defineProperty(ne,"name",{value:e})}catch(e){}return ne.signatures=I(o),ne}function P(e,t,n){throw N(e,t,n)}function j(e){return-1===l.ignore.indexOf(e)}function F(e){return e.trim()}function $(e){return!!e}function H(e){return null!==e}function U(e){return 0===e.types.length}function q(e){return e.slice(0,e.length-1)}function V(e){return e[e.length-1]}function W(e,t,n){return Array.prototype.slice.call(e,t,n)}function K(e,t){return-1!==e.indexOf(t)}function G(e,t){for(var n=0;n<e.length;n++)if(K(t,e[n]))return!0;return!1}function J(e,t){for(var n=0;n<e.length;n++)if(t(e[n]))return e[n]}function Y(e){for(var t={},n=0;n<e.length;n++)t[e[n]]=!0;return Object.keys(t)}function Z(e,t){return Array.prototype.concat.apply([],e.map(t))}function X(e){for(var t="",n=0;n<e.length;n++){var r=e[n];if(("object"==typeof r.signatures||"string"==typeof r.signature)&&""!==r.name)if(""===t)t=r.name;else if(t!==r.name){var i=new Error("Function names do not match (expected: "+t+", actual: "+r.name+")");throw i.data={actual:r.name,expected:t},i}}return t}function Q(e){var t,n={};function r(e,r){if(n.hasOwnProperty(e)&&r!==n[e])throw(t=new Error('Signature "'+e+'" is defined twice')).data={signature:e},t}for(var i=0;i<e.length;i++){var o=e[i];if("object"==typeof o.signatures)for(var s in o.signatures)o.signatures.hasOwnProperty(s)&&(r(s,o.signatures[s]),n[s]=o.signatures[s]);else{if("string"!=typeof o.signature)throw(t=new TypeError("Function is no typed-function (index: "+i+")")).data={index:i},t;r(o.signature,o),n[o.signature]=o}}return n}return l=z("typed",{"string, Object":z,Object:function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(e[n]);return z(X(t),e)},"...Function":function(e){return z(X(e),Q(e))},"string, ...Function":function(e,t){return z(e,Q(t))}}),l.create=r,l.types=i,l.conversions=a,l.ignore=s,l.onMismatch=P,l.throwMismatchError=P,l.createError=N,l.convert=h,l.find=p,l.addType=function(e,t){if(!e||"string"!=typeof e.name||"function"!=typeof e.test)throw new TypeError("Object with properties {name: string, test: function} expected");if(!1!==t)for(var n=0;n<l.types.length;n++)if("Object"===l.types[n].name)return void l.types.splice(n,0,e);l.types.push(e)},l.addConversion=function(e){if(!e||"string"!=typeof e.from||"string"!=typeof e.to||"function"!=typeof e.convert)throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");l.conversions.push(e)},l}return r()}();var LL=IL.exports;function BL(e){return"boolean"==typeof e||!!isFinite(e)&&e===Math.round(e)}var zL=Math.sign||function(e){return e>0?1:e<0?-1:0},PL=Math.log2||function(e){return Math.log(e)/Math.LN2},jL=Math.log10||function(e){return Math.log(e)/Math.LN10},FL=Math.log1p||function(e){return Math.log(e+1)},$L=Math.cbrt||function(e){if(0===e)return e;var t,n=e<0;return n&&(e=-e),t=isFinite(e)?(e/((t=Math.exp(Math.log(e)/3))*t)+2*t)/3:e,n?-t:t},HL=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function UL(e,t){if("function"==typeof t)return t(e);if(e===1/0)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var n,r="auto";switch(t&&(t.notation&&(r=t.notation),HI(t)?n=t:HI(t.precision)&&(n=t.precision)),r){case"fixed":return VL(e,n);case"exponential":return WL(e,n);case"engineering":return function(e,t){if(isNaN(e)||!isFinite(e))return String(e);var n=qL(e),r=KL(n,t),i=r.exponent,o=r.coefficients,s=i%3==0?i:i<0?i-3-i%3:i-i%3;if(HI(t))for(;t>o.length||i-s+1>o.length;)o.push(0);else for(var a=Math.abs(i-s)-(o.length-1),l=0;l<a;l++)o.push(0);var c=Math.abs(i-s),u=1;for(;c>0;)u++,c--;var d=o.slice(u).join(""),p=HI(t)&&d.length||d.match(/[1-9]/)?"."+d:"",h=o.slice(0,u).join("")+p+"e"+(i>=0?"+":"")+s.toString();return r.sign+h}(e,n);case"auto":return function(e,t,n){if(isNaN(e)||!isFinite(e))return String(e);var r=n&&void 0!==n.lowerExp?n.lowerExp:-3,i=n&&void 0!==n.upperExp?n.upperExp:5,o=qL(e),s=t?KL(o,t):o;if(s.exponent<r||s.exponent>=i)return WL(e,t);var a=s.coefficients,l=s.exponent;a.length<t&&(a=a.concat(GL(t-a.length))),a=a.concat(GL(l-a.length+1+(a.length<t?t-a.length:0)));var c=l>0?l:0;return c<(a=GL(-l).concat(a)).length-1&&a.splice(c+1,0,"."),s.sign+a.join("")}(e,n,t&&t).replace(/((\.\d*?)(0+))($|e)/,function(){var e=arguments[2],t=arguments[4];return"."!==e?e+t:t});default:throw new Error('Unknown notation "'+r+'". Choose "auto", "exponential", or "fixed".')}}function qL(e){var t=String(e).toLowerCase().match(/^0*?(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw new SyntaxError("Invalid number "+e);var n=t[1],r=t[2],i=parseFloat(t[4]||"0"),o=r.indexOf(".");i+=-1!==o?o-1:r.length-1;var s=r.replace(".","").replace(/^0*/,function(e){return i-=e.length,""}).replace(/0*$/,"").split("").map(function(e){return parseInt(e)});return 0===s.length&&(s.push(0),i++),{sign:n,coefficients:s,exponent:i}}function VL(e,t){if(isNaN(e)||!isFinite(e))return String(e);var n=qL(e),r="number"==typeof t?KL(n,n.exponent+1+t):n,i=r.coefficients,o=r.exponent+1,s=o+(t||0);return i.length<s&&(i=i.concat(GL(s-i.length))),o<0&&(i=GL(1-o).concat(i),o=1),o<i.length&&i.splice(o,0,0===o?"0.":"."),r.sign+i.join("")}function WL(e,t){if(isNaN(e)||!isFinite(e))return String(e);var n=qL(e),r=t?KL(n,t):n,i=r.coefficients,o=r.exponent;i.length<t&&(i=i.concat(GL(t-i.length)));var s=i.shift();return r.sign+s+(i.length>0?"."+i.join(""):"")+"e"+(o>=0?"+":"")+o}function KL(e,t){for(var n={sign:e.sign,coefficients:e.coefficients,exponent:e.exponent},r=n.coefficients;t<=0;)r.unshift(0),n.exponent++,t++;if(r.length>t&&r.splice(t,r.length-t)[0]>=5){var i=t-1;for(r[i]++;10===r[i];)r.pop(),0===i&&(r.unshift(0),n.exponent++,i++),r[--i]++}return n}function GL(e){for(var t=[],n=0;n<e;n++)t.push(0);return t}var JL=Number.EPSILON||2220446049250313e-31;function YL(e,t,n){if(null==n)return e===t;if(e===t)return!0;if(isNaN(e)||isNaN(t))return!1;if(isFinite(e)&&isFinite(t)){var r=Math.abs(e-t);return r<JL||r<=Math.max(Math.abs(e),Math.abs(t))*n}return!1}var ZL=Math.acosh||function(e){return Math.log(Math.sqrt(e*e-1)+e)},XL=Math.asinh||function(e){return Math.log(Math.sqrt(e*e+1)+e)},QL=Math.atanh||function(e){return Math.log((1+e)/(1-e))/2},eB=Math.cosh||function(e){return(Math.exp(e)+Math.exp(-e))/2},tB=Math.sinh||function(e){return(Math.exp(e)-Math.exp(-e))/2},nB=Math.tanh||function(e){var t=Math.exp(2*e);return(t-1)/(t+1)};function rB(e,t){if("function"==typeof t)return t(e);if(!e.isFinite())return e.isNaN()?"NaN":e.gt(0)?"Infinity":"-Infinity";var n,r="auto";switch(void 0!==t&&(t.notation&&(r=t.notation),"number"==typeof t?n=t:t.precision&&(n=t.precision)),r){case"fixed":return function(e,t){return e.toFixed(t)}(e,n);case"exponential":return iB(e,n);case"engineering":return function(e,t){var n=e.e,r=n%3==0?n:n<0?n-3-n%3:n-n%3,i=e.mul(Math.pow(10,-r)),o=i.toPrecision(t);-1!==o.indexOf("e")&&(o=i.toString());return o+"e"+(n>=0?"+":"")+r.toString()}(e,n);case"auto":var i=t&&void 0!==t.lowerExp?t.lowerExp:-3,o=t&&void 0!==t.upperExp?t.upperExp:5;if(e.isZero())return"0";var s=e.toSignificantDigits(n),a=s.e;return(a>=i&&a<o?s.toFixed():iB(e,n)).replace(/((\.\d*?)(0+))($|e)/,function(){var e=arguments[2],t=arguments[4];return"."!==e?e+t:t});default:throw new Error('Unknown notation "'+r+'". Choose "auto", "exponential", or "fixed".')}}function iB(e,t){return void 0!==t?e.toExponential(t-1):e.toExponential()}function oB(e){return oB="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},oB(e)}function sB(e,t){var n=e.length-t.length,r=e.length;return e.substring(n,r)===t}function aB(e,t){if("number"==typeof e)return UL(e,t);if(UI(e))return rB(e,t);if(function(e){return e&&"object"===oB(e)&&"number"==typeof e.s&&"number"==typeof e.n&&"number"==typeof e.d||!1}(e))return t&&"decimal"===t.fraction?e.toString():e.s*e.n+"/"+e.d;if(Array.isArray(e))return lB(e,t);if(KI(e))return'"'+e+'"';if("function"==typeof e)return e.syntax?String(e.syntax):"function";if(e&&"object"===oB(e)){if("function"==typeof e.format)return e.format(t);if(e&&e.toString(t)!=={}.toString())return e.toString(t);var n=Object.keys(e).map(function(n){return'"'+n+'": '+aB(e[n],t)});return"{"+n.join(", ")+"}"}return String(e)}function lB(e,t){if(Array.isArray(e)){for(var n="[",r=e.length,i=0;i<r;i++)0!==i&&(n+=", "),n+=lB(e[i],t);return n+="]"}return aB(e,t)}function cB(e,t){if(!KI(e))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+NL(e)+", index: 0)");if(!KI(t))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+NL(t)+", index: 1)");return e===t?0:e>t?1:-1}function uB(e,t,n){if(!(this instanceof uB))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=t,this.relation=n,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(t)?"["+t.join(", ")+"]":t)+")",this.stack=(new Error).stack}function dB(e,t,n){if(!(this instanceof dB))throw new SyntaxError("Constructor must be called with the new operator");this.index=e,arguments.length<3?(this.min=0,this.max=t):(this.min=t,this.max=n),void 0!==this.min&&this.index<this.min?this.message="Index out of range ("+this.index+" < "+this.min+")":void 0!==this.max&&this.index>=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=(new Error).stack}function pB(e){for(var t=[];Array.isArray(e);)t.push(e.length),e=e[0];return t}function hB(e,t,n){var r,i=e.length;if(i!==t[n])throw new uB(i,t[n]);if(n<t.length-1){var o=n+1;for(r=0;r<i;r++){var s=e[r];if(!Array.isArray(s))throw new uB(t.length-1,t.length,"<");hB(e[r],t,o)}}else for(r=0;r<i;r++)if(Array.isArray(e[r]))throw new uB(t.length+1,t.length,">")}function fB(e,t){if(0===t.length){if(Array.isArray(e))throw new uB(e.length,0)}else hB(e,t,0)}function mB(e,t){if(!HI(e)||!BL(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||"number"==typeof t&&e>=t)throw new dB(e,t)}function gB(e,t,n){if(!Array.isArray(e)||!Array.isArray(t))throw new TypeError("Array expected");if(0===t.length)throw new Error("Resizing to scalar is not supported");return t.forEach(function(e){if(!HI(e)||!BL(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+aB(t)+")")}),yB(e,t,0,void 0!==n?n:0),e}function yB(e,t,n,r){var i,o,s=e.length,a=t[n],l=Math.min(s,a);if(e.length=a,n<t.length-1){var c=n+1;for(i=0;i<l;i++)o=e[i],Array.isArray(o)||(o=[o],e[i]=o),yB(o,t,c,r);for(i=l;i<a;i++)o=[],e[i]=o,yB(o,t,c,r)}else{for(i=0;i<l;i++)for(;Array.isArray(e[i]);)e[i]=e[i][0];for(i=l;i<a;i++)e[i]=r}}function vB(e,t){var n,r=SB(e);function i(e){return e.reduce(function(e,t){return e*t})}if(!Array.isArray(e)||!Array.isArray(t))throw new TypeError("Array expected");if(0===t.length)throw new uB(0,i(pB(e)),"!=");for(var o=1,s=0;s<t.length;s++)o*=t[s];if(r.length!==o)throw new uB(i(t),i(pB(e)),"!=");try{n=function(e,t){for(var n,r=e,i=t.length-1;i>0;i--){var o=t[i];n=[];for(var s=r.length/o,a=0;a<s;a++)n.push(r.slice(a*o,(a+1)*o));r=n}return r}(r,t)}catch(n){if(n instanceof uB)throw new uB(i(t),i(pB(e)),"!=");throw n}return n}function bB(e,t){for(var n=t||pB(e);Array.isArray(e)&&1===e.length;)e=e[0],n.shift();for(var r=n.length;1===n[r-1];)r--;return r<n.length&&(e=wB(e,r,0),n.length=r),e}function wB(e,t,n){var r,i;if(n<t){var o=n+1;for(r=0,i=e.length;r<i;r++)e[r]=wB(e[r],t,o)}else for(;Array.isArray(e);)e=e[0];return e}function xB(e,t,n,r){var i=r||pB(e);if(n)for(var o=0;o<n;o++)e=[e],i.unshift(1);for(e=MB(e,t,0);i.length<t;)i.push(1);return e}function MB(e,t,n){var r,i;if(Array.isArray(e)){var o=n+1;for(r=0,i=e.length;r<i;r++)e[r]=MB(e[r],t,o)}else for(var s=n;s<t;s++)e=[e];return e}function SB(e){if(!Array.isArray(e))return e;var t=[];return e.forEach(function e(n){Array.isArray(n)?n.forEach(e):t.push(n)}),t}function EB(e,t){if(1!==pB(e).length)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(e,function(e){return t.test(e)})}function CB(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(0===e.length)return e;var t=[],n=0;t[0]={value:e[0],identifier:0};for(var r=1;r<e.length;r++)e[r]===e[r-1]?n++:n=0,t.push({value:e[r],identifier:n});return t}function NB(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(0===e.length)return e;for(var t=[],n=0;n<e.length;n++)t.push(e[n].value);return t}function AB(e,t){for(var n,r=0,i=0;i<e.length;i++){var o=e[i],s=Array.isArray(o);if(0===i&&s&&(r=o.length),s&&o.length!==r)return;var a=s?AB(o,t):t(o);if(void 0===n)n=a;else if(n!==a)return"mixed"}return n}function kB(e,t,n,r){function i(r){var i=function(e,t){for(var n={},r=0;r<t.length;r++){var i=t[r],o=e[i];void 0!==o&&(n[i]=o)}return n}(r,t.map(TB));return function(e,t,n){var r=t.filter(function(e){return!function(e){return e&&"?"===e[0]}(e)}).every(function(e){return void 0!==n[e]});if(!r){var i=t.filter(function(e){return void 0===n[e]});throw new Error('Cannot create function "'.concat(e,'", ')+"some dependencies are missing: ".concat(i.map(function(e){return'"'.concat(e,'"')}).join(", "),"."))}}(e,t,r),n(i)}return i.isFactory=!0,i.fn=e,i.dependencies=t.slice().sort(),r&&(i.meta=r),i}function TB(e){return e&&"?"===e[0]?e.slice(1):e}uB.prototype=new RangeError,uB.prototype.constructor=RangeError,uB.prototype.name="DimensionError",uB.prototype.isDimensionError=!0,dB.prototype=new RangeError,dB.prototype.constructor=RangeError,dB.prototype.name="IndexError",dB.prototype.isIndexError=!0;var OB=function(){return OB=LL.create,LL},_B=kB("typed",["?BigNumber","?Complex","?DenseMatrix","?Fraction"],function(e){var t=e.BigNumber,n=e.Complex,r=e.DenseMatrix,i=e.Fraction,o=OB();return o.types=[{name:"number",test:HI},{name:"Complex",test:qI},{name:"BigNumber",test:UI},{name:"Fraction",test:VI},{name:"Unit",test:WI},{name:"string",test:KI},{name:"Chain",test:CL},{name:"Array",test:GI},{name:"Matrix",test:JI},{name:"DenseMatrix",test:ZI},{name:"SparseMatrix",test:XI},{name:"Range",test:QI},{name:"Index",test:eL},{name:"boolean",test:tL},{name:"ResultSet",test:nL},{name:"Help",test:rL},{name:"function",test:iL},{name:"Date",test:oL},{name:"RegExp",test:sL},{name:"null",test:lL},{name:"undefined",test:cL},{name:"AccessorNode",test:uL},{name:"ArrayNode",test:dL},{name:"AssignmentNode",test:pL},{name:"BlockNode",test:hL},{name:"ConditionalNode",test:fL},{name:"ConstantNode",test:mL},{name:"FunctionNode",test:yL},{name:"FunctionAssignmentNode",test:gL},{name:"IndexNode",test:vL},{name:"Node",test:bL},{name:"ObjectNode",test:wL},{name:"OperatorNode",test:xL},{name:"ParenthesisNode",test:ML},{name:"RangeNode",test:SL},{name:"SymbolNode",test:EL},{name:"Object",test:aL}],o.conversions=[{from:"number",to:"BigNumber",convert:function(e){if(t||RB(e),e.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+e+"). Use function bignumber(x) to convert to BigNumber.");return new t(e)}},{from:"number",to:"Complex",convert:function(e){return n||DB(e),new n(e,0)}},{from:"number",to:"string",convert:function(e){return e+""}},{from:"BigNumber",to:"Complex",convert:function(e){return n||DB(e),new n(e.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(e){throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.")}},{from:"Fraction",to:"Complex",convert:function(e){return n||DB(e),new n(e.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(e){i||IB(e);var t=new i(e);if(t.valueOf()!==e)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+e+"). Use function fraction(x) to convert to Fraction.");return t}},{from:"string",to:"number",convert:function(e){var t=Number(e);if(isNaN(t))throw new Error('Cannot convert "'+e+'" to a number');return t}},{from:"string",to:"BigNumber",convert:function(e){t||RB(e);try{return new t(e)}catch(t){throw new Error('Cannot convert "'+e+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(e){i||IB(e);try{return new i(e)}catch(t){throw new Error('Cannot convert "'+e+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(e){n||DB(e);try{return new n(e)}catch(t){throw new Error('Cannot convert "'+e+'" to Complex')}}},{from:"boolean",to:"number",convert:function(e){return+e}},{from:"boolean",to:"BigNumber",convert:function(e){return t||RB(e),new t(+e)}},{from:"boolean",to:"Fraction",convert:function(e){return i||IB(e),new i(+e)}},{from:"boolean",to:"string",convert:function(e){return String(e)}},{from:"Array",to:"Matrix",convert:function(e){return r||function(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}(),new r(e)}},{from:"Matrix",to:"Array",convert:function(e){return e.valueOf()}}],o});function RB(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function DB(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function IB(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}var LB,BB,zB=kB("ResultSet",[],function(){function e(t){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");this.entries=t||[]}return e.prototype.type="ResultSet",e.prototype.isResultSet=!0,e.prototype.valueOf=function(){return this.entries},e.prototype.toString=function(){return"["+this.entries.join(", ")+"]"},e.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},e.fromJSON=function(t){return new e(t.entries)},e},{isClass:!0}),PB=9e15,jB=1e9,FB="0123456789abcdef",$B="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",HB="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",UB={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-PB,maxE:PB,crypto:!1},qB=!0,VB="[DecimalError] ",WB=VB+"Invalid argument: ",KB=VB+"Precision limit exceeded",GB=VB+"crypto unavailable",JB="[object Decimal]",YB=Math.floor,ZB=Math.pow,XB=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,QB=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,ez=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,tz=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,nz=1e7,rz=$B.length-1,iz=HB.length-1,oz={toStringTag:JB};function sz(e){var t,n,r,i=e.length-1,o="",s=e[0];if(i>0){for(o+=s,t=1;t<i;t++)(n=7-(r=e[t]+"").length)&&(o+=yz(n)),o+=r;(n=7-(r=(s=e[t])+"").length)&&(o+=yz(n))}else if(0===s)return"0";for(;s%10==0;)s/=10;return o+s}function az(e,t,n){if(e!==~~e||e<t||e>n)throw Error(WB+e)}function lz(e,t,n,r){var i,o,s,a;for(o=e[0];o>=10;o/=10)--t;return--t<0?(t+=7,i=0):(i=Math.ceil((t+1)/7),t%=7),o=ZB(10,7-t),a=e[i]%o|0,null==r?t<3?(0==t?a=a/100|0:1==t&&(a=a/10|0),s=n<4&&99999==a||n>3&&49999==a||5e4==a||0==a):s=(n<4&&a+1==o||n>3&&a+1==o/2)&&(e[i+1]/o/100|0)==ZB(10,t-2)-1||(a==o/2||0==a)&&!(e[i+1]/o/100|0):t<4?(0==t?a=a/1e3|0:1==t?a=a/100|0:2==t&&(a=a/10|0),s=(r||n<4)&&9999==a||!r&&n>3&&4999==a):s=((r||n<4)&&a+1==o||!r&&n>3&&a+1==o/2)&&(e[i+1]/o/1e3|0)==ZB(10,t-3)-1,s}function cz(e,t,n){for(var r,i,o=[0],s=0,a=e.length;s<a;){for(i=o.length;i--;)o[i]*=t;for(o[0]+=FB.indexOf(e.charAt(s++)),r=0;r<o.length;r++)o[r]>n-1&&(void 0===o[r+1]&&(o[r+1]=0),o[r+1]+=o[r]/n|0,o[r]%=n)}return o.reverse()}oz.absoluteValue=oz.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),dz(e)},oz.ceil=function(){return dz(new this.constructor(this),this.e+1,2)},oz.clampedTo=oz.clamp=function(e,t){var n=this,r=n.constructor;if(e=new r(e),t=new r(t),!e.s||!t.s)return new r(NaN);if(e.gt(t))throw Error(WB+t);return n.cmp(e)<0?e:n.cmp(t)>0?t:new r(n)},oz.comparedTo=oz.cmp=function(e){var t,n,r,i,o=this,s=o.d,a=(e=new o.constructor(e)).d,l=o.s,c=e.s;if(!s||!a)return l&&c?l!==c?l:s===a?0:!s^l<0?1:-1:NaN;if(!s[0]||!a[0])return s[0]?l:a[0]?-c:0;if(l!==c)return l;if(o.e!==e.e)return o.e>e.e^l<0?1:-1;for(t=0,n=(r=s.length)<(i=a.length)?r:i;t<n;++t)if(s[t]!==a[t])return s[t]>a[t]^l<0?1:-1;return r===i?0:r>i^l<0?1:-1},oz.cosine=oz.cos=function(){var e,t,n=this,r=n.constructor;return n.d?n.d[0]?(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+7,r.rounding=1,n=function(e,t){var n,r,i;if(t.isZero())return t;r=t.d.length,r<32?i=(1/Az(4,n=Math.ceil(r/3))).toString():(n=16,i="2.3283064365386962890625e-10");e.precision+=n,t=Nz(e,1,t.times(i),new e(1));for(var o=n;o--;){var s=t.times(t);t=s.times(s).minus(s).times(8).plus(1)}return e.precision-=n,t}(r,kz(r,n)),r.precision=e,r.rounding=t,dz(2==BB||3==BB?n.neg():n,e,t,!0)):new r(1):new r(NaN)},oz.cubeRoot=oz.cbrt=function(){var e,t,n,r,i,o,s,a,l,c,u=this,d=u.constructor;if(!u.isFinite()||u.isZero())return new d(u);for(qB=!1,(o=u.s*ZB(u.s*u,1/3))&&Math.abs(o)!=1/0?r=new d(o.toString()):(n=sz(u.d),(o=((e=u.e)-n.length+1)%3)&&(n+=1==o||-2==o?"0":"00"),o=ZB(n,1/3),e=YB((e+1)/3)-(e%3==(e<0?-1:2)),(r=new d(n=o==1/0?"5e"+e:(n=o.toExponential()).slice(0,n.indexOf("e")+1)+e)).s=u.s),s=(e=d.precision)+3;;)if(c=(l=(a=r).times(a).times(a)).plus(u),r=uz(c.plus(u).times(a),c.plus(l),s+2,1),sz(a.d).slice(0,s)===(n=sz(r.d)).slice(0,s)){if("9999"!=(n=n.slice(s-3,s+1))&&(i||"4999"!=n)){+n&&(+n.slice(1)||"5"!=n.charAt(0))||(dz(r,e+1,1),t=!r.times(r).times(r).eq(u));break}if(!i&&(dz(a,e+1,0),a.times(a).times(a).eq(u))){r=a;break}s+=4,i=1}return qB=!0,dz(r,e,d.rounding,t)},oz.decimalPlaces=oz.dp=function(){var e,t=this.d,n=NaN;if(t){if(n=7*((e=t.length-1)-YB(this.e/7)),e=t[e])for(;e%10==0;e/=10)n--;n<0&&(n=0)}return n},oz.dividedBy=oz.div=function(e){return uz(this,new this.constructor(e))},oz.dividedToIntegerBy=oz.divToInt=function(e){var t=this.constructor;return dz(uz(this,new t(e),0,1,1),t.precision,t.rounding)},oz.equals=oz.eq=function(e){return 0===this.cmp(e)},oz.floor=function(){return dz(new this.constructor(this),this.e+1,3)},oz.greaterThan=oz.gt=function(e){return this.cmp(e)>0},oz.greaterThanOrEqualTo=oz.gte=function(e){var t=this.cmp(e);return 1==t||0===t},oz.hyperbolicCosine=oz.cosh=function(){var e,t,n,r,i,o=this,s=o.constructor,a=new s(1);if(!o.isFinite())return new s(o.s?1/0:NaN);if(o.isZero())return a;n=s.precision,r=s.rounding,s.precision=n+Math.max(o.e,o.sd())+4,s.rounding=1,(i=o.d.length)<32?t=(1/Az(4,e=Math.ceil(i/3))).toString():(e=16,t="2.3283064365386962890625e-10"),o=Nz(s,1,o.times(t),new s(1),!0);for(var l,c=e,u=new s(8);c--;)l=o.times(o),o=a.minus(l.times(u.minus(l.times(u))));return dz(o,s.precision=n,s.rounding=r,!0)},oz.hyperbolicSine=oz.sinh=function(){var e,t,n,r,i=this,o=i.constructor;if(!i.isFinite()||i.isZero())return new o(i);if(t=o.precision,n=o.rounding,o.precision=t+Math.max(i.e,i.sd())+4,o.rounding=1,(r=i.d.length)<3)i=Nz(o,2,i,i,!0);else{e=(e=1.4*Math.sqrt(r))>16?16:0|e,i=Nz(o,2,i=i.times(1/Az(5,e)),i,!0);for(var s,a=new o(5),l=new o(16),c=new o(20);e--;)s=i.times(i),i=i.times(a.plus(s.times(l.times(s).plus(c))))}return o.precision=t,o.rounding=n,dz(i,t,n,!0)},oz.hyperbolicTangent=oz.tanh=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+7,r.rounding=1,uz(n.sinh(),n.cosh(),r.precision=e,r.rounding=t)):new r(n.s)},oz.inverseCosine=oz.acos=function(){var e=this,t=e.constructor,n=e.abs().cmp(1),r=t.precision,i=t.rounding;return-1!==n?0===n?e.isNeg()?mz(t,r,i):new t(0):new t(NaN):e.isZero()?mz(t,r+4,i).times(.5):(t.precision=r+6,t.rounding=1,e=new t(1).minus(e).div(e.plus(1)).sqrt().atan(),t.precision=r,t.rounding=i,e.times(2))},oz.inverseHyperbolicCosine=oz.acosh=function(){var e,t,n=this,r=n.constructor;return n.lte(1)?new r(n.eq(1)?0:NaN):n.isFinite()?(e=r.precision,t=r.rounding,r.precision=e+Math.max(Math.abs(n.e),n.sd())+4,r.rounding=1,qB=!1,n=n.times(n).minus(1).sqrt().plus(n),qB=!0,r.precision=e,r.rounding=t,n.ln()):new r(n)},oz.inverseHyperbolicSine=oz.asinh=function(){var e,t,n=this,r=n.constructor;return!n.isFinite()||n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+2*Math.max(Math.abs(n.e),n.sd())+6,r.rounding=1,qB=!1,n=n.times(n).plus(1).sqrt().plus(n),qB=!0,r.precision=e,r.rounding=t,n.ln())},oz.inverseHyperbolicTangent=oz.atanh=function(){var e,t,n,r,i=this,o=i.constructor;return i.isFinite()?i.e>=0?new o(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=o.precision,t=o.rounding,r=i.sd(),Math.max(r,e)<2*-i.e-1?dz(new o(i),e,t,!0):(o.precision=n=r-i.e,i=uz(i.plus(1),new o(1).minus(i),n+e,1),o.precision=e+4,o.rounding=1,i=i.ln(),o.precision=e,o.rounding=t,i.times(.5))):new o(NaN)},oz.inverseSine=oz.asin=function(){var e,t,n,r,i=this,o=i.constructor;return i.isZero()?new o(i):(t=i.abs().cmp(1),n=o.precision,r=o.rounding,-1!==t?0===t?((e=mz(o,n+4,r).times(.5)).s=i.s,e):new o(NaN):(o.precision=n+6,o.rounding=1,i=i.div(new o(1).minus(i.times(i)).sqrt().plus(1)).atan(),o.precision=n,o.rounding=r,i.times(2)))},oz.inverseTangent=oz.atan=function(){var e,t,n,r,i,o,s,a,l,c=this,u=c.constructor,d=u.precision,p=u.rounding;if(c.isFinite()){if(c.isZero())return new u(c);if(c.abs().eq(1)&&d+4<=iz)return(s=mz(u,d+4,p).times(.25)).s=c.s,s}else{if(!c.s)return new u(NaN);if(d+4<=iz)return(s=mz(u,d+4,p).times(.5)).s=c.s,s}for(u.precision=a=d+10,u.rounding=1,e=n=Math.min(28,a/7+2|0);e;--e)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(qB=!1,t=Math.ceil(a/7),r=1,l=c.times(c),s=new u(c),i=c;-1!==e;)if(i=i.times(l),o=s.minus(i.div(r+=2)),i=i.times(l),void 0!==(s=o.plus(i.div(r+=2))).d[t])for(e=t;s.d[e]===o.d[e]&&e--;);return n&&(s=s.times(2<<n-1)),qB=!0,dz(s,u.precision=d,u.rounding=p,!0)},oz.isFinite=function(){return!!this.d},oz.isInteger=oz.isInt=function(){return!!this.d&&YB(this.e/7)>this.d.length-2},oz.isNaN=function(){return!this.s},oz.isNegative=oz.isNeg=function(){return this.s<0},oz.isPositive=oz.isPos=function(){return this.s>0},oz.isZero=function(){return!!this.d&&0===this.d[0]},oz.lessThan=oz.lt=function(e){return this.cmp(e)<0},oz.lessThanOrEqualTo=oz.lte=function(e){return this.cmp(e)<1},oz.logarithm=oz.log=function(e){var t,n,r,i,o,s,a,l,c=this,u=c.constructor,d=u.precision,p=u.rounding;if(null==e)e=new u(10),t=!0;else{if(n=(e=new u(e)).d,e.s<0||!n||!n[0]||e.eq(1))return new u(NaN);t=e.eq(10)}if(n=c.d,c.s<0||!n||!n[0]||c.eq(1))return new u(n&&!n[0]?-1/0:1!=c.s?NaN:n?0:1/0);if(t)if(n.length>1)o=!0;else{for(i=n[0];i%10==0;)i/=10;o=1!==i}if(qB=!1,s=Mz(c,a=d+5),r=t?fz(u,a+10):Mz(e,a),lz((l=uz(s,r,a,1)).d,i=d,p))do{if(s=Mz(c,a+=10),r=t?fz(u,a+10):Mz(e,a),l=uz(s,r,a,1),!o){+sz(l.d).slice(i+1,i+15)+1==1e14&&(l=dz(l,d+1,0));break}}while(lz(l.d,i+=10,p));return qB=!0,dz(l,d,p)},oz.minus=oz.sub=function(e){var t,n,r,i,o,s,a,l,c,u,d,p,h=this,f=h.constructor;if(e=new f(e),!h.d||!e.d)return h.s&&e.s?h.d?e.s=-e.s:e=new f(e.d||h.s!==e.s?h:NaN):e=new f(NaN),e;if(h.s!=e.s)return e.s=-e.s,h.plus(e);if(c=h.d,p=e.d,a=f.precision,l=f.rounding,!c[0]||!p[0]){if(p[0])e.s=-e.s;else{if(!c[0])return new f(3===l?-0:0);e=new f(h)}return qB?dz(e,a,l):e}if(n=YB(e.e/7),u=YB(h.e/7),c=c.slice(),o=u-n){for((d=o<0)?(t=c,o=-o,s=p.length):(t=p,n=u,s=c.length),o>(r=Math.max(Math.ceil(a/7),s)+2)&&(o=r,t.length=1),t.reverse(),r=o;r--;)t.push(0);t.reverse()}else{for((d=(r=c.length)<(s=p.length))&&(s=r),r=0;r<s;r++)if(c[r]!=p[r]){d=c[r]<p[r];break}o=0}for(d&&(t=c,c=p,p=t,e.s=-e.s),s=c.length,r=p.length-s;r>0;--r)c[s++]=0;for(r=p.length;r>o;){if(c[--r]<p[r]){for(i=r;i&&0===c[--i];)c[i]=nz-1;--c[i],c[r]+=nz}c[r]-=p[r]}for(;0===c[--s];)c.pop();for(;0===c[0];c.shift())--n;return c[0]?(e.d=c,e.e=hz(c,n),qB?dz(e,a,l):e):new f(3===l?-0:0)},oz.modulo=oz.mod=function(e){var t,n=this,r=n.constructor;return e=new r(e),!n.d||!e.s||e.d&&!e.d[0]?new r(NaN):!e.d||n.d&&!n.d[0]?dz(new r(n),r.precision,r.rounding):(qB=!1,9==r.modulo?(t=uz(n,e.abs(),0,3,1)).s*=e.s:t=uz(n,e,0,r.modulo,1),t=t.times(e),qB=!0,n.minus(t))},oz.naturalExponential=oz.exp=function(){return xz(this)},oz.naturalLogarithm=oz.ln=function(){return Mz(this)},oz.negated=oz.neg=function(){var e=new this.constructor(this);return e.s=-e.s,dz(e)},oz.plus=oz.add=function(e){var t,n,r,i,o,s,a,l,c,u,d=this,p=d.constructor;if(e=new p(e),!d.d||!e.d)return d.s&&e.s?d.d||(e=new p(e.d||d.s===e.s?d:NaN)):e=new p(NaN),e;if(d.s!=e.s)return e.s=-e.s,d.minus(e);if(c=d.d,u=e.d,a=p.precision,l=p.rounding,!c[0]||!u[0])return u[0]||(e=new p(d)),qB?dz(e,a,l):e;if(o=YB(d.e/7),r=YB(e.e/7),c=c.slice(),i=o-r){for(i<0?(n=c,i=-i,s=u.length):(n=u,r=o,s=c.length),i>(s=(o=Math.ceil(a/7))>s?o+1:s+1)&&(i=s,n.length=1),n.reverse();i--;)n.push(0);n.reverse()}for((s=c.length)-(i=u.length)<0&&(i=s,n=u,u=c,c=n),t=0;i;)t=(c[--i]=c[i]+u[i]+t)/nz|0,c[i]%=nz;for(t&&(c.unshift(t),++r),s=c.length;0==c[--s];)c.pop();return e.d=c,e.e=hz(c,r),qB?dz(e,a,l):e},oz.precision=oz.sd=function(e){var t,n=this;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(WB+e);return n.d?(t=gz(n.d),e&&n.e+1>t&&(t=n.e+1)):t=NaN,t},oz.round=function(){var e=this,t=e.constructor;return dz(new t(e),e.e+1,t.rounding)},oz.sine=oz.sin=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+7,r.rounding=1,n=function(e,t){var n,r=t.d.length;if(r<3)return t.isZero()?t:Nz(e,2,t,t);n=1.4*Math.sqrt(r),n=n>16?16:0|n,t=t.times(1/Az(5,n)),t=Nz(e,2,t,t);for(var i,o=new e(5),s=new e(16),a=new e(20);n--;)i=t.times(t),t=t.times(o.plus(i.times(s.times(i).minus(a))));return t}(r,kz(r,n)),r.precision=e,r.rounding=t,dz(BB>2?n.neg():n,e,t,!0)):new r(NaN)},oz.squareRoot=oz.sqrt=function(){var e,t,n,r,i,o,s=this,a=s.d,l=s.e,c=s.s,u=s.constructor;if(1!==c||!a||!a[0])return new u(!c||c<0&&(!a||a[0])?NaN:a?s:1/0);for(qB=!1,0==(c=Math.sqrt(+s))||c==1/0?(((t=sz(a)).length+l)%2==0&&(t+="0"),c=Math.sqrt(t),l=YB((l+1)/2)-(l<0||l%2),r=new u(t=c==1/0?"5e"+l:(t=c.toExponential()).slice(0,t.indexOf("e")+1)+l)):r=new u(c.toString()),n=(l=u.precision)+3;;)if(r=(o=r).plus(uz(s,o,n+2,1)).times(.5),sz(o.d).slice(0,n)===(t=sz(r.d)).slice(0,n)){if("9999"!=(t=t.slice(n-3,n+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(dz(r,l+1,1),e=!r.times(r).eq(s));break}if(!i&&(dz(o,l+1,0),o.times(o).eq(s))){r=o;break}n+=4,i=1}return qB=!0,dz(r,l,u.rounding,e)},oz.tangent=oz.tan=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+10,r.rounding=1,(n=n.sin()).s=1,n=uz(n,new r(1).minus(n.times(n)).sqrt(),e+10,0),r.precision=e,r.rounding=t,dz(2==BB||4==BB?n.neg():n,e,t,!0)):new r(NaN)},oz.times=oz.mul=function(e){var t,n,r,i,o,s,a,l,c,u=this,d=u.constructor,p=u.d,h=(e=new d(e)).d;if(e.s*=u.s,!(p&&p[0]&&h&&h[0]))return new d(!e.s||p&&!p[0]&&!h||h&&!h[0]&&!p?NaN:p&&h?0*e.s:e.s/0);for(n=YB(u.e/7)+YB(e.e/7),(l=p.length)<(c=h.length)&&(o=p,p=h,h=o,s=l,l=c,c=s),o=[],r=s=l+c;r--;)o.push(0);for(r=c;--r>=0;){for(t=0,i=l+r;i>r;)a=o[i]+h[r]*p[i-r-1]+t,o[i--]=a%nz|0,t=a/nz|0;o[i]=(o[i]+t)%nz|0}for(;!o[--s];)o.pop();return t?++n:o.shift(),e.d=o,e.e=hz(o,n),qB?dz(e,d.precision,d.rounding):e},oz.toBinary=function(e,t){return Tz(this,2,e,t)},oz.toDecimalPlaces=oz.toDP=function(e,t){var n=this,r=n.constructor;return n=new r(n),void 0===e?n:(az(e,0,jB),void 0===t?t=r.rounding:az(t,0,8),dz(n,e+n.e+1,t))},oz.toExponential=function(e,t){var n,r=this,i=r.constructor;return void 0===e?n=pz(r,!0):(az(e,0,jB),void 0===t?t=i.rounding:az(t,0,8),n=pz(r=dz(new i(r),e+1,t),!0,e+1)),r.isNeg()&&!r.isZero()?"-"+n:n},oz.toFixed=function(e,t){var n,r,i=this,o=i.constructor;return void 0===e?n=pz(i):(az(e,0,jB),void 0===t?t=o.rounding:az(t,0,8),n=pz(r=dz(new o(i),e+i.e+1,t),!1,e+r.e+1)),i.isNeg()&&!i.isZero()?"-"+n:n},oz.toFraction=function(e){var t,n,r,i,o,s,a,l,c,u,d,p,h=this,f=h.d,m=h.constructor;if(!f)return new m(h);if(c=n=new m(1),r=l=new m(0),s=(o=(t=new m(r)).e=gz(f)-h.e-1)%7,t.d[0]=ZB(10,s<0?7+s:s),null==e)e=o>0?t:c;else{if(!(a=new m(e)).isInt()||a.lt(c))throw Error(WB+a);e=a.gt(t)?o>0?t:c:a}for(qB=!1,a=new m(sz(f)),u=m.precision,m.precision=o=7*f.length*2;d=uz(a,t,0,1,1),1!=(i=n.plus(d.times(r))).cmp(e);)n=r,r=i,i=c,c=l.plus(d.times(i)),l=i,i=t,t=a.minus(d.times(i)),a=i;return i=uz(e.minus(n),r,0,1,1),l=l.plus(i.times(c)),n=n.plus(i.times(r)),l.s=c.s=h.s,p=uz(c,r,o,1).minus(h).abs().cmp(uz(l,n,o,1).minus(h).abs())<1?[c,r]:[l,n],m.precision=u,qB=!0,p},oz.toHexadecimal=oz.toHex=function(e,t){return Tz(this,16,e,t)},oz.toNearest=function(e,t){var n=this,r=n.constructor;if(n=new r(n),null==e){if(!n.d)return n;e=new r(1),t=r.rounding}else{if(e=new r(e),void 0===t?t=r.rounding:az(t,0,8),!n.d)return e.s?n:e;if(!e.d)return e.s&&(e.s=n.s),e}return e.d[0]?(qB=!1,n=uz(n,e,0,t,1).times(e),qB=!0,dz(n)):(e.s=n.s,n=e),n},oz.toNumber=function(){return+this},oz.toOctal=function(e,t){return Tz(this,8,e,t)},oz.toPower=oz.pow=function(e){var t,n,r,i,o,s,a=this,l=a.constructor,c=+(e=new l(e));if(!(a.d&&e.d&&a.d[0]&&e.d[0]))return new l(ZB(+a,c));if((a=new l(a)).eq(1))return a;if(r=l.precision,o=l.rounding,e.eq(1))return dz(a,r,o);if((t=YB(e.e/7))>=e.d.length-1&&(n=c<0?-c:c)<=9007199254740991)return i=vz(l,a,n,r),e.s<0?new l(1).div(i):dz(i,r,o);if((s=a.s)<0){if(t<e.d.length-1)return new l(NaN);if(1&e.d[t]||(s=1),0==a.e&&1==a.d[0]&&1==a.d.length)return a.s=s,a}return(t=0!=(n=ZB(+a,c))&&isFinite(n)?new l(n+"").e:YB(c*(Math.log("0."+sz(a.d))/Math.LN10+a.e+1)))>l.maxE+1||t<l.minE-1?new l(t>0?s/0:0):(qB=!1,l.rounding=a.s=1,n=Math.min(12,(t+"").length),(i=xz(e.times(Mz(a,r+n)),r)).d&&lz((i=dz(i,r+5,1)).d,r,o)&&(t=r+10,+sz((i=dz(xz(e.times(Mz(a,t+n)),t),t+5,1)).d).slice(r+1,r+15)+1==1e14&&(i=dz(i,r+1,0))),i.s=s,qB=!0,l.rounding=o,dz(i,r,o))},oz.toPrecision=function(e,t){var n,r=this,i=r.constructor;return void 0===e?n=pz(r,r.e<=i.toExpNeg||r.e>=i.toExpPos):(az(e,1,jB),void 0===t?t=i.rounding:az(t,0,8),n=pz(r=dz(new i(r),e,t),e<=r.e||r.e<=i.toExpNeg,e)),r.isNeg()&&!r.isZero()?"-"+n:n},oz.toSignificantDigits=oz.toSD=function(e,t){var n=this.constructor;return void 0===e?(e=n.precision,t=n.rounding):(az(e,1,jB),void 0===t?t=n.rounding:az(t,0,8)),dz(new n(this),e,t)},oz.toString=function(){var e=this,t=e.constructor,n=pz(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+n:n},oz.truncated=oz.trunc=function(){return dz(new this.constructor(this),this.e+1,1)},oz.valueOf=oz.toJSON=function(){var e=this,t=e.constructor,n=pz(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+n:n};var uz=function(){function e(e,t,n){var r,i=0,o=e.length;for(e=e.slice();o--;)r=e[o]*t+i,e[o]=r%n|0,i=r/n|0;return i&&e.unshift(i),e}function t(e,t,n,r){var i,o;if(n!=r)o=n>r?1:-1;else for(i=o=0;i<n;i++)if(e[i]!=t[i]){o=e[i]>t[i]?1:-1;break}return o}function n(e,t,n,r){for(var i=0;n--;)e[n]-=i,i=e[n]<t[n]?1:0,e[n]=i*r+e[n]-t[n];for(;!e[0]&&e.length>1;)e.shift()}return function(r,i,o,s,a,l){var c,u,d,p,h,f,m,g,y,v,b,w,x,M,S,E,C,N,A,k,T=r.constructor,O=r.s==i.s?1:-1,_=r.d,R=i.d;if(!(_&&_[0]&&R&&R[0]))return new T(r.s&&i.s&&(_?!R||_[0]!=R[0]:R)?_&&0==_[0]||!R?0*O:O/0:NaN);for(l?(h=1,u=r.e-i.e):(l=nz,h=7,u=YB(r.e/h)-YB(i.e/h)),A=R.length,C=_.length,v=(y=new T(O)).d=[],d=0;R[d]==(_[d]||0);d++);if(R[d]>(_[d]||0)&&u--,null==o?(M=o=T.precision,s=T.rounding):M=a?o+(r.e-i.e)+1:o,M<0)v.push(1),f=!0;else{if(M=M/h+2|0,d=0,1==A){for(p=0,R=R[0],M++;(d<C||p)&&M--;d++)S=p*l+(_[d]||0),v[d]=S/R|0,p=S%R|0;f=p||d<C}else{for((p=l/(R[0]+1)|0)>1&&(R=e(R,p,l),_=e(_,p,l),A=R.length,C=_.length),E=A,w=(b=_.slice(0,A)).length;w<A;)b[w++]=0;(k=R.slice()).unshift(0),N=R[0],R[1]>=l/2&&++N;do{p=0,(c=t(R,b,A,w))<0?(x=b[0],A!=w&&(x=x*l+(b[1]||0)),(p=x/N|0)>1?(p>=l&&(p=l-1),1==(c=t(m=e(R,p,l),b,g=m.length,w=b.length))&&(p--,n(m,A<g?k:R,g,l))):(0==p&&(c=p=1),m=R.slice()),(g=m.length)<w&&m.unshift(0),n(b,m,w,l),-1==c&&(c=t(R,b,A,w=b.length))<1&&(p++,n(b,A<w?k:R,w,l)),w=b.length):0===c&&(p++,b=[0]),v[d++]=p,c&&b[0]?b[w++]=_[E]||0:(b=[_[E]],w=1)}while((E++<C||void 0!==b[0])&&M--);f=void 0!==b[0]}v[0]||v.shift()}if(1==h)y.e=u,LB=f;else{for(d=1,p=v[0];p>=10;p/=10)d++;y.e=d+u*h-1,dz(y,a?o+y.e+1:o,s,f)}return y}}();function dz(e,t,n,r){var i,o,s,a,l,c,u,d,p,h=e.constructor;e:if(null!=t){if(!(d=e.d))return e;for(i=1,a=d[0];a>=10;a/=10)i++;if((o=t-i)<0)o+=7,s=t,l=(u=d[p=0])/ZB(10,i-s-1)%10|0;else if((p=Math.ceil((o+1)/7))>=(a=d.length)){if(!r)break e;for(;a++<=p;)d.push(0);u=l=0,i=1,s=(o%=7)-7+1}else{for(u=a=d[p],i=1;a>=10;a/=10)i++;l=(s=(o%=7)-7+i)<0?0:u/ZB(10,i-s-1)%10|0}if(r=r||t<0||void 0!==d[p+1]||(s<0?u:u%ZB(10,i-s-1)),c=n<4?(l||r)&&(0==n||n==(e.s<0?3:2)):l>5||5==l&&(4==n||r||6==n&&(o>0?s>0?u/ZB(10,i-s):0:d[p-1])%10&1||n==(e.s<0?8:7)),t<1||!d[0])return d.length=0,c?(t-=e.e+1,d[0]=ZB(10,(7-t%7)%7),e.e=-t||0):d[0]=e.e=0,e;if(0==o?(d.length=p,a=1,p--):(d.length=p+1,a=ZB(10,7-o),d[p]=s>0?(u/ZB(10,i-s)%ZB(10,s)|0)*a:0),c)for(;;){if(0==p){for(o=1,s=d[0];s>=10;s/=10)o++;for(s=d[0]+=a,a=1;s>=10;s/=10)a++;o!=a&&(e.e++,d[0]==nz&&(d[0]=1));break}if(d[p]+=a,d[p]!=nz)break;d[p--]=0,a=1}for(o=d.length;0===d[--o];)d.pop()}return qB&&(e.e>h.maxE?(e.d=null,e.e=NaN):e.e<h.minE&&(e.e=0,e.d=[0])),e}function pz(e,t,n){if(!e.isFinite())return Sz(e);var r,i=e.e,o=sz(e.d),s=o.length;return t?(n&&(r=n-s)>0?o=o.charAt(0)+"."+o.slice(1)+yz(r):s>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(e.e<0?"e":"e+")+e.e):i<0?(o="0."+yz(-i-1)+o,n&&(r=n-s)>0&&(o+=yz(r))):i>=s?(o+=yz(i+1-s),n&&(r=n-i-1)>0&&(o=o+"."+yz(r))):((r=i+1)<s&&(o=o.slice(0,r)+"."+o.slice(r)),n&&(r=n-s)>0&&(i+1===s&&(o+="."),o+=yz(r))),o}function hz(e,t){var n=e[0];for(t*=7;n>=10;n/=10)t++;return t}function fz(e,t,n){if(t>rz)throw qB=!0,n&&(e.precision=n),Error(KB);return dz(new e($B),t,1,!0)}function mz(e,t,n){if(t>iz)throw Error(KB);return dz(new e(HB),t,n,!0)}function gz(e){var t=e.length-1,n=7*t+1;if(t=e[t]){for(;t%10==0;t/=10)n--;for(t=e[0];t>=10;t/=10)n++}return n}function yz(e){for(var t="";e--;)t+="0";return t}function vz(e,t,n,r){var i,o=new e(1),s=Math.ceil(r/7+4);for(qB=!1;;){if(n%2&&Oz((o=o.times(t)).d,s)&&(i=!0),0===(n=YB(n/2))){n=o.d.length-1,i&&0===o.d[n]&&++o.d[n];break}Oz((t=t.times(t)).d,s)}return qB=!0,o}function bz(e){return 1&e.d[e.d.length-1]}function wz(e,t,n){for(var r,i,o=new e(t[0]),s=0;++s<t.length;){if(!(i=new e(t[s])).s){o=i;break}((r=o.cmp(i))===n||0===r&&o.s===n)&&(o=i)}return o}function xz(e,t){var n,r,i,o,s,a,l,c=0,u=0,d=0,p=e.constructor,h=p.rounding,f=p.precision;if(!e.d||!e.d[0]||e.e>17)return new p(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(null==t?(qB=!1,l=f):l=t,a=new p(.03125);e.e>-2;)e=e.times(a),d+=5;for(l+=r=Math.log(ZB(2,d))/Math.LN10*2+5|0,n=o=s=new p(1),p.precision=l;;){if(o=dz(o.times(e),l,1),n=n.times(++u),sz((a=s.plus(uz(o,n,l,1))).d).slice(0,l)===sz(s.d).slice(0,l)){for(i=d;i--;)s=dz(s.times(s),l,1);if(null!=t)return p.precision=f,s;if(!(c<3&&lz(s.d,l-r,h,c)))return dz(s,p.precision=f,h,qB=!0);p.precision=l+=10,n=o=a=new p(1),u=0,c++}s=a}}function Mz(e,t){var n,r,i,o,s,a,l,c,u,d,p,h=1,f=e,m=f.d,g=f.constructor,y=g.rounding,v=g.precision;if(f.s<0||!m||!m[0]||!f.e&&1==m[0]&&1==m.length)return new g(m&&!m[0]?-1/0:1!=f.s?NaN:m?0:f);if(null==t?(qB=!1,u=v):u=t,g.precision=u+=10,r=(n=sz(m)).charAt(0),!(Math.abs(o=f.e)<15e14))return c=fz(g,u+2,v).times(o+""),f=Mz(new g(r+"."+n.slice(1)),u-10).plus(c),g.precision=v,null==t?dz(f,v,y,qB=!0):f;for(;r<7&&1!=r||1==r&&n.charAt(1)>3;)r=(n=sz((f=f.times(e)).d)).charAt(0),h++;for(o=f.e,r>1?(f=new g("0."+n),o++):f=new g(r+"."+n.slice(1)),d=f,l=s=f=uz(f.minus(1),f.plus(1),u,1),p=dz(f.times(f),u,1),i=3;;){if(s=dz(s.times(p),u,1),sz((c=l.plus(uz(s,new g(i),u,1))).d).slice(0,u)===sz(l.d).slice(0,u)){if(l=l.times(2),0!==o&&(l=l.plus(fz(g,u+2,v).times(o+""))),l=uz(l,new g(h),u,1),null!=t)return g.precision=v,l;if(!lz(l.d,u-10,y,a))return dz(l,g.precision=v,y,qB=!0);g.precision=u+=10,c=s=f=uz(d.minus(1),d.plus(1),u,1),p=dz(f.times(f),u,1),i=a=1}l=c,i+=2}}function Sz(e){return String(e.s*e.s/0)}function Ez(e,t){var n,r,i;for((n=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;48===t.charCodeAt(r);r++);for(i=t.length;48===t.charCodeAt(i-1);--i);if(t=t.slice(r,i)){if(i-=r,e.e=n=n-r-1,e.d=[],r=(n+1)%7,n<0&&(r+=7),r<i){for(r&&e.d.push(+t.slice(0,r)),i-=7;r<i;)e.d.push(+t.slice(r,r+=7));r=7-(t=t.slice(r)).length}else r-=i;for(;r--;)t+="0";e.d.push(+t),qB&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function Cz(e,t){var n,r,i,o,s,a,l,c,u;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),tz.test(t))return Ez(e,t)}else if("Infinity"===t||"NaN"===t)return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(QB.test(t))n=16,t=t.toLowerCase();else if(XB.test(t))n=2;else{if(!ez.test(t))throw Error(WB+t);n=8}for((o=t.search(/p/i))>0?(l=+t.slice(o+1),t=t.substring(2,o)):t=t.slice(2),s=(o=t.indexOf("."))>=0,r=e.constructor,s&&(o=(a=(t=t.replace(".","")).length)-o,i=vz(r,new r(n),o,2*o)),o=u=(c=cz(t,n,nz)).length-1;0===c[o];--o)c.pop();return o<0?new r(0*e.s):(e.e=hz(c,u),e.d=c,qB=!1,s&&(e=uz(e,i,4*a)),l&&(e=e.times(Math.abs(l)<54?ZB(2,l):yP.pow(2,l))),qB=!0,e)}function Nz(e,t,n,r,i){var o,s,a,l,c=e.precision,u=Math.ceil(c/7);for(qB=!1,l=n.times(n),a=new e(r);;){if(s=uz(a.times(l),new e(t++*t++),c,1),a=i?r.plus(s):r.minus(s),r=uz(s.times(l),new e(t++*t++),c,1),void 0!==(s=a.plus(r)).d[u]){for(o=u;s.d[o]===a.d[o]&&o--;);if(-1==o)break}o=a,a=r,r=s,s=o}return qB=!0,s.d.length=u+1,s}function Az(e,t){for(var n=e;--t;)n*=e;return n}function kz(e,t){var n,r=t.s<0,i=mz(e,e.precision,1),o=i.times(.5);if((t=t.abs()).lte(o))return BB=r?4:1,t;if((n=t.divToInt(i)).isZero())BB=r?3:2;else{if((t=t.minus(n.times(i))).lte(o))return BB=bz(n)?r?2:3:r?4:1,t;BB=bz(n)?r?1:4:r?3:2}return t.minus(i).abs()}function Tz(e,t,n,r){var i,o,s,a,l,c,u,d,p,h=e.constructor,f=void 0!==n;if(f?(az(n,1,jB),void 0===r?r=h.rounding:az(r,0,8)):(n=h.precision,r=h.rounding),e.isFinite()){for(f?(i=2,16==t?n=4*n-3:8==t&&(n=3*n-2)):i=t,(s=(u=pz(e)).indexOf("."))>=0&&(u=u.replace(".",""),(p=new h(1)).e=u.length-s,p.d=cz(pz(p),10,i),p.e=p.d.length),o=l=(d=cz(u,10,i)).length;0==d[--l];)d.pop();if(d[0]){if(s<0?o--:((e=new h(e)).d=d,e.e=o,d=(e=uz(e,p,n,r,0,i)).d,o=e.e,c=LB),s=d[n],a=i/2,c=c||void 0!==d[n+1],c=r<4?(void 0!==s||c)&&(0===r||r===(e.s<0?3:2)):s>a||s===a&&(4===r||c||6===r&&1&d[n-1]||r===(e.s<0?8:7)),d.length=n,c)for(;++d[--n]>i-1;)d[n]=0,n||(++o,d.unshift(1));for(l=d.length;!d[l-1];--l);for(s=0,u="";s<l;s++)u+=FB.charAt(d[s]);if(f){if(l>1)if(16==t||8==t){for(s=16==t?4:3,--l;l%s;l++)u+="0";for(l=(d=cz(u,i,t)).length;!d[l-1];--l);for(s=1,u="1.";s<l;s++)u+=FB.charAt(d[s])}else u=u.charAt(0)+"."+u.slice(1);u=u+(o<0?"p":"p+")+o}else if(o<0){for(;++o;)u="0"+u;u="0."+u}else if(++o>l)for(o-=l;o--;)u+="0";else o<l&&(u=u.slice(0,o)+"."+u.slice(o))}else u=f?"0p+0":"0";u=(16==t?"0x":2==t?"0b":8==t?"0o":"")+u}else u=Sz(e);return e.s<0?"-"+u:u}function Oz(e,t){if(e.length>t)return e.length=t,!0}function _z(e){return new this(e).abs()}function Rz(e){return new this(e).acos()}function Dz(e){return new this(e).acosh()}function Iz(e,t){return new this(e).plus(t)}function Lz(e){return new this(e).asin()}function Bz(e){return new this(e).asinh()}function zz(e){return new this(e).atan()}function Pz(e){return new this(e).atanh()}function jz(e,t){e=new this(e),t=new this(t);var n,r=this.precision,i=this.rounding,o=r+4;return e.s&&t.s?e.d||t.d?!t.d||e.isZero()?(n=t.s<0?mz(this,r,i):new this(0)).s=e.s:!e.d||t.isZero()?(n=mz(this,o,1).times(.5)).s=e.s:t.s<0?(this.precision=o,this.rounding=1,n=this.atan(uz(e,t,o,1)),t=mz(this,o,1),this.precision=r,this.rounding=i,n=e.s<0?n.minus(t):n.plus(t)):n=this.atan(uz(e,t,o,1)):(n=mz(this,o,1).times(t.s>0?.25:.75)).s=e.s:n=new this(NaN),n}function Fz(e){return new this(e).cbrt()}function $z(e){return dz(e=new this(e),e.e+1,2)}function Hz(e,t,n){return new this(e).clamp(t,n)}function Uz(e){if(!e||"object"!=typeof e)throw Error(VB+"Object expected");var t,n,r,i=!0===e.defaults,o=["precision",1,jB,"rounding",0,8,"toExpNeg",-PB,0,"toExpPos",0,PB,"maxE",0,PB,"minE",-PB,0,"modulo",0,9];for(t=0;t<o.length;t+=3)if(n=o[t],i&&(this[n]=UB[n]),void 0!==(r=e[n])){if(!(YB(r)===r&&r>=o[t+1]&&r<=o[t+2]))throw Error(WB+n+": "+r);this[n]=r}if(n="crypto",i&&(this[n]=UB[n]),void 0!==(r=e[n])){if(!0!==r&&!1!==r&&0!==r&&1!==r)throw Error(WB+n+": "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(GB);this[n]=!0}else this[n]=!1}return this}function qz(e){return new this(e).cos()}function Vz(e){return new this(e).cosh()}function Wz(e,t){return new this(e).div(t)}function Kz(e){return new this(e).exp()}function Gz(e){return dz(e=new this(e),e.e+1,3)}function Jz(){var e,t,n=new this(0);for(qB=!1,e=0;e<arguments.length;)if((t=new this(arguments[e++])).d)n.d&&(n=n.plus(t.times(t)));else{if(t.s)return qB=!0,new this(1/0);n=t}return qB=!0,n.sqrt()}function Yz(e){return e instanceof yP||e&&e.toStringTag===JB||!1}function Zz(e){return new this(e).ln()}function Xz(e,t){return new this(e).log(t)}function Qz(e){return new this(e).log(2)}function eP(e){return new this(e).log(10)}function tP(){return wz(this,arguments,-1)}function nP(){return wz(this,arguments,1)}function rP(e,t){return new this(e).mod(t)}function iP(e,t){return new this(e).mul(t)}function oP(e,t){return new this(e).pow(t)}function sP(e){var t,n,r,i,o=0,s=new this(1),a=[];if(void 0===e?e=this.precision:az(e,1,jB),r=Math.ceil(e/7),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(r));o<r;)(i=t[o])>=429e7?t[o]=crypto.getRandomValues(new Uint32Array(1))[0]:a[o++]=i%1e7;else{if(!crypto.randomBytes)throw Error(GB);for(t=crypto.randomBytes(r*=4);o<r;)(i=t[o]+(t[o+1]<<8)+(t[o+2]<<16)+((127&t[o+3])<<24))>=214e7?crypto.randomBytes(4).copy(t,o):(a.push(i%1e7),o+=4);o=r/4}else for(;o<r;)a[o++]=1e7*Math.random()|0;for(e%=7,(r=a[--o])&&e&&(i=ZB(10,7-e),a[o]=(r/i|0)*i);0===a[o];o--)a.pop();if(o<0)n=0,a=[0];else{for(n=-1;0===a[0];n-=7)a.shift();for(r=1,i=a[0];i>=10;i/=10)r++;r<7&&(n-=7-r)}return s.e=n,s.d=a,s}function aP(e){return dz(e=new this(e),e.e+1,this.rounding)}function lP(e){return(e=new this(e)).d?e.d[0]?e.s:0*e.s:e.s||NaN}function cP(e){return new this(e).sin()}function uP(e){return new this(e).sinh()}function dP(e){return new this(e).sqrt()}function pP(e,t){return new this(e).sub(t)}function hP(){var e=0,t=arguments,n=new this(t[e]);for(qB=!1;n.s&&++e<t.length;)n=n.plus(t[e]);return qB=!0,dz(n,this.precision,this.rounding)}function fP(e){return new this(e).tan()}function mP(e){return new this(e).tanh()}function gP(e){return dz(e=new this(e),e.e+1,1)}oz[Symbol.for("nodejs.util.inspect.custom")]=oz.toString,oz[Symbol.toStringTag]="Decimal";var yP=oz.constructor=function e(t){var n,r,i;function o(e){var t,n,r,i=this;if(!(i instanceof o))return new o(e);if(i.constructor=o,Yz(e))return i.s=e.s,void(qB?!e.d||e.e>o.maxE?(i.e=NaN,i.d=null):e.e<o.minE?(i.e=0,i.d=[0]):(i.e=e.e,i.d=e.d.slice()):(i.e=e.e,i.d=e.d?e.d.slice():e.d));if("number"===(r=typeof e)){if(0===e)return i.s=1/e<0?-1:1,i.e=0,void(i.d=[0]);if(e<0?(e=-e,i.s=-1):i.s=1,e===~~e&&e<1e7){for(t=0,n=e;n>=10;n/=10)t++;return void(qB?t>o.maxE?(i.e=NaN,i.d=null):t<o.minE?(i.e=0,i.d=[0]):(i.e=t,i.d=[e]):(i.e=t,i.d=[e]))}return 0*e!=0?(e||(i.s=NaN),i.e=NaN,void(i.d=null)):Ez(i,e.toString())}if("string"===r)return 45===(n=e.charCodeAt(0))?(e=e.slice(1),i.s=-1):(43===n&&(e=e.slice(1)),i.s=1),tz.test(e)?Ez(i,e):Cz(i,e);if("bigint"===r)return e<0?(e=-e,i.s=-1):i.s=1,Ez(i,e.toString());throw Error(WB+e)}if(o.prototype=oz,o.ROUND_UP=0,o.ROUND_DOWN=1,o.ROUND_CEIL=2,o.ROUND_FLOOR=3,o.ROUND_HALF_UP=4,o.ROUND_HALF_DOWN=5,o.ROUND_HALF_EVEN=6,o.ROUND_HALF_CEIL=7,o.ROUND_HALF_FLOOR=8,o.EUCLID=9,o.config=o.set=Uz,o.clone=e,o.isDecimal=Yz,o.abs=_z,o.acos=Rz,o.acosh=Dz,o.add=Iz,o.asin=Lz,o.asinh=Bz,o.atan=zz,o.atanh=Pz,o.atan2=jz,o.cbrt=Fz,o.ceil=$z,o.clamp=Hz,o.cos=qz,o.cosh=Vz,o.div=Wz,o.exp=Kz,o.floor=Gz,o.hypot=Jz,o.ln=Zz,o.log=Xz,o.log10=eP,o.log2=Qz,o.max=tP,o.min=nP,o.mod=rP,o.mul=iP,o.pow=oP,o.random=sP,o.round=aP,o.sign=lP,o.sin=cP,o.sinh=uP,o.sqrt=dP,o.sub=pP,o.sum=hP,o.tan=fP,o.tanh=mP,o.trunc=gP,void 0===t&&(t={}),t&&!0!==t.defaults)for(i=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],n=0;n<i.length;)t.hasOwnProperty(r=i[n++])||(t[r]=this[r]);return o.config(t),o}(UB);$B=new yP($B),HB=new yP(HB);var vP=kB("BigNumber",["?on","config"],function(e){var t=e.on,n=e.config,r=yP.clone({precision:n.precision,modulo:9});return r.prototype.type="BigNumber",r.prototype.isBigNumber=!0,r.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},r.fromJSON=function(e){return new r(e.value)},t&&t("config",function(e,t){e.precision!==t.precision&&r.config({precision:e.precision})}),r},{isClass:!0});const bP=Math.cosh||function(e){return Math.abs(e)<1e-9?1-e:.5*(Math.exp(e)+Math.exp(-e))},wP=Math.sinh||function(e){return Math.abs(e)<1e-9?e:.5*(Math.exp(e)-Math.exp(-e))},xP=function(e,t){return(e=Math.abs(e))<(t=Math.abs(t))&&([e,t]=[t,e]),e<1e8?Math.sqrt(e*e+t*t):(t/=e,e*Math.sqrt(1+t*t))},MP=function(){throw SyntaxError("Invalid Param")};function SP(e,t){const n=Math.abs(e),r=Math.abs(t);return 0===e?Math.log(r):0===t?Math.log(n):n<3e3&&r<3e3?.5*Math.log(e*e+t*t):(e*=.5,t*=.5,.5*Math.log(e*e+t*t)+Math.LN2)}const EP={re:0,im:0},CP=function(e,t){const n=EP;if(null==e)n.re=n.im=0;else if(void 0!==t)n.re=e,n.im=t;else switch(typeof e){case"object":if("im"in e&&"re"in e)n.re=e.re,n.im=e.im;else if("abs"in e&&"arg"in e){if(!isFinite(e.abs)&&isFinite(e.arg))return NP.INFINITY;n.re=e.abs*Math.cos(e.arg),n.im=e.abs*Math.sin(e.arg)}else if("r"in e&&"phi"in e){if(!isFinite(e.r)&&isFinite(e.phi))return NP.INFINITY;n.re=e.r*Math.cos(e.phi),n.im=e.r*Math.sin(e.phi)}else 2===e.length?(n.re=e[0],n.im=e[1]):MP();break;case"string":n.im=n.re=0;const t=e.replace(/_/g,"").match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g);let r=1,i=0;null===t&&MP();for(let e=0;e<t.length;e++){const o=t[e];" "===o||"\t"===o||"\n"===o||("+"===o?r++:"-"===o?i++:"i"===o||"I"===o?(r+i===0&&MP()," "===t[e+1]||isNaN(t[e+1])?n.im+=parseFloat((i%2?"-":"")+"1"):(n.im+=parseFloat((i%2?"-":"")+t[e+1]),e++),r=i=0):((r+i===0||isNaN(o))&&MP(),"i"===t[e+1]||"I"===t[e+1]?(n.im+=parseFloat((i%2?"-":"")+o),e++):n.re+=parseFloat((i%2?"-":"")+o),r=i=0))}r+i>0&&MP();break;case"number":n.im=0,n.re=e;break;default:MP()}return isNaN(n.re)||isNaN(n.im),n};function NP(e,t){if(!(this instanceof NP))return new NP(e,t);const n=CP(e,t);this.re=n.re,this.im=n.im}function AP(e){return AP="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},AP(e)}NP.prototype={re:0,im:0,sign:function(){const e=xP(this.re,this.im);return new NP(this.re/e,this.im/e)},add:function(e,t){const n=CP(e,t),r=this.isInfinite(),i=!(isFinite(n.re)&&isFinite(n.im));return r||i?r&&i?NP.NAN:NP.INFINITY:new NP(this.re+n.re,this.im+n.im)},sub:function(e,t){const n=CP(e,t),r=this.isInfinite(),i=!(isFinite(n.re)&&isFinite(n.im));return r||i?r&&i?NP.NAN:NP.INFINITY:new NP(this.re-n.re,this.im-n.im)},mul:function(e,t){const n=CP(e,t),r=this.isInfinite(),i=!(isFinite(n.re)&&isFinite(n.im)),o=0===this.re&&0===this.im,s=0===n.re&&0===n.im;return r&&s||i&&o?NP.NAN:r||i?NP.INFINITY:0===n.im&&0===this.im?new NP(this.re*n.re,0):new NP(this.re*n.re-this.im*n.im,this.re*n.im+this.im*n.re)},div:function(e,t){const n=CP(e,t),r=this.isInfinite(),i=!(isFinite(n.re)&&isFinite(n.im)),o=0===this.re&&0===this.im,s=0===n.re&&0===n.im;if(o&&s||r&&i)return NP.NAN;if(s||r)return NP.INFINITY;if(o||i)return NP.ZERO;if(0===n.im)return new NP(this.re/n.re,this.im/n.re);if(Math.abs(n.re)<Math.abs(n.im)){const e=n.re/n.im,t=n.re*e+n.im;return new NP((this.re*e+this.im)/t,(this.im*e-this.re)/t)}{const e=n.im/n.re,t=n.im*e+n.re;return new NP((this.re+this.im*e)/t,(this.im-this.re*e)/t)}},pow:function(e,t){const n=CP(e,t),r=0===this.re&&0===this.im;if(0===n.re&&0===n.im)return NP.ONE;if(0===n.im){if(0===this.im&&this.re>0)return new NP(Math.pow(this.re,n.re),0);if(0===this.re)switch((n.re%4+4)%4){case 0:return new NP(Math.pow(this.im,n.re),0);case 1:return new NP(0,Math.pow(this.im,n.re));case 2:return new NP(-Math.pow(this.im,n.re),0);case 3:return new NP(0,-Math.pow(this.im,n.re))}}if(r&&n.re>0)return NP.ZERO;const i=Math.atan2(this.im,this.re),o=SP(this.re,this.im);let s=Math.exp(n.re*o-n.im*i),a=n.im*o+n.re*i;return new NP(s*Math.cos(a),s*Math.sin(a))},sqrt:function(){const e=this.re,t=this.im;if(0===t)return e>=0?new NP(Math.sqrt(e),0):new NP(0,Math.sqrt(-e));const n=xP(e,t);let r=Math.sqrt(.5*(n+Math.abs(e))),i=Math.abs(t)/(2*r);return e>=0?new NP(r,t<0?-i:i):new NP(i,t<0?-r:r)},exp:function(){const e=Math.exp(this.re);return 0===this.im?new NP(e,0):new NP(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){const e=this.re,t=this.im;return new NP(Math.expm1(e)*Math.cos(t)+function(e){const t=Math.PI/4;if(-t>e||e>t)return Math.cos(e)-1;const n=e*e;return n*(n*(n*(n*(n*(n*(n*(n/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-.5)}(t),Math.exp(e)*Math.sin(t))},log:function(){const e=this.re,t=this.im;return 0===t&&e>0?new NP(Math.log(e),0):new NP(SP(e,t),Math.atan2(t,e))},abs:function(){return xP(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){const e=this.re,t=this.im;return new NP(Math.sin(e)*bP(t),Math.cos(e)*wP(t))},cos:function(){const e=this.re,t=this.im;return new NP(Math.cos(e)*bP(t),-Math.sin(e)*wP(t))},tan:function(){const e=2*this.re,t=2*this.im,n=Math.cos(e)+bP(t);return new NP(Math.sin(e)/n,wP(t)/n)},cot:function(){const e=2*this.re,t=2*this.im,n=Math.cos(e)-bP(t);return new NP(-Math.sin(e)/n,wP(t)/n)},sec:function(){const e=this.re,t=this.im,n=.5*bP(2*t)+.5*Math.cos(2*e);return new NP(Math.cos(e)*bP(t)/n,Math.sin(e)*wP(t)/n)},csc:function(){const e=this.re,t=this.im,n=.5*bP(2*t)-.5*Math.cos(2*e);return new NP(Math.sin(e)*bP(t)/n,-Math.cos(e)*wP(t)/n)},asin:function(){const e=this.re,t=this.im,n=new NP(t*t-e*e+1,-2*e*t).sqrt(),r=new NP(n.re-t,n.im+e).log();return new NP(r.im,-r.re)},acos:function(){const e=this.re,t=this.im,n=new NP(t*t-e*e+1,-2*e*t).sqrt(),r=new NP(n.re-t,n.im+e).log();return new NP(Math.PI/2-r.im,r.re)},atan:function(){const e=this.re,t=this.im;if(0===e){if(1===t)return new NP(0,1/0);if(-1===t)return new NP(0,-1/0)}const n=e*e+(1-t)*(1-t),r=new NP((1-t*t-e*e)/n,-2*e/n).log();return new NP(-.5*r.im,.5*r.re)},acot:function(){const e=this.re,t=this.im;if(0===t)return new NP(Math.atan2(1,e),0);const n=e*e+t*t;return 0!==n?new NP(e/n,-t/n).atan():new NP(0!==e?e/0:0,0!==t?-t/0:0).atan()},asec:function(){const e=this.re,t=this.im;if(0===e&&0===t)return new NP(0,1/0);const n=e*e+t*t;return 0!==n?new NP(e/n,-t/n).acos():new NP(0!==e?e/0:0,0!==t?-t/0:0).acos()},acsc:function(){const e=this.re,t=this.im;if(0===e&&0===t)return new NP(Math.PI/2,1/0);const n=e*e+t*t;return 0!==n?new NP(e/n,-t/n).asin():new NP(0!==e?e/0:0,0!==t?-t/0:0).asin()},sinh:function(){const e=this.re,t=this.im;return new NP(wP(e)*Math.cos(t),bP(e)*Math.sin(t))},cosh:function(){const e=this.re,t=this.im;return new NP(bP(e)*Math.cos(t),wP(e)*Math.sin(t))},tanh:function(){const e=2*this.re,t=2*this.im,n=bP(e)+Math.cos(t);return new NP(wP(e)/n,Math.sin(t)/n)},coth:function(){const e=2*this.re,t=2*this.im,n=bP(e)-Math.cos(t);return new NP(wP(e)/n,-Math.sin(t)/n)},csch:function(){const e=this.re,t=this.im,n=Math.cos(2*t)-bP(2*e);return new NP(-2*wP(e)*Math.cos(t)/n,2*bP(e)*Math.sin(t)/n)},sech:function(){const e=this.re,t=this.im,n=Math.cos(2*t)+bP(2*e);return new NP(2*bP(e)*Math.cos(t)/n,-2*wP(e)*Math.sin(t)/n)},asinh:function(){let e=this.im;this.im=-this.re,this.re=e;const t=this.asin();return this.re=-this.im,this.im=e,e=t.re,t.re=-t.im,t.im=e,t},acosh:function(){const e=this.acos();if(e.im<=0){const t=e.re;e.re=-e.im,e.im=t}else{const t=e.im;e.im=-e.re,e.re=t}return e},atanh:function(){const e=this.re,t=this.im,n=e>1&&0===t,r=1-e,i=1+e,o=r*r+t*t,s=0!==o?new NP((i*r-t*t)/o,(t*r+i*t)/o):new NP(-1!==e?e/0:0,0!==t?t/0:0),a=s.re;return s.re=SP(s.re,s.im)/2,s.im=Math.atan2(s.im,a)/2,n&&(s.im=-s.im),s},acoth:function(){const e=this.re,t=this.im;if(0===e&&0===t)return new NP(0,Math.PI/2);const n=e*e+t*t;return 0!==n?new NP(e/n,-t/n).atanh():new NP(0!==e?e/0:0,0!==t?-t/0:0).atanh()},acsch:function(){const e=this.re,t=this.im;if(0===t)return new NP(0!==e?Math.log(e+Math.sqrt(e*e+1)):1/0,0);const n=e*e+t*t;return 0!==n?new NP(e/n,-t/n).asinh():new NP(0!==e?e/0:0,0!==t?-t/0:0).asinh()},asech:function(){const e=this.re,t=this.im;if(this.isZero())return NP.INFINITY;const n=e*e+t*t;return 0!==n?new NP(e/n,-t/n).acosh():new NP(0!==e?e/0:0,0!==t?-t/0:0).acosh()},inverse:function(){if(this.isZero())return NP.INFINITY;if(this.isInfinite())return NP.ZERO;const e=this.re,t=this.im,n=e*e+t*t;return new NP(e/n,-t/n)},conjugate:function(){return new NP(this.re,-this.im)},neg:function(){return new NP(-this.re,-this.im)},ceil:function(e){return e=Math.pow(10,e||0),new NP(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)},floor:function(e){return e=Math.pow(10,e||0),new NP(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)},round:function(e){return e=Math.pow(10,e||0),new NP(Math.round(this.re*e)/e,Math.round(this.im*e)/e)},equals:function(e,t){const n=CP(e,t);return Math.abs(n.re-this.re)<=NP.EPSILON&&Math.abs(n.im-this.im)<=NP.EPSILON},clone:function(){return new NP(this.re,this.im)},toString:function(){let e=this.re,t=this.im,n="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)<NP.EPSILON&&(e=0),Math.abs(t)<NP.EPSILON&&(t=0),0===t?n+e:(0!==e?(n+=e,n+=" ",t<0?(t=-t,n+="-"):n+="+",n+=" "):t<0&&(t=-t,n+="-"),1!==t&&(n+=t),n+"i"))},toVector:function(){return[this.re,this.im]},valueOf:function(){return 0===this.im?this.re:null},isNaN:function(){return isNaN(this.re)||isNaN(this.im)},isZero:function(){return 0===this.im&&0===this.re},isFinite:function(){return isFinite(this.re)&&isFinite(this.im)},isInfinite:function(){return!this.isFinite()}},NP.ZERO=new NP(0,0),NP.ONE=new NP(1,0),NP.I=new NP(0,1),NP.PI=new NP(Math.PI,0),NP.E=new NP(Math.E,0),NP.INFINITY=new NP(1/0,1/0),NP.NAN=new NP(NaN,NaN),NP.EPSILON=1e-15;var kP=kB("Complex",[],function(){return NP.prototype.type="Complex",NP.prototype.isComplex=!0,NP.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},NP.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},NP.prototype.format=function(e){var t=this.im,n=this.re,r=UL(this.re,e),i=UL(this.im,e),o=HI(e)?e:e?e.precision:null;if(null!==o){var s=Math.pow(10,-o);Math.abs(n/t)<s&&(n=0),Math.abs(t/n)<s&&(t=0)}return 0===t?r:0===n?1===t?"i":-1===t?"-i":i+"i":t<0?-1===t?r+" - i":r+" - "+i.substring(1)+"i":1===t?r+" + i":r+" + "+i+"i"},NP.fromPolar=function(e){switch(arguments.length){case 1:var t=arguments[0];if("object"===AP(t))return NP(t);throw new TypeError("Input has to be an object with r and phi keys.");case 2:var n=arguments[0],r=arguments[1];if(HI(n)){if(WI(r)&&r.hasBase("ANGLE")&&(r=r.toNumber("rad")),HI(r))return new NP({r:n,phi:r});throw new TypeError("Phi is not a number nor an angle unit.")}throw new TypeError("Radius r is not a number.");default:throw new SyntaxError("Wrong number of arguments in function fromPolar")}},NP.prototype.valueOf=NP.prototype.toString,NP.fromJSON=function(e){return new NP(e)},NP.compare=function(e,t){return e.re>t.re?1:e.re<t.re?-1:e.im>t.im?1:e.im<t.im?-1:0},NP},{isClass:!0}),TP={s:1,n:0,d:1};function OP(e,t){if(isNaN(e=parseInt(e,10)))throw zP();return e*t}function _P(e,t){if(0===t)throw BP();var n=Object.create(LP.prototype);n.s=e<0?-1:1;var r=IP(e=e<0?-e:e,t);return n.n=e/r,n.d=t/r,n}function RP(e){for(var t={},n=e,r=2,i=4;i<=n;){for(;n%r===0;)n/=r,t[r]=(t[r]||0)+1;i+=1+2*r++}return n!==e?n>1&&(t[n]=(t[n]||0)+1):t[e]=(t[e]||0)+1,t}var DP=function(e,t){var n,r=0,i=1,o=1,s=0,a=0,l=0,c=1,u=1,d=0,p=1,h=1,f=1,m=1e7;if(null==e);else if(void 0!==t){if(o=(r=e)*(i=t),r%1!=0||i%1!=0)throw PP()}else switch(typeof e){case"object":if("d"in e&&"n"in e)r=e.n,i=e.d,"s"in e&&(r*=e.s);else{if(!(0 in e))throw zP();r=e[0],1 in e&&(i=e[1])}o=r*i;break;case"number":if(e<0&&(o=e,e=-e),e%1==0)r=e;else if(e>0){for(e>=1&&(e/=u=Math.pow(10,Math.floor(1+Math.log(e)/Math.LN10)));p<=m&&f<=m;){if(e===(n=(d+h)/(p+f))){p+f<=m?(r=d+h,i=p+f):f>p?(r=h,i=f):(r=d,i=p);break}e>n?(d+=h,p+=f):(h+=d,f+=p),p>m?(r=h,i=f):(r=d,i=p)}r*=u}else(isNaN(e)||isNaN(t))&&(i=r=NaN);break;case"string":if(null===(p=e.match(/\d+|./g)))throw zP();if("-"===p[d]?(o=-1,d++):"+"===p[d]&&d++,p.length===d+1?a=OP(p[d++],o):"."===p[d+1]||"."===p[d]?("."!==p[d]&&(s=OP(p[d++],o)),(++d+1===p.length||"("===p[d+1]&&")"===p[d+3]||"'"===p[d+1]&&"'"===p[d+3])&&(a=OP(p[d],o),c=Math.pow(10,p[d].length),d++),("("===p[d]&&")"===p[d+2]||"'"===p[d]&&"'"===p[d+2])&&(l=OP(p[d+1],o),u=Math.pow(10,p[d+1].length)-1,d+=3)):"/"===p[d+1]||":"===p[d+1]?(a=OP(p[d],o),c=OP(p[d+2],1),d+=3):"/"===p[d+3]&&" "===p[d+1]&&(s=OP(p[d],o),a=OP(p[d+2],o),c=OP(p[d+4],1),d+=5),p.length<=d){o=r=l+(i=c*u)*s+u*a;break}default:throw zP()}if(0===i)throw BP();TP.s=o<0?-1:1,TP.n=Math.abs(r),TP.d=Math.abs(i)};function IP(e,t){if(!e)return t;if(!t)return e;for(;;){if(!(e%=t))return t;if(!(t%=e))return e}}function LP(e,t){if(DP(e,t),!(this instanceof LP))return _P(TP.s*TP.n,TP.d);e=IP(TP.d,TP.n),this.s=TP.s,this.n=TP.n/e,this.d=TP.d/e}var BP=function(){return new Error("Division by Zero")},zP=function(){return new Error("Invalid argument")},PP=function(){return new Error("Parameters must be integer")};LP.prototype={s:1,n:0,d:1,abs:function(){return _P(this.n,this.d)},neg:function(){return _P(-this.s*this.n,this.d)},add:function(e,t){return DP(e,t),_P(this.s*this.n*TP.d+TP.s*this.d*TP.n,this.d*TP.d)},sub:function(e,t){return DP(e,t),_P(this.s*this.n*TP.d-TP.s*this.d*TP.n,this.d*TP.d)},mul:function(e,t){return DP(e,t),_P(this.s*TP.s*this.n*TP.n,this.d*TP.d)},div:function(e,t){return DP(e,t),_P(this.s*TP.s*this.n*TP.d,this.d*TP.n)},clone:function(){return _P(this.s*this.n,this.d)},mod:function(e,t){if(isNaN(this.n)||isNaN(this.d))return new LP(NaN);if(void 0===e)return _P(this.s*this.n%this.d,1);if(DP(e,t),0===TP.n&&0===this.d)throw BP();return _P(this.s*(TP.d*this.n)%(TP.n*this.d),TP.d*this.d)},gcd:function(e,t){return DP(e,t),_P(IP(TP.n,this.n)*IP(TP.d,this.d),TP.d*this.d)},lcm:function(e,t){return DP(e,t),0===TP.n&&0===this.n?_P(0,1):_P(TP.n*this.n,IP(TP.n,this.n)*IP(TP.d,this.d))},ceil:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new LP(NaN):_P(Math.ceil(e*this.s*this.n/this.d),e)},floor:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new LP(NaN):_P(Math.floor(e*this.s*this.n/this.d),e)},round:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new LP(NaN):_P(Math.round(e*this.s*this.n/this.d),e)},roundTo:function(e,t){return DP(e,t),_P(this.s*Math.round(this.n*TP.d/(this.d*TP.n))*TP.n,TP.d)},inverse:function(){return _P(this.s*this.d,this.n)},pow:function(e,t){if(DP(e,t),1===TP.d)return TP.s<0?_P(Math.pow(this.s*this.d,TP.n),Math.pow(this.n,TP.n)):_P(Math.pow(this.s*this.n,TP.n),Math.pow(this.d,TP.n));if(this.s<0)return null;var n=RP(this.n),r=RP(this.d),i=1,o=1;for(var s in n)if("1"!==s){if("0"===s){i=0;break}if(n[s]*=TP.n,n[s]%TP.d!==0)return null;n[s]/=TP.d,i*=Math.pow(s,n[s])}for(var s in r)if("1"!==s){if(r[s]*=TP.n,r[s]%TP.d!==0)return null;r[s]/=TP.d,o*=Math.pow(s,r[s])}return TP.s<0?_P(o,i):_P(i,o)},equals:function(e,t){return DP(e,t),this.s*this.n*TP.d===TP.s*TP.n*this.d},compare:function(e,t){DP(e,t);var n=this.s*this.n*TP.d-TP.s*TP.n*this.d;return(0<n)-(n<0)},simplify:function(e){if(isNaN(this.n)||isNaN(this.d))return this;e=e||.001;for(var t=this.abs(),n=t.toContinued(),r=1;r<n.length;r++){for(var i=_P(n[r-1],1),o=r-2;o>=0;o--)i=i.inverse().add(n[o]);if(Math.abs(i.sub(t).valueOf())<e)return i.mul(this.s)}return this},divisible:function(e,t){return DP(e,t),!(!(TP.n*this.d)||this.n*TP.d%(TP.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(e){var t,n="",r=this.n,i=this.d;return this.s<0&&(n+="-"),1===i?n+=r:(e&&(t=Math.floor(r/i))>0&&(n+=t,n+=" ",r%=i),n+=r,n+="/",n+=i),n},toLatex:function(e){var t,n="",r=this.n,i=this.d;return this.s<0&&(n+="-"),1===i?n+=r:(e&&(t=Math.floor(r/i))>0&&(n+=t,r%=i),n+="\\frac{",n+=r,n+="}{",n+=i,n+="}"),n},toContinued:function(){var e,t=this.n,n=this.d,r=[];if(isNaN(t)||isNaN(n))return r;do{r.push(Math.floor(t/n)),e=t%n,t=n,n=e}while(1!==t);return r},toString:function(e){var t=this.n,n=this.d;if(isNaN(t)||isNaN(n))return"NaN";e=e||15;var r=function(e,t){for(;t%2==0;t/=2);for(;t%5==0;t/=5);if(1===t)return 0;for(var n=10%t,r=1;1!==n;r++)if(n=10*n%t,r>2e3)return 0;return r}(0,n),i=function(e,t,n){for(var r=1,i=function(e,t,n){for(var r=1;t>0;e=e*e%n,t>>=1)1&t&&(r=r*e%n);return r}(10,n,t),o=0;o<300;o++){if(r===i)return o;r=10*r%t,i=10*i%t}return 0}(0,n,r),o=this.s<0?"-":"";if(o+=t/n|0,t%=n,(t*=10)&&(o+="."),r){for(var s=i;s--;)o+=t/n|0,t%=n,t*=10;o+="(";for(s=r;s--;)o+=t/n|0,t%=n,t*=10;o+=")"}else for(s=e;t&&s--;)o+=t/n|0,t%=n,t*=10;return o}};var jP=kB("Fraction",[],function(){return LP.prototype.type="Fraction",LP.prototype.isFraction=!0,LP.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},LP.fromJSON=function(e){return new LP(e)},LP},{isClass:!0}),FP=kB("Range",[],function(){function e(t,n,r){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");var i=null!=t,o=null!=n,s=null!=r;if(i)if(UI(t))t=t.toNumber();else if("number"!=typeof t)throw new TypeError("Parameter start must be a number");if(o)if(UI(n))n=n.toNumber();else if("number"!=typeof n)throw new TypeError("Parameter end must be a number");if(s)if(UI(r))r=r.toNumber();else if("number"!=typeof r)throw new TypeError("Parameter step must be a number");this.start=i?parseFloat(t):0,this.end=o?parseFloat(n):0,this.step=s?parseFloat(r):1}return e.prototype.type="Range",e.prototype.isRange=!0,e.parse=function(t){if("string"!=typeof t)return null;var n=t.split(":").map(function(e){return parseFloat(e)});if(n.some(function(e){return isNaN(e)}))return null;switch(n.length){case 2:return new e(n[0],n[1]);case 3:return new e(n[0],n[2],n[1]);default:return null}},e.prototype.clone=function(){return new e(this.start,this.end,this.step)},e.prototype.size=function(){var e=0,t=this.start,n=this.step,r=this.end-t;return zL(n)===zL(r)?e=Math.ceil(r/n):0===r&&(e=0),isNaN(e)&&(e=0),[e]},e.prototype.min=function(){var e=this.size()[0];return e>0?this.step>0?this.start:this.start+(e-1)*this.step:void 0},e.prototype.max=function(){var e=this.size()[0];return e>0?this.step>0?this.start+(e-1)*this.step:this.start:void 0},e.prototype.forEach=function(e){var t=this.start,n=this.step,r=this.end,i=0;if(n>0)for(;t<r;)e(t,[i],this),t+=n,i++;else if(n<0)for(;t>r;)e(t,[i],this),t+=n,i++},e.prototype.map=function(e){var t=[];return this.forEach(function(n,r,i){t[r[0]]=e(n,r,i)}),t},e.prototype.toArray=function(){var e=[];return this.forEach(function(t,n){e[n[0]]=t}),e},e.prototype.valueOf=function(){return this.toArray()},e.prototype.format=function(e){var t=UL(this.start,e);return 1!==this.step&&(t+=":"+UL(this.step,e)),t+=":"+UL(this.end,e)},e.prototype.toString=function(){return this.format()},e.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},e.fromJSON=function(t){return new e(t.start,t.end,t.step)},e},{isClass:!0}),$P=kB("Matrix",[],function(){function e(){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator")}return e.prototype.type="Matrix",e.prototype.isMatrix=!0,e.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},e.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},e.prototype.create=function(e,t){throw new Error("Cannot invoke create on a Matrix interface")},e.prototype.subset=function(e,t,n){throw new Error("Cannot invoke subset on a Matrix interface")},e.prototype.get=function(e){throw new Error("Cannot invoke get on a Matrix interface")},e.prototype.set=function(e,t,n){throw new Error("Cannot invoke set on a Matrix interface")},e.prototype.resize=function(e,t){throw new Error("Cannot invoke resize on a Matrix interface")},e.prototype.reshape=function(e,t){throw new Error("Cannot invoke reshape on a Matrix interface")},e.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},e.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},e.prototype.map=function(e,t){throw new Error("Cannot invoke map on a Matrix interface")},e.prototype.forEach=function(e){throw new Error("Cannot invoke forEach on a Matrix interface")},e.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},e.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},e.prototype.format=function(e){throw new Error("Cannot invoke format on a Matrix interface")},e.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},e},{isClass:!0}),HP=kB("DenseMatrix",["Matrix"],function(e){var t=e.Matrix;function n(e,t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!KI(t))throw new Error("Invalid datatype: "+t);if(JI(e))"DenseMatrix"===e.type?(this._data=kL(e._data),this._size=kL(e._size),this._datatype=t||e._datatype):(this._data=e.toArray(),this._size=e.size(),this._datatype=t||e._datatype);else if(e&&GI(e.data)&&GI(e.size))this._data=e.data,this._size=e.size,fB(this._data,this._size),this._datatype=t||e.datatype;else if(GI(e))this._data=a(e),this._size=pB(this._data),fB(this._data,this._size),this._datatype=t;else{if(e)throw new TypeError("Unsupported type of data ("+NL(e)+")");this._data=[],this._size=[0],this._datatype=t}}function r(e,t,n,i){var o=i===n-1,s=t.dimension(i);return o?s.map(function(t){return mB(t,e.length),e[t]}).valueOf():s.map(function(o){return mB(o,e.length),r(e[o],t,n,i+1)}).valueOf()}function i(e,t,n,r,o){var s=o===r-1,a=t.dimension(o);s?a.forEach(function(t,r){mB(t),e[t]=n[r[0]]}):a.forEach(function(s,a){mB(s),i(e[s],t,n[a[0]],r,o+1)})}function o(e,t,n){if(0===t.length){for(var r=e._data;GI(r);)r=r[0];return r}return e._size=t.slice(0),e._data=gB(e._data,e._size,n),e}function s(e,t,n){for(var r=e._size.slice(0),i=!1;r.length<t.length;)r.push(0),i=!0;for(var s=0,a=t.length;s<a;s++)t[s]>r[s]&&(r[s]=t[s],i=!0);i&&o(e,r,n)}function a(e){for(var t=0,n=e.length;t<n;t++){var r=e[t];GI(r)?e[t]=a(r):r&&!0===r.isMatrix&&(e[t]=a(r.valueOf()))}return e}return n.prototype=new t,n.prototype.createDenseMatrix=function(e,t){return new n(e,t)},n.prototype.type="DenseMatrix",n.prototype.isDenseMatrix=!0,n.prototype.getDataType=function(){return AB(this._data,NL)},n.prototype.storage=function(){return"dense"},n.prototype.datatype=function(){return this._datatype},n.prototype.create=function(e,t){return new n(e,t)},n.prototype.subset=function(e,t,o){switch(arguments.length){case 1:return function(e,t){if(!eL(t))throw new TypeError("Invalid index");var i=t.isScalar();if(i)return e.get(t.min());var o=t.size();if(o.length!==e._size.length)throw new uB(o.length,e._size.length);for(var s=t.min(),a=t.max(),l=0,c=e._size.length;l<c;l++)mB(s[l],e._size[l]),mB(a[l],e._size[l]);return new n(r(e._data,t,o.length,0),e._datatype)}(this,e);case 2:case 3:return function(e,t,n,r){if(!t||!0!==t.isIndex)throw new TypeError("Invalid index");var o,a=t.size(),l=t.isScalar();JI(n)?(o=n.size(),n=n.valueOf()):o=pB(n);if(l){if(0!==o.length)throw new TypeError("Scalar expected");e.set(t.min(),n,r)}else{if(a.length<e._size.length)throw new uB(a.length,e._size.length,"<");if(o.length<a.length){for(var c=0,u=0;1===a[c]&&1===o[c];)c++;for(;1===a[c];)u++,c++;n=xB(n,a.length,u,o)}if(!OL(a,o))throw new uB(a,o,">");var d=t.max().map(function(e){return e+1});s(e,d,r);var p=a.length,h=0;i(e._data,t,n,p,h)}return e}(this,e,t,o);default:throw new SyntaxError("Wrong number of arguments")}},n.prototype.get=function(e){if(!GI(e))throw new TypeError("Array expected");if(e.length!==this._size.length)throw new uB(e.length,this._size.length);for(var t=0;t<e.length;t++)mB(e[t],this._size[t]);for(var n=this._data,r=0,i=e.length;r<i;r++){var o=e[r];mB(o,n.length),n=n[o]}return n},n.prototype.set=function(e,t,n){if(!GI(e))throw new TypeError("Array expected");if(e.length<this._size.length)throw new uB(e.length,this._size.length,"<");var r,i,o,a=e.map(function(e){return e+1});s(this,a,n);var l=this._data;for(r=0,i=e.length-1;r<i;r++)mB(o=e[r],l.length),l=l[o];return mB(o=e[e.length-1],l.length),l[o]=t,this},n.prototype.resize=function(e,t,n){if(!YI(e))throw new TypeError("Array or Matrix expected");var r=e.valueOf().map(function(e){return Array.isArray(e)&&1===e.length?e[0]:e});return o(n?this.clone():this,r,t)},n.prototype.reshape=function(e,t){var n=t?this.clone():this;return n._data=vB(n._data,e),n._size=e.slice(0),n},n.prototype.clone=function(){return new n({data:kL(this._data),size:kL(this._size),datatype:this._datatype})},n.prototype.size=function(){return this._size.slice(0)},n.prototype.map=function(e){var t=this,r=function n(r,i){return GI(r)?r.map(function(e,t){return n(e,i.concat(t))}):e(r,i,t)}(this._data,[]);return new n(r,void 0!==this._datatype?AB(r,NL):void 0)},n.prototype.forEach=function(e){var t=this;!function n(r,i){GI(r)?r.forEach(function(e,t){n(e,i.concat(t))}):e(r,i,t)}(this._data,[])},n.prototype.toArray=function(){return kL(this._data)},n.prototype.valueOf=function(){return this._data},n.prototype.format=function(e){return aB(this._data,e)},n.prototype.toString=function(){return aB(this._data)},n.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},n.prototype.diagonal=function(e){if(e){if(UI(e)&&(e=e.toNumber()),!HI(e)||!BL(e))throw new TypeError("The parameter k must be an integer number")}else e=0;for(var t=e>0?e:0,r=e<0?-e:0,i=this._size[0],o=this._size[1],s=Math.min(i-r,o-t),a=[],l=0;l<s;l++)a[l]=this._data[l+r][l+t];return new n({data:a,size:[s],datatype:this._datatype})},n.diagonal=function(e,t,r,i){if(!GI(e))throw new TypeError("Array expected, size parameter");if(2!==e.length)throw new Error("Only two dimensions matrix are supported");if(e=e.map(function(e){if(UI(e)&&(e=e.toNumber()),!HI(e)||!BL(e)||e<1)throw new Error("Size values must be positive integers");return e}),r){if(UI(r)&&(r=r.toNumber()),!HI(r)||!BL(r))throw new TypeError("The parameter k must be an integer number")}else r=0;var o,s=r>0?r:0,a=r<0?-r:0,l=e[0],c=e[1],u=Math.min(l-a,c-s);if(GI(t)){if(t.length!==u)throw new Error("Invalid value array length");o=function(e){return t[e]}}else if(JI(t)){var d=t.size();if(1!==d.length||d[0]!==u)throw new Error("Invalid matrix length");o=function(e){return t.get([e])}}else o=function(){return t};i||(i=UI(o(0))?o(0).mul(0):0);var p=[];if(e.length>0){p=gB(p,e,i);for(var h=0;h<u;h++)p[h+a][h+s]=o(h)}return new n({data:p,size:[l,c]})},n.fromJSON=function(e){return new n(e)},n.prototype.swapRows=function(e,t){if(!(HI(e)&&BL(e)&&HI(t)&&BL(t)))throw new Error("Row index must be positive integers");if(2!==this._size.length)throw new Error("Only two dimensional matrix is supported");return mB(e,this._size[0]),mB(t,this._size[0]),n._swapRows(e,t,this._data),this},n._swapRows=function(e,t,n){var r=n[e];n[e]=n[t],n[t]=r},n},{isClass:!0}),UP="clone",qP=kB(UP,["typed"],function(e){return(0,e.typed)(UP,{any:kL})});function VP(e){for(var t=0;t<e.length;t++)if(YI(e[t]))return!0;return!1}function WP(e,t){JI(e)&&(e=e.valueOf());for(var n=0,r=e.length;n<r;n++){var i=e[n];Array.isArray(i)?WP(i,t):t(i)}}function KP(e,t,n){return e&&"function"==typeof e.map?e.map(function(e){return KP(e,t)}):t(e)}function GP(e,t,n){var r=Array.isArray(e)?pB(e):e.size();if(t<0||t>=r.length)throw new dB(t,r.length);return JI(e)?e.create(JP(e.valueOf(),t,n)):JP(e,t,n)}function JP(e,t,n){var r,i,o,s;if(t<=0){if(Array.isArray(e[0])){for(s=function(e){var t,n,r=e.length,i=e[0].length,o=[];for(n=0;n<i;n++){var s=[];for(t=0;t<r;t++)s.push(e[t][n]);o.push(s)}return o}(e),i=[],r=0;r<s.length;r++)i[r]=JP(s[r],t-1,n);return i}for(o=e[0],r=1;r<e.length;r++)o=n(o,e[r]);return o}for(i=[],r=0;r<e.length;r++)i[r]=JP(e[r],t-1,n);return i}function YP(e,t,n,r,i,o,s,a,l,c,u){var d,p,h,f,m=e._values,g=e._index,y=e._ptr;if(r)for(p=y[t],h=y[t+1],d=p;d<h;d++)n[f=g[d]]!==o?(n[f]=o,s.push(f),c?(r[f]=l?a(m[d],u):a(u,m[d]),i[f]=o):r[f]=m[d]):(r[f]=l?a(m[d],r[f]):a(r[f],m[d]),i[f]=o);else for(p=y[t],h=y[t+1],d=p;d<h;d++)n[f=g[d]]!==o?(n[f]=o,s.push(f)):i[f]=o}var ZP="isInteger",XP=kB(ZP,["typed"],function(e){return(0,e.typed)(ZP,{number:BL,BigNumber:function(e){return e.isInt()},Fraction:function(e){return 1===e.d&&isFinite(e.n)},"Array | Matrix":function(e){return KP(e,this)}})}),QP="number",ej="number, number";function tj(e){return Math.abs(e)}function nj(e,t){return e+t}function rj(e,t){return e*t}function ij(e){return-e}function oj(e){return e}function sj(e){return $L(e)}function aj(e){return Math.ceil(e)}function lj(e){return e*e*e}function cj(e){return Math.exp(e)}function uj(e){return HL(e)}function dj(e,t){if(!BL(e)||!BL(t))throw new Error("Parameters in function gcd must be integer numbers");for(var n;0!==t;)n=e%t,e=t,t=n;return e<0?-e:e}function pj(e,t){if(!BL(e)||!BL(t))throw new Error("Parameters in function lcm must be integer numbers");if(0===e||0===t)return 0;for(var n,r=e*t;0!==t;)t=e%(n=t),e=n;return Math.abs(r/e)}function hj(e){return Math.log(e)}function fj(e){return jL(e)}function mj(e){return PL(e)}function gj(e,t){if(t>0)return e-t*Math.floor(e/t);if(0===t)return e;throw new Error("Cannot calculate mod for a negative divisor")}function yj(e,t){var n=t<0;if(n&&(t=-t),0===t)throw new Error("Root must be non-zero");if(e<0&&Math.abs(t)%2!=1)throw new Error("Root must be odd when a is negative.");if(0===e)return n?1/0:0;if(!isFinite(e))return n?0:e;var r=Math.pow(Math.abs(e),1/t);return r=e<0?-r:r,n?1/r:r}function vj(e){return zL(e)}function bj(e){return e*e}function wj(e,t){var n,r,i,o=0,s=1,a=1,l=0;if(!BL(e)||!BL(t))throw new Error("Parameters in function xgcd must be integer numbers");for(;t;)i=e-(r=Math.floor(e/t))*t,n=o,o=s-r*o,s=n,n=a,a=l-r*a,l=n,e=t,t=i;return e<0?[-e,-s,-l]:[e,e?s:0,l]}function xj(e,t){return e*e<1&&t===1/0||e*e>1&&t===-1/0?0:Math.pow(e,t)}function Mj(e){return parseFloat(VL(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0))}tj.signature=QP,nj.signature=ej,rj.signature=ej,ij.signature=QP,oj.signature=QP,sj.signature=QP,aj.signature=QP,lj.signature=QP,cj.signature=QP,uj.signature=QP,dj.signature=ej,pj.signature=ej,hj.signature=QP,fj.signature=QP,mj.signature=QP,gj.signature=ej,yj.signature=ej,vj.signature=QP,bj.signature=QP,wj.signature=ej,xj.signature=ej,Mj.signature=ej;var Sj="number, number";function Ej(e,t){if(!BL(e)||!BL(t))throw new Error("Integers expected in function bitAnd");return e&t}function Cj(e){if(!BL(e))throw new Error("Integer expected in function bitNot");return~e}function Nj(e,t){if(!BL(e)||!BL(t))throw new Error("Integers expected in function bitOr");return e|t}function Aj(e,t){if(!BL(e)||!BL(t))throw new Error("Integers expected in function bitXor");return e^t}function kj(e,t){if(!BL(e)||!BL(t))throw new Error("Integers expected in function leftShift");return e<<t}function Tj(e,t){if(!BL(e)||!BL(t))throw new Error("Integers expected in function rightArithShift");return e>>t}function Oj(e,t){if(!BL(e)||!BL(t))throw new Error("Integers expected in function rightLogShift");return e>>>t}function _j(e,t){if(t<e)return 1;if(t===e)return t;var n=t+e>>1;return _j(e,n)*_j(n+1,t)}function Rj(e,t){if(!BL(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(!BL(t)||t<0)throw new TypeError("Positive integer value expected in function combinations");if(t>e)throw new TypeError("k must be less than or equal to n");var n=e-t;return t<n?_j(n+1,e)/_j(1,t):_j(t+1,e)/_j(1,n)}Ej.signature=Sj,Cj.signature="number",Nj.signature=Sj,Aj.signature=Sj,kj.signature=Sj,Tj.signature=Sj,Oj.signature=Sj,Rj.signature="number, number";var Dj=Math.PI,Ij=2*Math.PI,Lj=Math.E,Bj="number, number";function zj(e){return!e}function Pj(e,t){return!(!e&&!t)}function jj(e,t){return!!e!=!!t}function Fj(e,t){return!(!e||!t)}function $j(e){var t;if(BL(e))return e<=0?isFinite(e)?1/0:NaN:e>171?1/0:_j(1,e-1);if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*$j(1-e));if(e>=171.35)return 1/0;if(e>85){var n=e*e,r=n*e,i=r*e,o=i*e;return Math.sqrt(2*Math.PI/e)*Math.pow(e/Math.E,e)*(1+1/(12*e)+1/(288*n)-139/(51840*r)-571/(2488320*i)+163879/(209018880*o)+5246819/(75246796800*o*e))}--e,t=Uj[0];for(var s=1;s<Uj.length;++s)t+=Uj[s]/(e+s);var a=e+Hj+.5;return Math.sqrt(2*Math.PI)*Math.pow(a,e+.5)*Math.exp(-a)*t}zj.signature="number",Pj.signature=Bj,jj.signature=Bj,Fj.signature=Bj,$j.signature="number";var Hj=4.7421875,Uj=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],qj="number";function Vj(e){return ZL(e)}function Wj(e){return Math.atan(1/e)}function Kj(e){return isFinite(e)?(Math.log((e+1)/e)+Math.log(e/(e-1)))/2:0}function Gj(e){return Math.asin(1/e)}function Jj(e){var t=1/e;return Math.log(t+Math.sqrt(t*t+1))}function Yj(e){return Math.acos(1/e)}function Zj(e){var t=1/e,n=Math.sqrt(t*t-1);return Math.log(n+t)}function Xj(e){return XL(e)}function Qj(e){return QL(e)}function eF(e){return 1/Math.tan(e)}function tF(e){var t=Math.exp(2*e);return(t+1)/(t-1)}function nF(e){return 1/Math.sin(e)}function rF(e){return 0===e?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*zL(e)}function iF(e){return 1/Math.cos(e)}function oF(e){return 2/(Math.exp(e)+Math.exp(-e))}function sF(e){return tB(e)}Vj.signature=qj,Wj.signature=qj,Kj.signature=qj,Gj.signature=qj,Jj.signature=qj,Yj.signature=qj,Zj.signature=qj,Xj.signature=qj,Qj.signature=qj,eF.signature=qj,tF.signature=qj,nF.signature=qj,rF.signature=qj,iF.signature=qj,oF.signature=qj,sF.signature=qj;var aF="number";function lF(e){return e<0}function cF(e){return e>0}function uF(e){return 0===e}function dF(e){return Number.isNaN(e)}lF.signature=aF,cF.signature=aF,uF.signature=aF,dF.signature=aF;var pF="isNegative",hF=kB(pF,["typed"],function(e){return(0,e.typed)(pF,{number:lF,BigNumber:function(e){return e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return e.s<0},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return KP(e,this)}})}),fF="isNumeric",mF=kB(fF,["typed"],function(e){return(0,e.typed)(fF,{"number | BigNumber | Fraction | boolean":function(){return!0},"Complex | Unit | string | null | undefined | Node":function(){return!1},"Array | Matrix":function(e){return KP(e,this)}})}),gF="hasNumericValue",yF=kB(gF,["typed","isNumeric"],function(e){var t=e.typed,n=e.isNumeric;return t(gF,{string:function(e){return e.trim().length>0&&!isNaN(Number(e))},any:function(e){return n(e)}})}),vF="isPositive",bF=kB(vF,["typed"],function(e){return(0,e.typed)(vF,{number:cF,BigNumber:function(e){return!e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return e.s>0&&e.n>0},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return KP(e,this)}})}),wF="isZero",xF=kB(wF,["typed"],function(e){return(0,e.typed)(wF,{number:uF,BigNumber:function(e){return e.isZero()},Complex:function(e){return 0===e.re&&0===e.im},Fraction:function(e){return 1===e.d&&0===e.n},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return KP(e,this)}})}),MF="isNaN",SF=kB(MF,["typed"],function(e){return(0,e.typed)(MF,{number:dF,BigNumber:function(e){return e.isNaN()},Fraction:function(e){return!1},Complex:function(e){return e.isNaN()},Unit:function(e){return Number.isNaN(e.value)},"Array | Matrix":function(e){return KP(e,Number.isNaN)}})}),EF="typeOf",CF=kB(EF,["typed"],function(e){return(0,e.typed)(EF,{any:NL})});function NF(e,t,n){if(null==n)return e.eq(t);if(e.eq(t))return!0;if(e.isNaN()||t.isNaN())return!1;if(e.isFinite()&&t.isFinite()){var r=e.minus(t).abs();if(r.isZero())return!0;var i=e.constructor.max(e.abs(),t.abs());return r.lte(i.times(n))}return!1}var AF="equalScalar",kF=kB(AF,["typed","config"],function(e){var t=e.typed,n=e.config;return t(AF,{"boolean, boolean":function(e,t){return e===t},"number, number":function(e,t){return YL(e,t,n.epsilon)},"BigNumber, BigNumber":function(e,t){return e.eq(t)||NF(e,t,n.epsilon)},"Fraction, Fraction":function(e,t){return e.equals(t)},"Complex, Complex":function(e,t){return function(e,t,n){return YL(e.re,t.re,n)&&YL(e.im,t.im,n)}(e,t,n.epsilon)},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)}})});kB(AF,["typed","config"],function(e){var t=e.typed,n=e.config;return t(AF,{"number, number":function(e,t){return YL(e,t,n.epsilon)}})});var TF=kB("SparseMatrix",["typed","equalScalar","Matrix"],function(e){var t=e.typed,n=e.equalScalar,r=e.Matrix;function i(e,t){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!KI(t))throw new Error("Invalid datatype: "+t);if(JI(e))!function(e,t,n){"SparseMatrix"===t.type?(e._values=t._values?kL(t._values):void 0,e._index=kL(t._index),e._ptr=kL(t._ptr),e._size=kL(t._size),e._datatype=n||t._datatype):o(e,t.valueOf(),n||t._datatype)}(this,e,t);else if(e&&GI(e.index)&&GI(e.ptr)&&GI(e.size))this._values=e.values,this._index=e.index,this._ptr=e.ptr,this._size=e.size,this._datatype=t||e.datatype;else if(GI(e))o(this,e,t);else{if(e)throw new TypeError("Unsupported type of data ("+NL(e)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=t}}function o(e,r,i){e._values=[],e._index=[],e._ptr=[],e._datatype=i;var o=r.length,s=0,a=n,l=0;if(KI(i)&&(a=t.find(n,[i,i])||n,l=t.convert(0,i)),o>0){var c=0;do{e._ptr.push(e._index.length);for(var u=0;u<o;u++){var d=r[u];if(GI(d)){if(0===c&&s<d.length&&(s=d.length),c<d.length){var p=d[c];a(p,l)||(e._values.push(p),e._index.push(u))}}else 0===c&&s<1&&(s=1),a(d,l)||(e._values.push(d),e._index.push(u))}c++}while(c<s)}e._ptr.push(e._index.length),e._size=[o,s]}function s(e,t,n,r){if(n-t===0)return n;for(var i=t;i<n;i++)if(r[i]===e)return i;return t}function a(e,t,n,r,i,o,s){i.splice(e,0,r),o.splice(e,0,t);for(var a=n+1;a<s.length;a++)s[a]++}function l(e,r,i,o){var s=o||0,a=n,l=0;KI(e._datatype)&&(a=t.find(n,[e._datatype,e._datatype])||n,l=t.convert(0,e._datatype),s=t.convert(s,e._datatype));var c,u,d,p=!a(s,l),h=e._size[0],f=e._size[1];if(i>f){for(u=f;u<i;u++)if(e._ptr[u]=e._values.length,p)for(c=0;c<h;c++)e._values.push(s),e._index.push(c);e._ptr[i]=e._values.length}else i<f&&(e._ptr.splice(i+1,f-i),e._values.splice(e._ptr[i],e._values.length),e._index.splice(e._ptr[i],e._index.length));if(f=i,r>h){if(p){var m=0;for(u=0;u<f;u++){e._ptr[u]=e._ptr[u]+m,d=e._ptr[u+1]+m;var g=0;for(c=h;c<r;c++,g++)e._values.splice(d+g,0,s),e._index.splice(d+g,0,c),m++}e._ptr[f]=e._values.length}}else if(r<h){var y=0;for(u=0;u<f;u++){e._ptr[u]=e._ptr[u]-y;var v=e._ptr[u],b=e._ptr[u+1]-y;for(d=v;d<b;d++)(c=e._index[d])>r-1&&(e._values.splice(d,1),e._index.splice(d,1),y++)}e._ptr[u]=e._values.length}return e._size[0]=r,e._size[1]=i,e}function c(e,t,n,r,i){var o,s,a=r[0],l=r[1],c=[];for(o=0;o<a;o++)for(c[o]=[],s=0;s<l;s++)c[o][s]=0;for(s=0;s<l;s++)for(var u=n[s],d=n[s+1],p=u;p<d;p++)c[o=t[p]][s]=e?i?kL(e[p]):e[p]:1;return c}return i.prototype=new r,i.prototype.createSparseMatrix=function(e,t){return new i(e,t)},i.prototype.type="SparseMatrix",i.prototype.isSparseMatrix=!0,i.prototype.getDataType=function(){return AB(this._values,NL)},i.prototype.storage=function(){return"sparse"},i.prototype.datatype=function(){return this._datatype},i.prototype.create=function(e,t){return new i(e,t)},i.prototype.density=function(){var e=this._size[0],t=this._size[1];return 0!==e&&0!==t?this._index.length/(e*t):0},i.prototype.subset=function(e,t,n){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return function(e,t){if(!eL(t))throw new TypeError("Invalid index");if(t.isScalar())return e.get(t.min());var n,r,o,s,a=t.size();if(a.length!==e._size.length)throw new uB(a.length,e._size.length);var l=t.min(),c=t.max();for(n=0,r=e._size.length;n<r;n++)mB(l[n],e._size[n]),mB(c[n],e._size[n]);var u=e._values,d=e._index,p=e._ptr,h=t.dimension(0),f=t.dimension(1),m=[],g=[];h.forEach(function(e,t){g[e]=t[0],m[e]=!0});var y=u?[]:void 0,v=[],b=[];return f.forEach(function(e){for(b.push(v.length),o=p[e],s=p[e+1];o<s;o++)n=d[o],!0===m[n]&&(v.push(g[n]),y&&y.push(u[o]))}),b.push(v.length),new i({values:y,index:v,ptr:b,size:a,datatype:e._datatype})}(this,e);case 2:case 3:return function(e,t,n,r){if(!t||!0!==t.isIndex)throw new TypeError("Invalid index");var i,o=t.size(),s=t.isScalar();JI(n)?(i=n.size(),n=n.toArray()):i=pB(n);if(s){if(0!==i.length)throw new TypeError("Scalar expected");e.set(t.min(),n,r)}else{if(1!==o.length&&2!==o.length)throw new uB(o.length,e._size.length,"<");if(i.length<o.length){for(var a=0,l=0;1===o[a]&&1===i[a];)a++;for(;1===o[a];)l++,a++;n=xB(n,o.length,l,i)}if(!OL(o,i))throw new uB(o,i,">");for(var c=t.min()[0],u=t.min()[1],d=i[0],p=i[1],h=0;h<d;h++)for(var f=0;f<p;f++){var m=n[h][f];e.set([h+c,f+u],m,r)}}return e}(this,e,t,n);default:throw new SyntaxError("Wrong number of arguments")}},i.prototype.get=function(e){if(!GI(e))throw new TypeError("Array expected");if(e.length!==this._size.length)throw new uB(e.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var t=e[0],n=e[1];mB(t,this._size[0]),mB(n,this._size[1]);var r=s(t,this._ptr[n],this._ptr[n+1],this._index);return r<this._ptr[n+1]&&this._index[r]===t?this._values[r]:0},i.prototype.set=function(e,r,i){if(!GI(e))throw new TypeError("Array expected");if(e.length!==this._size.length)throw new uB(e.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var o=e[0],c=e[1],u=this._size[0],d=this._size[1],p=n,h=0;KI(this._datatype)&&(p=t.find(n,[this._datatype,this._datatype])||n,h=t.convert(0,this._datatype)),(o>u-1||c>d-1)&&(l(this,Math.max(o+1,u),Math.max(c+1,d),i),u=this._size[0],d=this._size[1]),mB(o,u),mB(c,d);var f=s(o,this._ptr[c],this._ptr[c+1],this._index);return f<this._ptr[c+1]&&this._index[f]===o?p(r,h)?function(e,t,n,r,i){n.splice(e,1),r.splice(e,1);for(var o=t+1;o<i.length;o++)i[o]--}(f,c,this._values,this._index,this._ptr):this._values[f]=r:a(f,o,c,r,this._values,this._index,this._ptr),this},i.prototype.resize=function(e,t,n){if(!YI(e))throw new TypeError("Array or Matrix expected");var r=e.valueOf().map(function(e){return Array.isArray(e)&&1===e.length?e[0]:e});if(2!==r.length)throw new Error("Only two dimensions matrix are supported");return r.forEach(function(e){if(!HI(e)||!BL(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+aB(r)+")")}),l(n?this.clone():this,r[0],r[1],t)},i.prototype.reshape=function(e,t){if(!GI(e))throw new TypeError("Array expected");if(2!==e.length)throw new Error("Sparse matrices can only be reshaped in two dimensions");if(e.forEach(function(t){if(!HI(t)||!BL(t)||t<0)throw new TypeError("Invalid size, must contain positive integers (size: "+aB(e)+")")}),this._size[0]*this._size[1]!==e[0]*e[1])throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var n=t?this.clone():this;if(this._size[0]===e[0]&&this._size[1]===e[1])return n;for(var r=[],i=0;i<n._ptr.length;i++)for(var o=0;o<n._ptr[i+1]-n._ptr[i];o++)r.push(i);for(var l=n._values.slice(),c=n._index.slice(),u=0;u<n._index.length;u++){var d=c[u],p=r[u],h=d*n._size[1]+p;r[u]=h%e[1],c[u]=Math.floor(h/e[1])}n._values.length=0,n._index.length=0,n._ptr.length=e[1]+1,n._size=e.slice();for(var f=0;f<n._ptr.length;f++)n._ptr[f]=0;for(var m=0;m<l.length;m++){var g=c[m],y=r[m],v=l[m];a(s(g,n._ptr[y],n._ptr[y+1],n._index),g,y,v,n._values,n._index,n._ptr)}return n},i.prototype.clone=function(){return new i({values:this._values?kL(this._values):void 0,index:kL(this._index),ptr:kL(this._ptr),size:kL(this._size),datatype:this._datatype})},i.prototype.size=function(){return this._size.slice(0)},i.prototype.map=function(e,r){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var o=this;return function(e,r,o,s,a,l,c){var u=[],d=[],p=[],h=n,f=0;KI(e._datatype)&&(h=t.find(n,[e._datatype,e._datatype])||n,f=t.convert(0,e._datatype));for(var m=function(e,t,n){e=l(e,t,n),h(e,f)||(u.push(e),d.push(t))},g=s;g<=a;g++){p.push(u.length);var y=e._ptr[g],v=e._ptr[g+1];if(c)for(var b=y;b<v;b++){var w=e._index[b];w>=r&&w<=o&&m(e._values[b],w-r,g-s)}else{for(var x={},M=y;M<v;M++){x[e._index[M]]=e._values[M]}for(var S=r;S<=o;S++){m(S in x?x[S]:0,S-r,g-s)}}}return p.push(u.length),new i({values:u,index:d,ptr:p,size:[o-r+1,a-s+1]})}(this,0,this._size[0]-1,0,this._size[1]-1,function(t,n,r){return e(t,[n,r],o)},r)},i.prototype.forEach=function(e,t){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var n=this._size[0],r=this._size[1],i=0;i<r;i++){var o=this._ptr[i],s=this._ptr[i+1];if(t)for(var a=o;a<s;a++){var l=this._index[a];e(this._values[a],[l,i],this)}else{for(var c={},u=o;u<s;u++){c[this._index[u]]=this._values[u]}for(var d=0;d<n;d++){e(d in c?c[d]:0,[d,i],this)}}}},i.prototype.toArray=function(){return c(this._values,this._index,this._ptr,this._size,!0)},i.prototype.valueOf=function(){return c(this._values,this._index,this._ptr,this._size,!1)},i.prototype.format=function(e){for(var t=this._size[0],n=this._size[1],r=this.density(),i="Sparse Matrix ["+aB(t,e)+" x "+aB(n,e)+"] density: "+aB(r,e)+"\n",o=0;o<n;o++)for(var s=this._ptr[o],a=this._ptr[o+1],l=s;l<a;l++){i+="\n ("+aB(this._index[l],e)+", "+aB(o,e)+") ==> "+(this._values?aB(this._values[l],e):"X")}return i},i.prototype.toString=function(){return aB(this.toArray())},i.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},i.prototype.diagonal=function(e){if(e){if(UI(e)&&(e=e.toNumber()),!HI(e)||!BL(e))throw new TypeError("The parameter k must be an integer number")}else e=0;var t=e>0?e:0,n=e<0?-e:0,r=this._size[0],o=this._size[1],s=Math.min(r-n,o-t),a=[],l=[],c=[];c[0]=0;for(var u=t;u<o&&a.length<s;u++)for(var d=this._ptr[u],p=this._ptr[u+1],h=d;h<p;h++){var f=this._index[h];if(f===u-t+n){a.push(this._values[h]),l[a.length-1]=f-n;break}}return c.push(a.length),new i({values:a,index:l,ptr:c,size:[s,1]})},i.fromJSON=function(e){return new i(e)},i.diagonal=function(e,r,o,s,a){if(!GI(e))throw new TypeError("Array expected, size parameter");if(2!==e.length)throw new Error("Only two dimensions matrix are supported");if(e=e.map(function(e){if(UI(e)&&(e=e.toNumber()),!HI(e)||!BL(e)||e<1)throw new Error("Size values must be positive integers");return e}),o){if(UI(o)&&(o=o.toNumber()),!HI(o)||!BL(o))throw new TypeError("The parameter k must be an integer number")}else o=0;var l=n,c=0;KI(a)&&(l=t.find(n,[a,a])||n,c=t.convert(0,a));var u,d=o>0?o:0,p=o<0?-o:0,h=e[0],f=e[1],m=Math.min(h-p,f-d);if(GI(r)){if(r.length!==m)throw new Error("Invalid value array length");u=function(e){return r[e]}}else if(JI(r)){var g=r.size();if(1!==g.length||g[0]!==m)throw new Error("Invalid matrix length");u=function(e){return r.get([e])}}else u=function(){return r};for(var y=[],v=[],b=[],w=0;w<f;w++){b.push(y.length);var x=w-d;if(x>=0&&x<m){var M=u(x);l(M,c)||(v.push(x+p),y.push(M))}}return b.push(y.length),new i({values:y,index:v,ptr:b,size:[h,f]})},i.prototype.swapRows=function(e,t){if(!(HI(e)&&BL(e)&&HI(t)&&BL(t)))throw new Error("Row index must be positive integers");if(2!==this._size.length)throw new Error("Only two dimensional matrix is supported");return mB(e,this._size[0]),mB(t,this._size[0]),i._swapRows(e,t,this._size[1],this._values,this._index,this._ptr),this},i._forEachRow=function(e,t,n,r,i){for(var o=r[e],s=r[e+1],a=o;a<s;a++)i(n[a],t[a])},i._swapRows=function(e,t,n,r,i,o){for(var a=0;a<n;a++){var l=o[a],c=o[a+1],u=s(e,l,c,i),d=s(t,l,c,i);if(u<c&&d<c&&i[u]===e&&i[d]===t){if(r){var p=r[u];r[u]=r[d],r[d]=p}}else if(u<c&&i[u]===e&&(d>=c||i[d]!==t)){var h=r?r[u]:void 0;i.splice(d,0,t),r&&r.splice(d,0,h),i.splice(d<=u?u+1:u,1),r&&r.splice(d<=u?u+1:u,1)}else if(d<c&&i[d]===t&&(u>=c||i[u]!==e)){var f=r?r[d]:void 0;i.splice(u,0,e),r&&r.splice(u,0,f),i.splice(u<=d?d+1:d,1),r&&r.splice(u<=d?d+1:d,1)}}},i},{isClass:!0}),OF=kB("number",["typed"],function(e){var t=(0,e.typed)("number",{"":function(){return 0},number:function(e){return e},string:function(e){if("NaN"===e)return NaN;var t=Number(e);if(isNaN(t))throw new SyntaxError('String "'+e+'" is no valid number');if(["0b","0o","0x"].includes(e.substring(0,2))){if(t>Math.pow(2,32)-1)throw new SyntaxError('String "'.concat(e,'" is out of range'));2147483648&t&&(t=-1*~(t-1))}return t},BigNumber:function(e){return e.toNumber()},Fraction:function(e){return e.valueOf()},Unit:function(e){throw new Error("Second argument with valueless unit expected")},null:function(e){return 0},"Unit, string | Unit":function(e,t){return e.toNumber(t)},"Array | Matrix":function(e){return KP(e,this)}});return t.fromJSON=function(e){return parseFloat(e.value)},t}),_F="string",RF=kB(_F,["typed"],function(e){return(0,e.typed)(_F,{"":function(){return""},number:UL,null:function(e){return"null"},boolean:function(e){return e+""},string:function(e){return e},"Array | Matrix":function(e){return KP(e,this)},any:function(e){return String(e)}})}),DF="boolean",IF=kB(DF,["typed"],function(e){return(0,e.typed)(DF,{"":function(){return!1},boolean:function(e){return e},number:function(e){return!!e},null:function(e){return!1},BigNumber:function(e){return!e.isZero()},string:function(e){var t=e.toLowerCase();if("true"===t)return!0;if("false"===t)return!1;var n=Number(e);if(""!==e&&!isNaN(n))return!!n;throw new Error('Cannot convert "'+e+'" to a boolean')},"Array | Matrix":function(e){return KP(e,this)}})}),LF=kB("bignumber",["typed","BigNumber"],function(e){var t=e.typed,n=e.BigNumber;return t("bignumber",{"":function(){return new n(0)},number:function(e){return new n(e+"")},string:function(e){return new n(e)},BigNumber:function(e){return e},Fraction:function(e){return new n(e.n).div(e.d).times(e.s)},null:function(e){return new n(0)},"Array | Matrix":function(e){return KP(e,this)}})}),BF=kB("complex",["typed","Complex"],function(e){var t=e.typed,n=e.Complex;return t("complex",{"":function(){return n.ZERO},number:function(e){return new n(e,0)},"number, number":function(e,t){return new n(e,t)},"BigNumber, BigNumber":function(e,t){return new n(e.toNumber(),t.toNumber())},Fraction:function(e){return new n(e.valueOf(),0)},Complex:function(e){return e.clone()},string:function(e){return n(e)},null:function(e){return n(0)},Object:function(e){if("re"in e&&"im"in e)return new n(e.re,e.im);if("r"in e&&"phi"in e||"abs"in e&&"arg"in e)return new n(e);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":function(e){return KP(e,this)}})}),zF=kB("fraction",["typed","Fraction"],function(e){var t=e.typed,n=e.Fraction;return t("fraction",{number:function(e){if(!isFinite(e)||isNaN(e))throw new Error(e+" cannot be represented as a fraction");return new n(e)},string:function(e){return new n(e)},"number, number":function(e,t){return new n(e,t)},null:function(e){return new n(0)},BigNumber:function(e){return new n(e.toString())},Fraction:function(e){return e},Object:function(e){return new n(e)},"Array | Matrix":function(e){return KP(e,this)}})}),PF="matrix",jF=kB(PF,["typed","Matrix","DenseMatrix","SparseMatrix"],function(e){var t=e.typed;e.Matrix;var n=e.DenseMatrix,r=e.SparseMatrix;return t(PF,{"":function(){return i([])},string:function(e){return i([],e)},"string, string":function(e,t){return i([],e,t)},Array:function(e){return i(e)},Matrix:function(e){return i(e,e.storage())},"Array | Matrix, string":i,"Array | Matrix, string, string":i});function i(e,t,i){if("dense"===t||"default"===t||void 0===t)return new n(e,i);if("sparse"===t)return new r(e,i);throw new TypeError("Unknown matrix type "+JSON.stringify(t)+".")}}),FF="splitUnit",$F=kB(FF,["typed"],function(e){return(0,e.typed)(FF,{"Unit, Array":function(e,t){return e.splitUnit(t)}})}),HF="unaryMinus",UF=kB(HF,["typed"],function(e){return(0,e.typed)(HF,{number:ij,Complex:function(e){return e.neg()},BigNumber:function(e){return e.neg()},Fraction:function(e){return e.neg()},Unit:function(e){var t=e.clone();return t.value=this(e.value),t},"Array | Matrix":function(e){return KP(e,this)}})}),qF="unaryPlus",VF=kB(qF,["typed","config","BigNumber"],function(e){var t=e.typed,n=e.config,r=e.BigNumber;return t(qF,{number:oj,Complex:function(e){return e},BigNumber:function(e){return e},Fraction:function(e){return e},Unit:function(e){return e.clone()},"Array | Matrix":function(e){return KP(e,this)},"boolean | string":function(e){return"BigNumber"===n.number?new r(+e):+e}})}),WF=kB("abs",["typed"],function(e){return(0,e.typed)("abs",{number:tj,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},Fraction:function(e){return e.abs()},"Array | Matrix":function(e){return KP(e,this)},Unit:function(e){return e.abs()}})}),KF="apply",GF=kB(KF,["typed","isInteger"],function(e){var t=e.typed,n=e.isInteger;return t(KF,{"Array | Matrix, number | BigNumber, function":function(e,t,r){if(!n(t))throw new TypeError("Integer number expected for dimension");var i=Array.isArray(e)?pB(e):e.size();if(t<0||t>=i.length)throw new dB(t,i.length);return JI(e)?e.create(JF(e.valueOf(),t,r)):JF(e,t,r)}})});function JF(e,t,n){var r,i,o;if(t<=0){if(Array.isArray(e[0])){for(o=function(e){var t,n,r=e.length,i=e[0].length,o=[];for(n=0;n<i;n++){var s=[];for(t=0;t<r;t++)s.push(e[t][n]);o.push(s)}return o}(e),i=[],r=0;r<o.length;r++)i[r]=JF(o[r],t-1,n);return i}return n(e)}for(i=[],r=0;r<e.length;r++)i[r]=JF(e[r],t-1,n);return i}var YF="addScalar",ZF=kB(YF,["typed"],function(e){return(0,e.typed)(YF,{"number, number":nj,"Complex, Complex":function(e,t){return e.add(t)},"BigNumber, BigNumber":function(e,t){return e.plus(t)},"Fraction, Fraction":function(e,t){return e.add(t)},"Unit, Unit":function(e,t){if(null===e.value||void 0===e.value)throw new Error("Parameter x contains a unit with undefined value");if(null===t.value||void 0===t.value)throw new Error("Parameter y contains a unit with undefined value");if(!e.equalBase(t))throw new Error("Units do not match");var n=e.clone();return n.value=this(n.value,t.value),n.fixPrefix=!1,n}})}),XF="cbrt",QF=kB(XF,["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],function(e){var t=e.config,n=e.typed,r=e.isNegative,i=e.unaryMinus,o=e.matrix,s=e.Complex,a=e.BigNumber,l=e.Fraction;return n(XF,{number:sj,Complex:c,"Complex, boolean":c,BigNumber:function(e){return e.cbrt()},Unit:function(e){if(e.value&&qI(e.value)){var t=e.clone();return t.value=1,(t=t.pow(1/3)).value=c(e.value),t}var n,o=r(e.value);o&&(e.value=i(e.value)),n=UI(e.value)?new a(1).div(3):VI(e.value)?new l(1,3):1/3;var s=e.pow(n);return o&&(s.value=i(s.value)),s},"Array | Matrix":function(e){return KP(e,this)}});function c(e,n){var r=e.arg()/3,i=e.abs(),a=new s(sj(i),0).mul(new s(0,r).exp());if(n){var l=[a,new s(sj(i),0).mul(new s(0,r+2*Math.PI/3).exp()),new s(sj(i),0).mul(new s(0,r-2*Math.PI/3).exp())];return"Array"===t.matrix?l:o(l)}return a}}),e$=kB("algorithm11",["typed","equalScalar"],function(e){var t=e.typed,n=e.equalScalar;return function(e,r,i,o){var s=e._values,a=e._index,l=e._ptr,c=e._size,u=e._datatype;if(!s)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var d,p=c[0],h=c[1],f=n,m=0,g=i;"string"==typeof u&&(d=u,f=t.find(n,[d,d]),m=t.convert(0,d),r=t.convert(r,d),g=t.find(i,[d,d]));for(var y=[],v=[],b=[],w=0;w<h;w++){b[w]=v.length;for(var x=l[w],M=l[w+1],S=x;S<M;S++){var E=a[S],C=o?g(r,s[S]):g(s[S],r);f(C,m)||(v.push(E),y.push(C))}}return b[h]=v.length,e.createSparseMatrix({values:y,index:v,ptr:b,size:[p,h],datatype:d})}}),t$=kB("algorithm14",["typed"],function(e){var t=e.typed;return function(e,r,i,o){var s,a=e._data,l=e._size,c=e._datatype,u=i;"string"==typeof c&&(s=c,r=t.convert(r,s),u=t.find(i,[s,s]));var d=l.length>0?n(u,0,l,l[0],a,r,o):[];return e.createDenseMatrix({data:d,size:kL(l),datatype:s})};function n(e,t,r,i,o,s,a){var l=[];if(t===r.length-1)for(var c=0;c<i;c++)l[c]=a?e(s,o[c]):e(o[c],s);else for(var u=0;u<i;u++)l[u]=n(e,t+1,r,r[t+1],o[u],s,a);return l}});function n$(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,i=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(r=(s=a.next()).done)&&(n.push(s.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==a.return||a.return()}finally{if(i)throw o}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return r$(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r$(e,t)}(e,t)||function(){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 r$(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var i$=kB("ceil",["typed","config","round","matrix","equalScalar"],function(e){var t=e.typed,n=e.config,r=e.round,i=e.matrix,o=e.equalScalar,s=e$({typed:t,equalScalar:o}),a=t$({typed:t});return t("ceil",{number:function(e){return YL(e,r(e),n.epsilon)?r(e):aj(e)},"number, number":function(e,t){if(YL(e,r(e,t),n.epsilon))return r(e,t);var i=n$("".concat(e,"e").split("e"),2),o=i[0],s=i[1],a=Math.ceil(Number("".concat(o,"e").concat(Number(s)+t))),l=n$("".concat(a,"e").split("e"),2);return o=l[0],s=l[1],Number("".concat(o,"e").concat(Number(s)-t))},Complex:function(e){return e.ceil()},"Complex, number":function(e,t){return e.ceil(t)},BigNumber:function(e){return NF(e,r(e),n.epsilon)?r(e):e.ceil()},"BigNumber, BigNumber":function(e,t){return NF(e,r(e,t),n.epsilon)?r(e,t):e.toDecimalPlaces(t.toNumber(),yP.ROUND_CEIL)},Fraction:function(e){return e.ceil()},"Fraction, number":function(e,t){return e.ceil(t)},"Array | Matrix":function(e){return KP(e,this)},"Array | Matrix, number":function(e,t){var n=this;return KP(e,function(e){return n(e,t)})},"SparseMatrix, number | BigNumber":function(e,t){return s(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return a(e,t,this,!1)},"number | Complex | BigNumber, Array":function(e,t){return a(i(t),e,this,!0).valueOf()}})}),o$="cube",s$=kB(o$,["typed"],function(e){return(0,e.typed)(o$,{number:lj,Complex:function(e){return e.mul(e).mul(e)},BigNumber:function(e){return e.times(e).times(e)},Fraction:function(e){return e.pow(3)},"Array | Matrix":function(e){return KP(e,this)},Unit:function(e){return e.pow(3)}})}),a$=kB("exp",["typed"],function(e){return(0,e.typed)("exp",{number:cj,Complex:function(e){return e.exp()},BigNumber:function(e){return e.exp()},"Array | Matrix":function(e){return KP(e,this)}})}),l$="expm1",c$=kB(l$,["typed","Complex"],function(e){var t=e.typed,n=e.Complex;return t(l$,{number:uj,Complex:function(e){var t=Math.exp(e.re);return new n(t*Math.cos(e.im)-1,t*Math.sin(e.im))},BigNumber:function(e){return e.exp().minus(1)},"Array | Matrix":function(e){return KP(e,this)}})}),u$=kB("fix",["typed","Complex","matrix","ceil","floor"],function(e){var t=e.typed,n=e.Complex,r=e.matrix,i=e.ceil,o=e.floor,s=t$({typed:t});return t("fix",{number:function(e){return e>0?o(e):i(e)},"number, number | BigNumber":function(e,t){return e>0?o(e,t):i(e,t)},Complex:function(e){return new n(e.re>0?Math.floor(e.re):Math.ceil(e.re),e.im>0?Math.floor(e.im):Math.ceil(e.im))},"Complex, number | BigNumber":function(e,t){return new n(e.re>0?o(e.re,t):i(e.re,t),e.im>0?o(e.im,t):i(e.im,t))},BigNumber:function(e){return e.isNegative()?i(e):o(e)},"BigNumber, number | BigNumber":function(e,t){return e.isNegative()?i(e,t):o(e,t)},Fraction:function(e){return e.s<0?e.ceil():e.floor()},"Fraction, number | BigNumber":function(e,t){return e.s<0?e.ceil(t):e.floor(t)},"Array | Matrix":function(e){return KP(e,this)},"Array | Matrix, number | BigNumber":function(e,t){var n=this;return KP(e,function(e){return n(e,t)})},"number | Complex | BigNumber, Array":function(e,t){return s(r(t),e,this,!0).valueOf()}})});function d$(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,i=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(r=(s=a.next()).done)&&(n.push(s.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==a.return||a.return()}finally{if(i)throw o}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return p$(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return p$(e,t)}(e,t)||function(){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 p$(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var h$=kB("floor",["typed","config","round","matrix","equalScalar"],function(e){var t=e.typed,n=e.config,r=e.round,i=e.matrix,o=e.equalScalar,s=e$({typed:t,equalScalar:o}),a=t$({typed:t});return t("floor",{number:function(e){return YL(e,r(e),n.epsilon)?r(e):Math.floor(e)},"number, number":function(e,t){if(YL(e,r(e,t),n.epsilon))return r(e,t);var i=d$("".concat(e,"e").split("e"),2),o=i[0],s=i[1],a=Math.floor(Number("".concat(o,"e").concat(Number(s)+t))),l=d$("".concat(a,"e").split("e"),2);return o=l[0],s=l[1],Number("".concat(o,"e").concat(Number(s)-t))},Complex:function(e){return e.floor()},"Complex, number":function(e,t){return e.floor(t)},BigNumber:function(e){return NF(e,r(e),n.epsilon)?r(e):e.floor()},"BigNumber, BigNumber":function(e,t){return NF(e,r(e,t),n.epsilon)?r(e,t):e.toDecimalPlaces(t.toNumber(),yP.ROUND_FLOOR)},Fraction:function(e){return e.floor()},"Fraction, number":function(e,t){return e.floor(t)},"Array | Matrix":function(e){return KP(e,this)},"Array | Matrix, number":function(e,t){var n=this;return KP(e,function(e){return n(e,t)})},"SparseMatrix, number | BigNumber":function(e,t){return s(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return a(e,t,this,!1)},"number | Complex | BigNumber, Array":function(e,t){return a(i(t),e,this,!0).valueOf()}})}),f$=kB("algorithm01",["typed"],function(e){var t=e.typed;return function(e,n,r,i){var o=e._data,s=e._size,a=e._datatype,l=n._values,c=n._index,u=n._ptr,d=n._size,p=n._datatype;if(s.length!==d.length)throw new uB(s.length,d.length);if(s[0]!==d[0]||s[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+d+")");if(!l)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var h,f,m=s[0],g=s[1],y="string"==typeof a&&a===p?a:void 0,v=y?t.find(r,[y,y]):r,b=[];for(h=0;h<m;h++)b[h]=[];var w=[],x=[];for(f=0;f<g;f++){for(var M=f+1,S=u[f],E=u[f+1],C=S;C<E;C++)w[h=c[C]]=i?v(l[C],o[h][f]):v(o[h][f],l[C]),x[h]=M;for(h=0;h<m;h++)x[h]===M?b[h][f]=w[h]:b[h][f]=o[h][f]}return e.createDenseMatrix({data:b,size:[m,g],datatype:y})}}),m$=kB("algorithm04",["typed","equalScalar"],function(e){var t=e.typed,n=e.equalScalar;return function(e,r,i){var o=e._values,s=e._index,a=e._ptr,l=e._size,c=e._datatype,u=r._values,d=r._index,p=r._ptr,h=r._size,f=r._datatype;if(l.length!==h.length)throw new uB(l.length,h.length);if(l[0]!==h[0]||l[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+h+")");var m,g=l[0],y=l[1],v=n,b=0,w=i;"string"==typeof c&&c===f&&(m=c,v=t.find(n,[m,m]),b=t.convert(0,m),w=t.find(i,[m,m]));var x,M,S,E,C,N=o&&u?[]:void 0,A=[],k=[],T=o&&u?[]:void 0,O=o&&u?[]:void 0,_=[],R=[];for(M=0;M<y;M++){k[M]=A.length;var D=M+1;for(E=a[M],C=a[M+1],S=E;S<C;S++)x=s[S],A.push(x),_[x]=D,T&&(T[x]=o[S]);for(E=p[M],C=p[M+1],S=E;S<C;S++)if(_[x=d[S]]===D){if(T){var I=w(T[x],u[S]);v(I,b)?_[x]=null:T[x]=I}}else A.push(x),R[x]=D,O&&(O[x]=u[S]);if(T&&O)for(S=k[M];S<A.length;)_[x=A[S]]===D?(N[S]=T[x],S++):R[x]===D?(N[S]=O[x],S++):A.splice(S,1)}return k[y]=A.length,e.createSparseMatrix({values:N,index:A,ptr:k,size:[g,y],datatype:m})}}),g$=kB("algorithm10",["typed","DenseMatrix"],function(e){var t=e.typed,n=e.DenseMatrix;return function(e,r,i,o){var s=e._values,a=e._index,l=e._ptr,c=e._size,u=e._datatype;if(!s)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var d,p=c[0],h=c[1],f=i;"string"==typeof u&&(d=u,r=t.convert(r,d),f=t.find(i,[d,d]));for(var m=[],g=[],y=[],v=0;v<h;v++){for(var b=v+1,w=l[v],x=l[v+1],M=w;M<x;M++){var S=a[M];g[S]=s[M],y[S]=b}for(var E=0;E<p;E++)0===v&&(m[E]=[]),y[E]===b?m[E][v]=o?f(r,g[E]):f(g[E],r):m[E][v]=r}return new n({data:m,size:[p,h],datatype:d})}}),y$=kB("algorithm13",["typed"],function(e){var t=e.typed;return function(e,r,i){var o,s=e._data,a=e._size,l=e._datatype,c=r._data,u=r._size,d=r._datatype,p=[];if(a.length!==u.length)throw new uB(a.length,u.length);for(var h=0;h<a.length;h++){if(a[h]!==u[h])throw new RangeError("Dimension mismatch. Matrix A ("+a+") must match Matrix B ("+u+")");p[h]=a[h]}var f=i;"string"==typeof l&&l===d&&(o=l,f=t.find(i,[o,o]));var m=p.length>0?n(f,0,p,p[0],s,c):[];return e.createDenseMatrix({data:m,size:p,datatype:o})};function n(e,t,r,i,o,s){var a=[];if(t===r.length-1)for(var l=0;l<i;l++)a[l]=e(o[l],s[l]);else for(var c=0;c<i;c++)a[c]=n(e,t+1,r,r[t+1],o[c],s[c]);return a}}),v$=kB("gcd",["typed","matrix","equalScalar","BigNumber","DenseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.equalScalar,i=e.BigNumber,o=e.DenseMatrix,s=f$({typed:t}),a=m$({typed:t,equalScalar:r}),l=g$({typed:t,DenseMatrix:o}),c=y$({typed:t}),u=t$({typed:t});return t("gcd",{"number, number":dj,"BigNumber, BigNumber":function(e,t){if(!e.isInt()||!t.isInt())throw new Error("Parameters in function gcd must be integer numbers");var n=new i(0);for(;!t.isZero();){var r=e.mod(t);e=t,t=r}return e.lt(n)?e.neg():e},"Fraction, Fraction":function(e,t){return e.gcd(t)},"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, number | BigNumber":function(e,t){return l(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return l(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return u(n(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return u(n(t),e,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(e,t,n){for(var r=this(e,t),i=0;i<n.length;i++)r=this(r,n[i]);return r}})}),b$=kB("algorithm02",["typed","equalScalar"],function(e){var t=e.typed,n=e.equalScalar;return function(e,r,i,o){var s=e._data,a=e._size,l=e._datatype,c=r._values,u=r._index,d=r._ptr,p=r._size,h=r._datatype;if(a.length!==p.length)throw new uB(a.length,p.length);if(a[0]!==p[0]||a[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+a+") must match Matrix B ("+p+")");if(!c)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var f,m=a[0],g=a[1],y=n,v=0,b=i;"string"==typeof l&&l===h&&(f=l,y=t.find(n,[f,f]),v=t.convert(0,f),b=t.find(i,[f,f]));for(var w=[],x=[],M=[],S=0;S<g;S++){M[S]=x.length;for(var E=d[S],C=d[S+1],N=E;N<C;N++){var A=u[N],k=o?b(c[N],s[A][S]):b(s[A][S],c[N]);y(k,v)||(x.push(A),w.push(k))}}return M[g]=x.length,r.createSparseMatrix({values:w,index:x,ptr:M,size:[m,g],datatype:f})}}),w$=kB("algorithm06",["typed","equalScalar"],function(e){var t=e.typed,n=e.equalScalar;return function(e,r,i){var o=e._values,s=e._size,a=e._datatype,l=r._values,c=r._size,u=r._datatype;if(s.length!==c.length)throw new uB(s.length,c.length);if(s[0]!==c[0]||s[1]!==c[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+c+")");var d,p=s[0],h=s[1],f=n,m=0,g=i;"string"==typeof a&&a===u&&(d=a,f=t.find(n,[d,d]),m=t.convert(0,d),g=t.find(i,[d,d]));for(var y=o&&l?[]:void 0,v=[],b=[],w=y?[]:void 0,x=[],M=[],S=0;S<h;S++){b[S]=v.length;var E=S+1;if(YP(e,S,x,w,M,E,v,g),YP(r,S,x,w,M,E,v,g),w)for(var C=b[S];C<v.length;){var N=v[C];if(M[N]===E){var A=w[N];f(A,m)?v.splice(C,1):(y.push(A),C++)}else v.splice(C,1)}else for(var k=b[S];k<v.length;){M[v[k]]!==E?v.splice(k,1):k++}}return b[h]=v.length,e.createSparseMatrix({values:y,index:v,ptr:b,size:[p,h],datatype:d})}}),x$=kB("lcm",["typed","matrix","equalScalar"],function(e){var t=e.typed,n=e.matrix,r=e.equalScalar,i=b$({typed:t,equalScalar:r}),o=w$({typed:t,equalScalar:r}),s=e$({typed:t,equalScalar:r}),a=y$({typed:t}),l=t$({typed:t});return t("lcm",{"number, number":pj,"BigNumber, BigNumber":function(e,t){if(!e.isInt()||!t.isInt())throw new Error("Parameters in function lcm must be integer numbers");if(e.isZero())return e;if(t.isZero())return t;var n=e.times(t);for(;!t.isZero();){var r=t;t=e.mod(r),e=r}return n.div(e).abs()},"Fraction, Fraction":function(e,t){return e.lcm(t)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return a(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, number | BigNumber":function(e,t){return s(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return l(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return s(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return l(n(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return l(n(t),e,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(e,t,n){for(var r=this(e,t),i=0;i<n.length;i++)r=this(r,n[i]);return r}})}),M$="log10",S$=kB(M$,["typed","config","Complex"],function(e){var t=e.typed,n=e.config,r=e.Complex;return t(M$,{number:function(e){return e>=0||n.predictable?fj(e):new r(e,0).log().div(Math.LN10)},Complex:function(e){return new r(e).log().div(Math.LN10)},BigNumber:function(e){return!e.isNegative()||n.predictable?e.log():new r(e.toNumber(),0).log().div(Math.LN10)},"Array | Matrix":function(e){return KP(e,this)}})}),E$="log2",C$=kB(E$,["typed","config","Complex"],function(e){var t=e.typed,n=e.config,r=e.Complex;return t(E$,{number:function(e){return e>=0||n.predictable?mj(e):i(new r(e,0))},Complex:i,BigNumber:function(e){return!e.isNegative()||n.predictable?e.log(2):i(new r(e.toNumber(),0))},"Array | Matrix":function(e){return KP(e,this)}});function i(e){var t=Math.sqrt(e.re*e.re+e.im*e.im);return new r(Math.log2?Math.log2(t):Math.log(t)/Math.LN2,Math.atan2(e.im,e.re)/Math.LN2)}}),N$=kB("algorithm03",["typed"],function(e){var t=e.typed;return function(e,n,r,i){var o=e._data,s=e._size,a=e._datatype,l=n._values,c=n._index,u=n._ptr,d=n._size,p=n._datatype;if(s.length!==d.length)throw new uB(s.length,d.length);if(s[0]!==d[0]||s[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+d+")");if(!l)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var h,f=s[0],m=s[1],g=0,y=r;"string"==typeof a&&a===p&&(h=a,g=t.convert(0,h),y=t.find(r,[h,h]));for(var v=[],b=0;b<f;b++)v[b]=[];for(var w=[],x=[],M=0;M<m;M++){for(var S=M+1,E=u[M],C=u[M+1],N=E;N<C;N++){var A=c[N];w[A]=i?y(l[N],o[A][M]):y(o[A][M],l[N]),x[A]=S}for(var k=0;k<f;k++)x[k]===S?v[k][M]=w[k]:v[k][M]=i?y(g,o[k][M]):y(o[k][M],g)}return e.createDenseMatrix({data:v,size:[f,m],datatype:h})}}),A$=kB("algorithm05",["typed","equalScalar"],function(e){var t=e.typed,n=e.equalScalar;return function(e,r,i){var o=e._values,s=e._index,a=e._ptr,l=e._size,c=e._datatype,u=r._values,d=r._index,p=r._ptr,h=r._size,f=r._datatype;if(l.length!==h.length)throw new uB(l.length,h.length);if(l[0]!==h[0]||l[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+h+")");var m,g=l[0],y=l[1],v=n,b=0,w=i;"string"==typeof c&&c===f&&(m=c,v=t.find(n,[m,m]),b=t.convert(0,m),w=t.find(i,[m,m]));var x,M,S,E,C=o&&u?[]:void 0,N=[],A=[],k=C?[]:void 0,T=C?[]:void 0,O=[],_=[];for(M=0;M<y;M++){A[M]=N.length;var R=M+1;for(S=a[M],E=a[M+1];S<E;S++)x=s[S],N.push(x),O[x]=R,k&&(k[x]=o[S]);for(S=p[M],E=p[M+1];S<E;S++)O[x=d[S]]!==R&&N.push(x),_[x]=R,T&&(T[x]=u[S]);if(C)for(S=A[M];S<N.length;){var D=O[x=N[S]],I=_[x];if(D===R||I===R){var L=w(D===R?k[x]:b,I===R?T[x]:b);v(L,b)?N.splice(S,1):(C.push(L),S++)}}}return A[y]=N.length,e.createSparseMatrix({values:C,index:N,ptr:A,size:[g,y],datatype:m})}}),k$=kB("algorithm12",["typed","DenseMatrix"],function(e){var t=e.typed,n=e.DenseMatrix;return function(e,r,i,o){var s=e._values,a=e._index,l=e._ptr,c=e._size,u=e._datatype;if(!s)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var d,p=c[0],h=c[1],f=i;"string"==typeof u&&(d=u,r=t.convert(r,d),f=t.find(i,[d,d]));for(var m=[],g=[],y=[],v=0;v<h;v++){for(var b=v+1,w=l[v],x=l[v+1],M=w;M<x;M++){var S=a[M];g[S]=s[M],y[S]=b}for(var E=0;E<p;E++)0===v&&(m[E]=[]),y[E]===b?m[E][v]=o?f(r,g[E]):f(g[E],r):m[E][v]=o?f(r,0):f(0,r)}return new n({data:m,size:[p,h],datatype:d})}}),T$=kB("mod",["typed","matrix","equalScalar","DenseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.equalScalar,i=e.DenseMatrix,o=b$({typed:t,equalScalar:r}),s=N$({typed:t}),a=A$({typed:t,equalScalar:r}),l=e$({typed:t,equalScalar:r}),c=k$({typed:t,DenseMatrix:i}),u=y$({typed:t}),d=t$({typed:t});return t("mod",{"number, number":gj,"BigNumber, BigNumber":function(e,t){if(t.isNeg())throw new Error("Cannot calculate mod for a negative divisor");return t.isZero()?e:e.mod(t)},"Fraction, Fraction":function(e,t){if(t.compare(0)<0)throw new Error("Cannot calculate mod for a negative divisor");return e.compare(0)>=0?e.mod(t):e.mod(t).add(t).mod(t)},"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return l(e,t,this,!1)},"DenseMatrix, any":function(e,t){return d(e,t,this,!1)},"any, SparseMatrix":function(e,t){return c(t,e,this,!0)},"any, DenseMatrix":function(e,t){return d(t,e,this,!0)},"Array, any":function(e,t){return d(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return d(n(t),e,this,!0).valueOf()}})}),O$=kB("multiplyScalar",["typed"],function(e){return(0,e.typed)("multiplyScalar",{"number, number":rj,"Complex, Complex":function(e,t){return e.mul(t)},"BigNumber, BigNumber":function(e,t){return e.times(t)},"Fraction, Fraction":function(e,t){return e.mul(t)},"number | Fraction | BigNumber | Complex, Unit":function(e,t){var n=t.clone();return n.value=null===n.value?n._normalize(e):this(n.value,e),n},"Unit, number | Fraction | BigNumber | Complex":function(e,t){var n=e.clone();return n.value=null===n.value?n._normalize(t):this(n.value,t),n},"Unit, Unit":function(e,t){return e.multiply(t)}})}),_$="multiply",R$=kB(_$,["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],function(e){var t=e.typed,n=e.matrix,r=e.addScalar,i=e.multiplyScalar,o=e.equalScalar,s=e.dot,a=e$({typed:t,equalScalar:o}),l=t$({typed:t});function c(e,t){switch(e.length){case 1:switch(t.length){case 1:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+e[0]+") must match Matrix rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;case 2:switch(t.length){case 1:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+e[1]+") must match Vector length ("+t[0]+")");break;case 2:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+e[1]+") must match Matrix B rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+e.length+" dimensions)")}}function u(e,n){if("dense"!==n.storage())throw new Error("Support for SparseMatrix not implemented");return function(e,n){var o,s=e._data,a=e._size,l=e._datatype,c=n._data,u=n._size,d=n._datatype,p=a[0],h=u[1],f=r,m=i;l&&d&&l===d&&"string"==typeof l&&(o=l,f=t.find(r,[o,o]),m=t.find(i,[o,o]));for(var g=[],y=0;y<h;y++){for(var v=m(s[0],c[0][y]),b=1;b<p;b++)v=f(v,m(s[b],c[b][y]));g[y]=v}return e.createDenseMatrix({data:g,size:[h],datatype:o})}(e,n)}var d=t("_multiplyMatrixVector",{"DenseMatrix, any":function(e,n){var o,s=e._data,a=e._size,l=e._datatype,c=n._data,u=n._datatype,d=a[0],p=a[1],h=r,f=i;l&&u&&l===u&&"string"==typeof l&&(o=l,h=t.find(r,[o,o]),f=t.find(i,[o,o]));for(var m=[],g=0;g<d;g++){for(var y=s[g],v=f(y[0],c[0]),b=1;b<p;b++)v=h(v,f(y[b],c[b]));m[g]=v}return e.createDenseMatrix({data:m,size:[d],datatype:o})},"SparseMatrix, any":function(e,n){var s=e._values,a=e._index,l=e._ptr,c=e._datatype;if(!s)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var u,d=n._data,p=n._datatype,h=e._size[0],f=n._size[0],m=[],g=[],y=[],v=r,b=i,w=o,x=0;c&&p&&c===p&&"string"==typeof c&&(u=c,v=t.find(r,[u,u]),b=t.find(i,[u,u]),w=t.find(o,[u,u]),x=t.convert(0,u));var M=[],S=[];y[0]=0;for(var E=0;E<f;E++){var C=d[E];if(!w(C,x))for(var N=l[E],A=l[E+1],k=N;k<A;k++){var T=a[k];S[T]?M[T]=v(M[T],b(C,s[k])):(S[T]=!0,g.push(T),M[T]=b(C,s[k]))}}for(var O=g.length,_=0;_<O;_++){var R=g[_];m[_]=M[R]}return y[1]=g.length,e.createSparseMatrix({values:m,index:g,ptr:y,size:[h,1],datatype:u})}}),p=t("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":function(e,n){var o,s=e._data,a=e._size,l=e._datatype,c=n._data,u=n._size,d=n._datatype,p=a[0],h=a[1],f=u[1],m=r,g=i;l&&d&&l===d&&"string"==typeof l&&(o=l,m=t.find(r,[o,o]),g=t.find(i,[o,o]));for(var y=[],v=0;v<p;v++){var b=s[v];y[v]=[];for(var w=0;w<f;w++){for(var x=g(b[0],c[0][w]),M=1;M<h;M++)x=m(x,g(b[M],c[M][w]));y[v][w]=x}}return e.createDenseMatrix({data:y,size:[p,f],datatype:o})},"DenseMatrix, SparseMatrix":function(e,n){var s=e._data,a=e._size,l=e._datatype,c=n._values,u=n._index,d=n._ptr,p=n._size,h=n._datatype;if(!c)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var f,m=a[0],g=p[1],y=r,v=i,b=o,w=0;l&&h&&l===h&&"string"==typeof l&&(f=l,y=t.find(r,[f,f]),v=t.find(i,[f,f]),b=t.find(o,[f,f]),w=t.convert(0,f));for(var x=[],M=[],S=[],E=n.createSparseMatrix({values:x,index:M,ptr:S,size:[m,g],datatype:f}),C=0;C<g;C++){S[C]=M.length;var N=d[C],A=d[C+1];if(A>N)for(var k=0,T=0;T<m;T++){for(var O=T+1,_=void 0,R=N;R<A;R++){var D=u[R];k!==O?(_=v(s[T][D],c[R]),k=O):_=y(_,v(s[T][D],c[R]))}k!==O||b(_,w)||(M.push(T),x.push(_))}}return S[g]=M.length,E},"SparseMatrix, DenseMatrix":function(e,n){var s=e._values,a=e._index,l=e._ptr,c=e._datatype;if(!s)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var u,d=n._data,p=n._datatype,h=e._size[0],f=n._size[0],m=n._size[1],g=r,y=i,v=o,b=0;c&&p&&c===p&&"string"==typeof c&&(u=c,g=t.find(r,[u,u]),y=t.find(i,[u,u]),v=t.find(o,[u,u]),b=t.convert(0,u));for(var w=[],x=[],M=[],S=e.createSparseMatrix({values:w,index:x,ptr:M,size:[h,m],datatype:u}),E=[],C=[],N=0;N<m;N++){M[N]=x.length;for(var A=N+1,k=0;k<f;k++){var T=d[k][N];if(!v(T,b))for(var O=l[k],_=l[k+1],R=O;R<_;R++){var D=a[R];C[D]!==A?(C[D]=A,x.push(D),E[D]=y(T,s[R])):E[D]=g(E[D],y(T,s[R]))}}for(var I=M[N],L=x.length,B=I;B<L;B++){var z=x[B];w[B]=E[z]}}return M[m]=x.length,S},"SparseMatrix, SparseMatrix":function(e,n){var o,s=e._values,a=e._index,l=e._ptr,c=e._datatype,u=n._values,d=n._index,p=n._ptr,h=n._datatype,f=e._size[0],m=n._size[1],g=s&&u,y=r,v=i;c&&h&&c===h&&"string"==typeof c&&(o=c,y=t.find(r,[o,o]),v=t.find(i,[o,o]));for(var b,w,x,M,S,E,C,N,A=g?[]:void 0,k=[],T=[],O=e.createSparseMatrix({values:A,index:k,ptr:T,size:[f,m],datatype:o}),_=g?[]:void 0,R=[],D=0;D<m;D++){T[D]=k.length;var I=D+1;for(S=p[D],E=p[D+1],M=S;M<E;M++)if(N=d[M],g)for(w=l[N],x=l[N+1],b=w;b<x;b++)R[C=a[b]]!==I?(R[C]=I,k.push(C),_[C]=v(u[M],s[b])):_[C]=y(_[C],v(u[M],s[b]));else for(w=l[N],x=l[N+1],b=w;b<x;b++)R[C=a[b]]!==I&&(R[C]=I,k.push(C));if(g)for(var L=T[D],B=k.length,z=L;z<B;z++){var P=k[z];A[z]=_[P]}}return T[m]=k.length,O}});return t(_$,TL({"Array, Array":function(e,t){c(pB(e),pB(t));var r=this(n(e),n(t));return JI(r)?r.valueOf():r},"Matrix, Matrix":function(e,t){var n=e.size(),r=t.size();return c(n,r),1===n.length?1===r.length?function(e,t,n){if(0===n)throw new Error("Cannot multiply two empty vectors");return s(e,t)}(e,t,n[0]):u(e,t):1===r.length?d(e,t):p(e,t)},"Matrix, Array":function(e,t){return this(e,n(t))},"Array, Matrix":function(e,t){return this(n(e,t.storage()),t)},"SparseMatrix, any":function(e,t){return a(e,t,i,!1)},"DenseMatrix, any":function(e,t){return l(e,t,i,!1)},"any, SparseMatrix":function(e,t){return a(t,e,i,!0)},"any, DenseMatrix":function(e,t){return l(t,e,i,!0)},"Array, any":function(e,t){return l(n(e),t,i,!1).valueOf()},"any, Array":function(e,t){return l(n(t),e,i,!0).valueOf()},"any, any":i,"any, any, ...any":function(e,t,n){for(var r=this(e,t),i=0;i<n.length;i++)r=this(r,n[i]);return r}},i.signatures))}),D$="nthRoot",I$=kB(D$,["typed","matrix","equalScalar","BigNumber"],function(e){var t=e.typed,n=e.matrix,r=e.equalScalar,i=e.BigNumber,o=f$({typed:t}),s=b$({typed:t,equalScalar:r}),a=w$({typed:t,equalScalar:r}),l=e$({typed:t,equalScalar:r}),c=y$({typed:t}),u=t$({typed:t}),d="Complex number not supported in function nthRoot. Use nthRoots instead.";return t(D$,{number:function(e){return yj(e,2)},"number, number":yj,BigNumber:function(e){return p(e,new i(2))},Complex:function(e){throw new Error(d)},"Complex, number":function(e,t){throw new Error(d)},"BigNumber, BigNumber":p,"Array | Matrix":function(e){return this(e,2)},"SparseMatrix, SparseMatrix":function(e,t){if(1===t.density())return a(e,t,this);throw new Error("Root must be non-zero")},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){if(1===t.density())return o(e,t,this,!1);throw new Error("Root must be non-zero")},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, number | BigNumber":function(e,t){return l(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){if(1===t.density())return l(t,e,this,!0);throw new Error("Root must be non-zero")},"number | BigNumber, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(n(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,n(t)).valueOf()}});function p(e,t){var n=i.precision,r=i.clone({precision:n+2}),o=new i(0),s=new r(1),a=t.isNegative();if(a&&(t=t.neg()),t.isZero())throw new Error("Root must be non-zero");if(e.isNegative()&&!t.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(e.isZero())return a?new r(1/0):0;if(!e.isFinite())return a?o:e;var l=e.abs().pow(s.div(t));return l=e.isNeg()?l.neg():l,new i((a?s.div(l):l).toPrecision(n))}});kB(D$,["typed"],function(e){return(0,e.typed)(D$,{number:yj,"number, number":yj})});var L$="sign",B$=kB(L$,["typed","BigNumber","Fraction","complex"],function(e){var t=e.typed,n=e.BigNumber,r=e.complex,i=e.Fraction;return t(L$,{number:vj,Complex:function(e){return 0===e.im?r(vj(e.re)):e.sign()},BigNumber:function(e){return new n(e.cmp(0))},Fraction:function(e){return new i(e.s,1)},"Array | Matrix":function(e){return KP(e,this)},Unit:function(e){return this(e.value)}})}),z$=kB("sqrt",["config","typed","Complex"],function(e){var t=e.config,n=e.typed,r=e.Complex;return n("sqrt",{number:i,Complex:function(e){return e.sqrt()},BigNumber:function(e){return!e.isNegative()||t.predictable?e.sqrt():i(e.toNumber())},"Array | Matrix":function(e){return KP(e,this)},Unit:function(e){return e.pow(.5)}});function i(e){return isNaN(e)?NaN:e>=0||t.predictable?Math.sqrt(e):new r(e,0).sqrt()}}),P$="square",j$=kB(P$,["typed"],function(e){return(0,e.typed)(P$,{number:bj,Complex:function(e){return e.mul(e)},BigNumber:function(e){return e.times(e)},Fraction:function(e){return e.mul(e)},"Array | Matrix":function(e){return KP(e,this)},Unit:function(e){return e.pow(2)}})}),F$="subtract",$$=kB(F$,["typed","matrix","equalScalar","addScalar","unaryMinus","DenseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.equalScalar,i=e.addScalar,o=e.unaryMinus,s=e.DenseMatrix,a=f$({typed:t}),l=N$({typed:t}),c=A$({typed:t,equalScalar:r}),u=g$({typed:t,DenseMatrix:s}),d=y$({typed:t}),p=t$({typed:t});return t(F$,{"number, number":function(e,t){return e-t},"Complex, Complex":function(e,t){return e.sub(t)},"BigNumber, BigNumber":function(e,t){return e.minus(t)},"Fraction, Fraction":function(e,t){return e.sub(t)},"Unit, Unit":function(e,t){if(null===e.value)throw new Error("Parameter x contains a unit with undefined value");if(null===t.value)throw new Error("Parameter y contains a unit with undefined value");if(!e.equalBase(t))throw new Error("Units do not match");var n=e.clone();return n.value=this(n.value,t.value),n.fixPrefix=!1,n},"SparseMatrix, SparseMatrix":function(e,t){return H$(e,t),c(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return H$(e,t),l(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return H$(e,t),a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return H$(e,t),d(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return u(e,o(t),i)},"DenseMatrix, any":function(e,t){return p(e,t,this)},"any, SparseMatrix":function(e,t){return u(t,e,this,!0)},"any, DenseMatrix":function(e,t){return p(t,e,this,!0)},"Array, any":function(e,t){return p(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return p(n(t),e,this,!0).valueOf()}})});function H$(e,t){var n=e.size(),r=t.size();if(n.length!==r.length)throw new uB(n.length,r.length)}var U$="xgcd",q$=kB(U$,["typed","config","matrix","BigNumber"],function(e){var t=e.typed,n=e.config,r=e.matrix,i=e.BigNumber;return t(U$,{"number, number":function(e,t){var i=wj(e,t);return"Array"===n.matrix?i:r(i)},"BigNumber, BigNumber":function(e,t){var o,s,a,l,c=new i(0),u=new i(1),d=c,p=u,h=u,f=c;if(!e.isInt()||!t.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!t.isZero();)s=e.div(t).floor(),a=e.mod(t),o=d,d=p.minus(s.times(d)),p=o,o=h,h=f.minus(s.times(h)),f=o,e=t,t=a;l=e.lt(c)?[e.neg(),p.neg(),f.neg()]:[e,e.isZero()?0:p,f];return"Array"===n.matrix?l:r(l)}})}),V$=kB("algorithm09",["typed","equalScalar"],function(e){var t=e.typed,n=e.equalScalar;return function(e,r,i){var o=e._values,s=e._index,a=e._ptr,l=e._size,c=e._datatype,u=r._values,d=r._index,p=r._ptr,h=r._size,f=r._datatype;if(l.length!==h.length)throw new uB(l.length,h.length);if(l[0]!==h[0]||l[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+h+")");var m,g=l[0],y=l[1],v=n,b=0,w=i;"string"==typeof c&&c===f&&(m=c,v=t.find(n,[m,m]),b=t.convert(0,m),w=t.find(i,[m,m]));var x,M,S,E,C,N=o&&u?[]:void 0,A=[],k=[],T=N?[]:void 0,O=[];for(M=0;M<y;M++){k[M]=A.length;var _=M+1;if(T)for(E=p[M],C=p[M+1],S=E;S<C;S++)O[x=d[S]]=_,T[x]=u[S];for(E=a[M],C=a[M+1],S=E;S<C;S++)if(x=s[S],T){var R=O[x]===_?T[x]:b,D=w(o[S],R);v(D,b)||(A.push(x),N.push(D))}else A.push(x)}return k[y]=A.length,e.createSparseMatrix({values:N,index:A,ptr:k,size:[g,y],datatype:m})}}),W$="dotMultiply",K$=kB(W$,["typed","matrix","equalScalar","multiplyScalar"],function(e){var t=e.typed,n=e.matrix,r=e.equalScalar,i=e.multiplyScalar,o=b$({typed:t,equalScalar:r}),s=V$({typed:t,equalScalar:r}),a=e$({typed:t,equalScalar:r}),l=y$({typed:t}),c=t$({typed:t});return t(W$,{"any, any":i,"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,i,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,i,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,i,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,i)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return a(e,t,i,!1)},"DenseMatrix, any":function(e,t){return c(e,t,i,!1)},"any, SparseMatrix":function(e,t){return a(t,e,i,!0)},"any, DenseMatrix":function(e,t){return c(t,e,i,!0)},"Array, any":function(e,t){return c(n(e),t,i,!1).valueOf()},"any, Array":function(e,t){return c(n(t),e,i,!0).valueOf()}})});function G$(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitAnd");var n=e.constructor;if(e.isNaN()||t.isNaN())return new n(NaN);if(e.isZero()||t.eq(-1)||e.eq(t))return e;if(t.isZero()||e.eq(-1))return t;if(!e.isFinite()||!t.isFinite()){if(!e.isFinite()&&!t.isFinite())return e.isNegative()===t.isNegative()?e:new n(0);if(!e.isFinite())return t.isNegative()?e:e.isNegative()?new n(0):t;if(!t.isFinite())return e.isNegative()?t:t.isNegative()?new n(0):e}return Z$(e,t,function(e,t){return e&t})}function J$(e){if(e.isFinite()&&!e.isInteger())throw new Error("Integer expected in function bitNot");var t=e.constructor,n=t.precision;t.config({precision:1e9});var r=e.plus(new t(1));return r.s=-r.s||null,t.config({precision:n}),r}function Y$(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitOr");var n=e.constructor;if(e.isNaN()||t.isNaN())return new n(NaN);var r=new n(-1);return e.isZero()||t.eq(r)||e.eq(t)?t:t.isZero()||e.eq(r)?e:e.isFinite()&&t.isFinite()?Z$(e,t,function(e,t){return e|t}):!e.isFinite()&&!e.isNegative()&&t.isNegative()||e.isNegative()&&!t.isNegative()&&!t.isFinite()?r:e.isNegative()&&t.isNegative()?e.isFinite()?e:t:e.isFinite()?t:e}function Z$(e,t,n){var r,i,o,s,a,l=e.constructor,c=+(e.s<0),u=+(t.s<0);if(c){r=X$(J$(e));for(var d=0;d<r.length;++d)r[d]^=1}else r=X$(e);if(u){i=X$(J$(t));for(var p=0;p<i.length;++p)i[p]^=1}else i=X$(t);r.length<=i.length?(o=r,s=i,a=c):(o=i,s=r,a=u);var h=o.length,f=s.length,m=1^n(c,u),g=new l(1^m),y=new l(1),v=new l(2),b=l.precision;for(l.config({precision:1e9});h>0;)n(o[--h],s[--f])===m&&(g=g.plus(y)),y=y.times(v);for(;f>0;)n(a,s[--f])===m&&(g=g.plus(y)),y=y.times(v);return l.config({precision:b}),0===m&&(g.s=-g.s),g}function X$(e){for(var t=e.d,n=t[0]+"",r=1;r<t.length;++r){for(var i=t[r]+"",o=7-i.length;o--;)i="0"+i;n+=i}for(var s=n.length;"0"===n.charAt(s);)s--;var a=e.e,l=n.slice(0,s+1||1),c=l.length;if(a>0)if(++a>c)for(a-=c;a--;)l+="0";else a<c&&(l=l.slice(0,a)+"."+l.slice(a));for(var u=[0],d=0;d<l.length;){for(var p=u.length;p--;)u[p]*=10;u[0]+=parseInt(l.charAt(d++));for(var h=0;h<u.length;++h)u[h]>1&&(null!==u[h+1]&&void 0!==u[h+1]||(u[h+1]=0),u[h+1]+=u[h]>>1,u[h]&=1)}return u.reverse()}function Q$(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitXor");var n=e.constructor;if(e.isNaN()||t.isNaN())return new n(NaN);if(e.isZero())return t;if(t.isZero())return e;if(e.eq(t))return new n(0);var r=new n(-1);return e.eq(r)?J$(t):t.eq(r)?J$(e):e.isFinite()&&t.isFinite()?Z$(e,t,function(e,t){return e^t}):e.isFinite()||t.isFinite()?new n(e.isNegative()===t.isNegative()?1/0:-1/0):r}function eH(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function leftShift");var n=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new n(NaN):e.isZero()||t.isZero()?e:e.isFinite()||t.isFinite()?t.lt(55)?e.times(Math.pow(2,t.toNumber())+""):e.times(new n(2).pow(t)):new n(NaN)}function tH(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function rightArithShift");var n=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new n(NaN):e.isZero()||t.isZero()?e:t.isFinite()?t.lt(55)?e.div(Math.pow(2,t.toNumber())+"").floor():e.div(new n(2).pow(t)).floor():e.isNegative()?new n(-1):e.isFinite()?new n(0):new n(NaN)}var nH="bitAnd",rH=kB(nH,["typed","matrix","equalScalar"],function(e){var t=e.typed,n=e.matrix,r=e.equalScalar,i=b$({typed:t,equalScalar:r}),o=w$({typed:t,equalScalar:r}),s=e$({typed:t,equalScalar:r}),a=y$({typed:t}),l=t$({typed:t});return t(nH,{"number, number":Ej,"BigNumber, BigNumber":G$,"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return a(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return l(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, any":function(e,t){return l(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return l(n(t),e,this,!0).valueOf()}})}),iH="bitNot",oH=kB(iH,["typed"],function(e){return(0,e.typed)(iH,{number:Cj,BigNumber:J$,"Array | Matrix":function(e){return KP(e,this)}})}),sH="bitOr",aH=kB(sH,["typed","matrix","equalScalar","DenseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.equalScalar,i=e.DenseMatrix,o=f$({typed:t}),s=m$({typed:t,equalScalar:r}),a=g$({typed:t,DenseMatrix:i}),l=y$({typed:t}),c=t$({typed:t});return t(sH,{"number, number":Nj,"BigNumber, BigNumber":Y$,"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return a(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return a(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(n(t),e,this,!0).valueOf()}})}),lH=kB("algorithm07",["typed","DenseMatrix"],function(e){var t=e.typed,n=e.DenseMatrix;return function(e,i,o){var s=e._size,a=e._datatype,l=i._size,c=i._datatype;if(s.length!==l.length)throw new uB(s.length,l.length);if(s[0]!==l[0]||s[1]!==l[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+l+")");var u,d,p,h=s[0],f=s[1],m=0,g=o;"string"==typeof a&&a===c&&(u=a,m=t.convert(0,u),g=t.find(o,[u,u]));var y=[];for(d=0;d<h;d++)y[d]=[];var v=[],b=[],w=[],x=[];for(p=0;p<f;p++){var M=p+1;for(r(e,p,w,v,M),r(i,p,x,b,M),d=0;d<h;d++){var S=w[d]===M?v[d]:m,E=x[d]===M?b[d]:m;y[d][p]=g(S,E)}}return new n({data:y,size:[h,f],datatype:u})};function r(e,t,n,r,i){for(var o=e._values,s=e._index,a=e._ptr,l=a[t],c=a[t+1];l<c;l++){var u=s[l];n[u]=i,r[u]=o[l]}}}),cH="bitXor",uH=kB(cH,["typed","matrix","DenseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.DenseMatrix,i=N$({typed:t}),o=lH({typed:t,DenseMatrix:r}),s=k$({typed:t,DenseMatrix:r}),a=y$({typed:t}),l=t$({typed:t});return t(cH,{"number, number":Aj,"BigNumber, BigNumber":Q$,"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return a(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return l(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, any":function(e,t){return l(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return l(n(t),e,this,!0).valueOf()}})}),dH=kB("arg",["typed"],function(e){return(0,e.typed)("arg",{number:function(e){return Math.atan2(0,e)},BigNumber:function(e){return e.constructor.atan2(0,e)},Complex:function(e){return e.arg()},"Array | Matrix":function(e){return KP(e,this)}})}),pH="conj",hH=kB(pH,["typed"],function(e){return(0,e.typed)(pH,{number:function(e){return e},BigNumber:function(e){return e},Complex:function(e){return e.conjugate()},"Array | Matrix":function(e){return KP(e,this)}})}),fH=kB("im",["typed"],function(e){return(0,e.typed)("im",{number:function(e){return 0},BigNumber:function(e){return e.mul(0)},Complex:function(e){return e.im},"Array | Matrix":function(e){return KP(e,this)}})}),mH=kB("re",["typed"],function(e){return(0,e.typed)("re",{number:function(e){return e},BigNumber:function(e){return e},Complex:function(e){return e.re},"Array | Matrix":function(e){return KP(e,this)}})}),gH=kB("not",["typed"],function(e){return(0,e.typed)("not",{number:zj,Complex:function(e){return 0===e.re&&0===e.im},BigNumber:function(e){return e.isZero()||e.isNaN()},Unit:function(e){return null===e.value||this(e.value)},"Array | Matrix":function(e){return KP(e,this)}})}),yH=kB("or",["typed","matrix","equalScalar","DenseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.equalScalar,i=e.DenseMatrix,o=N$({typed:t}),s=A$({typed:t,equalScalar:r}),a=k$({typed:t,DenseMatrix:i}),l=y$({typed:t}),c=t$({typed:t});return t("or",{"number, number":Pj,"Complex, Complex":function(e,t){return 0!==e.re||0!==e.im||0!==t.re||0!==t.im},"BigNumber, BigNumber":function(e,t){return!e.isZero()&&!e.isNaN()||!t.isZero()&&!t.isNaN()},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return a(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return a(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(n(t),e,this,!0).valueOf()}})}),vH=kB("xor",["typed","matrix","DenseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.DenseMatrix,i=N$({typed:t}),o=lH({typed:t,DenseMatrix:r}),s=k$({typed:t,DenseMatrix:r}),a=y$({typed:t}),l=t$({typed:t});return t("xor",{"number, number":jj,"Complex, Complex":function(e,t){return(0!==e.re||0!==e.im)!=(0!==t.re||0!==t.im)},"BigNumber, BigNumber":function(e,t){return(!e.isZero()&&!e.isNaN())!=(!t.isZero()&&!t.isNaN())},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return a(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return l(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, any":function(e,t){return l(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return l(n(t),e,this,!0).valueOf()}})}),bH="concat",wH=kB(bH,["typed","matrix","isInteger"],function(e){var t=e.typed,n=e.matrix,r=e.isInteger;return t(bH,{"...Array | Matrix | number | BigNumber":function(e){var t,i,o=e.length,s=-1,a=!1,l=[];for(t=0;t<o;t++){var c=e[t];if(JI(c)&&(a=!0),HI(c)||UI(c)){if(t!==o-1)throw new Error("Dimension must be specified as last argument");if(i=s,s=c.valueOf(),!r(s))throw new TypeError("Integer number expected for dimension");if(s<0||t>0&&s>i)throw new dB(s,i+1)}else{var u=kL(c).valueOf(),d=pB(u);if(l[t]=u,i=s,s=d.length-1,t>0&&s!==i)throw new uB(i+1,s+1)}}if(0===l.length)throw new SyntaxError("At least one matrix expected");for(var p=l.shift();l.length;)p=xH(p,l.shift(),s,0);return a?n(p):p},"...string":function(e){return e.join("")}})});function xH(e,t,n,r){if(r<n){if(e.length!==t.length)throw new uB(e.length,t.length);for(var i=[],o=0;o<e.length;o++)i[o]=xH(e[o],t[o],n,r+1);return i}return e.concat(t)}var MH="column",SH=kB(MH,["typed","Index","matrix","range"],function(e){var t=e.typed,n=e.Index,r=e.matrix,i=e.range;return t(MH,{"Matrix, number":o,"Array, number":function(e,t){return o(r(kL(e)),t).valueOf()}});function o(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");mB(t,e.size()[1]);var r=i(0,e.size()[0]),o=new n(r,t);return e.subset(o)}}),EH="cross",CH=kB(EH,["typed","matrix","subtract","multiply"],function(e){var t=e.typed,n=e.matrix,r=e.subtract,i=e.multiply;return t(EH,{"Matrix, Matrix":function(e,t){return n(o(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return n(o(e.toArray(),t))},"Array, Matrix":function(e,t){return n(o(e,t.toArray()))},"Array, Array":o});function o(e,t){var n=Math.max(pB(e).length,pB(t).length);e=bB(e),t=bB(t);var o=pB(e),s=pB(t);if(1!==o.length||1!==s.length||3!==o[0]||3!==s[0])throw new RangeError("Vectors with length 3 expected (Size A = ["+o.join(", ")+"], B = ["+s.join(", ")+"])");var a=[r(i(e[1],t[2]),i(e[2],t[1])),r(i(e[2],t[0]),i(e[0],t[2])),r(i(e[0],t[1]),i(e[1],t[0]))];return n>1?[a]:a}}),NH="diag",AH=kB(NH,["typed","matrix","DenseMatrix","SparseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.DenseMatrix,i=e.SparseMatrix;return t(NH,{Array:function(e){return o(e,0,pB(e),null)},"Array, number":function(e,t){return o(e,t,pB(e),null)},"Array, BigNumber":function(e,t){return o(e,t.toNumber(),pB(e),null)},"Array, string":function(e,t){return o(e,0,pB(e),t)},"Array, number, string":function(e,t,n){return o(e,t,pB(e),n)},"Array, BigNumber, string":function(e,t,n){return o(e,t.toNumber(),pB(e),n)},Matrix:function(e){return o(e,0,e.size(),e.storage())},"Matrix, number":function(e,t){return o(e,t,e.size(),e.storage())},"Matrix, BigNumber":function(e,t){return o(e,t.toNumber(),e.size(),e.storage())},"Matrix, string":function(e,t){return o(e,0,e.size(),t)},"Matrix, number, string":function(e,t,n){return o(e,t,e.size(),n)},"Matrix, BigNumber, string":function(e,t,n){return o(e,t.toNumber(),e.size(),n)}});function o(e,t,o,s){if(!BL(t))throw new TypeError("Second parameter in function diag must be an integer");var a=t>0?t:0,l=t<0?-t:0;switch(o.length){case 1:return function(e,t,n,o,s,a){var l=[o+s,o+a];if(n&&"sparse"!==n&&"dense"!==n)throw new TypeError("Unknown matrix type ".concat(n,'"'));var c="sparse"===n?i.diagonal(l,e,t):r.diagonal(l,e,t);return null!==n?c:c.valueOf()}(e,t,s,o[0],l,a);case 2:return function(e,t,r,i,o,s){if(JI(e)){var a=e.diagonal(t);return null!==r?r!==a.storage()?n(a,r):a:a.valueOf()}for(var l=Math.min(i[0]-o,i[1]-s),c=[],u=0;u<l;u++)c[u]=e[u+o][u+s];return null!==r?n(c):c}(e,t,s,o,l,a)}throw new RangeError("Matrix for function diag must be 2 dimensional")}});function kH(e){return kH="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},kH(e)}function TH(e,t){return function n(){"object"!==kH(n.cache)&&(n.cache={});for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var o=t?t(r):JSON.stringify(r);return o in n.cache||(n.cache[o]=e.apply(e,r)),n.cache[o]}}function OH(e){return Object.keys(e.signatures||{}).reduce(function(e,t){var n=(t.match(/,/g)||[]).length+1;return Math.max(e,n)},-1)}var _H=kB("filter",["typed"],function(e){return(0,e.typed)("filter",{"Array, function":RH,"Matrix, function":function(e,t){return e.create(RH(e.toArray(),t))},"Array, RegExp":EB,"Matrix, RegExp":function(e,t){return e.create(EB(e.toArray(),t))}})});function RH(e,t){var n=OH(t);return function(e,t){if(1!==pB(e).length)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(e,t)}(e,function(e,r,i){return 1===n?t(e):2===n?t(e,[r]):t(e,[r],i)})}var DH="flatten",IH=kB(DH,["typed","matrix"],function(e){var t=e.typed,n=e.matrix;return t(DH,{Array:function(e){return SB(kL(e))},Matrix:function(e){var t=SB(kL(e.toArray()));return n(t)}})}),LH="forEach",BH=kB(LH,["typed"],function(e){return(0,e.typed)(LH,{"Array, function":zH,"Matrix, function":function(e,t){return e.forEach(t)}})});function zH(e,t){var n=OH(t);!function r(i,o){Array.isArray(i)?function(e,t){Array.prototype.forEach.call(e,t)}(i,function(e,t){r(e,o.concat(t))}):1===n?t(i):2===n?t(i,o):t(i,o,e)}(e,[])}var PH="getMatrixDataType",jH=kB(PH,["typed"],function(e){return(0,e.typed)(PH,{Array:function(e){return AB(e,NL)},Matrix:function(e){return e.getDataType()}})}),FH="identity",$H=kB(FH,["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],function(e){var t=e.typed,n=e.config,r=e.matrix,i=e.BigNumber,o=e.DenseMatrix,s=e.SparseMatrix;return t(FH,{"":function(){return"Matrix"===n.matrix?r([]):[]},string:function(e){return r(e)},"number | BigNumber":function(e){return l(e,e,"Matrix"===n.matrix?"dense":void 0)},"number | BigNumber, string":function(e,t){return l(e,e,t)},"number | BigNumber, number | BigNumber":function(e,t){return l(e,t,"Matrix"===n.matrix?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(e,t,n){return l(e,t,n)},Array:function(e){return a(e)},"Array, string":function(e,t){return a(e,t)},Matrix:function(e){return a(e.valueOf(),e.storage())},"Matrix, string":function(e,t){return a(e.valueOf(),t)}});function a(e,t){switch(e.length){case 0:return t?r(t):[];case 1:return l(e[0],e[0],t);case 2:return l(e[0],e[1],t);default:throw new Error("Vector containing two values expected")}}function l(e,t,n){var r=UI(e)||UI(t)?i:null;if(UI(e)&&(e=e.toNumber()),UI(t)&&(t=t.toNumber()),!BL(e)||e<1)throw new Error("Parameters in function identity must be positive integers");if(!BL(t)||t<1)throw new Error("Parameters in function identity must be positive integers");var a=r?new i(1):1,l=r?new r(0):0,c=[e,t];if(n){if("sparse"===n)return s.diagonal(c,a,0,l);if("dense"===n)return o.diagonal(c,a,0,l);throw new TypeError('Unknown matrix type "'.concat(n,'"'))}for(var u=gB([],c,l),d=e<t?e:t,p=0;p<d;p++)u[p][p]=a;return u}}),HH="kron",UH=kB(HH,["typed","matrix","multiplyScalar"],function(e){var t=e.typed,n=e.matrix,r=e.multiplyScalar;return t(HH,{"Matrix, Matrix":function(e,t){return n(i(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return n(i(e.toArray(),t))},"Array, Matrix":function(e,t){return n(i(e,t.toArray()))},"Array, Array":i});function i(e,t){if(1===pB(e).length&&(e=[e]),1===pB(t).length&&(t=[t]),pB(e).length>2||pB(t).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(e.length)+", y = "+JSON.stringify(t.length)+")");var n=[],i=[];return e.map(function(e){return t.map(function(t){return i=[],n.push(i),e.map(function(e){return t.map(function(t){return i.push(r(e,t))})})})})&&n}}),qH=kB("map",["typed"],function(e){return(0,e.typed)("map",{"Array, function":VH,"Matrix, function":function(e,t){return e.map(t)}})});function VH(e,t){var n=OH(t);return function r(i,o){return Array.isArray(i)?i.map(function(e,t){return r(e,o.concat(t))}):1===n?t(i):2===n?t(i,o):t(i,o,e)}(e,[])}var WH="diff",KH=kB(WH,["typed","matrix","subtract","number"],function(e){var t=e.typed,n=e.matrix,r=e.subtract,i=e.number;return t(WH,{"Array | Matrix":function(e){return JI(e)?n(s(e.toArray())):s(e)},"Array | Matrix, number":function(e,t){if(!BL(t))throw new RangeError("Dimension must be a whole number");return JI(e)?n(o(e.toArray(),t)):o(e,t)},"Array | Matrix, BigNumber":function(e,t){return this(e,i(t))}});function o(e,t){if(JI(e)&&(e=e.toArray()),!Array.isArray(e))throw RangeError("Array/Matrix does not have that many dimensions");if(t>0){var n=[];return e.forEach(function(e){n.push(o(e,t-1))}),n}if(0===t)return s(e);throw RangeError("Cannot have negative dimension")}function s(e){var t=[],n=e.length;if(n<2)return e;for(var r=1;r<n;r++)t.push(a(e[r-1],e[r]));return t}function a(e,t){JI(e)&&(e=e.toArray()),JI(t)&&(t=t.toArray());var n=Array.isArray(e),i=Array.isArray(t);if(n&&i)return function(e,t){if(e.length!==t.length)throw RangeError("Not all sub-arrays have the same length");for(var n=[],r=e.length,i=0;i<r;i++)n.push(a(e[i],t[i]));return n}(e,t);if(!n&&!i)return r(t,e);throw TypeError("Cannot calculate difference between 1 array and 1 non-array")}}),GH=kB("ones",["typed","config","matrix","BigNumber"],function(e){var t=e.typed,n=e.config,r=e.matrix,i=e.BigNumber;return t("ones",{"":function(){return"Array"===n.matrix?o([]):o([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var t=e.pop();return o(e,t)}return"Array"===n.matrix?o(e):o(e,"default")},Array:o,Matrix:function(e){var t=e.storage();return o(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return o(e.valueOf(),t)}});function o(e,t){var n=function(e){var t=!1;return e.forEach(function(e,n,r){UI(e)&&(t=!0,r[n]=e.toNumber())}),t}(e),o=n?new i(1):1;if(function(e){e.forEach(function(e){if("number"!=typeof e||!BL(e)||e<0)throw new Error("Parameters in function ones must be positive integers")})}(e),t){var s=r(t);return e.length>0?s.resize(e,o):s}var a=[];return e.length>0?gB(a,e,o):a}});function JH(){throw new Error('No "bignumber" implementation available')}function YH(){throw new Error('No "fraction" implementation available')}function ZH(){throw new Error('No "matrix" implementation available')}var XH="range",QH=kB(XH,["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],function(e){var t=e.typed,n=e.config,r=e.matrix,i=e.bignumber,o=e.smaller,s=e.smallerEq,a=e.larger,l=e.largerEq;return t(XH,{string:u,"string, boolean":u,"number, number":function(e,t){return c(d(e,t,1))},"number, number, number":function(e,t,n){return c(d(e,t,n))},"number, number, boolean":function(e,t,n){return c(n?p(e,t,1):d(e,t,1))},"number, number, number, boolean":function(e,t,n,r){return c(r?p(e,t,n):d(e,t,n))},"BigNumber, BigNumber":function(e,t){return c(h(e,t,new(0,e.constructor)(1)))},"BigNumber, BigNumber, BigNumber":function(e,t,n){return c(h(e,t,n))},"BigNumber, BigNumber, boolean":function(e,t,n){var r=e.constructor;return c(n?f(e,t,new r(1)):h(e,t,new r(1)))},"BigNumber, BigNumber, BigNumber, boolean":function(e,t,n,r){return c(r?f(e,t,n):h(e,t,n))}});function c(e){return"Matrix"===n.matrix?r?r(e):ZH():e}function u(e,t){var r=function(e){var t=e.split(":"),n=t.map(function(e){return Number(e)});if(n.some(function(e){return isNaN(e)}))return null;switch(n.length){case 2:return{start:n[0],end:n[1],step:1};case 3:return{start:n[0],end:n[2],step:n[1]};default:return null}}(e);if(!r)throw new SyntaxError('String "'+e+'" is no valid range');return"BigNumber"===n.number?(void 0===i&&JH(),c((t?f:h)(i(r.start),i(r.end),i(r.step)))):c((t?p:d)(r.start,r.end,r.step))}function d(e,t,n){var r=[],i=e;if(n>0)for(;o(i,t);)r.push(i),i+=n;else if(n<0)for(;a(i,t);)r.push(i),i+=n;return r}function p(e,t,n){var r=[],i=e;if(n>0)for(;s(i,t);)r.push(i),i+=n;else if(n<0)for(;l(i,t);)r.push(i),i+=n;return r}function h(e,t,n){var r=i(0),s=[],l=e;if(n.gt(r))for(;o(l,t);)s.push(l),l=l.plus(n);else if(n.lt(r))for(;a(l,t);)s.push(l),l=l.plus(n);return s}function f(e,t,n){var r=i(0),o=[],a=e;if(n.gt(r))for(;s(a,t);)o.push(a),a=a.plus(n);else if(n.lt(r))for(;l(a,t);)o.push(a),a=a.plus(n);return o}}),eU="reshape",tU=kB(eU,["typed","isInteger","matrix"],function(e){var t=e.typed,n=e.isInteger,r=e.matrix;return t(eU,{"Matrix, Array":function(e,t){return e.reshape?e.reshape(t):r(vB(e.valueOf(),t))},"Array, Array":function(e,t){return t.forEach(function(e){if(!n(e))throw new TypeError("Invalid size for dimension: "+e)}),vB(e,t)}})});function nU(e,t,n,r){if(!(this instanceof nU))throw new SyntaxError("Constructor must be called with the new operator");this.fn=e,this.count=t,this.min=n,this.max=r,this.message="Wrong number of arguments in function "+e+" ("+t+" provided, "+n+(null!=r?"-"+r:"")+" expected)",this.stack=(new Error).stack}nU.prototype=new Error,nU.prototype.constructor=Error,nU.prototype.name="ArgumentsError",nU.prototype.isArgumentsError=!0;var rU=kB("resize",["config","matrix"],function(e){var t=e.config,n=e.matrix;return function(e,r,i){if(2!==arguments.length&&3!==arguments.length)throw new nU("resize",arguments.length,2,3);if(JI(r)&&(r=r.valueOf()),UI(r[0])&&(r=r.map(function(e){return UI(e)?e.toNumber():e})),JI(e))return e.resize(r,i,!0);if("string"==typeof e)return function(e,t,n){if(void 0!==n){if("string"!=typeof n||1!==n.length)throw new TypeError("Single character expected as defaultValue")}else n=" ";if(1!==t.length)throw new uB(t.length,1);var r=t[0];if("number"!=typeof r||!BL(r))throw new TypeError("Invalid size, must contain positive integers (size: "+aB(t)+")");if(e.length>r)return e.substring(0,r);if(e.length<r){for(var i=e,o=0,s=r-e.length;o<s;o++)i+=n;return i}return e}(e,r,i);var o=!Array.isArray(e)&&"Array"!==t.matrix;if(0===r.length){for(;Array.isArray(e);)e=e[0];return kL(e)}Array.isArray(e)||(e=[e]);var s=gB(e=kL(e),r,i);return o?n(s):s}}),iU="rotate",oU=kB(iU,["typed","multiply","rotationMatrix"],function(e){var t=e.typed,n=e.multiply,r=e.rotationMatrix;return t(iU,{"Array , number | BigNumber | Complex | Unit":function(e,t){return i(e,2),n(r(t),e).toArray()},"Matrix , number | BigNumber | Complex | Unit":function(e,t){return i(e,2),n(r(t),e)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,o){return i(e,3),n(r(t,o),e)},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,o){return i(e,3),n(r(t,o),e)}});function i(e,t){var n=Array.isArray(e)?pB(e):e.size();if(n.length>2)throw new RangeError("Vector must be of dimensions 1x".concat(t));if(2===n.length&&1!==n[1])throw new RangeError("Vector must be of dimensions 1x".concat(t));if(n[0]!==t)throw new RangeError("Vector must be of dimensions 1x".concat(t))}}),sU="rotationMatrix",aU=kB(sU,["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],function(e){var t=e.typed,n=e.config,r=e.multiplyScalar,i=e.addScalar,o=e.unaryMinus,s=e.norm,a=e.BigNumber,l=e.matrix,c=e.DenseMatrix,u=e.SparseMatrix,d=e.cos,p=e.sin;return t(sU,{"":function(){return"Matrix"===n.matrix?l([]):[]},string:function(e){return l(e)},"number | BigNumber | Complex | Unit":function(e){return h(e,"Matrix"===n.matrix?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(e,t){return h(e,t)},"number | BigNumber | Complex | Unit, Array":function(e,t){var n=l(t);return f(n),y(e,n,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(e,t){f(t);var r=t.storage()||("Matrix"===n.matrix?"dense":void 0);return y(e,t,r)},"number | BigNumber | Complex | Unit, Array, string":function(e,t,n){var r=l(t);return f(r),y(e,r,n)},"number | BigNumber | Complex | Unit, Matrix, string":function(e,t,n){return f(t),y(e,t,n)}});function h(e,t){var n=UI(e)?new a(-1):-1,i=d(e),o=p(e);return g([[i,r(n,o)],[o,i]],t)}function f(e){var t=e.size();if(t.length<1||3!==t[0])throw new RangeError("Vector must be of dimensions 1x3")}function m(e){return e.reduce(function(e,t){return r(e,t)})}function g(e,t){if(t){if("sparse"===t)return new u(e);if("dense"===t)return new c(e);throw new TypeError('Unknown matrix type "'.concat(t,'"'))}return e}function y(e,t,n){var r=s(t);if(0===r)throw new RangeError("Rotation around zero vector");var l=UI(e)?a:null,c=l?new l(1):1,u=l?new l(-1):-1,h=l?new l(t.get([0])/r):t.get([0])/r,f=l?new l(t.get([1])/r):t.get([1])/r,y=l?new l(t.get([2])/r):t.get([2])/r,v=d(e),b=i(c,o(v)),w=p(e);return g([[i(v,m([h,h,b])),i(m([h,f,b]),m([u,y,w])),i(m([h,y,b]),m([f,w]))],[i(m([h,f,b]),m([y,w])),i(v,m([f,f,b])),i(m([f,y,b]),m([u,h,w]))],[i(m([h,y,b]),m([u,f,w])),i(m([f,y,b]),m([h,w])),i(v,m([y,y,b]))]],n)}}),lU=kB("row",["typed","Index","matrix","range"],function(e){var t=e.typed,n=e.Index,r=e.matrix,i=e.range;return t("row",{"Matrix, number":o,"Array, number":function(e,t){return o(r(kL(e)),t).valueOf()}});function o(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");mB(t,e.size()[0]);var r=i(0,e.size()[1]),o=new n(t,r);return e.subset(o)}}),cU="size",uU=kB(cU,["typed","config","?matrix"],function(e){var t=e.typed,n=e.config,r=e.matrix;return t(cU,{Matrix:function(e){return e.create(e.size())},Array:pB,string:function(e){return"Array"===n.matrix?[e.length]:r([e.length])},"number | Complex | BigNumber | Unit | boolean | null":function(e){return"Array"===n.matrix?[]:r?r([]):ZH()}})}),dU="squeeze",pU=kB(dU,["typed","matrix"],function(e){var t=e.typed,n=e.matrix;return t(dU,{Array:function(e){return bB(kL(e))},Matrix:function(e){var t=bB(e.toArray());return Array.isArray(t)?n(t):t},any:function(e){return kL(e)}})});function hU(e){return hU="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},hU(e)}function fU(e,t){if(gU(e)&&mU(e,t))return e[t];if("function"==typeof e[t]&&function(e,t){if(null==e||"function"!=typeof e[t])return!1;if(_L(e,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(e))return!1;if(_L(vU,t))return!0;if(t in Object.prototype)return!1;if(t in Function.prototype)return!1;return!0}(e,t))throw new Error('Cannot access method "'+t+'" as a property');throw new Error('No access to property "'+t+'"')}function mU(e,t){return!(!e||"object"!==hU(e))&&(!!_L(yU,t)||!(t in Object.prototype)&&!(t in Function.prototype))}function gU(e){return"object"===hU(e)&&e&&e.constructor===Object}var yU={length:!0,name:!0},vU={toString:!0,valueOf:!0,toLocaleString:!0},bU="subset",wU=kB(bU,["typed","matrix"],function(e){var t=e.typed,n=e.matrix;return t(bU,{"Array, Index":function(e,t){var r=n(e).subset(t);return t.isScalar()?r:r.valueOf()},"Matrix, Index":function(e,t){return e.subset(t)},"Object, Index":SU,"string, Index":xU,"Array, Index, any":function(e,t,r){return n(kL(e)).subset(t,r,void 0).valueOf()},"Array, Index, any, any":function(e,t,r,i){return n(kL(e)).subset(t,r,i).valueOf()},"Matrix, Index, any":function(e,t,n){return e.clone().subset(t,n)},"Matrix, Index, any, any":function(e,t,n,r){return e.clone().subset(t,n,r)},"string, Index, string":MU,"string, Index, string, string":MU,"Object, Index, any":EU})});function xU(e,t){if(!eL(t))throw new TypeError("Index expected");if(1!==t.size().length)throw new uB(t.size().length,1);var n=e.length;mB(t.min()[0],n),mB(t.max()[0],n);var r=t.dimension(0),i="";return r.forEach(function(t){i+=e.charAt(t)}),i}function MU(e,t,n,r){if(!t||!0!==t.isIndex)throw new TypeError("Index expected");if(1!==t.size().length)throw new uB(t.size().length,1);if(void 0!==r){if("string"!=typeof r||1!==r.length)throw new TypeError("Single character expected as defaultValue")}else r=" ";var i=t.dimension(0);if(i.size()[0]!==n.length)throw new uB(i.size()[0],n.length);var o=e.length;mB(t.min()[0]),mB(t.max()[0]);for(var s=[],a=0;a<o;a++)s[a]=e.charAt(a);if(i.forEach(function(e,t){s[e]=n.charAt(t[0])}),s.length>o)for(var l=o-1,c=s.length;l<c;l++)s[l]||(s[l]=r);return s.join("")}function SU(e,t){if(1!==t.size().length)throw new uB(t.size(),1);var n=t.dimension(0);if("string"!=typeof n)throw new TypeError("String expected as index to retrieve an object property");return fU(e,n)}function EU(e,t,n){if(1!==t.size().length)throw new uB(t.size(),1);var r=t.dimension(0);if("string"!=typeof r)throw new TypeError("String expected as index to retrieve an object property");var i=kL(e);return function(e,t,n){if(gU(e)&&mU(e,t))return e[t]=n,n;throw new Error('No access to property "'+t+'"')}(i,r,n),i}var CU=kB("transpose",["typed","matrix"],function(e){var t=e.typed,n=e.matrix;return t("transpose",{Array:function(e){return this(n(e)).valueOf()},Matrix:function(e){var t,n=e.size();switch(n.length){case 1:t=e.clone();break;case 2:var r=n[0],i=n[1];if(0===i)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+aB(n)+")");switch(e.storage()){case"dense":t=function(e,t,n){for(var r,i=e._data,o=[],s=0;s<n;s++){r=o[s]=[];for(var a=0;a<t;a++)r[a]=kL(i[a][s])}return e.createDenseMatrix({data:o,size:[n,t],datatype:e._datatype})}(e,r,i);break;case"sparse":t=function(e,t,n){for(var r,i,o,s=e._values,a=e._index,l=e._ptr,c=s?[]:void 0,u=[],d=[],p=[],h=0;h<t;h++)p[h]=0;for(r=0,i=a.length;r<i;r++)p[a[r]]++;for(var f=0,m=0;m<t;m++)d.push(f),f+=p[m],p[m]=d[m];for(d.push(f),o=0;o<n;o++)for(var g=l[o],y=l[o+1],v=g;v<y;v++){var b=p[a[v]]++;u[b]=o,s&&(c[b]=kL(s[v]))}return e.createSparseMatrix({values:c,index:u,ptr:d,size:[n,t],datatype:e._datatype})}(e,r,i)}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+aB(this._size)+")")}return t},any:function(e){return kL(e)}})}),NU="ctranspose",AU=kB(NU,["typed","transpose","conj"],function(e){var t=e.typed,n=e.transpose,r=e.conj;return t(NU,{any:function(e){return r(n(e))}})}),kU="zeros",TU=kB(kU,["typed","config","matrix","BigNumber"],function(e){var t=e.typed,n=e.config,r=e.matrix,i=e.BigNumber;return t(kU,{"":function(){return"Array"===n.matrix?o([]):o([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var t=e.pop();return o(e,t)}return"Array"===n.matrix?o(e):o(e,"default")},Array:o,Matrix:function(e){var t=e.storage();return o(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return o(e.valueOf(),t)}});function o(e,t){var n=function(e){var t=!1;return e.forEach(function(e,n,r){UI(e)&&(t=!0,r[n]=e.toNumber())}),t}(e),o=n?new i(0):0;if(function(e){e.forEach(function(e){if("number"!=typeof e||!BL(e)||e<0)throw new Error("Parameters in function zeros must be positive integers")})}(e),t){var s=r(t);return e.length>0?s.resize(e,o):s}var a=[];return e.length>0?gB(a,e,o):a}}),OU=kB("erf",["typed"],function(e){return(0,e.typed)("name",{number:function(e){var t=Math.abs(e);return t>=LU?zL(e):t<=_U?zL(e)*function(e){var t,n=e*e,r=DU[0][4]*n,i=n;for(t=0;t<3;t+=1)r=(r+DU[0][t])*n,i=(i+IU[0][t])*n;return e*(r+DU[0][3])/(i+IU[0][3])}(t):t<=4?zL(e)*(1-function(e){var t,n=DU[1][8]*e,r=e;for(t=0;t<7;t+=1)n=(n+DU[1][t])*e,r=(r+IU[1][t])*e;var i=(n+DU[1][7])/(r+IU[1][7]),o=parseInt(16*e)/16,s=(e-o)*(e+o);return Math.exp(-o*o)*Math.exp(-s)*i}(t)):zL(e)*(1-function(e){var t,n=1/(e*e),r=DU[2][5]*n,i=n;for(t=0;t<4;t+=1)r=(r+DU[2][t])*n,i=(i+IU[2][t])*n;var o=n*(r+DU[2][4])/(i+IU[2][4]);o=(RU-o)/e,n=parseInt(16*e)/16;var s=(e-n)*(e+n);return Math.exp(-n*n)*Math.exp(-s)*o}(t))},"Array | Matrix":function(e){return KP(e,this)}})}),_U=.46875,RU=.5641895835477563,DU=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,2.1531153547440383e-8],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],IU=[[23.601290952344122,244.02463793444417,1282.6165260773723,2844.236833439171],[15.744926110709835,117.6939508913125,537.1811018620099,1621.3895745666903,3290.7992357334597,4362.619090143247,3439.3676741437216,1230.3393548037495],[2.568520192289822,1.8729528499234604,.5279051029514285,.06051834131244132,.0023352049762686918]],LU=Math.pow(2,53),BU="mode",zU=kB(BU,["typed","isNaN","isNumeric"],function(e){var t=e.typed,n=e.isNaN,r=e.isNumeric;return t(BU,{"Array | Matrix":i,"...":function(e){return i(e)}});function i(e){if(0===(e=SB(e.valueOf())).length)throw new Error("Cannot calculate mode of an empty array");for(var t={},i=[],o=0,s=0;s<e.length;s++){var a=e[s];if(r(a)&&n(a))throw new Error("Cannot calculate mode of an array containing NaN values");a in t||(t[a]=0),t[a]++,t[a]===o?i.push(a):t[a]>o&&(o=t[a],i=[a])}return i}});function PU(e,t,n){var r;return-1!==String(e).indexOf("Unexpected type")?(r=arguments.length>2?" (type: "+NL(n)+", value: "+JSON.stringify(n)+")":" (type: "+e.data.actual+")",new TypeError("Cannot calculate "+t+", unexpected type of argument"+r)):-1!==String(e).indexOf("complex numbers")?(r=arguments.length>2?" (type: "+NL(n)+", value: "+JSON.stringify(n)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+r)):e}var jU="prod",FU=kB(jU,["typed","config","multiplyScalar","numeric"],function(e){var t=e.typed,n=e.config,r=e.multiplyScalar,i=e.numeric;return t(jU,{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("prod(A, dim) is not yet supported")},"...":function(e){return o(e)}});function o(e){var t;if(WP(e,function(e){try{t=void 0===t?e:r(t,e)}catch(t){throw PU(t,"prod",e)}}),"string"==typeof t&&(t=i(t,n.number)),void 0===t)throw new Error("Cannot calculate prod of an empty array");return t}}),$U="format",HU=kB($U,["typed"],function(e){return(0,e.typed)($U,{any:aB,"any, Object | function | number":aB})});function UU(e){var t={2:"0b",8:"0o",16:"0x"}[e];return function(n){if(n>Math.pow(2,31)-1||n<-Math.pow(2,31))throw new Error("Value must be in range [-2^31, 2^31-1]");if(!BL(n))throw new Error("Value must be an integer");return n<0&&(n+=Math.pow(2,32)),"".concat(t).concat(n.toString(e))}}var qU=["typed"];function VU(e,t){return kB(e,qU,function(n){return(0,n.typed)(e,{number:UU(t)})})}var WU=VU("bin",2),KU=VU("oct",8),GU=VU("hex",16),JU="print",YU=kB(JU,["typed"],function(e){return(0,e.typed)(JU,{"string, Object | Array":ZU,"string, Object | Array, number | Object":ZU})});function ZU(e,t,n){return e.replace(/\$([\w.]+)/g,function(e,r){for(var i=r.split("."),o=t[i.shift()];i.length&&void 0!==o;){var s=i.shift();o=s?o[s]:o+"."}return void 0!==o?KI(o)?o:aB(o,n):e})}var XU=kB("to",["typed","matrix"],function(e){var t=e.typed,n=e.matrix,r=y$({typed:t}),i=t$({typed:t});return t("to",{"Unit, Unit | string":function(e,t){return e.to(t)},"Matrix, Matrix":function(e,t){return r(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"Matrix, any":function(e,t){return i(e,t,this,!1)},"any, Matrix":function(e,t){return i(t,e,this,!0)},"Array, any":function(e,t){return i(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return i(n(t),e,this,!0).valueOf()}})}),QU="isPrime",eq=kB(QU,["typed"],function(e){return(0,e.typed)(QU,{number:function(e){if(0*e!=0)return!1;if(e<=3)return e>1;if(e%2==0||e%3==0)return!1;for(var t=5;t*t<=e;t+=6)if(e%t===0||e%(t+2)===0)return!1;return!0},BigNumber:function(e){if(0*e.toNumber()!=0)return!1;if(e.lte(3))return e.gt(1);if(e.mod(2).eq(0)||e.mod(3).eq(0))return!1;for(var t=5;e.gte(t*t);t+=6)if(e.mod(t).eq(0)||e.mod(t+2).eq(0))return!1;return!0},"Array | Matrix":function(e){return KP(e,this)}})}),tq=kB("numeric",["number","?bignumber","?fraction"],function(e){var t=e.number,n=e.bignumber,r=e.fraction,i={string:!0,number:!0,BigNumber:!0,Fraction:!0},o={number:function(e){return t(e)},BigNumber:n?function(e){return n(e)}:JH,Fraction:r?function(e){return r(e)}:YH};return function(e,t){var n=NL(e);if(!(n in i))throw new TypeError("Cannot convert "+e+' of type "'+n+'"; valid input types are '+Object.keys(i).join(", "));if(!(t in o))throw new TypeError("Cannot convert "+e+' to type "'+t+'"; valid output types are '+Object.keys(o).join(", "));return t===n?e:o[t](e)}}),nq="divideScalar",rq=kB(nq,["typed","numeric"],function(e){var t=e.typed,n=e.numeric;return t(nq,{"number, number":function(e,t){return e/t},"Complex, Complex":function(e,t){return e.div(t)},"BigNumber, BigNumber":function(e,t){return e.div(t)},"Fraction, Fraction":function(e,t){return e.div(t)},"Unit, number | Fraction | BigNumber":function(e,t){var r=e.clone(),i=n(1,NL(t));return r.value=this(null===r.value?r._normalize(i):r.value,t),r},"number | Fraction | BigNumber, Unit":function(e,t){var r=t.clone();r=r.pow(-1);var i=n(1,NL(e));return r.value=this(e,null===t.value?t._normalize(i):t.value),r},"Unit, Unit":function(e,t){return e.divide(t)}})}),iq=kB("pow",["typed","config","identity","multiply","matrix","fraction","number","Complex"],function(e){var t=e.typed,n=e.config,r=e.identity,i=e.multiply,o=e.matrix,s=e.number,a=e.fraction,l=e.Complex;return t("pow",{"number, number":c,"Complex, Complex":function(e,t){return e.pow(t)},"BigNumber, BigNumber":function(e,t){return t.isInteger()||e>=0||n.predictable?e.pow(t):new l(e.toNumber(),0).pow(t.toNumber(),0)},"Fraction, Fraction":function(e,t){if(1!==t.d){if(n.predictable)throw new Error("Function pow does not support non-integer exponents for fractions.");return c(e.valueOf(),t.valueOf())}return e.pow(t)},"Array, number":u,"Array, BigNumber":function(e,t){return u(e,t.toNumber())},"Matrix, number":d,"Matrix, BigNumber":function(e,t){return d(e,t.toNumber())},"Unit, number | BigNumber":function(e,t){return e.pow(t)}});function c(e,t){if(n.predictable&&!BL(t)&&e<0)try{var r=a(t),i=s(r);if((t===i||Math.abs((t-i)/t)<1e-14)&&r.d%2==1)return(r.n%2==0?1:-1)*Math.pow(-e,t)}catch(e){}return n.predictable&&(e<-1&&t===1/0||e>-1&&e<0&&t===-1/0)?NaN:BL(t)||e>=0||n.predictable?xj(e,t):e*e<1&&t===1/0||e*e>1&&t===-1/0?0:new l(e,0).pow(t,0)}function u(e,t){if(!BL(t)||t<0)throw new TypeError("For A^b, b must be a positive integer (value is "+t+")");var n=pB(e);if(2!==n.length)throw new Error("For A^b, A must be 2 dimensional (A has "+n.length+" dimensions)");if(n[0]!==n[1])throw new Error("For A^b, A must be square (size is "+n[0]+"x"+n[1]+")");for(var o=r(n[0]).valueOf(),s=e;t>=1;)1&~t||(o=i(s,o)),t>>=1,s=i(s,s);return o}function d(e,t){return o(u(e.valueOf(),t))}});function oq(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 sq(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?oq(Object(n),!0).forEach(function(t){aq(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):oq(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function aq(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var lq="Number of decimals in function round must be an integer",cq="round",uq=kB(cq,["typed","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.equalScalar,i=e.zeros,o=e.BigNumber,s=e.DenseMatrix,a=e$({typed:t,equalScalar:r}),l=k$({typed:t,DenseMatrix:s}),c=t$({typed:t});return t(cq,sq(sq({},dq),{},{Complex:function(e){return e.round()},"Complex, number":function(e,t){if(t%1)throw new TypeError(lq);return e.round(t)},"Complex, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(lq);var n=t.toNumber();return e.round(n)},"number, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(lq);return new o(e).toDecimalPlaces(t.toNumber())},BigNumber:function(e){return e.toDecimalPlaces(0)},"BigNumber, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(lq);return e.toDecimalPlaces(t.toNumber())},Fraction:function(e){return e.round()},"Fraction, number":function(e,t){if(t%1)throw new TypeError(lq);return e.round(t)},"Array | Matrix":function(e){return KP(e,this)},"SparseMatrix, number | BigNumber":function(e,t){return a(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return c(e,t,this,!1)},"number | Complex | BigNumber, SparseMatrix":function(e,t){return r(e,0)?i(t.size(),t.storage()):l(t,e,this,!0)},"number | Complex | BigNumber, DenseMatrix":function(e,t){return r(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return c(n(e),t,this,!1).valueOf()},"number | Complex | BigNumber, Array":function(e,t){return c(n(t),e,this,!0).valueOf()}}))}),dq={number:Mj,"number, number":function(e,t){if(!BL(t))throw new TypeError(lq);if(t<0||t>15)throw new Error("Number of decimals in function round must be in te range of 0-15");return Mj(e,t)}};kB(cq,["typed"],function(e){return(0,e.typed)(cq,dq)});var pq=kB("log",["config","typed","divideScalar","Complex"],function(e){var t=e.typed,n=e.config,r=e.divideScalar,i=e.Complex;return t("log",{number:function(e){return e>=0||n.predictable?hj(e):new i(e,0).log()},Complex:function(e){return e.log()},BigNumber:function(e){return!e.isNegative()||n.predictable?e.ln():new i(e.toNumber(),0).log()},"Array | Matrix":function(e){return KP(e,this)},"any, any":function(e,t){return r(this(e),this(t))}})}),hq="log1p",fq=kB(hq,["typed","config","divideScalar","log","Complex"],function(e){var t=e.typed,n=e.config,r=e.divideScalar,i=e.log,o=e.Complex;return t(hq,{number:function(e){return e>=-1||n.predictable?FL(e):s(new o(e,0))},Complex:s,BigNumber:function(e){var t=e.plus(1);return!t.isNegative()||n.predictable?t.ln():s(new o(e.toNumber(),0))},"Array | Matrix":function(e){return KP(e,this)},"any, any":function(e,t){return r(this(e),i(t))}});function s(e){var t=e.re+1;return new o(Math.log(Math.sqrt(t*t+e.im*e.im)),Math.atan2(e.im,t))}}),mq="nthRoots",gq=kB(mq,["config","typed","divideScalar","Complex"],function(e){var t=e.typed;e.config,e.divideScalar;var n=e.Complex,r=[function(e){return new n(e,0)},function(e){return new n(0,e)},function(e){return new n(-e,0)},function(e){return new n(0,-e)}];function i(e,t){if(t<0)throw new Error("Root must be greater than zero");if(0===t)throw new Error("Root must be non-zero");if(t%1!=0)throw new Error("Root must be an integer");if(0===e||0===e.abs())return[new n(0,0)];var i,o="number"==typeof e;(o||0===e.re||0===e.im)&&(i=o?2*+(e<0):0===e.im?2*+(e.re<0):2*+(e.im<0)+1);for(var s=e.arg(),a=e.abs(),l=[],c=Math.pow(a,1/t),u=0;u<t;u++){var d=(i+4*u)/t;d!==Math.round(d)?l.push(new n({r:c,phi:(s+2*Math.PI*u)/t})):l.push(r[d%4](c))}return l}return t(mq,{Complex:function(e){return i(e,2)},"Complex, number":i})}),yq="dotPow",vq=kB(yq,["typed","equalScalar","matrix","pow","DenseMatrix"],function(e){var t=e.typed,n=e.equalScalar,r=e.matrix,i=e.pow,o=e.DenseMatrix,s=N$({typed:t}),a=lH({typed:t,DenseMatrix:o}),l=e$({typed:t,equalScalar:n}),c=k$({typed:t,DenseMatrix:o}),u=y$({typed:t}),d=t$({typed:t});return t(yq,{"any, any":i,"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,i,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,i,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,i,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,i)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return l(e,t,this,!1)},"DenseMatrix, any":function(e,t){return d(e,t,this,!1)},"any, SparseMatrix":function(e,t){return c(t,e,this,!0)},"any, DenseMatrix":function(e,t){return d(t,e,this,!0)},"Array, any":function(e,t){return d(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return d(r(t),e,this,!0).valueOf()}})}),bq="dotDivide",wq=kB(bq,["typed","matrix","equalScalar","divideScalar","DenseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.equalScalar,i=e.divideScalar,o=e.DenseMatrix,s=b$({typed:t,equalScalar:r}),a=N$({typed:t}),l=lH({typed:t,DenseMatrix:o}),c=e$({typed:t,equalScalar:r}),u=k$({typed:t,DenseMatrix:o}),d=y$({typed:t}),p=t$({typed:t});return t(bq,{"any, any":i,"SparseMatrix, SparseMatrix":function(e,t){return l(e,t,i,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,i,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,i,!1)},"DenseMatrix, DenseMatrix":function(e,t){return d(e,t,i)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return c(e,t,i,!1)},"DenseMatrix, any":function(e,t){return p(e,t,i,!1)},"any, SparseMatrix":function(e,t){return u(t,e,i,!0)},"any, DenseMatrix":function(e,t){return p(t,e,i,!0)},"Array, any":function(e,t){return p(n(e),t,i,!1).valueOf()},"any, Array":function(e,t){return p(n(t),e,i,!0).valueOf()}})});function xq(e){var t=e.DenseMatrix;return function(e,n,r){var i=e.size();if(2!==i.length)throw new RangeError("Matrix must be two dimensional (size: "+aB(i)+")");var o=i[0];if(o!==i[1])throw new RangeError("Matrix must be square (size: "+aB(i)+")");var s=[];if(JI(n)){var a=n.size(),l=n._data;if(1===a.length){if(a[0]!==o)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var c=0;c<o;c++)s[c]=[l[c]];return new t({data:s,size:[o,1],datatype:n._datatype})}if(2===a.length){if(a[0]!==o||1!==a[1])throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");if(ZI(n)){if(r){s=[];for(var u=0;u<o;u++)s[u]=[l[u][0]];return new t({data:s,size:[o,1],datatype:n._datatype})}return n}if(XI(n)){for(var d=0;d<o;d++)s[d]=[0];for(var p=n._values,h=n._index,f=n._ptr,m=f[1],g=f[0];g<m;g++){s[h[g]][0]=p[g]}return new t({data:s,size:[o,1],datatype:n._datatype})}}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}if(GI(n)){var y=pB(n);if(1===y.length){if(y[0]!==o)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var v=0;v<o;v++)s[v]=[n[v]];return new t({data:s,size:[o,1]})}if(2===y.length){if(y[0]!==o||1!==y[1])throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var b=0;b<o;b++)s[b]=[n[b][0]];return new t({data:s,size:[o,1]})}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}}}var Mq="lsolve",Sq=kB(Mq,["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.divideScalar,i=e.multiplyScalar,o=e.subtract,s=e.equalScalar,a=e.DenseMatrix,l=xq({DenseMatrix:a});return t(Mq,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var n=(t=l(e,t,!0))._data,c=e._size[0],u=e._size[1],d=e._values,p=e._index,h=e._ptr,f=[],m=0;m<u;m++){var g=n[m][0]||0;if(s(g,0))f[m]=[0];else{for(var y=0,v=[],b=[],w=h[m],x=h[m+1],M=w;M<x;M++){var S=p[M];S===m?y=d[M]:S>m&&(v.push(d[M]),b.push(S))}if(s(y,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var E=r(g,y),C=0,N=b.length;C<N;C++){var A=b[C];n[A]=[o(n[A][0]||0,i(E,v[C]))]}f[m]=[E]}}return new a({data:f,size:[c,1]})}(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return c(e,t)},"Array, Array | Matrix":function(e,t){return c(n(e),t).valueOf()}});function c(e,t){for(var n=(t=l(e,t,!0))._data,c=e._size[0],u=e._size[1],d=[],p=e._data,h=0;h<u;h++){var f=n[h][0]||0,m=void 0;if(s(f,0))m=0;else{var g=p[h][h];if(s(g,0))throw new Error("Linear system cannot be solved since matrix is singular");m=r(f,g);for(var y=h+1;y<c;y++)n[y]=[o(n[y][0]||0,i(m,p[y][h]))]}d[h]=[m]}return new a({data:d,size:[c,1]})}}),Eq="usolve",Cq=kB(Eq,["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.divideScalar,i=e.multiplyScalar,o=e.subtract,s=e.equalScalar,a=e.DenseMatrix,l=xq({DenseMatrix:a});return t(Eq,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var n=(t=l(e,t,!0))._data,c=e._size[0],u=e._size[1],d=e._values,p=e._index,h=e._ptr,f=[],m=u-1;m>=0;m--){var g=n[m][0]||0;if(s(g,0))f[m]=[0];else{for(var y=0,v=[],b=[],w=h[m],x=h[m+1]-1;x>=w;x--){var M=p[x];M===m?y=d[x]:M<m&&(v.push(d[x]),b.push(M))}if(s(y,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var S=r(g,y),E=0,C=b.length;E<C;E++){var N=b[E];n[N]=[o(n[N][0],i(S,v[E]))]}f[m]=[S]}}return new a({data:f,size:[c,1]})}(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return c(e,t)},"Array, Array | Matrix":function(e,t){return c(n(e),t).valueOf()}});function c(e,t){for(var n=(t=l(e,t,!0))._data,c=e._size[0],u=e._size[1],d=[],p=e._data,h=u-1;h>=0;h--){var f=n[h][0]||0,m=void 0;if(s(f,0))m=0;else{var g=p[h][h];if(s(g,0))throw new Error("Linear system cannot be solved since matrix is singular");m=r(f,g);for(var y=h-1;y>=0;y--)n[y]=[o(n[y][0]||0,i(m,p[y][h]))]}d[h]=[m]}return new a({data:d,size:[c,1]})}});function Nq(e){return function(e){if(Array.isArray(e))return Aq(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return Aq(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Aq(e,t)}(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 Aq(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var kq="lsolveAll",Tq=kB(kq,["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.divideScalar,i=e.multiplyScalar,o=e.subtract,s=e.equalScalar,a=e.DenseMatrix,l=xq({DenseMatrix:a});return t(kq,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var n=[l(e,t,!0)._data.map(function(e){return e[0]})],c=e._size[0],u=e._size[1],d=e._values,p=e._index,h=e._ptr,f=0;f<u;f++)for(var m=n.length,g=0;g<m;g++){for(var y=n[g],v=[],b=[],w=h[f],x=h[f+1],M=0,S=w;S<x;S++){var E=p[S];E===f?M=d[S]:E>f&&(v.push(d[S]),b.push(E))}if(s(M,0))if(s(y[f],0)){if(0===g){var C=Nq(y);C[f]=1;for(var N=0,A=b.length;N<A;N++){var k=b[N];C[k]=o(C[k],v[N])}n.push(C)}}else{if(0===g)return[];n.splice(g,1),g-=1,m-=1}else{y[f]=r(y[f],M);for(var T=0,O=b.length;T<O;T++){var _=b[T];y[_]=o(y[_],i(y[f],v[T]))}}}return n.map(function(e){return new a({data:e.map(function(e){return[e]}),size:[c,1]})})}(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return c(e,t)},"Array, Array | Matrix":function(e,t){return c(n(e),t).map(function(e){return e.valueOf()})}});function c(e,t){for(var n=[l(e,t,!0)._data.map(function(e){return e[0]})],c=e._data,u=e._size[0],d=e._size[1],p=0;p<d;p++)for(var h=n.length,f=0;f<h;f++){var m=n[f];if(s(c[p][p],0))if(s(m[p],0)){if(0===f){var g=Nq(m);g[p]=1;for(var y=p+1;y<d;y++)g[y]=o(g[y],c[y][p]);n.push(g)}}else{if(0===f)return[];n.splice(f,1),f-=1,h-=1}else{m[p]=r(m[p],c[p][p]);for(var v=p+1;v<d;v++)m[v]=o(m[v],i(m[p],c[v][p]))}}return n.map(function(e){return new a({data:e.map(function(e){return[e]}),size:[u,1]})})}});function Oq(e){return function(e){if(Array.isArray(e))return _q(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return _q(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _q(e,t)}(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 _q(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Rq="usolveAll",Dq=kB(Rq,["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.divideScalar,i=e.multiplyScalar,o=e.subtract,s=e.equalScalar,a=e.DenseMatrix,l=xq({DenseMatrix:a});return t(Rq,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var n=[l(e,t,!0)._data.map(function(e){return e[0]})],c=e._size[0],u=e._size[1],d=e._values,p=e._index,h=e._ptr,f=u-1;f>=0;f--)for(var m=n.length,g=0;g<m;g++){for(var y=n[g],v=[],b=[],w=h[f],x=0,M=h[f+1]-1;M>=w;M--){var S=p[M];S===f?x=d[M]:S<f&&(v.push(d[M]),b.push(S))}if(s(x,0))if(s(y[f],0)){if(0===g){var E=Oq(y);E[f]=1;for(var C=0,N=b.length;C<N;C++){var A=b[C];E[A]=o(E[A],v[C])}n.push(E)}}else{if(0===g)return[];n.splice(g,1),g-=1,m-=1}else{y[f]=r(y[f],x);for(var k=0,T=b.length;k<T;k++){var O=b[k];y[O]=o(y[O],i(y[f],v[k]))}}}return n.map(function(e){return new a({data:e.map(function(e){return[e]}),size:[c,1]})})}(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return c(e,t)},"Array, Array | Matrix":function(e,t){return c(n(e),t).map(function(e){return e.valueOf()})}});function c(e,t){for(var n=[l(e,t,!0)._data.map(function(e){return e[0]})],c=e._data,u=e._size[0],d=e._size[1]-1;d>=0;d--)for(var p=n.length,h=0;h<p;h++){var f=n[h];if(s(c[d][d],0))if(s(f[d],0)){if(0===h){var m=Oq(f);m[d]=1;for(var g=d-1;g>=0;g--)m[g]=o(m[g],c[g][d]);n.push(m)}}else{if(0===h)return[];n.splice(h,1),h-=1,p-=1}else{f[d]=r(f[d],c[d][d]);for(var y=d-1;y>=0;y--)f[y]=o(f[y],i(f[d],c[y][d]))}}return n.map(function(e){return new a({data:e.map(function(e){return[e]}),size:[u,1]})})}}),Iq=kB("algorithm08",["typed","equalScalar"],function(e){var t=e.typed,n=e.equalScalar;return function(e,r,i){var o=e._values,s=e._index,a=e._ptr,l=e._size,c=e._datatype,u=r._values,d=r._index,p=r._ptr,h=r._size,f=r._datatype;if(l.length!==h.length)throw new uB(l.length,h.length);if(l[0]!==h[0]||l[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+h+")");if(!o||!u)throw new Error("Cannot perform operation on Pattern Sparse Matrices");var m,g=l[0],y=l[1],v=n,b=0,w=i;"string"==typeof c&&c===f&&(m=c,v=t.find(n,[m,m]),b=t.convert(0,m),w=t.find(i,[m,m]));for(var x,M,S,E,C=[],N=[],A=[],k=[],T=[],O=0;O<y;O++){A[O]=N.length;var _=O+1;for(M=a[O],S=a[O+1],x=M;x<S;x++)T[E=s[x]]=_,k[E]=o[x],N.push(E);for(M=p[O],S=p[O+1],x=M;x<S;x++)T[E=d[x]]===_&&(k[E]=w(k[E],u[x]));for(x=A[O];x<N.length;){var R=k[E=N[x]];v(R,b)?N.splice(x,1):(C.push(R),x++)}}return A[y]=N.length,e.createSparseMatrix({values:C,index:N,ptr:A,size:[g,y],datatype:m})}}),Lq="leftShift",Bq=kB(Lq,["typed","matrix","equalScalar","zeros","DenseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.equalScalar,i=e.zeros,o=e.DenseMatrix,s=f$({typed:t}),a=b$({typed:t,equalScalar:r}),l=Iq({typed:t,equalScalar:r}),c=g$({typed:t,DenseMatrix:o}),u=e$({typed:t,equalScalar:r}),d=y$({typed:t}),p=t$({typed:t});return t(Lq,{"number, number":kj,"BigNumber, BigNumber":eH,"SparseMatrix, SparseMatrix":function(e,t){return l(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return d(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, number | BigNumber":function(e,t){return r(t,0)?e.clone():u(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return r(t,0)?e.clone():p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return r(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return r(e,0)?i(t.size(),t.storage()):p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(n(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,n(t)).valueOf()}})}),zq="rightArithShift",Pq=kB(zq,["typed","matrix","equalScalar","zeros","DenseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.equalScalar,i=e.zeros,o=e.DenseMatrix,s=f$({typed:t}),a=b$({typed:t,equalScalar:r}),l=Iq({typed:t,equalScalar:r}),c=g$({typed:t,DenseMatrix:o}),u=e$({typed:t,equalScalar:r}),d=y$({typed:t}),p=t$({typed:t});return t(zq,{"number, number":Tj,"BigNumber, BigNumber":tH,"SparseMatrix, SparseMatrix":function(e,t){return l(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return d(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, number | BigNumber":function(e,t){return r(t,0)?e.clone():u(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return r(t,0)?e.clone():p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return r(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return r(e,0)?i(t.size(),t.storage()):p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(n(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,n(t)).valueOf()}})}),jq="rightLogShift",Fq=kB(jq,["typed","matrix","equalScalar","zeros","DenseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.equalScalar,i=e.zeros,o=e.DenseMatrix,s=f$({typed:t}),a=b$({typed:t,equalScalar:r}),l=Iq({typed:t,equalScalar:r}),c=g$({typed:t,DenseMatrix:o}),u=e$({typed:t,equalScalar:r}),d=y$({typed:t}),p=t$({typed:t});return t(jq,{"number, number":Oj,"SparseMatrix, SparseMatrix":function(e,t){return l(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return d(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, number | BigNumber":function(e,t){return r(t,0)?e.clone():u(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return r(t,0)?e.clone():p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return r(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return r(e,0)?i(t.size(),t.storage()):p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(n(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,n(t)).valueOf()}})}),$q=kB("and",["typed","matrix","equalScalar","zeros","not"],function(e){var t=e.typed,n=e.matrix,r=e.equalScalar,i=e.zeros,o=e.not,s=b$({typed:t,equalScalar:r}),a=w$({typed:t,equalScalar:r}),l=e$({typed:t,equalScalar:r}),c=y$({typed:t}),u=t$({typed:t});return t("and",{"number, number":Fj,"Complex, Complex":function(e,t){return!(0===e.re&&0===e.im||0===t.re&&0===t.im)},"BigNumber, BigNumber":function(e,t){return!(e.isZero()||t.isZero()||e.isNaN()||t.isNaN())},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return o(t)?i(e.size(),e.storage()):l(e,t,this,!1)},"DenseMatrix, any":function(e,t){return o(t)?i(e.size(),e.storage()):u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(e)?i(e.size(),e.storage()):l(t,e,this,!0)},"any, DenseMatrix":function(e,t){return o(e)?i(e.size(),e.storage()):u(t,e,this,!0)},"Array, any":function(e,t){return this(n(e),t).valueOf()},"any, Array":function(e,t){return this(e,n(t)).valueOf()}})}),Hq="compare",Uq=kB(Hq,["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix"],function(e){var t=e.typed,n=e.config,r=e.equalScalar,i=e.matrix,o=e.BigNumber,s=e.Fraction,a=e.DenseMatrix,l=N$({typed:t}),c=A$({typed:t,equalScalar:r}),u=k$({typed:t,DenseMatrix:a}),d=y$({typed:t}),p=t$({typed:t});return t(Hq,{"boolean, boolean":function(e,t){return e===t?0:e>t?1:-1},"number, number":function(e,t){return YL(e,t,n.epsilon)?0:e>t?1:-1},"BigNumber, BigNumber":function(e,t){return NF(e,t,n.epsilon)?new o(0):new o(e.cmp(t))},"Fraction, Fraction":function(e,t){return new s(e.compare(t))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return c(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return l(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return l(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return d(e,t,this)},"Array, Array":function(e,t){return this(i(e),i(t)).valueOf()},"Array, Matrix":function(e,t){return this(i(e),t)},"Matrix, Array":function(e,t){return this(e,i(t))},"SparseMatrix, any":function(e,t){return u(e,t,this,!1)},"DenseMatrix, any":function(e,t){return p(e,t,this,!1)},"any, SparseMatrix":function(e,t){return u(t,e,this,!0)},"any, DenseMatrix":function(e,t){return p(t,e,this,!0)},"Array, any":function(e,t){return p(i(e),t,this,!1).valueOf()},"any, Array":function(e,t){return p(i(t),e,this,!0).valueOf()}})});kB(Hq,["typed","config"],function(e){var t=e.typed,n=e.config;return t(Hq,{"number, number":function(e,t){return YL(e,t,n.epsilon)?0:e>t?1:-1}})});var qq=function e(t,n){var r,i,o=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,s=/(^[ ]*|[ ]*$)/g,a=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,l=/^0x[0-9a-f]+$/i,c=/^0/,u=function(t){return e.insensitive&&(""+t).toLowerCase()||""+t},d=u(t).replace(s,"")||"",p=u(n).replace(s,"")||"",h=d.replace(o,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),f=p.replace(o,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),m=parseInt(d.match(l),16)||1!==h.length&&d.match(a)&&Date.parse(d),g=parseInt(p.match(l),16)||m&&p.match(a)&&Date.parse(p)||null;if(g){if(m<g)return-1;if(m>g)return 1}for(var y=0,v=Math.max(h.length,f.length);y<v;y++){if(r=!(h[y]||"").match(c)&&parseFloat(h[y])||h[y]||0,i=!(f[y]||"").match(c)&&parseFloat(f[y])||f[y]||0,isNaN(r)!==isNaN(i))return isNaN(r)?1:-1;if(typeof r!=typeof i&&(r+="",i+=""),r<i)return-1;if(r>i)return 1}return 0},Vq="compareNatural",Wq=kB(Vq,["typed","compare"],function(e){var t=e.typed,n=e.compare,r=n.signatures["boolean,boolean"];return t(Vq,{"any, any":function(e,t){var s,a=NL(e),l=NL(t);if(!("number"!==a&&"BigNumber"!==a&&"Fraction"!==a||"number"!==l&&"BigNumber"!==l&&"Fraction"!==l))return"0"!==(s=n(e,t)).toString()?s>0?1:-1:qq(a,l);if("Array"===a||"Matrix"===a||"Array"===l||"Matrix"===l)return 0!==(s=i(this,e,t))?s:qq(a,l);if(a!==l)return qq(a,l);if("Complex"===a)return function(e,t){if(e.re>t.re)return 1;if(e.re<t.re)return-1;if(e.im>t.im)return 1;if(e.im<t.im)return-1;return 0}(e,t);if("Unit"===a)return e.equalBase(t)?this(e.value,t.value):o(this,e.formatUnits(),t.formatUnits());if("boolean"===a)return r(e,t);if("string"===a)return qq(e,t);if("Object"===a)return function(e,t,n){var r=Object.keys(t),i=Object.keys(n);r.sort(qq),i.sort(qq);var s=o(e,r,i);if(0!==s)return s;for(var a=0;a<r.length;a++){var l=e(t[r[a]],n[i[a]]);if(0!==l)return l}return 0}(this,e,t);if("null"===a)return 0;if("undefined"===a)return 0;throw new TypeError('Unsupported type of value "'+a+'"')}});function i(e,t,n){return XI(t)&&XI(n)?o(e,t.toJSON().values,n.toJSON().values):XI(t)?i(e,t.toArray(),n):XI(n)?i(e,t,n.toArray()):ZI(t)?i(e,t.toJSON().data,n):ZI(n)?i(e,t,n.toJSON().data):Array.isArray(t)?Array.isArray(n)?o(e,t,n):i(e,t,[n]):i(e,[t],n)}function o(e,t,n){for(var r=0,i=Math.min(t.length,n.length);r<i;r++){var o=e(t[r],n[r]);if(0!==o)return o}return t.length>n.length?1:t.length<n.length?-1:0}});var Kq="compareText",Gq=kB(Kq,["typed","matrix"],function(e){var t=e.typed,n=e.matrix,r=y$({typed:t}),i=t$({typed:t});return t(Kq,{"any, any":cB,"DenseMatrix, DenseMatrix":function(e,t){return r(e,t,cB)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"DenseMatrix, any":function(e,t){return i(e,t,cB,!1)},"any, DenseMatrix":function(e,t){return i(t,e,cB,!0)},"Array, any":function(e,t){return i(n(e),t,cB,!1).valueOf()},"any, Array":function(e,t){return i(n(t),e,cB,!0).valueOf()}})});kB(Kq,["typed"],function(e){return(0,e.typed)(Kq,{"any, any":cB})});var Jq="equal",Yq=kB(Jq,["typed","matrix","equalScalar","DenseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.equalScalar,i=e.DenseMatrix,o=N$({typed:t}),s=lH({typed:t,DenseMatrix:i}),a=k$({typed:t,DenseMatrix:i}),l=y$({typed:t}),c=t$({typed:t});return t(Jq,{"any, any":function(e,t){return null===e?null===t:null===t?null===e:void 0===e?void 0===t:void 0===t?void 0===e:r(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,r)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,r,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,r,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,r)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return a(e,t,r,!1)},"DenseMatrix, any":function(e,t){return c(e,t,r,!1)},"any, SparseMatrix":function(e,t){return a(t,e,r,!0)},"any, DenseMatrix":function(e,t){return c(t,e,r,!0)},"Array, any":function(e,t){return c(n(e),t,r,!1).valueOf()},"any, Array":function(e,t){return c(n(t),e,r,!0).valueOf()}})});kB(Jq,["typed","equalScalar"],function(e){var t=e.typed,n=e.equalScalar;return t(Jq,{"any, any":function(e,t){return null===e?null===t:null===t?null===e:void 0===e?void 0===t:void 0===t?void 0===e:n(e,t)}})});var Zq="equalText",Xq=kB(Zq,["typed","compareText","isZero"],function(e){var t=e.typed,n=e.compareText,r=e.isZero;return t(Zq,{"any, any":function(e,t){return r(n(e,t))}})}),Qq="smaller",eV=kB(Qq,["typed","config","matrix","DenseMatrix"],function(e){var t=e.typed,n=e.config,r=e.matrix,i=e.DenseMatrix,o=N$({typed:t}),s=lH({typed:t,DenseMatrix:i}),a=k$({typed:t,DenseMatrix:i}),l=y$({typed:t}),c=t$({typed:t});return t(Qq,{"boolean, boolean":function(e,t){return e<t},"number, number":function(e,t){return e<t&&!YL(e,t,n.epsilon)},"BigNumber, BigNumber":function(e,t){return e.lt(t)&&!NF(e,t,n.epsilon)},"Fraction, Fraction":function(e,t){return-1===e.compare(t)},"Complex, Complex":function(e,t){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return a(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return a(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,this,!0).valueOf()}})});kB(Qq,["typed","config"],function(e){var t=e.typed,n=e.config;return t(Qq,{"number, number":function(e,t){return e<t&&!YL(e,t,n.epsilon)}})});var tV="smallerEq",nV=kB(tV,["typed","config","matrix","DenseMatrix"],function(e){var t=e.typed,n=e.config,r=e.matrix,i=e.DenseMatrix,o=N$({typed:t}),s=lH({typed:t,DenseMatrix:i}),a=k$({typed:t,DenseMatrix:i}),l=y$({typed:t}),c=t$({typed:t});return t(tV,{"boolean, boolean":function(e,t){return e<=t},"number, number":function(e,t){return e<=t||YL(e,t,n.epsilon)},"BigNumber, BigNumber":function(e,t){return e.lte(t)||NF(e,t,n.epsilon)},"Fraction, Fraction":function(e,t){return 1!==e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return a(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return a(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,this,!0).valueOf()}})});kB(tV,["typed","config"],function(e){var t=e.typed,n=e.config;return t(tV,{"number, number":function(e,t){return e<=t||YL(e,t,n.epsilon)}})});var rV="larger",iV=kB(rV,["typed","config","matrix","DenseMatrix"],function(e){var t=e.typed,n=e.config,r=e.matrix,i=e.DenseMatrix,o=N$({typed:t}),s=lH({typed:t,DenseMatrix:i}),a=k$({typed:t,DenseMatrix:i}),l=y$({typed:t}),c=t$({typed:t});return t(rV,{"boolean, boolean":function(e,t){return e>t},"number, number":function(e,t){return e>t&&!YL(e,t,n.epsilon)},"BigNumber, BigNumber":function(e,t){return e.gt(t)&&!NF(e,t,n.epsilon)},"Fraction, Fraction":function(e,t){return 1===e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return a(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return a(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,this,!0).valueOf()}})});kB(rV,["typed","config"],function(e){var t=e.typed,n=e.config;return t(rV,{"number, number":function(e,t){return e>t&&!YL(e,t,n.epsilon)}})});var oV="largerEq",sV=kB(oV,["typed","config","matrix","DenseMatrix"],function(e){var t=e.typed,n=e.config,r=e.matrix,i=e.DenseMatrix,o=N$({typed:t}),s=lH({typed:t,DenseMatrix:i}),a=k$({typed:t,DenseMatrix:i}),l=y$({typed:t}),c=t$({typed:t});return t(oV,{"boolean, boolean":function(e,t){return e>=t},"number, number":function(e,t){return e>=t||YL(e,t,n.epsilon)},"BigNumber, BigNumber":function(e,t){return e.gte(t)||NF(e,t,n.epsilon)},"Fraction, Fraction":function(e,t){return-1!==e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return a(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return a(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,this,!0).valueOf()}})});kB(oV,["typed","config"],function(e){var t=e.typed,n=e.config;return t(oV,{"number, number":function(e,t){return e>=t||YL(e,t,n.epsilon)}})});var aV="deepEqual",lV=kB(aV,["typed","equal"],function(e){var t=e.typed,n=e.equal;return t(aV,{"any, any":function(e,t){return r(e.valueOf(),t.valueOf())}});function r(e,t){if(Array.isArray(e)){if(Array.isArray(t)){var i=e.length;if(i!==t.length)return!1;for(var o=0;o<i;o++)if(!r(e[o],t[o]))return!1;return!0}return!1}return!Array.isArray(t)&&n(e,t)}}),cV="unequal",uV=kB(cV,["typed","config","equalScalar","matrix","DenseMatrix"],function(e){var t=e.typed;e.config;var n=e.equalScalar,r=e.matrix,i=e.DenseMatrix,o=N$({typed:t}),s=lH({typed:t,DenseMatrix:i}),a=k$({typed:t,DenseMatrix:i}),l=y$({typed:t}),c=t$({typed:t});return t("unequal",{"any, any":function(e,t){return null===e?null!==t:null===t?null!==e:void 0===e?void 0!==t:void 0===t?void 0!==e:u(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,u)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,u,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,u,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,u)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return a(e,t,u,!1)},"DenseMatrix, any":function(e,t){return c(e,t,u,!1)},"any, SparseMatrix":function(e,t){return a(t,e,u,!0)},"any, DenseMatrix":function(e,t){return c(t,e,u,!0)},"Array, any":function(e,t){return c(r(e),t,u,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,u,!0).valueOf()}});function u(e,t){return!n(e,t)}});kB(cV,["typed","equalScalar"],function(e){var t=e.typed,n=e.equalScalar;return t(cV,{"any, any":function(e,t){return null===e?null!==t:null===t?null!==e:void 0===e?void 0!==t:void 0===t?void 0!==e:!n(e,t)}})});var dV="partitionSelect",pV=kB(dV,["typed","isNumeric","isNaN","compare"],function(e){var t=e.typed,n=e.isNumeric,r=e.isNaN,i=e.compare,o=i,s=function(e,t){return-i(e,t)};return t(dV,{"Array | Matrix, number":function(e,t){return a(e,t,o)},"Array | Matrix, number, string":function(e,t,n){if("asc"===n)return a(e,t,o);if("desc"===n)return a(e,t,s);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":a});function a(e,t,n){if(!BL(t)||t<0)throw new Error("k must be a non-negative integer");if(JI(e)){if(e.size().length>1)throw new Error("Only one dimensional matrices supported");return l(e.valueOf(),t,n)}if(Array.isArray(e))return l(e,t,n)}function l(e,t,i){if(t>=e.length)throw new Error("k out of bounds");for(var o=0;o<e.length;o++)if(n(e[o])&&r(e[o]))return e[o];for(var s=0,a=e.length-1;s<a;){for(var l=s,c=a,u=e[Math.floor(Math.random()*(a-s+1))+s];l<c;)if(i(e[l],u)>=0){var d=e[c];e[c]=e[l],e[l]=d,--c}else++l;i(e[l],u)>0&&--l,t<=l?a=l:s=l+1}return e[t]}}),hV="sort",fV=kB(hV,["typed","matrix","compare","compareNatural"],function(e){var t=e.typed,n=e.matrix,r=e.compare,i=e.compareNatural,o=r,s=function(e,t){return-r(e,t)};return t(hV,{Array:function(e){return l(e),e.sort(o)},Matrix:function(e){return c(e),n(e.toArray().sort(o),e.storage())},"Array, function":function(e,t){return l(e),e.sort(t)},"Matrix, function":function(e,t){return c(e),n(e.toArray().sort(t),e.storage())},"Array, string":function(e,t){return l(e),e.sort(a(t))},"Matrix, string":function(e,t){return c(e),n(e.toArray().sort(a(t)),e.storage())}});function a(e){if("asc"===e)return o;if("desc"===e)return s;if("natural"===e)return i;throw new Error('String "asc", "desc", or "natural" expected')}function l(e){if(1!==pB(e).length)throw new Error("One dimensional array expected")}function c(e){if(1!==e.size().length)throw new Error("One dimensional matrix expected")}}),mV=kB("max",["typed","config","numeric","larger"],function(e){var t=e.typed,n=e.config,r=e.numeric,i=e.larger;return t("max",{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(e,t){return GP(e,t.valueOf(),o)},"...":function(e){if(VP(e))throw new TypeError("Scalar values expected in function max");return s(e)}});function o(e,t){try{return i(e,t)?e:t}catch(e){throw PU(e,"max",t)}}function s(e){var t;if(WP(e,function(e){try{isNaN(e)&&"number"==typeof e?t=NaN:(void 0===t||i(e,t))&&(t=e)}catch(t){throw PU(t,"max",e)}}),void 0===t)throw new Error("Cannot calculate max of an empty array");return"string"==typeof t&&(t=r(t,n.number)),t}}),gV=kB("min",["typed","config","numeric","smaller"],function(e){var t=e.typed,n=e.config,r=e.numeric,i=e.smaller;return t("min",{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(e,t){return GP(e,t.valueOf(),o)},"...":function(e){if(VP(e))throw new TypeError("Scalar values expected in function min");return s(e)}});function o(e,t){try{return i(e,t)?e:t}catch(e){throw PU(e,"min",t)}}function s(e){var t;if(WP(e,function(e){try{isNaN(e)&&"number"==typeof e?t=NaN:(void 0===t||i(e,t))&&(t=e)}catch(t){throw PU(t,"min",e)}}),void 0===t)throw new Error("Cannot calculate min of an empty array");return"string"==typeof t&&(t=r(t,n.number)),t}}),yV=kB("ImmutableDenseMatrix",["smaller","DenseMatrix"],function(e){var t=e.smaller,n=e.DenseMatrix;function r(e,t){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!KI(t))throw new Error("Invalid datatype: "+t);if(JI(e)||GI(e)){var i=new n(e,t);this._data=i._data,this._size=i._size,this._datatype=i._datatype,this._min=null,this._max=null}else if(e&&GI(e.data)&&GI(e.size))this._data=e.data,this._size=e.size,this._datatype=e.datatype,this._min=void 0!==e.min?e.min:null,this._max=void 0!==e.max?e.max:null;else{if(e)throw new TypeError("Unsupported type of data ("+NL(e)+")");this._data=[],this._size=[0],this._datatype=t,this._min=null,this._max=null}}return r.prototype=new n,r.prototype.type="ImmutableDenseMatrix",r.prototype.isImmutableDenseMatrix=!0,r.prototype.subset=function(e){switch(arguments.length){case 1:var t=n.prototype.subset.call(this,e);return JI(t)?new r({data:t._data,size:t._size,datatype:t._datatype}):t;case 2:case 3:throw new Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},r.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},r.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},r.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},r.prototype.clone=function(){return new r({data:kL(this._data),size:kL(this._size),datatype:this._datatype})},r.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},r.fromJSON=function(e){return new r(e)},r.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},r.prototype.min=function(){if(null===this._min){var e=null;this.forEach(function(n){(null===e||t(n,e))&&(e=n)}),this._min=null!==e?e:void 0}return this._min},r.prototype.max=function(){if(null===this._max){var e=null;this.forEach(function(n){(null===e||t(e,n))&&(e=n)}),this._max=null!==e?e:void 0}return this._max},r},{isClass:!0}),vV=kB("Index",["ImmutableDenseMatrix"],function(e){var t=e.ImmutableDenseMatrix;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._isScalar=!0;for(var t=0,i=arguments.length;t<i;t++){var o=arguments[t];if(QI(o))this._dimensions.push(o),this._isScalar=!1;else if(Array.isArray(o)||JI(o)){var s=r(o.valueOf());this._dimensions.push(s);var a=s.size();1===a.length&&1===a[0]||(this._isScalar=!1)}else if("number"==typeof o)this._dimensions.push(r([o]));else{if("string"!=typeof o)throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");this._dimensions.push(o)}}}function r(e){for(var n=0,r=e.length;n<r;n++)if("number"!=typeof e[n]||!BL(e[n]))throw new TypeError("Index parameters must be positive integer numbers");return new t(e)}return n.prototype.type="Index",n.prototype.isIndex=!0,n.prototype.clone=function(){var e=new n;return e._dimensions=kL(this._dimensions),e._isScalar=this._isScalar,e},n.create=function(e){var t=new n;return n.apply(t,e),t},n.prototype.size=function(){for(var e=[],t=0,n=this._dimensions.length;t<n;t++){var r=this._dimensions[t];e[t]="string"==typeof r?1:r.size()[0]}return e},n.prototype.max=function(){for(var e=[],t=0,n=this._dimensions.length;t<n;t++){var r=this._dimensions[t];e[t]="string"==typeof r?r:r.max()}return e},n.prototype.min=function(){for(var e=[],t=0,n=this._dimensions.length;t<n;t++){var r=this._dimensions[t];e[t]="string"==typeof r?r:r.min()}return e},n.prototype.forEach=function(e){for(var t=0,n=this._dimensions.length;t<n;t++)e(this._dimensions[t],t,this)},n.prototype.dimension=function(e){return this._dimensions[e]||null},n.prototype.isObjectProperty=function(){return 1===this._dimensions.length&&"string"==typeof this._dimensions[0]},n.prototype.getObjectProperty=function(){return this.isObjectProperty()?this._dimensions[0]:null},n.prototype.isScalar=function(){return this._isScalar},n.prototype.toArray=function(){for(var e=[],t=0,n=this._dimensions.length;t<n;t++){var r=this._dimensions[t];e.push("string"==typeof r?r:r.toArray())}return e},n.prototype.valueOf=n.prototype.toArray,n.prototype.toString=function(){for(var e=[],t=0,n=this._dimensions.length;t<n;t++){var r=this._dimensions[t];"string"==typeof r?e.push(JSON.stringify(r)):e.push(r.toString())}return"["+e.join(", ")+"]"},n.prototype.toJSON=function(){return{mathjs:"Index",dimensions:this._dimensions}},n.fromJSON=function(e){return n.create(e.dimensions)},n},{isClass:!0}),bV=kB("FibonacciHeap",["smaller","larger"],function(e){var t=e.smaller,n=e.larger,r=1/Math.log((1+Math.sqrt(5))/2);function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null,this._size=0}function o(e,t,n){t.left.right=t.right,t.right.left=t.left,n.degree--,n.child===t&&(n.child=t.right),0===n.degree&&(n.child=null),t.left=e,t.right=e.right,e.right=t,t.right.left=t,t.parent=null,t.mark=!1}function s(e,t){var n=t.parent;n&&(t.mark?(o(e,t,n),s(n)):t.mark=!0)}i.prototype.type="FibonacciHeap",i.prototype.isFibonacciHeap=!0,i.prototype.insert=function(e,n){var r={key:e,value:n,degree:0};if(this._minimum){var i=this._minimum;r.left=i,r.right=i.right,i.right=r,r.right.left=r,t(e,i.key)&&(this._minimum=r)}else r.left=r,r.right=r,this._minimum=r;return this._size++,r},i.prototype.size=function(){return this._size},i.prototype.clear=function(){this._minimum=null,this._size=0},i.prototype.isEmpty=function(){return 0===this._size},i.prototype.extractMinimum=function(){var e=this._minimum;if(null===e)return e;for(var i=this._minimum,o=e.degree,s=e.child;o>0;){var l=s.right;s.left.right=s.right,s.right.left=s.left,s.left=i,s.right=i.right,i.right=s,s.right.left=s,s.parent=null,s=l,o--}return e.left.right=e.right,e.right.left=e.left,i=e===e.right?null:function(e,i){var o,s=Math.floor(Math.log(i)*r)+1,l=new Array(s),c=0,u=e;if(u)for(c++,u=u.right;u!==e;)c++,u=u.right;for(;c>0;){for(var d=u.degree,p=u.right;o=l[d];){if(n(u.key,o.key)){var h=o;o=u,u=h}a(o,u),l[d]=null,d++}l[d]=u,u=p,c--}e=null;for(var f=0;f<s;f++)(o=l[f])&&(e?(o.left.right=o.right,o.right.left=o.left,o.left=e,o.right=e.right,e.right=o,o.right.left=o,t(o.key,e.key)&&(e=o)):e=o);return e}(i=e.right,this._size),this._size--,this._minimum=i,e},i.prototype.remove=function(e){this._minimum=function(e,n,r){n.key=r;var i=n.parent;i&&t(n.key,i.key)&&(o(e,n,i),s(e,i));t(n.key,e.key)&&(e=n);return e}(this._minimum,e,-1),this.extractMinimum()};var a=function(e,t){e.left.right=e.right,e.right.left=e.left,e.parent=t,t.child?(e.left=t.child,e.right=t.child.right,t.child.right=e,e.right.left=e):(t.child=e,e.right=e,e.left=e),t.degree++,e.mark=!1};return i},{isClass:!0}),wV=kB("Spa",["addScalar","equalScalar","FibonacciHeap"],function(e){var t=e.addScalar,n=e.equalScalar,r=e.FibonacciHeap;function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");this._values=[],this._heap=new r}return i.prototype.type="Spa",i.prototype.isSpa=!0,i.prototype.set=function(e,t){if(this._values[e])this._values[e].value=t;else{var n=this._heap.insert(e,t);this._values[e]=n}},i.prototype.get=function(e){var t=this._values[e];return t?t.value:0},i.prototype.accumulate=function(e,n){var r=this._values[e];r?r.value=t(r.value,n):(r=this._heap.insert(e,n),this._values[e]=r)},i.prototype.forEach=function(e,t,r){var i=this._heap,o=this._values,s=[],a=i.extractMinimum();for(a&&s.push(a);a&&a.key<=t;)a.key>=e&&(n(a.value,0)||r(a.key,a.value,this)),(a=i.extractMinimum())&&s.push(a);for(var l=0;l<s.length;l++){var c=s[l];o[(a=i.insert(c.key,c.value)).key]=a}},i.prototype.swap=function(e,t){var n=this._values[e],r=this._values[t];if(!n&&r)n=this._heap.insert(e,r.value),this._heap.remove(r),this._values[e]=n,this._values[t]=void 0;else if(n&&!r)r=this._heap.insert(t,n.value),this._heap.remove(n),this._values[t]=r,this._values[e]=void 0;else if(n&&r){var i=n.value;n.value=r.value,r.value=i}},i},{isClass:!0}),xV=TH(function(e){return new e(1).exp()},CV),MV=TH(function(e){return new e(1).plus(new e(5).sqrt()).div(2)},CV),SV=TH(function(e){return e.acos(-1)},CV),EV=TH(function(e){return SV(e).times(2)},CV);function CV(e){return e[0].precision}function NV(e){return NV="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},NV(e)}function AV(){return AV=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},AV.apply(this,arguments)}function kV(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 TV(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?kV(Object(n),!0).forEach(function(t){OV(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):kV(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function OV(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var _V=kB("Unit",["?on","config","addScalar","subtract","multiplyScalar","divideScalar","pow","abs","fix","round","equal","isNumeric","format","number","Complex","BigNumber","Fraction"],function(e){var t,n,r,i=e.on,o=e.config,s=e.addScalar,a=e.subtract,l=e.multiplyScalar,c=e.divideScalar,u=e.pow,d=e.abs,p=e.fix,h=e.round,f=e.equal,m=e.isNumeric,g=e.format,y=e.number,v=e.Complex,b=e.BigNumber,w=e.Fraction,x=y;function M(e,t){if(!(this instanceof M))throw new Error("Constructor must be called with the new operator");if(null!=e&&!m(e)&&!qI(e))throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");if(void 0!==t&&("string"!=typeof t||""===t))throw new TypeError("Second parameter in Unit constructor must be a string");if(void 0!==t){var n=M.parse(t);this.units=n.units,this.dimensions=n.dimensions}else{this.units=[{unit:B,prefix:R.NONE,power:0}],this.dimensions=[];for(var r=0;r<D.length;r++)this.dimensions[r]=0}this.value=null!=e?this._normalize(e):null,this.fixPrefix=!1,this.skipAutomaticSimplification=!0}function S(){for(;" "===r||"\t"===r;)C()}function E(e){return e>="0"&&e<="9"}function C(){n++,r=t.charAt(n)}function N(e){n=e,r=t.charAt(n)}function A(){var e="",t=n;if("+"===r?C():"-"===r&&(e+=r,C()),!function(e){return e>="0"&&e<="9"||"."===e}(r))return N(t),null;if("."===r){if(e+=r,C(),!E(r))return N(t),null}else{for(;E(r);)e+=r,C();"."===r&&(e+=r,C())}for(;E(r);)e+=r,C();if("E"===r||"e"===r){var i="",o=n;if(i+=r,C(),"+"!==r&&"-"!==r||(i+=r,C()),!E(r))return N(o),e;for(e+=i;E(r);)e+=r,C()}return e}function k(){for(var e="";E(r)||M.isValidAlpha(r);)e+=r,C();var t=e.charAt(0);return M.isValidAlpha(t)?e:null}function T(e){return r===e?(C(),e):null}function O(e){if(_L(z,e)){var t=z[e];return{unit:t,prefix:t.prefixes[""]}}for(var n in z)if(_L(z,n)&&sB(e,n)){var r=z[n],i=e.length-n.length,o=e.substring(0,i),s=_L(r.prefixes,o)?r.prefixes[o]:void 0;if(void 0!==s)return{unit:r,prefix:s}}return null}function _(e){return e.equalBase(I.NONE)&&null!==e.value&&!o.predictable?e.value:e}M.prototype.type="Unit",M.prototype.isUnit=!0,M.parse=function(e,i){if(i=i||{},n=-1,r="","string"!=typeof(t=e))throw new TypeError("Invalid argument in Unit.parse, string expected");var s=new M;s.units=[];var a=1,l=!1;C(),S();var c=A(),u=null;if(c){if("BigNumber"===o.number)u=new b(c);else if("Fraction"===o.number)try{u=new w(c)}catch(e){u=parseFloat(c)}else u=parseFloat(c);S(),T("*")?(a=1,l=!0):T("/")&&(a=-1,l=!0)}for(var d=[],p=1;;){for(S();"("===r;)d.push(a),p*=a,a=1,C(),S();var h=void 0;if(!r)break;var f=r;if(null===(h=k()))throw new SyntaxError('Unexpected "'+f+'" in "'+t+'" at index '+n.toString());var m=O(h);if(null===m)throw new SyntaxError('Unit "'+h+'" not found.');var g=a*p;if(S(),T("^")){S();var y=A();if(null===y)throw new SyntaxError('In "'+e+'", "^" must be followed by a floating-point number');g*=y}s.units.push({unit:m.unit,prefix:m.prefix,power:g});for(var v=0;v<D.length;v++)s.dimensions[v]+=(m.unit.dimensions[v]||0)*g;for(S();")"===r;){if(0===d.length)throw new SyntaxError('Unmatched ")" in "'+t+'" at index '+n.toString());p/=d.pop(),C(),S()}if(l=!1,T("*")?(a=1,l=!0):T("/")?(a=-1,l=!0):a=1,m.unit.base){var x=m.unit.base.key;F.auto[x]={unit:m.unit,prefix:m.prefix}}}if(S(),r)throw new SyntaxError('Could not parse: "'+e+'"');if(l)throw new SyntaxError('Trailing characters: "'+e+'"');if(0!==d.length)throw new SyntaxError('Unmatched "(" in "'+t+'"');if(0===s.units.length&&!i.allowNoUnits)throw new SyntaxError('"'+e+'" contains no units');return s.value=void 0!==u?s._normalize(u):null,s},M.prototype.clone=function(){var e=new M;e.fixPrefix=this.fixPrefix,e.skipAutomaticSimplification=this.skipAutomaticSimplification,e.value=kL(this.value),e.dimensions=this.dimensions.slice(0),e.units=[];for(var t=0;t<this.units.length;t++)for(var n in e.units[t]={},this.units[t])_L(this.units[t],n)&&(e.units[t][n]=this.units[t][n]);return e},M.prototype._isDerived=function(){return 0!==this.units.length&&(this.units.length>1||Math.abs(this.units[0].power-1)>1e-15)},M.prototype._normalize=function(e){var t,n,r,i,o;if(null==e||0===this.units.length)return e;if(this._isDerived()){var a=e;o=M._getNumberConverter(NL(e));for(var c=0;c<this.units.length;c++)t=o(this.units[c].unit.value),i=o(this.units[c].prefix.value),r=o(this.units[c].power),a=l(a,u(l(t,i),r));return a}return t=(o=M._getNumberConverter(NL(e)))(this.units[0].unit.value),n=o(this.units[0].unit.offset),i=o(this.units[0].prefix.value),l(s(e,n),l(t,i))},M.prototype._denormalize=function(e,t){var n,r,i,o,s;if(null==e||0===this.units.length)return e;if(this._isDerived()){var d=e;s=M._getNumberConverter(NL(e));for(var p=0;p<this.units.length;p++)n=s(this.units[p].unit.value),o=s(this.units[p].prefix.value),i=s(this.units[p].power),d=c(d,u(l(n,o),i));return d}return n=(s=M._getNumberConverter(NL(e)))(this.units[0].unit.value),o=s(this.units[0].prefix.value),r=s(this.units[0].unit.offset),a(c(c(e,n),null==t?o:t),r)},M.isValuelessUnit=function(e){return null!==O(e)},M.prototype.hasBase=function(e){if("string"==typeof e&&(e=I[e]),!e)return!1;for(var t=0;t<D.length;t++)if(Math.abs((this.dimensions[t]||0)-(e.dimensions[t]||0))>1e-12)return!1;return!0},M.prototype.equalBase=function(e){for(var t=0;t<D.length;t++)if(Math.abs((this.dimensions[t]||0)-(e.dimensions[t]||0))>1e-12)return!1;return!0},M.prototype.equals=function(e){return this.equalBase(e)&&f(this.value,e.value)},M.prototype.multiply=function(e){for(var t=this.clone(),n=0;n<D.length;n++)t.dimensions[n]=(this.dimensions[n]||0)+(e.dimensions[n]||0);for(var r=0;r<e.units.length;r++){var i=TV({},e.units[r]);t.units.push(i)}if(null!==this.value||null!==e.value){var o=null===this.value?this._normalize(1):this.value,s=null===e.value?e._normalize(1):e.value;t.value=l(o,s)}else t.value=null;return t.skipAutomaticSimplification=!1,_(t)},M.prototype.divide=function(e){for(var t=this.clone(),n=0;n<D.length;n++)t.dimensions[n]=(this.dimensions[n]||0)-(e.dimensions[n]||0);for(var r=0;r<e.units.length;r++){var i=TV(TV({},e.units[r]),{},{power:-e.units[r].power});t.units.push(i)}if(null!==this.value||null!==e.value){var o=null===this.value?this._normalize(1):this.value,s=null===e.value?e._normalize(1):e.value;t.value=c(o,s)}else t.value=null;return t.skipAutomaticSimplification=!1,_(t)},M.prototype.pow=function(e){for(var t=this.clone(),n=0;n<D.length;n++)t.dimensions[n]=(this.dimensions[n]||0)*e;for(var r=0;r<t.units.length;r++)t.units[r].power*=e;return null!==t.value?t.value=u(t.value,e):t.value=null,t.skipAutomaticSimplification=!1,_(t)},M.prototype.abs=function(){var e=this.clone();for(var t in e.value=null!==e.value?d(e.value):null,e.units)"VA"!==e.units[t].unit.name&&"VAR"!==e.units[t].unit.name||(e.units[t].unit=z.W);return e},M.prototype.to=function(e){var t,n=null===this.value?this._normalize(1):this.value;if("string"==typeof e){if(t=M.parse(e),!this.equalBase(t))throw new Error("Units do not match ('".concat(t.toString(),"' != '").concat(this.toString(),"')"));if(null!==t.value)throw new Error("Cannot convert to a unit with a value");return t.value=kL(n),t.fixPrefix=!0,t.skipAutomaticSimplification=!0,t}if(WI(e)){if(!this.equalBase(e))throw new Error("Units do not match ('".concat(e.toString(),"' != '").concat(this.toString(),"')"));if(null!==e.value)throw new Error("Cannot convert to a unit with a value");return(t=e.clone()).value=kL(n),t.fixPrefix=!0,t.skipAutomaticSimplification=!0,t}throw new Error("String or Unit expected as parameter")},M.prototype.toNumber=function(e){return x(this.toNumeric(e))},M.prototype.toNumeric=function(e){var t;return(t=e?this.to(e):this.clone())._isDerived()||0===t.units.length?t._denormalize(t.value):t._denormalize(t.value,t.units[0].prefix.value)},M.prototype.toString=function(){return this.format()},M.prototype.toJSON=function(){return{mathjs:"Unit",value:this._denormalize(this.value),unit:this.formatUnits(),fixPrefix:this.fixPrefix}},M.fromJSON=function(e){var t=new M(e.value,e.unit);return t.fixPrefix=e.fixPrefix||!1,t},M.prototype.valueOf=M.prototype.toString,M.prototype.simplify=function(){var e,t,n=this.clone(),r=[];for(var i in $)if(_L($,i)&&n.hasBase(I[i])){e=i;break}if("NONE"===e)n.units=[];else if(e&&_L($,e)&&(t=$[e]),t)n.units=[{unit:t.unit,prefix:t.prefix,power:1}];else{for(var o=!1,s=0;s<D.length;s++){var a=D[s];Math.abs(n.dimensions[s]||0)>1e-12&&(_L($,a)?r.push({unit:$[a].unit,prefix:$[a].prefix,power:n.dimensions[s]||0}):o=!0)}r.length<n.units.length&&!o&&(n.units=r)}return n},M.prototype.toSI=function(){for(var e=this.clone(),t=[],n=0;n<D.length;n++){var r=D[n];if(Math.abs(e.dimensions[n]||0)>1e-12){if(!_L(F.si,r))throw new Error("Cannot express custom unit "+r+" in SI units");t.push({unit:F.si[r].unit,prefix:F.si[r].prefix,power:e.dimensions[n]||0})}}return e.units=t,e.fixPrefix=!0,e.skipAutomaticSimplification=!0,e},M.prototype.formatUnits=function(){for(var e="",t="",n=0,r=0,i=0;i<this.units.length;i++)this.units[i].power>0?(n++,e+=" "+this.units[i].prefix.name+this.units[i].unit.name,Math.abs(this.units[i].power-1)>1e-15&&(e+="^"+this.units[i].power)):this.units[i].power<0&&r++;if(r>0)for(var o=0;o<this.units.length;o++)this.units[o].power<0&&(n>0?(t+=" "+this.units[o].prefix.name+this.units[o].unit.name,Math.abs(this.units[o].power+1)>1e-15&&(t+="^"+-this.units[o].power)):(t+=" "+this.units[o].prefix.name+this.units[o].unit.name,t+="^"+this.units[o].power));e=e.substr(1),t=t.substr(1),n>1&&r>0&&(e="("+e+")"),r>1&&n>0&&(t="("+t+")");var s=e;return n>0&&r>0&&(s+=" / "),s+=t},M.prototype.format=function(e){var t=this.skipAutomaticSimplification||null===this.value?this.clone():this.simplify(),n=!1;for(var r in void 0!==t.value&&null!==t.value&&qI(t.value)&&(n=Math.abs(t.value.re)<1e-14),t.units)_L(t.units,r)&&t.units[r].unit&&("VA"===t.units[r].unit.name&&n?t.units[r].unit=z.VAR:"VAR"!==t.units[r].unit.name||n||(t.units[r].unit=z.VA));1!==t.units.length||t.fixPrefix||Math.abs(t.units[0].power-Math.round(t.units[0].power))<1e-14&&(t.units[0].prefix=t._bestPrefix());var i=t._denormalize(t.value),o=null!==t.value?g(i,e||{}):"",s=t.formatUnits();return t.value&&qI(t.value)&&(o="("+o+")"),s.length>0&&o.length>0&&(o+=" "),o+=s},M.prototype._bestPrefix=function(){if(1!==this.units.length)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");if(Math.abs(this.units[0].power-Math.round(this.units[0].power))>=1e-14)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");var e=null!==this.value?d(this.value):0,t=d(this.units[0].unit.value),n=this.units[0].prefix;if(0===e)return n;var r=this.units[0].power,i=Math.log(e/Math.pow(n.value*t,r))/Math.LN10-1.2;if(i>-2.200001&&i<1.800001)return n;i=Math.abs(i);var o=this.units[0].unit.prefixes;for(var s in o)if(_L(o,s)){var a=o[s];if(a.scientific){var l=Math.abs(Math.log(e/Math.pow(a.value*t,r))/Math.LN10-1.2);(l<i||l===i&&a.name.length<n.name.length)&&(n=a,i=l)}}return n},M.prototype.splitUnit=function(e){for(var t=this.clone(),n=[],r=0;r<e.length&&(t=t.to(e[r]),r!==e.length-1);r++){var i=t.toNumeric(),o=h(i),l=new M(f(o,i)?o:p(t.toNumeric()),e[r].toString());n.push(l),t=a(t,l)}for(var c=0,u=0;u<n.length;u++)c=s(c,n[u].value);return f(c,this.value)&&(t.value=0),n.push(t),n};var R={NONE:{"":{name:"",value:1,scientific:!0}},SHORT:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:10,scientific:!1},h:{name:"h",value:100,scientific:!1},k:{name:"k",value:1e3,scientific:!0},M:{name:"M",value:1e6,scientific:!0},G:{name:"G",value:1e9,scientific:!0},T:{name:"T",value:1e12,scientific:!0},P:{name:"P",value:1e15,scientific:!0},E:{name:"E",value:1e18,scientific:!0},Z:{name:"Z",value:1e21,scientific:!0},Y:{name:"Y",value:1e24,scientific:!0},d:{name:"d",value:.1,scientific:!1},c:{name:"c",value:.01,scientific:!1},m:{name:"m",value:.001,scientific:!0},u:{name:"u",value:1e-6,scientific:!0},n:{name:"n",value:1e-9,scientific:!0},p:{name:"p",value:1e-12,scientific:!0},f:{name:"f",value:1e-15,scientific:!0},a:{name:"a",value:1e-18,scientific:!0},z:{name:"z",value:1e-21,scientific:!0},y:{name:"y",value:1e-24,scientific:!0}},LONG:{"":{name:"",value:1,scientific:!0},deca:{name:"deca",value:10,scientific:!1},hecto:{name:"hecto",value:100,scientific:!1},kilo:{name:"kilo",value:1e3,scientific:!0},mega:{name:"mega",value:1e6,scientific:!0},giga:{name:"giga",value:1e9,scientific:!0},tera:{name:"tera",value:1e12,scientific:!0},peta:{name:"peta",value:1e15,scientific:!0},exa:{name:"exa",value:1e18,scientific:!0},zetta:{name:"zetta",value:1e21,scientific:!0},yotta:{name:"yotta",value:1e24,scientific:!0},deci:{name:"deci",value:.1,scientific:!1},centi:{name:"centi",value:.01,scientific:!1},milli:{name:"milli",value:.001,scientific:!0},micro:{name:"micro",value:1e-6,scientific:!0},nano:{name:"nano",value:1e-9,scientific:!0},pico:{name:"pico",value:1e-12,scientific:!0},femto:{name:"femto",value:1e-15,scientific:!0},atto:{name:"atto",value:1e-18,scientific:!0},zepto:{name:"zepto",value:1e-21,scientific:!0},yocto:{name:"yocto",value:1e-24,scientific:!0}},SQUARED:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:100,scientific:!1},h:{name:"h",value:1e4,scientific:!1},k:{name:"k",value:1e6,scientific:!0},M:{name:"M",value:1e12,scientific:!0},G:{name:"G",value:1e18,scientific:!0},T:{name:"T",value:1e24,scientific:!0},P:{name:"P",value:1e30,scientific:!0},E:{name:"E",value:1e36,scientific:!0},Z:{name:"Z",value:1e42,scientific:!0},Y:{name:"Y",value:1e48,scientific:!0},d:{name:"d",value:.01,scientific:!1},c:{name:"c",value:1e-4,scientific:!1},m:{name:"m",value:1e-6,scientific:!0},u:{name:"u",value:1e-12,scientific:!0},n:{name:"n",value:1e-18,scientific:!0},p:{name:"p",value:1e-24,scientific:!0},f:{name:"f",value:1e-30,scientific:!0},a:{name:"a",value:1e-36,scientific:!0},z:{name:"z",value:1e-42,scientific:!0},y:{name:"y",value:1e-48,scientific:!0}},CUBIC:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:1e3,scientific:!1},h:{name:"h",value:1e6,scientific:!1},k:{name:"k",value:1e9,scientific:!0},M:{name:"M",value:1e18,scientific:!0},G:{name:"G",value:1e27,scientific:!0},T:{name:"T",value:1e36,scientific:!0},P:{name:"P",value:1e45,scientific:!0},E:{name:"E",value:1e54,scientific:!0},Z:{name:"Z",value:1e63,scientific:!0},Y:{name:"Y",value:1e72,scientific:!0},d:{name:"d",value:.001,scientific:!1},c:{name:"c",value:1e-6,scientific:!1},m:{name:"m",value:1e-9,scientific:!0},u:{name:"u",value:1e-18,scientific:!0},n:{name:"n",value:1e-27,scientific:!0},p:{name:"p",value:1e-36,scientific:!0},f:{name:"f",value:1e-45,scientific:!0},a:{name:"a",value:1e-54,scientific:!0},z:{name:"z",value:1e-63,scientific:!0},y:{name:"y",value:1e-72,scientific:!0}},BINARY_SHORT_SI:{"":{name:"",value:1,scientific:!0},k:{name:"k",value:1e3,scientific:!0},M:{name:"M",value:1e6,scientific:!0},G:{name:"G",value:1e9,scientific:!0},T:{name:"T",value:1e12,scientific:!0},P:{name:"P",value:1e15,scientific:!0},E:{name:"E",value:1e18,scientific:!0},Z:{name:"Z",value:1e21,scientific:!0},Y:{name:"Y",value:1e24,scientific:!0}},BINARY_SHORT_IEC:{"":{name:"",value:1,scientific:!0},Ki:{name:"Ki",value:1024,scientific:!0},Mi:{name:"Mi",value:Math.pow(1024,2),scientific:!0},Gi:{name:"Gi",value:Math.pow(1024,3),scientific:!0},Ti:{name:"Ti",value:Math.pow(1024,4),scientific:!0},Pi:{name:"Pi",value:Math.pow(1024,5),scientific:!0},Ei:{name:"Ei",value:Math.pow(1024,6),scientific:!0},Zi:{name:"Zi",value:Math.pow(1024,7),scientific:!0},Yi:{name:"Yi",value:Math.pow(1024,8),scientific:!0}},BINARY_LONG_SI:{"":{name:"",value:1,scientific:!0},kilo:{name:"kilo",value:1e3,scientific:!0},mega:{name:"mega",value:1e6,scientific:!0},giga:{name:"giga",value:1e9,scientific:!0},tera:{name:"tera",value:1e12,scientific:!0},peta:{name:"peta",value:1e15,scientific:!0},exa:{name:"exa",value:1e18,scientific:!0},zetta:{name:"zetta",value:1e21,scientific:!0},yotta:{name:"yotta",value:1e24,scientific:!0}},BINARY_LONG_IEC:{"":{name:"",value:1,scientific:!0},kibi:{name:"kibi",value:1024,scientific:!0},mebi:{name:"mebi",value:Math.pow(1024,2),scientific:!0},gibi:{name:"gibi",value:Math.pow(1024,3),scientific:!0},tebi:{name:"tebi",value:Math.pow(1024,4),scientific:!0},pebi:{name:"pebi",value:Math.pow(1024,5),scientific:!0},exi:{name:"exi",value:Math.pow(1024,6),scientific:!0},zebi:{name:"zebi",value:Math.pow(1024,7),scientific:!0},yobi:{name:"yobi",value:Math.pow(1024,8),scientific:!0}},BTU:{"":{name:"",value:1,scientific:!0},MM:{name:"MM",value:1e6,scientific:!0}}};R.SHORTLONG=AV({},R.SHORT,R.LONG),R.BINARY_SHORT=AV({},R.BINARY_SHORT_SI,R.BINARY_SHORT_IEC),R.BINARY_LONG=AV({},R.BINARY_LONG_SI,R.BINARY_LONG_IEC);var D=["MASS","LENGTH","TIME","CURRENT","TEMPERATURE","LUMINOUS_INTENSITY","AMOUNT_OF_SUBSTANCE","ANGLE","BIT"],I={NONE:{dimensions:[0,0,0,0,0,0,0,0,0]},MASS:{dimensions:[1,0,0,0,0,0,0,0,0]},LENGTH:{dimensions:[0,1,0,0,0,0,0,0,0]},TIME:{dimensions:[0,0,1,0,0,0,0,0,0]},CURRENT:{dimensions:[0,0,0,1,0,0,0,0,0]},TEMPERATURE:{dimensions:[0,0,0,0,1,0,0,0,0]},LUMINOUS_INTENSITY:{dimensions:[0,0,0,0,0,1,0,0,0]},AMOUNT_OF_SUBSTANCE:{dimensions:[0,0,0,0,0,0,1,0,0]},FORCE:{dimensions:[1,1,-2,0,0,0,0,0,0]},SURFACE:{dimensions:[0,2,0,0,0,0,0,0,0]},VOLUME:{dimensions:[0,3,0,0,0,0,0,0,0]},ENERGY:{dimensions:[1,2,-2,0,0,0,0,0,0]},POWER:{dimensions:[1,2,-3,0,0,0,0,0,0]},PRESSURE:{dimensions:[1,-1,-2,0,0,0,0,0,0]},ELECTRIC_CHARGE:{dimensions:[0,0,1,1,0,0,0,0,0]},ELECTRIC_CAPACITANCE:{dimensions:[-1,-2,4,2,0,0,0,0,0]},ELECTRIC_POTENTIAL:{dimensions:[1,2,-3,-1,0,0,0,0,0]},ELECTRIC_RESISTANCE:{dimensions:[1,2,-3,-2,0,0,0,0,0]},ELECTRIC_INDUCTANCE:{dimensions:[1,2,-2,-2,0,0,0,0,0]},ELECTRIC_CONDUCTANCE:{dimensions:[-1,-2,3,2,0,0,0,0,0]},MAGNETIC_FLUX:{dimensions:[1,2,-2,-1,0,0,0,0,0]},MAGNETIC_FLUX_DENSITY:{dimensions:[1,0,-2,-1,0,0,0,0,0]},FREQUENCY:{dimensions:[0,0,-1,0,0,0,0,0,0]},ANGLE:{dimensions:[0,0,0,0,0,0,0,1,0]},BIT:{dimensions:[0,0,0,0,0,0,0,0,1]}};for(var L in I)_L(I,L)&&(I[L].key=L);var B={name:"",base:{},value:1,offset:0,dimensions:D.map(function(e){return 0})},z={meter:{name:"meter",base:I.LENGTH,prefixes:R.LONG,value:1,offset:0},inch:{name:"inch",base:I.LENGTH,prefixes:R.NONE,value:.0254,offset:0},foot:{name:"foot",base:I.LENGTH,prefixes:R.NONE,value:.3048,offset:0},yard:{name:"yard",base:I.LENGTH,prefixes:R.NONE,value:.9144,offset:0},mile:{name:"mile",base:I.LENGTH,prefixes:R.NONE,value:1609.344,offset:0},link:{name:"link",base:I.LENGTH,prefixes:R.NONE,value:.201168,offset:0},rod:{name:"rod",base:I.LENGTH,prefixes:R.NONE,value:5.0292,offset:0},chain:{name:"chain",base:I.LENGTH,prefixes:R.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:I.LENGTH,prefixes:R.NONE,value:1e-10,offset:0},m:{name:"m",base:I.LENGTH,prefixes:R.SHORT,value:1,offset:0},in:{name:"in",base:I.LENGTH,prefixes:R.NONE,value:.0254,offset:0},ft:{name:"ft",base:I.LENGTH,prefixes:R.NONE,value:.3048,offset:0},yd:{name:"yd",base:I.LENGTH,prefixes:R.NONE,value:.9144,offset:0},mi:{name:"mi",base:I.LENGTH,prefixes:R.NONE,value:1609.344,offset:0},li:{name:"li",base:I.LENGTH,prefixes:R.NONE,value:.201168,offset:0},rd:{name:"rd",base:I.LENGTH,prefixes:R.NONE,value:5.02921,offset:0},ch:{name:"ch",base:I.LENGTH,prefixes:R.NONE,value:20.1168,offset:0},mil:{name:"mil",base:I.LENGTH,prefixes:R.NONE,value:254e-7,offset:0},m2:{name:"m2",base:I.SURFACE,prefixes:R.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:I.SURFACE,prefixes:R.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:I.SURFACE,prefixes:R.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:I.SURFACE,prefixes:R.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:I.SURFACE,prefixes:R.NONE,value:2589988.110336,offset:0},sqrd:{name:"sqrd",base:I.SURFACE,prefixes:R.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:I.SURFACE,prefixes:R.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:I.SURFACE,prefixes:R.NONE,value:6.4516e-10,offset:0},acre:{name:"acre",base:I.SURFACE,prefixes:R.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:I.SURFACE,prefixes:R.NONE,value:1e4,offset:0},m3:{name:"m3",base:I.VOLUME,prefixes:R.CUBIC,value:1,offset:0},L:{name:"L",base:I.VOLUME,prefixes:R.SHORT,value:.001,offset:0},l:{name:"l",base:I.VOLUME,prefixes:R.SHORT,value:.001,offset:0},litre:{name:"litre",base:I.VOLUME,prefixes:R.LONG,value:.001,offset:0},cuin:{name:"cuin",base:I.VOLUME,prefixes:R.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:I.VOLUME,prefixes:R.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:I.VOLUME,prefixes:R.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:I.VOLUME,prefixes:R.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:I.VOLUME,prefixes:R.NONE,value:15e-6,offset:0},drop:{name:"drop",base:I.VOLUME,prefixes:R.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:I.VOLUME,prefixes:R.NONE,value:5e-8,offset:0},minim:{name:"minim",base:I.VOLUME,prefixes:R.NONE,value:6.161152e-8,offset:0},fluiddram:{name:"fluiddram",base:I.VOLUME,prefixes:R.NONE,value:36966911e-13,offset:0},fluidounce:{name:"fluidounce",base:I.VOLUME,prefixes:R.NONE,value:2957353e-11,offset:0},gill:{name:"gill",base:I.VOLUME,prefixes:R.NONE,value:.0001182941,offset:0},cc:{name:"cc",base:I.VOLUME,prefixes:R.NONE,value:1e-6,offset:0},cup:{name:"cup",base:I.VOLUME,prefixes:R.NONE,value:.0002365882,offset:0},pint:{name:"pint",base:I.VOLUME,prefixes:R.NONE,value:.0004731765,offset:0},quart:{name:"quart",base:I.VOLUME,prefixes:R.NONE,value:.0009463529,offset:0},gallon:{name:"gallon",base:I.VOLUME,prefixes:R.NONE,value:.003785412,offset:0},beerbarrel:{name:"beerbarrel",base:I.VOLUME,prefixes:R.NONE,value:.1173478,offset:0},oilbarrel:{name:"oilbarrel",base:I.VOLUME,prefixes:R.NONE,value:.1589873,offset:0},hogshead:{name:"hogshead",base:I.VOLUME,prefixes:R.NONE,value:.238481,offset:0},fldr:{name:"fldr",base:I.VOLUME,prefixes:R.NONE,value:36966911e-13,offset:0},floz:{name:"floz",base:I.VOLUME,prefixes:R.NONE,value:2957353e-11,offset:0},gi:{name:"gi",base:I.VOLUME,prefixes:R.NONE,value:.0001182941,offset:0},cp:{name:"cp",base:I.VOLUME,prefixes:R.NONE,value:.0002365882,offset:0},pt:{name:"pt",base:I.VOLUME,prefixes:R.NONE,value:.0004731765,offset:0},qt:{name:"qt",base:I.VOLUME,prefixes:R.NONE,value:.0009463529,offset:0},gal:{name:"gal",base:I.VOLUME,prefixes:R.NONE,value:.003785412,offset:0},bbl:{name:"bbl",base:I.VOLUME,prefixes:R.NONE,value:.1173478,offset:0},obl:{name:"obl",base:I.VOLUME,prefixes:R.NONE,value:.1589873,offset:0},g:{name:"g",base:I.MASS,prefixes:R.SHORT,value:.001,offset:0},gram:{name:"gram",base:I.MASS,prefixes:R.LONG,value:.001,offset:0},ton:{name:"ton",base:I.MASS,prefixes:R.SHORT,value:907.18474,offset:0},t:{name:"t",base:I.MASS,prefixes:R.SHORT,value:1e3,offset:0},tonne:{name:"tonne",base:I.MASS,prefixes:R.LONG,value:1e3,offset:0},grain:{name:"grain",base:I.MASS,prefixes:R.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:I.MASS,prefixes:R.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:I.MASS,prefixes:R.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:I.MASS,prefixes:R.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:I.MASS,prefixes:R.NONE,value:45.359237,offset:0},stick:{name:"stick",base:I.MASS,prefixes:R.NONE,value:.115,offset:0},stone:{name:"stone",base:I.MASS,prefixes:R.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:I.MASS,prefixes:R.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:I.MASS,prefixes:R.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:I.MASS,prefixes:R.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:I.MASS,prefixes:R.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:I.MASS,prefixes:R.NONE,value:45.359237,offset:0},s:{name:"s",base:I.TIME,prefixes:R.SHORT,value:1,offset:0},min:{name:"min",base:I.TIME,prefixes:R.NONE,value:60,offset:0},h:{name:"h",base:I.TIME,prefixes:R.NONE,value:3600,offset:0},second:{name:"second",base:I.TIME,prefixes:R.LONG,value:1,offset:0},sec:{name:"sec",base:I.TIME,prefixes:R.LONG,value:1,offset:0},minute:{name:"minute",base:I.TIME,prefixes:R.NONE,value:60,offset:0},hour:{name:"hour",base:I.TIME,prefixes:R.NONE,value:3600,offset:0},day:{name:"day",base:I.TIME,prefixes:R.NONE,value:86400,offset:0},week:{name:"week",base:I.TIME,prefixes:R.NONE,value:604800,offset:0},month:{name:"month",base:I.TIME,prefixes:R.NONE,value:2629800,offset:0},year:{name:"year",base:I.TIME,prefixes:R.NONE,value:31557600,offset:0},decade:{name:"decade",base:I.TIME,prefixes:R.NONE,value:315576e3,offset:0},century:{name:"century",base:I.TIME,prefixes:R.NONE,value:315576e4,offset:0},millennium:{name:"millennium",base:I.TIME,prefixes:R.NONE,value:315576e5,offset:0},hertz:{name:"Hertz",base:I.FREQUENCY,prefixes:R.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:I.FREQUENCY,prefixes:R.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:I.ANGLE,prefixes:R.SHORT,value:1,offset:0},radian:{name:"radian",base:I.ANGLE,prefixes:R.LONG,value:1,offset:0},deg:{name:"deg",base:I.ANGLE,prefixes:R.SHORT,value:null,offset:0},degree:{name:"degree",base:I.ANGLE,prefixes:R.LONG,value:null,offset:0},grad:{name:"grad",base:I.ANGLE,prefixes:R.SHORT,value:null,offset:0},gradian:{name:"gradian",base:I.ANGLE,prefixes:R.LONG,value:null,offset:0},cycle:{name:"cycle",base:I.ANGLE,prefixes:R.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:I.ANGLE,prefixes:R.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:I.ANGLE,prefixes:R.NONE,value:null,offset:0},A:{name:"A",base:I.CURRENT,prefixes:R.SHORT,value:1,offset:0},ampere:{name:"ampere",base:I.CURRENT,prefixes:R.LONG,value:1,offset:0},K:{name:"K",base:I.TEMPERATURE,prefixes:R.NONE,value:1,offset:0},degC:{name:"degC",base:I.TEMPERATURE,prefixes:R.NONE,value:1,offset:273.15},degF:{name:"degF",base:I.TEMPERATURE,prefixes:R.NONE,value:1/1.8,offset:459.67},degR:{name:"degR",base:I.TEMPERATURE,prefixes:R.NONE,value:1/1.8,offset:0},kelvin:{name:"kelvin",base:I.TEMPERATURE,prefixes:R.NONE,value:1,offset:0},celsius:{name:"celsius",base:I.TEMPERATURE,prefixes:R.NONE,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:I.TEMPERATURE,prefixes:R.NONE,value:1/1.8,offset:459.67},rankine:{name:"rankine",base:I.TEMPERATURE,prefixes:R.NONE,value:1/1.8,offset:0},mol:{name:"mol",base:I.AMOUNT_OF_SUBSTANCE,prefixes:R.SHORT,value:1,offset:0},mole:{name:"mole",base:I.AMOUNT_OF_SUBSTANCE,prefixes:R.LONG,value:1,offset:0},cd:{name:"cd",base:I.LUMINOUS_INTENSITY,prefixes:R.SHORT,value:1,offset:0},candela:{name:"candela",base:I.LUMINOUS_INTENSITY,prefixes:R.LONG,value:1,offset:0},N:{name:"N",base:I.FORCE,prefixes:R.SHORT,value:1,offset:0},newton:{name:"newton",base:I.FORCE,prefixes:R.LONG,value:1,offset:0},dyn:{name:"dyn",base:I.FORCE,prefixes:R.SHORT,value:1e-5,offset:0},dyne:{name:"dyne",base:I.FORCE,prefixes:R.LONG,value:1e-5,offset:0},lbf:{name:"lbf",base:I.FORCE,prefixes:R.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:I.FORCE,prefixes:R.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:I.FORCE,prefixes:R.LONG,value:4448.2216,offset:0},J:{name:"J",base:I.ENERGY,prefixes:R.SHORT,value:1,offset:0},joule:{name:"joule",base:I.ENERGY,prefixes:R.SHORT,value:1,offset:0},erg:{name:"erg",base:I.ENERGY,prefixes:R.NONE,value:1e-7,offset:0},Wh:{name:"Wh",base:I.ENERGY,prefixes:R.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:I.ENERGY,prefixes:R.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:I.ENERGY,prefixes:R.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:"electronvolt",base:I.ENERGY,prefixes:R.LONG,value:1602176565e-28,offset:0},W:{name:"W",base:I.POWER,prefixes:R.SHORT,value:1,offset:0},watt:{name:"watt",base:I.POWER,prefixes:R.LONG,value:1,offset:0},hp:{name:"hp",base:I.POWER,prefixes:R.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:I.POWER,prefixes:R.SHORT,value:v.I,offset:0},VA:{name:"VA",base:I.POWER,prefixes:R.SHORT,value:1,offset:0},Pa:{name:"Pa",base:I.PRESSURE,prefixes:R.SHORT,value:1,offset:0},psi:{name:"psi",base:I.PRESSURE,prefixes:R.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:I.PRESSURE,prefixes:R.NONE,value:101325,offset:0},bar:{name:"bar",base:I.PRESSURE,prefixes:R.SHORTLONG,value:1e5,offset:0},torr:{name:"torr",base:I.PRESSURE,prefixes:R.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:I.PRESSURE,prefixes:R.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:I.PRESSURE,prefixes:R.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:I.PRESSURE,prefixes:R.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:I.ELECTRIC_CHARGE,prefixes:R.LONG,value:1,offset:0},C:{name:"C",base:I.ELECTRIC_CHARGE,prefixes:R.SHORT,value:1,offset:0},farad:{name:"farad",base:I.ELECTRIC_CAPACITANCE,prefixes:R.LONG,value:1,offset:0},F:{name:"F",base:I.ELECTRIC_CAPACITANCE,prefixes:R.SHORT,value:1,offset:0},volt:{name:"volt",base:I.ELECTRIC_POTENTIAL,prefixes:R.LONG,value:1,offset:0},V:{name:"V",base:I.ELECTRIC_POTENTIAL,prefixes:R.SHORT,value:1,offset:0},ohm:{name:"ohm",base:I.ELECTRIC_RESISTANCE,prefixes:R.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:I.ELECTRIC_INDUCTANCE,prefixes:R.LONG,value:1,offset:0},H:{name:"H",base:I.ELECTRIC_INDUCTANCE,prefixes:R.SHORT,value:1,offset:0},siemens:{name:"siemens",base:I.ELECTRIC_CONDUCTANCE,prefixes:R.LONG,value:1,offset:0},S:{name:"S",base:I.ELECTRIC_CONDUCTANCE,prefixes:R.SHORT,value:1,offset:0},weber:{name:"weber",base:I.MAGNETIC_FLUX,prefixes:R.LONG,value:1,offset:0},Wb:{name:"Wb",base:I.MAGNETIC_FLUX,prefixes:R.SHORT,value:1,offset:0},tesla:{name:"tesla",base:I.MAGNETIC_FLUX_DENSITY,prefixes:R.LONG,value:1,offset:0},T:{name:"T",base:I.MAGNETIC_FLUX_DENSITY,prefixes:R.SHORT,value:1,offset:0},b:{name:"b",base:I.BIT,prefixes:R.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:I.BIT,prefixes:R.BINARY_LONG,value:1,offset:0},B:{name:"B",base:I.BIT,prefixes:R.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:I.BIT,prefixes:R.BINARY_LONG,value:8,offset:0}},P={meters:"meter",inches:"inch",feet:"foot",yards:"yard",miles:"mile",links:"link",rods:"rod",chains:"chain",angstroms:"angstrom",lt:"l",litres:"litre",liter:"litre",liters:"litre",teaspoons:"teaspoon",tablespoons:"tablespoon",minims:"minim",fluiddrams:"fluiddram",fluidounces:"fluidounce",gills:"gill",cups:"cup",pints:"pint",quarts:"quart",gallons:"gallon",beerbarrels:"beerbarrel",oilbarrels:"oilbarrel",hogsheads:"hogshead",gtts:"gtt",grams:"gram",tons:"ton",tonnes:"tonne",grains:"grain",drams:"dram",ounces:"ounce",poundmasses:"poundmass",hundredweights:"hundredweight",sticks:"stick",lb:"lbm",lbs:"lbm",kips:"kip",acres:"acre",hectares:"hectare",sqfeet:"sqft",sqyard:"sqyd",sqmile:"sqmi",sqmiles:"sqmi",mmhg:"mmHg",mmh2o:"mmH2O",cmh2o:"cmH2O",seconds:"second",secs:"second",minutes:"minute",mins:"minute",hours:"hour",hr:"hour",hrs:"hour",days:"day",weeks:"week",months:"month",years:"year",decades:"decade",centuries:"century",millennia:"millennium",hertz:"hertz",radians:"radian",degrees:"degree",gradians:"gradian",cycles:"cycle",arcsecond:"arcsec",arcseconds:"arcsec",arcminute:"arcmin",arcminutes:"arcmin",BTUs:"BTU",watts:"watt",joules:"joule",amperes:"ampere",coulombs:"coulomb",volts:"volt",ohms:"ohm",farads:"farad",webers:"weber",teslas:"tesla",electronvolts:"electronvolt",moles:"mole",bit:"bits",byte:"bytes"};function j(e){if("BigNumber"===e.number){var t=SV(b);z.rad.value=new b(1),z.deg.value=t.div(180),z.grad.value=t.div(200),z.cycle.value=t.times(2),z.arcsec.value=t.div(648e3),z.arcmin.value=t.div(10800)}else z.rad.value=1,z.deg.value=Math.PI/180,z.grad.value=Math.PI/200,z.cycle.value=2*Math.PI,z.arcsec.value=Math.PI/648e3,z.arcmin.value=Math.PI/10800;z.radian.value=z.rad.value,z.degree.value=z.deg.value,z.gradian.value=z.grad.value}j(o),i&&i("config",function(e,t){e.number!==t.number&&j(e)});var F={si:{NONE:{unit:B,prefix:R.NONE[""]},LENGTH:{unit:z.m,prefix:R.SHORT[""]},MASS:{unit:z.g,prefix:R.SHORT.k},TIME:{unit:z.s,prefix:R.SHORT[""]},CURRENT:{unit:z.A,prefix:R.SHORT[""]},TEMPERATURE:{unit:z.K,prefix:R.SHORT[""]},LUMINOUS_INTENSITY:{unit:z.cd,prefix:R.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:z.mol,prefix:R.SHORT[""]},ANGLE:{unit:z.rad,prefix:R.SHORT[""]},BIT:{unit:z.bits,prefix:R.SHORT[""]},FORCE:{unit:z.N,prefix:R.SHORT[""]},ENERGY:{unit:z.J,prefix:R.SHORT[""]},POWER:{unit:z.W,prefix:R.SHORT[""]},PRESSURE:{unit:z.Pa,prefix:R.SHORT[""]},ELECTRIC_CHARGE:{unit:z.C,prefix:R.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:z.F,prefix:R.SHORT[""]},ELECTRIC_POTENTIAL:{unit:z.V,prefix:R.SHORT[""]},ELECTRIC_RESISTANCE:{unit:z.ohm,prefix:R.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:z.H,prefix:R.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:z.S,prefix:R.SHORT[""]},MAGNETIC_FLUX:{unit:z.Wb,prefix:R.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:z.T,prefix:R.SHORT[""]},FREQUENCY:{unit:z.Hz,prefix:R.SHORT[""]}}};F.cgs=JSON.parse(JSON.stringify(F.si)),F.cgs.LENGTH={unit:z.m,prefix:R.SHORT.c},F.cgs.MASS={unit:z.g,prefix:R.SHORT[""]},F.cgs.FORCE={unit:z.dyn,prefix:R.SHORT[""]},F.cgs.ENERGY={unit:z.erg,prefix:R.NONE[""]},F.us=JSON.parse(JSON.stringify(F.si)),F.us.LENGTH={unit:z.ft,prefix:R.NONE[""]},F.us.MASS={unit:z.lbm,prefix:R.NONE[""]},F.us.TEMPERATURE={unit:z.degF,prefix:R.NONE[""]},F.us.FORCE={unit:z.lbf,prefix:R.NONE[""]},F.us.ENERGY={unit:z.BTU,prefix:R.BTU[""]},F.us.POWER={unit:z.hp,prefix:R.NONE[""]},F.us.PRESSURE={unit:z.psi,prefix:R.NONE[""]},F.auto=JSON.parse(JSON.stringify(F.si));var $=F.auto;for(var H in M.setUnitSystem=function(e){if(!_L(F,e))throw new Error("Unit system "+e+" does not exist. Choices are: "+Object.keys(F).join(", "));$=F[e]},M.getUnitSystem=function(){for(var e in F)if(_L(F,e)&&F[e]===$)return e},M.typeConverters={BigNumber:function(e){return new b(e+"")},Fraction:function(e){return new w(e)},Complex:function(e){return e},number:function(e){return e}},M._getNumberConverter=function(e){if(!M.typeConverters[e])throw new TypeError('Unsupported type "'+e+'"');return M.typeConverters[e]},z)if(_L(z,H)){var U=z[H];U.dimensions=U.base.dimensions}for(var q in P)if(_L(P,q)){var V=z[P[q]],W={};for(var K in V)_L(V,K)&&(W[K]=V[K]);W.name=q,z[q]=W}return M.isValidAlpha=function(e){return/^[a-zA-Z]$/.test(e)},M.createUnit=function(e,t){if("object"!==NV(e))throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(t&&t.override)for(var n in e)if(_L(e,n)&&M.deleteUnit(n),e[n].aliases)for(var r=0;r<e[n].aliases.length;r++)M.deleteUnit(e[n].aliases[r]);var i;for(var o in e)_L(e,o)&&(i=M.createUnitSingle(o,e[o]));return i},M.createUnitSingle=function(e,t,n){if(null==t&&(t={}),"string"!=typeof e)throw new TypeError("createUnitSingle expects first parameter to be of type 'string'");if(_L(z,e))throw new Error('Cannot create unit "'+e+'": a unit with that name already exists');!function(e){for(var t=0;t<e.length;t++){if(r=e.charAt(t),0===t&&!M.isValidAlpha(r))throw new Error('Invalid unit name (must begin with alpha character): "'+e+'"');if(t>0&&!M.isValidAlpha(r)&&!E(r))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+e+'"')}}(e);var i,o,s,a=null,l=[],c=0;if(t&&"Unit"===t.type)a=t.clone();else if("string"==typeof t)""!==t&&(i=t);else{if("object"!==NV(t))throw new TypeError('Cannot create unit "'+e+'" from "'+t.toString()+'": expecting "string" or "Unit" or "Object"');i=t.definition,o=t.prefixes,c=t.offset,s=t.baseName,t.aliases&&(l=t.aliases.valueOf())}if(l)for(var u=0;u<l.length;u++)if(_L(z,l[u]))throw new Error('Cannot create alias "'+l[u]+'": a unit with that name already exists');if(i&&"string"==typeof i&&!a)try{a=M.parse(i,{allowNoUnits:!0})}catch(t){throw t.message='Could not create unit "'+e+'" from "'+i+'": '+t.message,t}else i&&"Unit"===i.type&&(a=i.clone());l=l||[],c=c||0,o=o&&o.toUpperCase&&R[o.toUpperCase()]||R.NONE;var d={};if(a){d={name:e,value:a.value,dimensions:a.dimensions.slice(0),prefixes:o,offset:c};var p=!1;for(var h in I)if(_L(I,h)){for(var f=!0,m=0;m<D.length;m++)if(Math.abs((d.dimensions[m]||0)-(I[h].dimensions[m]||0))>1e-12){f=!1;break}if(f){p=!0,d.base=I[h];break}}if(!p){s=s||e+"_STUFF";var g={dimensions:a.dimensions.slice(0)};g.key=s,I[s]=g,$[s]={unit:d,prefix:R.NONE[""]},d.base=I[s]}}else{if(s=s||e+"_STUFF",D.indexOf(s)>=0)throw new Error('Cannot create new base unit "'+e+'": a base unit with that name already exists (and cannot be overridden)');for(var y in D.push(s),I)_L(I,y)&&(I[y].dimensions[D.length-1]=0);for(var v={dimensions:[]},b=0;b<D.length;b++)v.dimensions[b]=0;v.dimensions[D.length-1]=1,v.key=s,I[s]=v,d={name:e,value:1,dimensions:I[s].dimensions.slice(0),prefixes:o,offset:c,base:I[s]},$[s]={unit:d,prefix:R.NONE[""]}}M.UNITS[e]=d;for(var w=0;w<l.length;w++){var x=l[w],S={};for(var C in d)_L(d,C)&&(S[C]=d[C]);S.name=x,M.UNITS[x]=S}return new M(null,e)},M.deleteUnit=function(e){delete M.UNITS[e]},M.PREFIXES=R,M.BASE_DIMENSIONS=D,M.BASE_UNITS=I,M.UNIT_SYSTEMS=F,M.UNITS=z,M},{isClass:!0}),RV="unit",DV=kB(RV,["typed","Unit"],function(e){var t=e.typed,n=e.Unit;return t(RV,{Unit:function(e){return e.clone()},string:function(e){return n.isValuelessUnit(e)?new n(null,e):n.parse(e,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string":function(e,t){return new n(e,t)},"Array | Matrix":function(e){return KP(e,this)}})}),IV="sparse",LV=kB(IV,["typed","SparseMatrix"],function(e){var t=e.typed,n=e.SparseMatrix;return t(IV,{"":function(){return new n([])},string:function(e){return new n([],e)},"Array | Matrix":function(e){return new n(e)},"Array | Matrix, string":function(e,t){return new n(e,t)}})}),BV="createUnit",zV=kB(BV,["typed","Unit"],function(e){var t=e.typed,n=e.Unit;return t(BV,{"Object, Object":function(e,t){return n.createUnit(e,t)},Object:function(e){return n.createUnit(e,{})},"string, Unit | string | Object, Object":function(e,t,r){var i={};return i[e]=t,n.createUnit(i,r)},"string, Unit | string | Object":function(e,t){var r={};return r[e]=t,n.createUnit(r,{})},string:function(e){var t={};return t[e]={},n.createUnit(t,{})}})}),PV="acos",jV=kB(PV,["typed","config","Complex"],function(e){var t=e.typed,n=e.config,r=e.Complex;return t(PV,{number:function(e){return e>=-1&&e<=1||n.predictable?Math.acos(e):new r(e,0).acos()},Complex:function(e){return e.acos()},BigNumber:function(e){return e.acos()},"Array | Matrix":function(e){return KP(e,this)}})}),FV="acosh",$V=kB(FV,["typed","config","Complex"],function(e){var t=e.typed,n=e.config,r=e.Complex;return t(FV,{number:function(e){return e>=1||n.predictable?Vj(e):e<=-1?new r(Math.log(Math.sqrt(e*e-1)-e),Math.PI):new r(e,0).acosh()},Complex:function(e){return e.acosh()},BigNumber:function(e){return e.acosh()},"Array | Matrix":function(e){return KP(e,this)}})}),HV="acot",UV=kB(HV,["typed","BigNumber"],function(e){var t=e.typed,n=e.BigNumber;return t(HV,{number:Wj,Complex:function(e){return e.acot()},BigNumber:function(e){return new n(1).div(e).atan()},"Array | Matrix":function(e){return KP(e,this)}})}),qV="acoth",VV=kB(qV,["typed","config","Complex","BigNumber"],function(e){var t=e.typed,n=e.config,r=e.Complex,i=e.BigNumber;return t(qV,{number:function(e){return e>=1||e<=-1||n.predictable?Kj(e):new r(e,0).acoth()},Complex:function(e){return e.acoth()},BigNumber:function(e){return new i(1).div(e).atanh()},"Array | Matrix":function(e){return KP(e,this)}})}),WV="acsc",KV=kB(WV,["typed","config","Complex","BigNumber"],function(e){var t=e.typed,n=e.config,r=e.Complex,i=e.BigNumber;return t(WV,{number:function(e){return e<=-1||e>=1||n.predictable?Gj(e):new r(e,0).acsc()},Complex:function(e){return e.acsc()},BigNumber:function(e){return new i(1).div(e).asin()},"Array | Matrix":function(e){return KP(e,this)}})}),GV="acsch",JV=kB(GV,["typed","BigNumber"],function(e){var t=e.typed,n=e.BigNumber;return t(GV,{number:Jj,Complex:function(e){return e.acsch()},BigNumber:function(e){return new n(1).div(e).asinh()},"Array | Matrix":function(e){return KP(e,this)}})}),YV="asec",ZV=kB(YV,["typed","config","Complex","BigNumber"],function(e){var t=e.typed,n=e.config,r=e.Complex,i=e.BigNumber;return t(YV,{number:function(e){return e<=-1||e>=1||n.predictable?Yj(e):new r(e,0).asec()},Complex:function(e){return e.asec()},BigNumber:function(e){return new i(1).div(e).acos()},"Array | Matrix":function(e){return KP(e,this)}})}),XV="asech",QV=kB(XV,["typed","config","Complex","BigNumber"],function(e){var t=e.typed,n=e.config,r=e.Complex,i=e.BigNumber;return t(XV,{number:function(e){if(e<=1&&e>=-1||n.predictable){var t=1/e;if(t>0||n.predictable)return Zj(e);var i=Math.sqrt(t*t-1);return new r(Math.log(i-t),Math.PI)}return new r(e,0).asech()},Complex:function(e){return e.asech()},BigNumber:function(e){return new i(1).div(e).acosh()},"Array | Matrix":function(e){return KP(e,this)}})}),eW="asin",tW=kB(eW,["typed","config","Complex"],function(e){var t=e.typed,n=e.config,r=e.Complex;return t(eW,{number:function(e){return e>=-1&&e<=1||n.predictable?Math.asin(e):new r(e,0).asin()},Complex:function(e){return e.asin()},BigNumber:function(e){return e.asin()},"Array | Matrix":function(e){return KP(e,this)}})}),nW=kB("asinh",["typed"],function(e){return(0,e.typed)("asinh",{number:Xj,Complex:function(e){return e.asinh()},BigNumber:function(e){return e.asinh()},"Array | Matrix":function(e){return KP(e,this)}})}),rW=kB("atan",["typed"],function(e){return(0,e.typed)("atan",{number:function(e){return Math.atan(e)},Complex:function(e){return e.atan()},BigNumber:function(e){return e.atan()},"Array | Matrix":function(e){return KP(e,this)}})}),iW="atan2",oW=kB(iW,["typed","matrix","equalScalar","BigNumber","DenseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.equalScalar,i=e.BigNumber,o=e.DenseMatrix,s=b$({typed:t,equalScalar:r}),a=N$({typed:t}),l=V$({typed:t,equalScalar:r}),c=e$({typed:t,equalScalar:r}),u=k$({typed:t,DenseMatrix:o}),d=y$({typed:t}),p=t$({typed:t});return t(iW,{"number, number":Math.atan2,"BigNumber, BigNumber":function(e,t){return i.atan2(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return l(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return d(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, number | BigNumber":function(e,t){return c(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return u(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return p(n(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return p(n(t),e,this,!0).valueOf()}})}),sW="atanh",aW=kB(sW,["typed","config","Complex"],function(e){var t=e.typed,n=e.config,r=e.Complex;return t(sW,{number:function(e){return e<=1&&e>=-1||n.predictable?Qj(e):new r(e,0).atanh()},Complex:function(e){return e.atanh()},BigNumber:function(e){return e.atanh()},"Array | Matrix":function(e){return KP(e,this)}})}),lW=kB("cos",["typed"],function(e){return(0,e.typed)("cos",{number:Math.cos,Complex:function(e){return e.cos()},BigNumber:function(e){return e.cos()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cos is no angle");return this(e.value)},"Array | Matrix":function(e){return KP(e,this)}})}),cW="cosh",uW=kB(cW,["typed"],function(e){return(0,e.typed)(cW,{number:eB,Complex:function(e){return e.cosh()},BigNumber:function(e){return e.cosh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cosh is no angle");return this(e.value)},"Array | Matrix":function(e){return KP(e,this)}})}),dW=kB("cot",["typed","BigNumber"],function(e){var t=e.typed,n=e.BigNumber;return t("cot",{number:eF,Complex:function(e){return e.cot()},BigNumber:function(e){return new n(1).div(e.tan())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return this(e.value)},"Array | Matrix":function(e){return KP(e,this)}})}),pW="coth",hW=kB(pW,["typed","BigNumber"],function(e){var t=e.typed,n=e.BigNumber;return t(pW,{number:tF,Complex:function(e){return e.coth()},BigNumber:function(e){return new n(1).div(e.tanh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function coth is no angle");return this(e.value)},"Array | Matrix":function(e){return KP(e,this)}})}),fW=kB("csc",["typed","BigNumber"],function(e){var t=e.typed,n=e.BigNumber;return t("csc",{number:nF,Complex:function(e){return e.csc()},BigNumber:function(e){return new n(1).div(e.sin())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csc is no angle");return this(e.value)},"Array | Matrix":function(e){return KP(e,this)}})}),mW="csch",gW=kB(mW,["typed","BigNumber"],function(e){var t=e.typed,n=e.BigNumber;return t(mW,{number:rF,Complex:function(e){return e.csch()},BigNumber:function(e){return new n(1).div(e.sinh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csch is no angle");return this(e.value)},"Array | Matrix":function(e){return KP(e,this)}})}),yW=kB("sec",["typed","BigNumber"],function(e){var t=e.typed,n=e.BigNumber;return t("sec",{number:iF,Complex:function(e){return e.sec()},BigNumber:function(e){return new n(1).div(e.cos())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sec is no angle");return this(e.value)},"Array | Matrix":function(e){return KP(e,this)}})}),vW="sech",bW=kB(vW,["typed","BigNumber"],function(e){var t=e.typed,n=e.BigNumber;return t(vW,{number:oF,Complex:function(e){return e.sech()},BigNumber:function(e){return new n(1).div(e.cosh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sech is no angle");return this(e.value)},"Array | Matrix":function(e){return KP(e,this)}})}),wW=kB("sin",["typed"],function(e){return(0,e.typed)("sin",{number:Math.sin,Complex:function(e){return e.sin()},BigNumber:function(e){return e.sin()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sin is no angle");return this(e.value)},"Array | Matrix":function(e){return KP(e,this)}})}),xW="sinh",MW=kB(xW,["typed"],function(e){return(0,e.typed)(xW,{number:sF,Complex:function(e){return e.sinh()},BigNumber:function(e){return e.sinh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sinh is no angle");return this(e.value)},"Array | Matrix":function(e){return KP(e,this)}})}),SW=kB("tan",["typed"],function(e){return(0,e.typed)("tan",{number:Math.tan,Complex:function(e){return e.tan()},BigNumber:function(e){return e.tan()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tan is no angle");return this(e.value)},"Array | Matrix":function(e){return KP(e,this)}})}),EW=kB("tanh",["typed"],function(e){return(0,e.typed)("tanh",{number:nB,Complex:function(e){return e.tanh()},BigNumber:function(e){return e.tanh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tanh is no angle");return this(e.value)},"Array | Matrix":function(e){return KP(e,this)}})}),CW="setCartesian",NW=kB(CW,["typed","size","subset","compareNatural","Index","DenseMatrix"],function(e){var t=e.typed,n=e.size,r=e.subset,i=e.compareNatural,o=e.Index,s=e.DenseMatrix;return t(CW,{"Array | Matrix, Array | Matrix":function(e,t){var a=[];if(0!==r(n(e),new o(0))&&0!==r(n(t),new o(0))){var l=SB(Array.isArray(e)?e:e.toArray()).sort(i),c=SB(Array.isArray(t)?t:t.toArray()).sort(i);a=[];for(var u=0;u<l.length;u++)for(var d=0;d<c.length;d++)a.push([l[u],c[d]])}return Array.isArray(e)&&Array.isArray(t)?a:new s(a)}})}),AW="setDifference",kW=kB(AW,["typed","size","subset","compareNatural","Index","DenseMatrix"],function(e){var t=e.typed,n=e.size,r=e.subset,i=e.compareNatural,o=e.Index,s=e.DenseMatrix;return t(AW,{"Array | Matrix, Array | Matrix":function(e,t){var a;if(0===r(n(e),new o(0)))a=[];else{if(0===r(n(t),new o(0)))return SB(e.toArray());var l,c=CB(SB(Array.isArray(e)?e:e.toArray()).sort(i)),u=CB(SB(Array.isArray(t)?t:t.toArray()).sort(i));a=[];for(var d=0;d<c.length;d++){l=!1;for(var p=0;p<u.length;p++)if(0===i(c[d].value,u[p].value)&&c[d].identifier===u[p].identifier){l=!0;break}l||a.push(c[d])}}return Array.isArray(e)&&Array.isArray(t)?NB(a):new s(NB(a))}})}),TW="setDistinct",OW=kB(TW,["typed","size","subset","compareNatural","Index","DenseMatrix"],function(e){var t=e.typed,n=e.size,r=e.subset,i=e.compareNatural,o=e.Index,s=e.DenseMatrix;return t(TW,{"Array | Matrix":function(e){var t;if(0===r(n(e),new o(0)))t=[];else{var a=SB(Array.isArray(e)?e:e.toArray()).sort(i);(t=[]).push(a[0]);for(var l=1;l<a.length;l++)0!==i(a[l],a[l-1])&&t.push(a[l])}return Array.isArray(e)?t:new s(t)}})}),_W="setIntersect",RW=kB(_W,["typed","size","subset","compareNatural","Index","DenseMatrix"],function(e){var t=e.typed,n=e.size,r=e.subset,i=e.compareNatural,o=e.Index,s=e.DenseMatrix;return t(_W,{"Array | Matrix, Array | Matrix":function(e,t){var a;if(0===r(n(e),new o(0))||0===r(n(t),new o(0)))a=[];else{var l=CB(SB(Array.isArray(e)?e:e.toArray()).sort(i)),c=CB(SB(Array.isArray(t)?t:t.toArray()).sort(i));a=[];for(var u=0;u<l.length;u++)for(var d=0;d<c.length;d++)if(0===i(l[u].value,c[d].value)&&l[u].identifier===c[d].identifier){a.push(l[u]);break}}return Array.isArray(e)&&Array.isArray(t)?NB(a):new s(NB(a))}})}),DW="setIsSubset",IW=kB(DW,["typed","size","subset","compareNatural","Index"],function(e){var t=e.typed,n=e.size,r=e.subset,i=e.compareNatural,o=e.Index;return t(DW,{"Array | Matrix, Array | Matrix":function(e,t){if(0===r(n(e),new o(0)))return!0;if(0===r(n(t),new o(0)))return!1;for(var s,a=CB(SB(Array.isArray(e)?e:e.toArray()).sort(i)),l=CB(SB(Array.isArray(t)?t:t.toArray()).sort(i)),c=0;c<a.length;c++){s=!1;for(var u=0;u<l.length;u++)if(0===i(a[c].value,l[u].value)&&a[c].identifier===l[u].identifier){s=!0;break}if(!1===s)return!1}return!0}})}),LW="setMultiplicity",BW=kB(LW,["typed","size","subset","compareNatural","Index"],function(e){var t=e.typed,n=e.size,r=e.subset,i=e.compareNatural,o=e.Index;return t(LW,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(e,t){if(0===r(n(t),new o(0)))return 0;for(var s=SB(Array.isArray(t)?t:t.toArray()),a=0,l=0;l<s.length;l++)0===i(s[l],e)&&a++;return a}})}),zW="setPowerset",PW=kB(zW,["typed","size","subset","compareNatural","Index"],function(e){var t=e.typed,n=e.size,r=e.subset,i=e.compareNatural,o=e.Index;return t(zW,{"Array | Matrix":function(e){if(0===r(n(e),new o(0)))return[];for(var t=SB(Array.isArray(e)?e:e.toArray()).sort(i),a=[],l=0;l.toString(2).length<=t.length;)a.push(s(t,l.toString(2).split("").reverse())),l++;return function(e){for(var t=[],n=e.length-1;n>0;n--)for(var r=0;r<n;r++)e[r].length>e[r+1].length&&(t=e[r],e[r]=e[r+1],e[r+1]=t);return e}(a)}});function s(e,t){for(var n=[],r=0;r<t.length;r++)"1"===t[r]&&n.push(e[r]);return n}}),jW="setSize",FW=kB(jW,["typed","compareNatural"],function(e){var t=e.typed,n=e.compareNatural;return t(jW,{"Array | Matrix":function(e){return Array.isArray(e)?SB(e).length:SB(e.toArray()).length},"Array | Matrix, boolean":function(e,t){if(!1===t||0===e.length)return Array.isArray(e)?SB(e).length:SB(e.toArray()).length;for(var r=SB(Array.isArray(e)?e:e.toArray()).sort(n),i=1,o=1;o<r.length;o++)0!==n(r[o],r[o-1])&&i++;return i}})}),$W="setSymDifference",HW=kB($W,["typed","size","concat","subset","setDifference","Index"],function(e){var t=e.typed,n=e.size,r=e.concat,i=e.subset,o=e.setDifference,s=e.Index;return t($W,{"Array | Matrix, Array | Matrix":function(e,t){if(0===i(n(e),new s(0)))return SB(t);if(0===i(n(t),new s(0)))return SB(e);var a=SB(e),l=SB(t);return r(o(a,l),o(l,a))}})}),UW="setUnion",qW=kB(UW,["typed","size","concat","subset","setIntersect","setSymDifference","Index"],function(e){var t=e.typed,n=e.size,r=e.concat,i=e.subset,o=e.setIntersect,s=e.setSymDifference,a=e.Index;return t(UW,{"Array | Matrix, Array | Matrix":function(e,t){if(0===i(n(e),new a(0)))return SB(t);if(0===i(n(t),new a(0)))return SB(e);var l=SB(e),c=SB(t);return r(s(l,c),o(l,c))}})}),VW=kB("add",["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.addScalar,i=e.equalScalar,o=e.DenseMatrix;e.SparseMatrix;var s=f$({typed:t}),a=m$({typed:t,equalScalar:i}),l=g$({typed:t,DenseMatrix:o}),c=y$({typed:t}),u=t$({typed:t});return t("add",TL({"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,r)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,r,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,r,!0)},"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,r)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"DenseMatrix, any":function(e,t){return u(e,t,r,!1)},"SparseMatrix, any":function(e,t){return l(e,t,r,!1)},"any, DenseMatrix":function(e,t){return u(t,e,r,!0)},"any, SparseMatrix":function(e,t){return l(t,e,r,!0)},"Array, any":function(e,t){return u(n(e),t,r,!1).valueOf()},"any, Array":function(e,t){return u(n(t),e,r,!0).valueOf()},"any, any":r,"any, any, ...any":function(e,t,n){for(var r=this(e,t),i=0;i<n.length;i++)r=this(r,n[i]);return r}},r.signatures))}),WW="hypot",KW=kB(WW,["typed","abs","addScalar","divideScalar","multiplyScalar","sqrt","smaller","isPositive"],function(e){var t=e.typed,n=e.abs,r=e.addScalar,i=e.divideScalar,o=e.multiplyScalar,s=e.sqrt,a=e.smaller,l=e.isPositive;return t(WW,{"... number | BigNumber":function(e){for(var t=0,c=0,u=0;u<e.length;u++){var d=n(e[u]);a(c,d)?(t=o(t,o(i(c,d),i(c,d))),t=r(t,1),c=d):t=r(t,l(d)?o(i(d,c),i(d,c)):d)}return o(c,s(t))},Array:function(e){return this.apply(this,SB(e))},Matrix:function(e){return this.apply(this,SB(e.toArray()))}})}),GW="norm",JW=kB(GW,["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],function(e){var t=e.typed,n=e.abs,r=e.add,i=e.pow,o=e.conj,s=e.sqrt,a=e.multiply,l=e.equalScalar,c=e.larger,u=e.smaller,d=e.matrix,p=e.ctranspose,h=e.eigs;return t(GW,{number:Math.abs,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},boolean:function(e){return Math.abs(e)},Array:function(e){return g(d(e),2)},Matrix:function(e){return g(e,2)},"number | Complex | BigNumber | boolean, number | BigNumber | string":function(e){return this(e)},"Array, number | BigNumber | string":function(e,t){return g(d(e),t)},"Matrix, number | BigNumber | string":function(e,t){return g(e,t)}});function f(e,t){if(t===Number.POSITIVE_INFINITY||"inf"===t)return function(e){var t=0;return e.forEach(function(e){var r=n(e);c(r,t)&&(t=r)},!0),t}(e);if(t===Number.NEGATIVE_INFINITY||"-inf"===t)return function(e){var t;return e.forEach(function(e){var r=n(e);t&&!u(r,t)||(t=r)},!0),t||0}(e);if("fro"===t)return g(e,2);if("number"==typeof t&&!isNaN(t)){if(!l(t,0)){var o=0;return e.forEach(function(e){o=r(i(n(e),t),o)},!0),i(o,1/t)}return Number.POSITIVE_INFINITY}throw new Error("Unsupported parameter value")}function m(e,t){if(1===t)return function(e){var t=[],i=0;return e.forEach(function(e,o){var s=o[1],a=r(t[s]||0,n(e));c(a,i)&&(i=a),t[s]=a},!0),i}(e);if(t===Number.POSITIVE_INFINITY||"inf"===t)return function(e){var t=[],i=0;return e.forEach(function(e,o){var s=o[0],a=r(t[s]||0,n(e));c(a,i)&&(i=a),t[s]=a},!0),i}(e);if("fro"===t)return function(e){var t=0;return e.forEach(function(e,n){t=r(t,a(e,o(e)))}),n(s(t))}(e);if(2===t)return function(e){var t=e.size();if(t[0]!==t[1])throw new RangeError("Invalid matrix dimensions");var r=p(e),i=a(r,e),o=h(i).values,l=o.get([o.size()[0]-1]);return n(s(l))}(e);throw new Error("Unsupported parameter value "+t)}function g(e,t){var n=e.size();if(1===n.length)return f(e,t);if(2===n.length){if(n[0]&&n[1])return m(e,t);throw new RangeError("Invalid matrix dimensions")}}}),YW=kB("dot",["typed","addScalar","multiplyScalar","conj","size"],function(e){var t=e.typed,n=e.addScalar,r=e.multiplyScalar,i=e.conj,o=e.size;return t("dot",{"Array | DenseMatrix, Array | DenseMatrix":function(e,o){var l=s(e,o),c=JI(e)?e._data:e,u=JI(e)?e._datatype:void 0,d=JI(o)?o._data:o,p=JI(o)?o._datatype:void 0,h=2===a(e).length,f=2===a(o).length,m=n,g=r;if(u&&p&&u===p&&"string"==typeof u){var y=u;m=t.find(n,[y,y]),g=t.find(r,[y,y])}if(!h&&!f){for(var v=g(i(c[0]),d[0]),b=1;b<l;b++)v=m(v,g(i(c[b]),d[b]));return v}if(!h&&f){for(var w=g(i(c[0]),d[0][0]),x=1;x<l;x++)w=m(w,g(i(c[x]),d[x][0]));return w}if(h&&!f){for(var M=g(i(c[0][0]),d[0]),S=1;S<l;S++)M=m(M,g(i(c[S][0]),d[S]));return M}if(h&&f){for(var E=g(i(c[0][0]),d[0][0]),C=1;C<l;C++)E=m(E,g(i(c[C][0]),d[C][0]));return E}},"SparseMatrix, SparseMatrix":function(e,t){s(e,t);var i=e._index,o=e._values,a=t._index,l=t._values,c=0,u=n,d=r,p=0,h=0;for(;p<i.length&&h<a.length;){var f=i[p],m=a[h];f<m?p++:f>m?h++:f===m&&(c=u(c,d(o[p],l[h])),p++,h++)}return c}});function s(e,t){var n,r,i=a(e),o=a(t);if(1===i.length)n=i[0];else{if(2!==i.length||1!==i[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+i.join(", ")+")");n=i[0]}if(1===o.length)r=o[0];else{if(2!==o.length||1!==o[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+o.join(", ")+")");r=o[0]}if(n!==r)throw new RangeError("Vectors must have equal length ("+n+" != "+r+")");if(0===n)throw new RangeError("Cannot calculate the dot product of empty vectors");return n}function a(e){return JI(e)?e.size():o(e)}}),ZW=kB("trace",["typed","matrix","add"],function(e){var t=e.typed,n=e.matrix,r=e.add;return t("trace",{Array:function(e){return i(n(e))},SparseMatrix:function(e){var t=e._values,n=e._index,i=e._ptr,o=e._size,s=o[0],a=o[1];if(s===a){var l=0;if(t.length>0)for(var c=0;c<a;c++)for(var u=i[c],d=i[c+1],p=u;p<d;p++){var h=n[p];if(h===c){l=r(l,t[p]);break}if(h>c)break}return l}throw new RangeError("Matrix must be square (size: "+aB(o)+")")},DenseMatrix:i,any:kL});function i(e){var t=e._size,n=e._data;switch(t.length){case 1:if(1===t[0])return kL(n[0]);throw new RangeError("Matrix must be square (size: "+aB(t)+")");case 2:var i=t[0];if(i===t[1]){for(var o=0,s=0;s<i;s++)o=r(o,n[s][s]);return o}throw new RangeError("Matrix must be square (size: "+aB(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+aB(t)+")")}}}),XW="index",QW=kB(XW,["typed","Index"],function(e){var t=e.typed,n=e.Index;return t(XW,{"...number | string | BigNumber | Range | Array | Matrix":function(e){var t=e.map(function(e){return UI(e)?e.toNumber():Array.isArray(e)||JI(e)?e.map(function(e){return UI(e)?e.toNumber():e}):e}),r=new n;return n.apply(r,t),r}})}),eK=kB("lup",["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtract","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],function(e){var t=e.typed,n=e.matrix,r=e.abs,i=e.addScalar,o=e.divideScalar,s=e.multiplyScalar,a=e.subtract,l=e.larger,c=e.equalScalar,u=e.unaryMinus,d=e.DenseMatrix,p=e.SparseMatrix,h=e.Spa;return t("lup",{DenseMatrix:function(e){return f(e)},SparseMatrix:function(e){return m(e)},Array:function(e){var t=f(n(e));return{L:t.L.valueOf(),U:t.U.valueOf(),p:t.p}}});function f(e){var t,n,u,p=e._size[0],h=e._size[1],f=Math.min(p,h),m=kL(e._data),g=[],y=[p,f],v=[],b=[f,h],w=[];for(t=0;t<p;t++)w[t]=t;for(n=0;n<h;n++){if(n>0)for(t=0;t<p;t++){var x=Math.min(t,n),M=0;for(u=0;u<x;u++)M=i(M,s(m[t][u],m[u][n]));m[t][n]=a(m[t][n],M)}var S=n,E=0,C=0;for(t=n;t<p;t++){var N=m[t][n],A=r(N);l(A,E)&&(S=t,E=A,C=N)}if(n!==S&&(w[n]=[w[S],w[S]=w[n]][0],d._swapRows(n,S,m)),n<p)for(t=n+1;t<p;t++){var k=m[t][n];c(k,0)||(m[t][n]=o(m[t][n],C))}}for(n=0;n<h;n++)for(t=0;t<p;t++)0===n&&(t<h&&(v[t]=[]),g[t]=[]),t<n?(t<h&&(v[t][n]=m[t][n]),n<p&&(g[t][n]=0)):t!==n?(t<h&&(v[t][n]=0),n<p&&(g[t][n]=m[t][n])):(t<h&&(v[t][n]=m[t][n]),n<p&&(g[t][n]=1));var T=new d({data:g,size:y}),O=new d({data:v,size:b}),_=[];for(t=0,f=w.length;t<f;t++)_[w[t]]=t;return{L:T,U:O,p:_,toString:function(){return"L: "+this.L.toString()+"\nU: "+this.U.toString()+"\nP: "+this.p}}}function m(e){var t,n,i,a=e._size[0],d=e._size[1],f=Math.min(a,d),m=e._values,g=e._index,y=e._ptr,v=[],b=[],w=[],x=[a,f],M=[],S=[],E=[],C=[f,d],N=[],A=[];for(t=0;t<a;t++)N[t]=t,A[t]=t;var k=function(){var e=new h;n<a&&(w.push(v.length),v.push(1),b.push(n)),E.push(M.length);var d=y[n],f=y[n+1];for(i=d;i<f;i++)t=g[i],e.set(N[t],m[i]);n>0&&e.forEach(0,n-1,function(t,n){p._forEachRow(t,v,b,w,function(r,i){r>t&&e.accumulate(r,u(s(i,n)))})});var k,T,O,_,R=n,D=e.get(n),I=r(D);e.forEach(n+1,a-1,function(e,t){var n=r(t);l(n,I)&&(R=e,I=n,D=t)}),n!==R&&(p._swapRows(n,R,x[1],v,b,w),p._swapRows(n,R,C[1],M,S,E),e.swap(n,R),T=R,O=A[k=n],_=A[T],N[O]=T,N[_]=k,A[k]=_,A[T]=O),e.forEach(0,a-1,function(e,t){e<=n?(M.push(t),S.push(e)):(t=o(t,D),c(t,0)||(v.push(t),b.push(e)))})};for(n=0;n<d;n++)k();return E.push(M.length),w.push(v.length),{L:new p({values:v,index:b,ptr:w,size:x}),U:new p({values:M,index:S,ptr:E,size:C}),p:N,toString:function(){return"L: "+this.L.toString()+"\nU: "+this.U.toString()+"\nP: "+this.p}}}});function tK(){return tK=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},tK.apply(this,arguments)}var nK=kB("qr",["typed","matrix","zeros","identity","isZero","equal","sign","sqrt","conj","unaryMinus","addScalar","divideScalar","multiplyScalar","subtract","complex"],function(e){var t=e.typed,n=e.matrix,r=e.zeros,i=e.identity,o=e.isZero,s=e.equal,a=e.sign,l=e.sqrt,c=e.conj,u=e.unaryMinus,d=e.addScalar,p=e.divideScalar,h=e.multiplyScalar,f=e.subtract,m=e.complex;return tK(t("qr",{DenseMatrix:function(e){return y(e)},SparseMatrix:function(e){return function(){throw new Error("qr not implemented for sparse matrices yet")}()},Array:function(e){var t=y(n(e));return{Q:t.Q.valueOf(),R:t.R.valueOf()}}}),{_denseQRimpl:g});function g(e){var t,n,m,g=e._size[0],y=e._size[1],v=i([g],"dense"),b=v._data,w=e.clone(),x=w._data,M=r([g],"");for(m=0;m<Math.min(y,g);++m){var S=x[m][m],E=u(s(S,0)?1:a(S)),C=c(E),N=0;for(t=m;t<g;t++)N=d(N,h(x[t][m],c(x[t][m])));var A=h(E,l(N));if(!o(A)){var k=f(S,A);for(M[m]=1,t=m+1;t<g;t++)M[t]=p(x[t][m],k);var T=u(c(p(k,A))),O=void 0;for(n=m;n<y;n++){for(O=0,t=m;t<g;t++)O=d(O,h(c(M[t]),x[t][n]));for(O=h(O,T),t=m;t<g;t++)x[t][n]=h(f(x[t][n],h(M[t],O)),C)}for(t=0;t<g;t++){for(O=0,n=m;n<g;n++)O=d(O,h(b[t][n],M[n]));for(O=h(O,T),n=m;n<g;++n)b[t][n]=p(f(b[t][n],h(O,c(M[n]))),C)}}}return{Q:v,R:w,toString:function(){return"Q: "+this.Q.toString()+"\nR: "+this.R.toString()}}}function y(e){var t=g(e),n=t.R._data;if(e._data.length>0)for(var r="Complex"===n[0][0].type?m(0):0,i=0;i<n.length;++i)for(var o=0;o<i&&o<(n[0]||[]).length;++o)n[i][o]=r;return t}});function rK(e,t,n,r,i,o,s){var a=0;for(n[s]=e;a>=0;){var l=n[s+a],c=n[r+l];-1===c?(a--,o[t++]=l):(n[r+l]=n[i+c],n[s+ ++a]=c)}return t}function iK(e){return-e-2}var oK=kB("csAmd",["add","multiply","transpose"],function(e){var t=e.add,n=e.multiply,r=e.transpose;return function(e,s){if(!s||e<=0||e>3)return null;var a=s._size,l=a[0],c=a[1],u=0,d=Math.max(16,10*Math.sqrt(c)),p=function(e,i,o,s,a){var l=r(i);if(1===e&&s===o)return t(i,l);if(2===e){for(var c=l._index,u=l._ptr,d=0,p=0;p<o;p++){var h=u[p];if(u[p]=d,!(u[p+1]-h>a))for(var f=u[p+1];h<f;h++)c[d++]=c[h]}return u[o]=d,i=r(l),n(l,i)}return n(l,i)}(e,s,l,c,d=Math.min(c-2,d));!function(e,t,n){for(var r=e._values,i=e._index,o=e._ptr,s=e._size[1],a=0,l=0;l<s;l++){var c=o[l];for(o[l]=a;c<o[l+1];c++)t(i[c],l,r?r[c]:1,n)&&(i[a]=i[c],r&&(r[a]=r[c]),a++)}o[s]=a,i.splice(a,i.length-a),r&&r.splice(a,r.length-a)}(p,o,null);for(var h,f,m,g,y,v,b,w,x,M,S,E,C,N,A,k,T=p._index,O=p._ptr,_=O[c],R=[],D=[],I=c+1,L=2*(c+1),B=3*(c+1),z=4*(c+1),P=5*(c+1),j=6*(c+1),F=7*(c+1),$=R,H=function(e,t,n,r,o,s,a,l,c,u,d,p){for(var h=0;h<e;h++)n[r+h]=t[h+1]-t[h];n[r+e]=0;for(var f=0;f<=e;f++)n[o+f]=-1,s[f]=-1,n[a+f]=-1,n[l+f]=-1,n[c+f]=1,n[u+f]=1,n[d+f]=0,n[p+f]=n[r+f];var m=i(0,0,n,u,e);return n[d+e]=-2,t[e]=-1,n[u+e]=0,m}(c,O,D,0,B,$,L,F,I,j,z,P),U=function(e,t,n,r,i,o,s,a,l,c,u){for(var d=0,p=0;p<e;p++){var h=n[r+p];if(0===h)n[i+p]=-2,d++,t[p]=-1,n[o+p]=0;else if(h>s)n[a+p]=0,n[i+p]=-1,d++,t[p]=iK(e),n[a+e]++;else{var f=n[l+h];-1!==f&&(c[f]=p),n[u+p]=n[l+h],n[l+h]=p}}return d}(c,O,D,P,z,j,d,I,B,$,L),q=0;U<c;){for(m=-1;q<c&&-1===(m=D[B+q]);q++);-1!==D[L+m]&&($[D[L+m]]=-1),D[B+q]=D[L+m];var V=D[z+m],W=D[I+m];U+=W;var K=0;D[I+m]=-W;var G=O[m],J=0===V?G:_,Y=J;for(g=1;g<=V+1;g++){for(g>V?(v=m,b=G,w=D[0+m]-V):(b=O[v=T[G++]],w=D[0+v]),y=1;y<=w;y++)(x=D[I+(h=T[b++])])<=0||(K+=x,D[I+h]=-x,T[Y++]=h,-1!==D[L+h]&&($[D[L+h]]=$[h]),-1!==$[h]?D[L+$[h]]=D[L+h]:D[B+D[P+h]]=D[L+h]);v!==m&&(O[v]=iK(m),D[j+v]=0)}for(0!==V&&(_=Y),D[P+m]=K,O[m]=J,D[0+m]=Y-J,D[z+m]=-2,H=i(H,u,D,j,c),M=J;M<Y;M++)if(!((S=D[z+(h=T[M])])<=0)){var Z=H-(x=-D[I+h]);for(G=O[h],E=O[h]+S-1;G<=E;G++)D[j+(v=T[G])]>=H?D[j+v]-=x:0!==D[j+v]&&(D[j+v]=D[P+v]+Z)}for(M=J;M<Y;M++){for(C=(E=O[h=T[M]])+D[z+h]-1,N=E,A=0,k=0,G=E;G<=C;G++)if(0!==D[j+(v=T[G])]){var X=D[j+v]-H;X>0?(k+=X,T[N++]=v,A+=v):(O[v]=iK(m),D[j+v]=0)}D[z+h]=N-E+1;var Q=N,ee=E+D[0+h];for(G=C+1;G<ee;G++){var te=D[I+(f=T[G])];te<=0||(k+=te,T[N++]=f,A+=f)}0===k?(O[h]=iK(m),K-=x=-D[I+h],W+=x,U+=x,D[I+h]=0,D[z+h]=-1):(D[P+h]=Math.min(D[P+h],k),T[N]=T[Q],T[Q]=T[E],T[E]=m,D[0+h]=N-E+1,A=(A<0?-A:A)%c,D[L+h]=D[F+A],D[F+A]=h,$[h]=A)}for(D[P+m]=K,H=i(H+(u=Math.max(u,K)),u,D,j,c),M=J;M<Y;M++)if(!(D[I+(h=T[M])]>=0))for(h=D[F+(A=$[h])],D[F+A]=-1;-1!==h&&-1!==D[L+h];h=D[L+h],H++){for(w=D[0+h],S=D[z+h],G=O[h]+1;G<=O[h]+w-1;G++)D[j+T[G]]=H;var ne=h;for(f=D[L+h];-1!==f;){var re=D[0+f]===w&&D[z+f]===S;for(G=O[f]+1;re&&G<=O[f]+w-1;G++)D[j+T[G]]!==H&&(re=0);re?(O[f]=iK(h),D[I+h]+=D[I+f],D[I+f]=0,D[z+f]=-1,f=D[L+f],D[L+ne]=f):(ne=f,f=D[L+f])}}for(G=J,M=J;M<Y;M++)(x=-D[I+(h=T[M])])<=0||(D[I+h]=x,k=D[P+h]+K-x,-1!==D[B+(k=Math.min(k,c-U-x))]&&($[D[B+k]]=h),D[L+h]=D[B+k],$[h]=-1,D[B+k]=h,q=Math.min(q,k),D[P+h]=k,T[G++]=h);D[I+m]=W,0===(D[0+m]=G-J)&&(O[m]=-1,D[j+m]=0),0!==V&&(_=G)}for(h=0;h<c;h++)O[h]=iK(O[h]);for(f=0;f<=c;f++)D[B+f]=-1;for(f=c;f>=0;f--)D[I+f]>0||(D[L+f]=D[B+O[f]],D[B+O[f]]=f);for(v=c;v>=0;v--)D[I+v]<=0||-1!==O[v]&&(D[L+v]=D[B+O[v]],D[B+O[v]]=v);for(m=0,h=0;h<=c;h++)-1===O[h]&&(m=rK(h,m,D,B,L,R,j));return R.splice(R.length-1,1),R};function i(e,t,n,r,i){if(e<2||e+t<0){for(var o=0;o<i;o++)0!==n[r+o]&&(n[r+o]=1);e=2}return e}function o(e,t){return e!==t}});function sK(e,t,n,r,i,o,s){var a,l,c,u=0;if(e<=t||n[r+t]<=n[i+e])return-1;n[i+e]=n[r+t];var d=n[o+e];if(n[o+e]=t,-1===d)u=1,c=e;else{for(u=2,c=d;c!==n[s+c];c=n[s+c]);for(a=d;a!==c;a=l)l=n[s+a],n[s+a]=c}return{jleaf:u,q:c}}var aK=kB("csCounts",["transpose"],function(e){var t=e.transpose;return function(e,n,r,i){if(!e||!n||!r)return null;var o,s,a,l,c,u,d,p=e._size,h=p[0],f=p[1],m=4*f+(i?f+h+1:0),g=[],y=f,v=2*f,b=3*f,w=4*f,x=5*f+1;for(a=0;a<m;a++)g[a]=-1;var M=[],S=t(e),E=S._index,C=S._ptr;for(a=0;a<f;a++)for(M[s=r[a]]=-1===g[b+s]?1:0;-1!==s&&-1===g[b+s];s=n[s])g[b+s]=a;if(i){for(a=0;a<f;a++)g[r[a]]=a;for(o=0;o<h;o++){for(a=f,u=C[o],d=C[o+1],c=u;c<d;c++)a=Math.min(a,g[E[c]]);g[x+o]=g[w+a],g[w+a]=o}}for(o=0;o<f;o++)g[0+o]=o;for(a=0;a<f;a++){for(-1!==n[s=r[a]]&&M[n[s]]--,l=i?g[w+a]:s;-1!==l;l=i?g[x+l]:-1)for(c=C[l];c<C[l+1];c++){var N=sK(o=E[c],s,g,b,y,v,0);N.jleaf>=1&&M[s]++,2===N.jleaf&&M[N.q]--}-1!==n[s]&&(g[0+s]=n[s])}for(s=0;s<f;s++)-1!==n[s]&&(M[n[s]]+=M[s]);return M}}),lK=kB("csSqr",["add","multiply","transpose"],function(e){var t=e.add,n=e.multiply,r=e.transpose,i=oK({add:t,multiply:n,transpose:r}),o=aK({transpose:r});return function(e,t,n){var r,s=t._ptr,a=t._size[1],l={};if(l.q=i(e,t),e&&!l.q)return null;if(n){var c=e?function(e,t,n,r){for(var i=e._values,o=e._index,s=e._ptr,a=e._size,l=e._datatype,c=a[0],u=a[1],d=r&&e._values?[]:null,p=[],h=[],f=0,m=0;m<u;m++){h[m]=f;for(var g=n?n[m]:m,y=s[g],v=s[g+1],b=y;b<v;b++){var w=t?t[o[b]]:o[b];p[f]=w,d&&(d[f]=i[b]),f++}}return h[u]=f,e.createSparseMatrix({values:d,index:p,ptr:h,size:[c,u],datatype:l})}(t,null,l.q,0):t;l.parent=function(e,t){if(!e)return null;var n,r,i=e._index,o=e._ptr,s=e._size,a=s[0],l=s[1],c=[],u=[],d=l;if(t)for(n=0;n<a;n++)u[d+n]=-1;for(var p=0;p<l;p++){c[p]=-1,u[0+p]=-1;for(var h=o[p],f=o[p+1],m=h;m<f;m++){var g=i[m];for(n=t?u[d+g]:g;-1!==n&&n<p;n=r)r=u[0+n],u[0+n]=p,-1===r&&(c[n]=p);t&&(u[d+g]=p)}}return c}(c,1);var u=function(e,t){if(!e)return null;var n,r=0,i=[],o=[],s=t,a=2*t;for(n=0;n<t;n++)o[0+n]=-1;for(n=t-1;n>=0;n--)-1!==e[n]&&(o[s+n]=o[0+e[n]],o[0+e[n]]=n);for(n=0;n<t;n++)-1===e[n]&&(r=rK(n,r,o,0,s,i,a));return i}(l.parent,a);if(l.cp=o(c,l.parent,u,1),c&&l.parent&&l.cp&&function(e,t){var n=e._ptr,r=e._index,i=e._size,o=i[0],s=i[1];t.pinv=[],t.leftmost=[];var a,l,c,u,d,p=t.parent,h=t.pinv,f=t.leftmost,m=[],g=0,y=o,v=o+s,b=o+2*s;for(l=0;l<s;l++)m[y+l]=-1,m[v+l]=-1,m[b+l]=0;for(a=0;a<o;a++)f[a]=-1;for(l=s-1;l>=0;l--)for(u=n[l],d=n[l+1],c=u;c<d;c++)f[r[c]]=l;for(a=o-1;a>=0;a--)h[a]=-1,-1!==(l=f[a])&&(0===m[b+l]++&&(m[v+l]=a),m[g+a]=m[y+l],m[y+l]=a);for(t.lnz=0,t.m2=o,l=0;l<s;l++)if(a=m[y+l],t.lnz++,a<0&&(a=t.m2++),h[a]=l,!(--b[l]<=0)){t.lnz+=m[b+l];var w=p[l];-1!==w&&(0===m[b+w]&&(m[v+w]=m[v+l]),m[g+m[v+l]]=m[y+w],m[y+w]=m[g+a],m[b+w]+=m[b+l])}for(a=0;a<o;a++)h[a]<0&&(h[a]=l++);return!0}(c,l))for(l.unz=0,r=0;r<a;r++)l.unz+=l.cp[r]}else l.unz=4*s[a]+a,l.lnz=l.unz;return l}});function cK(e,t){return e[t]<0}function uK(e,t){e[t]=iK(e[t])}function dK(e){return e<0?iK(e):e}function pK(e,t,n,r,i){var o,s,a,l=t._index,c=t._ptr,u=t._size[1],d=0;for(r[0]=e;d>=0;){e=r[d];var p=i?i[e]:e;cK(c,e)||(uK(c,e),r[u+d]=p<0?0:dK(c[p]));var h=1;for(s=r[u+d],a=p<0?0:dK(c[p+1]);s<a;s++)if(!cK(c,o=l[s])){r[u+d]=s,r[++d]=o,h=0;break}h&&(d--,r[--n]=e)}return n}var hK=kB("csSpsolve",["divideScalar","multiply","subtract"],function(e){var t=e.divideScalar,n=e.multiply,r=e.subtract;return function(e,i,o,s,a,l,c){var u,d,p,h,f=e._values,m=e._index,g=e._ptr,y=e._size[1],v=i._values,b=i._index,w=i._ptr,x=function(e,t,n,r,i){var o,s,a,l=e._ptr,c=e._size,u=t._index,d=t._ptr,p=c[1],h=p;for(s=d[n],a=d[n+1],o=s;o<a;o++){var f=u[o];cK(l,f)||(h=pK(f,e,h,r,i))}for(o=h;o<p;o++)uK(l,r[o]);return h}(e,i,o,s,l);for(u=x;u<y;u++)a[s[u]]=0;for(d=w[o],p=w[o+1],u=d;u<p;u++)a[b[u]]=v[u];for(var M=x;M<y;M++){var S=s[M],E=l?l[S]:S;if(!(E<0))for(d=g[E],p=g[E+1],a[S]=t(a[S],f[c?d:p-1]),u=c?d+1:d,h=c?p:p-1;u<h;u++){var C=m[u];a[C]=r(a[C],n(f[u],a[S]))}}return x}}),fK=kB("csLu",["abs","divideScalar","multiply","subtract","larger","largerEq","SparseMatrix"],function(e){var t=e.abs,n=e.divideScalar,r=e.multiply,i=e.subtract,o=e.larger,s=e.largerEq,a=e.SparseMatrix,l=hK({divideScalar:n,multiply:r,subtract:i});return function(e,i,c){if(!e)return null;var u,d=e._size[1],p=100,h=100;i&&(u=i.q,p=i.lnz||p,h=i.unz||h);var f,m,g=[],y=[],v=[],b=new a({values:g,index:y,ptr:v,size:[d,d]}),w=[],x=[],M=[],S=new a({values:w,index:x,ptr:M,size:[d,d]}),E=[],C=[],N=[];for(f=0;f<d;f++)C[f]=0,E[f]=-1,v[f+1]=0;p=0,h=0;for(var A=0;A<d;A++){v[A]=p,M[A]=h;var k=u?u[A]:A,T=l(b,e,k,N,C,E,1),O=-1,_=-1;for(m=T;m<d;m++)if(E[f=N[m]]<0){var R=t(C[f]);o(R,_)&&(_=R,O=f)}else x[h]=E[f],w[h++]=C[f];if(-1===O||_<=0)return null;E[k]<0&&s(t(C[k]),r(_,c))&&(O=k);var D=C[O];for(x[h]=A,w[h++]=D,E[O]=A,y[p]=O,g[p++]=1,m=T;m<d;m++)E[f=N[m]]<0&&(y[p]=f,g[p++]=n(C[f],D)),C[f]=0}for(v[d]=p,M[d]=h,m=0;m<p;m++)y[m]=E[y[m]];return g.splice(p,g.length-p),y.splice(p,y.length-p),w.splice(h,w.length-h),x.splice(h,x.length-h),{L:b,U:S,pinv:E}}}),mK=kB("slu",["typed","abs","add","multiply","transpose","divideScalar","subtract","larger","largerEq","SparseMatrix"],function(e){var t=e.typed,n=e.abs,r=e.add,i=e.multiply,o=e.transpose,s=e.divideScalar,a=e.subtract,l=e.larger,c=e.largerEq,u=e.SparseMatrix,d=lK({add:r,multiply:i,transpose:o}),p=fK({abs:n,divideScalar:s,multiply:i,subtract:a,larger:l,largerEq:c,SparseMatrix:u});return t("slu",{"SparseMatrix, number, number":function(e,t,n){if(!BL(t)||t<0||t>3)throw new Error("Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]");if(n<0||n>1)throw new Error("Partial pivoting threshold must be a number from 0 to 1");var r=d(t,e,!1),i=p(e,r,n);return{L:i.L,U:i.U,p:i.pinv,q:r.q,toString:function(){return"L: "+this.L.toString()+"\nU: "+this.U.toString()+"\np: "+this.p.toString()+(this.q?"\nq: "+this.q.toString():"")+"\n"}}}})});function gK(e,t){var n,r=t.length,i=[];if(e)for(n=0;n<r;n++)i[e[n]]=t[n];else for(n=0;n<r;n++)i[n]=t[n];return i}var yK="lusolve",vK=kB(yK,["typed","matrix","lup","slu","usolve","lsolve","DenseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.lup,i=e.slu,o=e.usolve,s=e.lsolve,a=xq({DenseMatrix:e.DenseMatrix});return t(yK,{"Array, Array | Matrix":function(e,t){e=n(e);var i=r(e);return c(i.L,i.U,i.p,null,t).valueOf()},"DenseMatrix, Array | Matrix":function(e,t){var n=r(e);return c(n.L,n.U,n.p,null,t)},"SparseMatrix, Array | Matrix":function(e,t){var n=r(e);return c(n.L,n.U,n.p,null,t)},"SparseMatrix, Array | Matrix, number, number":function(e,t,n,r){var o=i(e,n,r);return c(o.L,o.U,o.p,o.q,t)},"Object, Array | Matrix":function(e,t){return c(e.L,e.U,e.p,e.q,t)}});function l(e){if(JI(e))return e;if(GI(e))return n(e);throw new TypeError("Invalid Matrix LU decomposition")}function c(e,t,n,r,i){e=l(e),t=l(t),n&&((i=a(e,i,!0))._data=gK(n,i._data));var c=s(e,i),u=o(t,c);return r&&(u._data=gK(r,u._data)),u}}),bK=kB("det",["typed","matrix","subtract","multiply","unaryMinus","lup"],function(e){var t=e.typed,n=e.matrix,r=e.subtract,i=e.multiply,o=e.unaryMinus,s=e.lup;return t("det",{any:function(e){return kL(e)},"Array | Matrix":function(e){var t;switch((t=JI(e)?e.size():Array.isArray(e)?(e=n(e)).size():[]).length){case 0:return kL(e);case 1:if(1===t[0])return kL(e.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+aB(t)+")");case 2:var a=t[0];if(a===t[1])return function(e,t){if(1===t)return kL(e[0][0]);if(2===t)return r(i(e[0][0],e[1][1]),i(e[1][0],e[0][1]));for(var n=s(e),a=n.U[0][0],l=1;l<t;l++)a=i(a,n.U[l][l]);for(var c=0,u=0,d=[];;){for(;d[u];)u++;if(u>=t)break;for(var p=u,h=0;!d[n.p[p]];)d[n.p[p]]=!0,p=n.p[p],h++;h%2==0&&c++}return c%2==0?a:o(a)}(e.clone().valueOf(),a);throw new RangeError("Matrix must be square (size: "+aB(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+aB(t)+")")}}})}),wK=kB("inv",["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],function(e){var t=e.typed,n=e.matrix,r=e.divideScalar,i=e.addScalar,o=e.multiply,s=e.unaryMinus,a=e.det,l=e.identity,c=e.abs;return t("inv",{"Array | Matrix":function(e){var t=JI(e)?e.size():pB(e);switch(t.length){case 1:if(1===t[0])return JI(e)?n([r(1,e.valueOf()[0])]):[r(1,e[0])];throw new RangeError("Matrix must be square (size: "+aB(t)+")");case 2:var i=t[0],o=t[1];if(i===o)return JI(e)?n(u(e.valueOf(),i,o),e.storage()):u(e,i,o);throw new RangeError("Matrix must be square (size: "+aB(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+aB(t)+")")}},any:function(e){return r(1,e)}});function u(e,t,n){var u,d,p,h,f;if(1===t){if(0===(h=e[0][0]))throw Error("Cannot calculate inverse, determinant is zero");return[[r(1,h)]]}if(2===t){var m=a(e);if(0===m)throw Error("Cannot calculate inverse, determinant is zero");return[[r(e[1][1],m),r(s(e[0][1]),m)],[r(s(e[1][0]),m),r(e[0][0],m)]]}var g=e.concat();for(u=0;u<t;u++)g[u]=g[u].concat();for(var y=l(t).valueOf(),v=0;v<n;v++){var b=c(g[v][v]),w=v;for(u=v+1;u<t;)c(g[u][v])>b&&(b=c(g[u][v]),w=u),u++;if(0===b)throw Error("Cannot calculate inverse, determinant is zero");(u=w)!==v&&(f=g[v],g[v]=g[u],g[u]=f,f=y[v],y[v]=y[u],y[u]=f);var x=g[v],M=y[v];for(u=0;u<t;u++){var S=g[u],E=y[u];if(u!==v){if(0!==S[v]){for(p=r(s(S[v]),x[v]),d=v;d<n;d++)S[d]=i(S[d],o(p,x[d]));for(d=0;d<n;d++)E[d]=i(E[d],o(p,M[d]))}}else{for(p=x[v],d=v;d<n;d++)S[d]=r(S[d],p);for(d=0;d<n;d++)E[d]=r(E[d],p)}}}return y}}),xK=kB("eigs",["config","typed","matrix","addScalar","equal","subtract","abs","atan","cos","sin","multiplyScalar","inv","bignumber","multiply","add"],function(e){var t=e.config,n=e.typed,r=e.matrix,i=e.addScalar,o=e.subtract,s=e.equal,a=e.abs,l=e.atan,c=e.cos,u=e.sin,d=e.multiplyScalar,p=e.inv,h=e.bignumber,f=e.multiply,m=e.add;return n("eigs",{Array:function(e){var t=r(e),n=t.size();if(2!==n.length||n[0]!==n[1])throw new RangeError("Matrix must be square (size: "+aB(n)+")");var i=g(t,n[0]);return{values:i[0],vectors:i[1]}},Matrix:function(e){var t=e.size();if(2!==t.length||t[0]!==t[1])throw new RangeError("Matrix must be square (size: "+aB(t)+")");var n=g(e,t[0]);return{values:r(n[0]),vectors:r(n[1])}}});function g(e,n){var r=e.datatype();if(void 0===r&&(r=e.getDataType()),"number"!==r&&"BigNumber"!==r&&"Fraction"!==r)throw"mixed"===r?new TypeError("Mixed matrix element type is not supported"):new TypeError("Matrix element type not supported ("+r+")");if(function(e,t){for(var n=0;n<t;n++)for(var r=n;r<t;r++)if(!s(e[n][r],e[r][n]))throw new TypeError("Input matrix is not symmetric")}(e.toArray(),n),"number"===r)return y(e.toArray());if("Fraction"===r){for(var i=e.toArray(),o=0;o<n;o++)for(var l=o;l<n;l++)i[o][l]=i[o][l].valueOf(),i[l][o]=i[o][l];return y(e.toArray())}return"BigNumber"===r?function(e){for(var n,r=e.length,i=a(t.epsilon/r),o=new Array(r),s=0;s<r;s++)o[s]=A(r,0),o[s][s]=1;var l=C(e);for(;a(l[1])>=a(i);){var c=l[0][0],u=l[0][1];e=M(e,n=b(e[c][c],e[u][u],e[c][u]),c,u),o=x(o,n,c,u),l=C(e)}for(var d=A(r,0),p=0;p<r;p++)d[p]=e[p][p];return N(kL(d),kL(o))}(e.toArray()):void 0}function y(e){for(var n,r=e.length,i=Math.abs(t.epsilon/r),o=new Array(r),s=0;s<r;s++)o[s]=A(r,0),o[s][s]=1;for(var a=E(e);Math.abs(a[1])>=Math.abs(i);){var l=a[0][0],c=a[0][1];e=S(e,n=v(e[l][l],e[c][c],e[l][c]),l,c),o=w(o,n,l,c),a=E(e)}for(var u=A(r,0),d=0;d<r;d++)u[d]=e[d][d];return N(kL(u),kL(o))}function v(e,n,r){var i=n-e;return Math.abs(i)<=t.epsilon?Math.PI/4:.5*Math.atan(2*r/(n-e))}function b(e,n,r){var i=o(n,e);return a(i)<=t.epsilon?h(-1).acos().div(4):d(.5,l(f(2,r,p(i))))}function w(e,t,n,r){for(var i=e.length,o=Math.cos(t),s=Math.sin(t),a=A(i,0),l=A(i,0),c=0;c<i;c++)a[c]=o*e[c][n]-s*e[c][r],l[c]=s*e[c][n]+o*e[c][r];for(var u=0;u<i;u++)e[u][n]=a[u],e[u][r]=l[u];return e}function x(e,t,n,r){for(var s=e.length,a=c(t),l=u(t),p=A(s,h(0)),f=A(s,h(0)),m=0;m<s;m++)p[m]=o(d(a,e[m][n]),d(l,e[m][r])),f[m]=i(d(l,e[m][n]),d(a,e[m][r]));for(var g=0;g<s;g++)e[g][n]=p[g],e[g][r]=f[g];return e}function M(e,t,n,r){for(var s=e.length,a=h(c(t)),l=h(u(t)),p=d(a,a),g=d(l,l),y=A(s,h(0)),v=A(s,h(0)),b=f(h(2),a,l,e[n][r]),w=i(o(d(p,e[n][n]),b),d(g,e[r][r])),x=m(d(g,e[n][n]),b,d(p,e[r][r])),M=0;M<s;M++)y[M]=o(d(a,e[n][M]),d(l,e[r][M])),v[M]=i(d(l,e[n][M]),d(a,e[r][M]));e[n][n]=w,e[r][r]=x,e[n][r]=h(0),e[r][n]=h(0);for(var S=0;S<s;S++)S!==n&&S!==r&&(e[n][S]=y[S],e[S][n]=y[S],e[r][S]=v[S],e[S][r]=v[S]);return e}function S(e,t,n,r){for(var i=e.length,o=Math.cos(t),s=Math.sin(t),a=o*o,l=s*s,c=A(i,0),u=A(i,0),d=a*e[n][n]-2*o*s*e[n][r]+l*e[r][r],p=l*e[n][n]+2*o*s*e[n][r]+a*e[r][r],h=0;h<i;h++)c[h]=o*e[n][h]-s*e[r][h],u[h]=s*e[n][h]+o*e[r][h];e[n][n]=d,e[r][r]=p,e[n][r]=0,e[r][n]=0;for(var f=0;f<i;f++)f!==n&&f!==r&&(e[n][f]=c[f],e[f][n]=c[f],e[r][f]=u[f],e[f][r]=u[f]);return e}function E(e){for(var t=e.length,n=0,r=[0,1],i=0;i<t;i++)for(var o=i+1;o<t;o++)Math.abs(n)<Math.abs(e[i][o])&&(n=Math.abs(e[i][o]),r=[i,o]);return[r,n]}function C(e){for(var t=e.length,n=0,r=[0,1],i=0;i<t;i++)for(var o=i+1;o<t;o++)a(n)<a(e[i][o])&&(n=a(e[i][o]),r=[i,o]);return[r,n]}function N(e,t){for(var n=e.length,r=Array(n),i=Array(n),o=0;o<n;o++)i[o]=Array(n);for(var s=0;s<n;s++){for(var a=0,l=e[0],c=0;c<e.length;c++)e[c]<l&&(l=e[a=c]);r[s]=e.splice(a,1)[0];for(var u=0;u<n;u++)i[u][s]=t[u][a],t[u].splice(a,1)}return[kL(r),kL(i)]}function A(e,t){for(var n=new Array(e),r=0;r<e;r++)n[r]=t;return n}}),MK="expm",SK=kB(MK,["typed","abs","add","identity","inv","multiply"],function(e){var t=e.typed,n=e.abs,r=e.add,i=e.identity,o=e.inv,s=e.multiply;return t(MK,{Matrix:function(e){var t=e.size();if(2!==t.length||t[0]!==t[1])throw new RangeError("Matrix must be square (size: "+aB(t)+")");for(var l=t[0],c=function(e){for(var t=e.size()[0],r=0,i=0;i<t;i++){for(var o=0,s=0;s<t;s++)o+=n(e.get([i,s]));r=Math.max(o,r)}return r}(e),u=function(e,t){for(var n=30,r=0;r<n;r++)for(var i=0;i<=r;i++){var o=r-i;if(a(e,i,o)<t)return{q:i,j:o}}throw new Error("Could not find acceptable parameters to compute the matrix exponential (try increasing maxSearchSize in expm.js)")}(c,1e-15),d=u.q,p=u.j,h=s(e,Math.pow(2,-p)),f=i(l),m=i(l),g=1,y=h,v=-1,b=1;b<=d;b++)b>1&&(y=s(y,h),v=-v),f=r(f,s(g=g*(d-b+1)/((2*d-b+1)*b),y)),m=r(m,s(g*v,y));for(var w=s(o(m),f),x=0;x<p;x++)w=s(w,w);return XI(e)?e.createSparseMatrix(w):w}});function a(e,t,n){for(var r=1,i=2;i<=t;i++)r*=i;for(var o=r,s=t+1;s<=2*t;s++)o*=s;var a=o*(2*t+1);return 8*Math.pow(e/Math.pow(2,n),2*t)*r*r/(o*a)}}),EK="sqrtm",CK=kB(EK,["typed","abs","add","multiply","sqrt","subtract","inv","size","max","identity"],function(e){var t=e.typed,n=e.abs,r=e.add,i=e.multiply,o=e.sqrt,s=e.subtract,a=e.inv,l=e.size,c=e.max,u=e.identity,d=1e-6;function p(e){var t,o=0,p=e,h=u(l(e));do{var f=p;if(p=i(.5,r(f,a(h))),h=i(.5,r(h,a(f))),(t=c(n(s(p,f))))>d&&++o>1e3)throw new Error("computing square root of matrix: iterative method could not converge")}while(t>d);return p}return t(EK,{"Array | Matrix":function(e){var t=JI(e)?e.size():pB(e);switch(t.length){case 1:if(1===t[0])return o(e);throw new RangeError("Matrix must be square (size: "+aB(t)+")");case 2:if(t[0]===t[1])return p(e);throw new RangeError("Matrix must be square (size: "+aB(t)+")");default:throw new RangeError("Matrix must be at most two dimensional (size: "+aB(t)+")")}}})}),NK=kB("divide",["typed","matrix","multiply","equalScalar","divideScalar","inv"],function(e){var t=e.typed,n=e.matrix,r=e.multiply,i=e.equalScalar,o=e.divideScalar,s=e.inv,a=e$({typed:t,equalScalar:i}),l=t$({typed:t});return t("divide",TL({"Array | Matrix, Array | Matrix":function(e,t){return r(e,s(t))},"DenseMatrix, any":function(e,t){return l(e,t,o,!1)},"SparseMatrix, any":function(e,t){return a(e,t,o,!1)},"Array, any":function(e,t){return l(n(e),t,o,!1).valueOf()},"any, Array | Matrix":function(e,t){return r(e,s(t))}},o.signatures))}),AK="distance",kK=kB(AK,["typed","addScalar","subtract","divideScalar","multiplyScalar","unaryMinus","sqrt","abs"],function(e){var t=e.typed,n=e.addScalar,r=e.subtract,i=e.multiplyScalar,o=e.divideScalar,s=e.unaryMinus,a=e.sqrt,l=e.abs;return t(AK,{"Array, Array, Array":function(e,t,n){if(2===e.length&&2===t.length&&2===n.length){if(!u(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!u(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!u(n))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");var a=o(r(n[1],n[0]),r(t[1],t[0])),l=i(i(a,a),t[0]),c=s(i(a,t[0])),d=e[1];return m(e[0],e[1],l,c,d)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object, Object":function(e,t,n){if(2===Object.keys(e).length&&2===Object.keys(t).length&&2===Object.keys(n).length){if(!u(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!u(t))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");if(!u(n))throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"lineOnePtX"in t&&"lineOnePtY"in t&&"lineTwoPtX"in n&&"lineTwoPtY"in n){var a=o(r(n.lineTwoPtY,n.lineTwoPtX),r(t.lineOnePtY,t.lineOnePtX)),l=i(i(a,a),t.lineOnePtX),c=s(i(a,t.lineOnePtX)),d=e.pointX;return m(e.pointX,e.pointY,l,c,d)}throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},"Array, Array":function(e,t){if(2===e.length&&3===t.length){if(!u(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!d(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");return m(e[0],e[1],t[0],t[1],t[2])}if(3===e.length&&6===t.length){if(!d(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!h(t))throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");return g(e[0],e[1],e[2],t[0],t[1],t[2],t[3],t[4],t[5])}if(e.length===t.length&&e.length>0){if(!p(e))throw new TypeError("All values of an array should be numbers or BigNumbers");if(!p(t))throw new TypeError("All values of an array should be numbers or BigNumbers");return y(e,t)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object":function(e,t){if(2===Object.keys(e).length&&3===Object.keys(t).length){if(!u(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!d(t))throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"xCoeffLine"in t&&"yCoeffLine"in t&&"constant"in t)return m(e.pointX,e.pointY,t.xCoeffLine,t.yCoeffLine,t.constant);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&6===Object.keys(t).length){if(!d(e))throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");if(!h(t))throw new TypeError("Values of x0, y0, z0, a, b and c should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"x0"in t&&"y0"in t&&"z0"in t&&"a"in t&&"b"in t&&"c"in t)return g(e.pointX,e.pointY,e.pointZ,t.x0,t.y0,t.z0,t.a,t.b,t.c);throw new TypeError("Key names do not match")}if(2===Object.keys(e).length&&2===Object.keys(t).length){if(!u(e))throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");if(!u(t))throw new TypeError("Values of pointTwoX and pointTwoY should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointTwoX"in t&&"pointTwoY"in t)return y([e.pointOneX,e.pointOneY],[t.pointTwoX,t.pointTwoY]);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&3===Object.keys(t).length){if(!d(e))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");if(!d(t))throw new TypeError("Values of pointTwoX, pointTwoY and pointTwoZ should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointOneZ"in e&&"pointTwoX"in t&&"pointTwoY"in t&&"pointTwoZ"in t)return y([e.pointOneX,e.pointOneY,e.pointOneZ],[t.pointTwoX,t.pointTwoY,t.pointTwoZ]);throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},Array:function(e){if(!function(e){if(2===e[0].length&&c(e[0][0])&&c(e[0][1])){if(e.some(function(e){return 2!==e.length||!c(e[0])||!c(e[1])}))return!1}else{if(!(3===e[0].length&&c(e[0][0])&&c(e[0][1])&&c(e[0][2])))return!1;if(e.some(function(e){return 3!==e.length||!c(e[0])||!c(e[1])||!c(e[2])}))return!1}return!0}(e))throw new TypeError("Incorrect array format entered for pairwise distance calculation");return function(e){for(var t=[],n=[],r=[],i=0;i<e.length-1;i++)for(var o=i+1;o<e.length;o++)2===e[0].length?(n=[e[i][0],e[i][1]],r=[e[o][0],e[o][1]]):3===e[0].length&&(n=[e[i][0],e[i][1],e[i][2]],r=[e[o][0],e[o][1],e[o][2]]),t.push(y(n,r));return t}(e)}});function c(e){return"number"==typeof e||UI(e)}function u(e){return e.constructor!==Array&&(e=f(e)),c(e[0])&&c(e[1])}function d(e){return e.constructor!==Array&&(e=f(e)),c(e[0])&&c(e[1])&&c(e[2])}function p(e){return Array.isArray(e)||(e=f(e)),e.every(c)}function h(e){return e.constructor!==Array&&(e=f(e)),c(e[0])&&c(e[1])&&c(e[2])&&c(e[3])&&c(e[4])&&c(e[5])}function f(e){for(var t=Object.keys(e),n=[],r=0;r<t.length;r++)n.push(e[t[r]]);return n}function m(e,t,r,s,c){var u=l(n(n(i(r,e),i(s,t)),c)),d=a(n(i(r,r),i(s,s)));return o(u,d)}function g(e,t,s,l,c,u,d,p,h){var f=[r(i(r(c,t),h),i(r(u,s),p)),r(i(r(u,s),d),i(r(l,e),h)),r(i(r(l,e),p),i(r(c,t),d))];f=a(n(n(i(f[0],f[0]),i(f[1],f[1])),i(f[2],f[2])));var m=a(n(n(i(d,d),i(p,p)),i(h,h)));return o(f,m)}function y(e,t){for(var o=e.length,s=0,l=0,c=0;c<o;c++)l=r(e[c],t[c]),s=n(i(l,l),s);return a(s)}}),TK=kB("intersect",["typed","config","abs","add","addScalar","matrix","multiply","multiplyScalar","divideScalar","subtract","smaller","equalScalar"],function(e){var t=e.typed,n=e.config,r=e.abs,i=e.add,o=e.addScalar,s=e.matrix,a=e.multiply,l=e.multiplyScalar,c=e.divideScalar,u=e.subtract,d=e.smaller,p=e.equalScalar;return t("intersect",{"Array, Array, Array":function(e,t,n){if(!m(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!m(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!function(e){return 4===e.length&&h(e[0])&&h(e[1])&&h(e[2])&&h(e[3])}(n))throw new TypeError("Array with 4 numbers expected as third argument");return function(e,t,n,r,i,s,a,d,p,h){var f=l(e,a),m=l(r,a),g=l(t,d),y=l(i,d),v=l(n,p),b=l(s,p),w=c(u(u(u(h,f),g),v),u(u(u(o(o(m,y),b),f),g),v)),x=o(e,l(w,u(r,e))),M=o(t,l(w,u(i,t))),S=o(n,l(w,u(s,n)));return[x,M,S]}(e[0],e[1],e[2],t[0],t[1],t[2],n[0],n[1],n[2],n[3])},"Array, Array, Array, Array":function(e,t,s,h){if(2===e.length){if(!f(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!f(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!f(s))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!f(h))throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");return function(e,t,s,p){var h=e,f=s,m=u(h,t),g=u(f,p),y=u(l(m[0],g[1]),l(g[0],m[1]));if(d(r(y),n.epsilon))return null;var v=l(g[0],h[1]),b=l(g[1],h[0]),w=l(g[0],f[1]),x=l(g[1],f[0]),M=c(o(u(u(v,b),w),x),y);return i(a(m,M),h)}(e,t,s,h)}if(3===e.length){if(!m(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!m(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!m(s))throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");if(!m(h))throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument");return function(e,t,n,r,i,s,a,d,h,f,m,y){var v=g(e,a,f,a,t,d,m,d,n,h,y,h),b=g(f,a,r,e,m,d,i,t,y,h,s,n),w=g(e,a,r,e,t,d,i,t,n,h,s,n),x=g(f,a,f,a,m,d,m,d,y,h,y,h),M=g(r,e,r,e,i,t,i,t,s,n,s,n),S=c(u(l(v,b),l(w,x)),u(l(M,x),l(b,b))),E=c(o(v,l(S,b)),x),C=o(e,l(S,u(r,e))),N=o(t,l(S,u(i,t))),A=o(n,l(S,u(s,n))),k=o(a,l(E,u(f,a))),T=o(d,l(E,u(m,d))),O=o(h,l(E,u(y,h)));return p(C,k)&&p(N,T)&&p(A,O)?[C,N,A]:null}(e[0],e[1],e[2],t[0],t[1],t[2],s[0],s[1],s[2],h[0],h[1],h[2])}throw new TypeError("Arrays with two or thee dimensional points expected")},"Matrix, Matrix, Matrix":function(e,t,n){return s(this(e.valueOf(),t.valueOf(),n.valueOf()))},"Matrix, Matrix, Matrix, Matrix":function(e,t,n,r){return s(this(e.valueOf(),t.valueOf(),n.valueOf(),r.valueOf()))}});function h(e){return"number"==typeof e||UI(e)}function f(e){return 2===e.length&&h(e[0])&&h(e[1])}function m(e){return 3===e.length&&h(e[0])&&h(e[1])&&h(e[2])}function g(e,t,n,r,i,s,a,c,d,p,h,f){var m=l(u(e,t),u(n,r)),g=l(u(i,s),u(a,c)),y=l(u(d,p),u(h,f));return o(o(m,g),y)}}),OK=kB("sum",["typed","config","add","numeric"],function(e){var t=e.typed,n=e.config,r=e.add,i=e.numeric;return t("sum",{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){try{return GP(e,t,r)}catch(e){throw PU(e,"sum")}},"...":function(e){if(VP(e))throw new TypeError("Scalar values expected in function sum");return o(e)}});function o(e){var t;return WP(e,function(e){try{t=void 0===t?e:r(t,e)}catch(t){throw PU(t,"sum",e)}}),void 0===t&&(t=i(0,n.number)),"string"==typeof t&&(t=i(t,n.number)),t}}),_K="mean",RK=kB(_K,["typed","add","divide"],function(e){var t=e.typed,n=e.add,r=e.divide;return t(_K,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(e,t){try{var i=GP(e,t,n),o=Array.isArray(e)?pB(e):e.size();return r(i,o[t])}catch(e){throw PU(e,"mean")}},"...":function(e){if(VP(e))throw new TypeError("Scalar values expected in function mean");return i(e)}});function i(e){var t,i=0;if(WP(e,function(e){try{t=void 0===t?e:n(t,e),i++}catch(t){throw PU(t,"mean",e)}}),0===i)throw new Error("Cannot calculate the mean of an empty array");return r(t,i)}}),DK="median",IK=kB(DK,["typed","add","divide","compare","partitionSelect"],function(e){var t=e.typed,n=e.add,r=e.divide,i=e.compare,o=e.partitionSelect;function s(e){try{var t=(e=SB(e.valueOf())).length;if(0===t)throw new Error("Cannot calculate median of an empty array");if(t%2==0){for(var n=t/2-1,r=o(e,n+1),s=e[n],c=0;c<n;++c)i(e[c],s)>0&&(s=e[c]);return l(s,r)}var u=o(e,(t-1)/2);return a(u)}catch(e){throw PU(e,"median")}}var a=t({"number | BigNumber | Complex | Unit":function(e){return e}}),l=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(e,t){return r(n(e,t),2)}});return t(DK,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("median(A, dim) is not yet supported")},"...":function(e){if(VP(e))throw new TypeError("Scalar values expected in function median");return s(e)}})}),LK=kB("mad",["typed","abs","map","median","subtract"],function(e){var t=e.typed,n=e.abs,r=e.map,i=e.median,o=e.subtract;return t("mad",{"Array | Matrix":s,"...":function(e){return s(e)}});function s(e){if(0===(e=SB(e.valueOf())).length)throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");try{var t=i(e);return i(r(e,function(e){return n(o(e,t))}))}catch(e){throw e instanceof TypeError&&-1!==e.message.indexOf("median")?new TypeError(e.message.replace("median","mad")):PU(e,"mad")}}}),BK="unbiased",zK="variance",PK=kB(zK,["typed","add","subtract","multiply","divide","apply","isNaN"],function(e){var t=e.typed,n=e.add,r=e.subtract,i=e.multiply,o=e.divide,s=e.apply,a=e.isNaN;return t(zK,{"Array | Matrix":function(e){return l(e,BK)},"Array | Matrix, string":l,"Array | Matrix, number | BigNumber":function(e,t){return c(e,t,BK)},"Array | Matrix, number | BigNumber, string":c,"...":function(e){return l(e,BK)}});function l(e,t){var s,l=0;if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");if(WP(e,function(e){try{s=void 0===s?e:n(s,e),l++}catch(t){throw PU(t,"variance",e)}}),0===l)throw new Error("Cannot calculate variance of an empty array");var c=o(s,l);if(s=void 0,WP(e,function(e){var t=r(e,c);s=void 0===s?i(t,t):n(s,i(t,t))}),a(s))return s;switch(t){case"uncorrected":return o(s,l);case"biased":return o(s,l+1);case"unbiased":var u=UI(s)?s.mul(0):0;return 1===l?u:o(s,l-1);default:throw new Error('Unknown normalization "'+t+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}function c(e,t,n){try{if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");return s(e,t,function(e){return l(e,n)})}catch(e){throw PU(e,"variance")}}}),jK=kB("quantileSeq",["typed","add","multiply","partitionSelect","compare"],function(e){var t=e.typed,n=e.add,r=e.multiply,i=e.partitionSelect,o=e.compare;function s(e,t,s){var l=SB(e),c=l.length;if(0===c)throw new Error("Cannot calculate quantile of an empty sequence");if(HI(t)){var u=t*(c-1),d=u%1;if(0===d){var p=s?l[u]:i(l,u);return a(p),p}var h,f,m=Math.floor(u);if(s)h=l[m],f=l[m+1];else{f=i(l,m+1),h=l[m];for(var g=0;g<m;++g)o(l[g],h)>0&&(h=l[g])}return a(h),a(f),n(r(h,1-d),r(f,d))}var y=t.times(c-1);if(y.isInteger()){y=y.toNumber();var v=s?l[y]:i(l,y);return a(v),v}var b,w,x=y.floor(),M=y.minus(x),S=x.toNumber();if(s)b=l[S],w=l[S+1];else{w=i(l,S+1),b=l[S];for(var E=0;E<S;++E)o(l[E],b)>0&&(b=l[E])}a(b),a(w);var C=new M.constructor(1);return n(r(b,C.minus(M)),r(w,M))}var a=t({"number | BigNumber | Unit":function(e){return e}});return function(e,t,n){var r,i,o;if(arguments.length<2||arguments.length>3)throw new SyntaxError("Function quantileSeq requires two or three parameters");if(YI(e)){if("boolean"==typeof(n=n||!1)){if(i=e.valueOf(),HI(t)){if(t<0)throw new Error("N/prob must be non-negative");if(t<=1)return s(i,t,n);if(t>1){if(!BL(t))throw new Error("N must be a positive integer");var a=t+1;r=new Array(t);for(var l=0;l<t;)r[l]=s(i,++l/a,n);return r}}if(UI(t)){var c=t.constructor;if(t.isNegative())throw new Error("N/prob must be non-negative");if(o=new c(1),t.lte(o))return new c(s(i,t,n));if(t.gt(o)){if(!t.isInteger())throw new Error("N must be a positive integer");var u=t.toNumber();if(u>4294967295)throw new Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");var d=new c(u+1);r=new Array(u);for(var p=0;p<u;)r[p]=new c(s(i,new c(++p).div(d),n));return r}}if(Array.isArray(t)){r=new Array(t.length);for(var h=0;h<r.length;++h){var f=t[h];if(HI(f)){if(f<0||f>1)throw new Error("Probability must be between 0 and 1, inclusive")}else{if(!UI(f))throw new TypeError("Unexpected type of argument in function quantileSeq");if(o=new f.constructor(1),f.isNegative()||f.gt(o))throw new Error("Probability must be between 0 and 1, inclusive")}r[h]=s(i,f,n)}return r}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}}),FK=kB("std",["typed","sqrt","variance"],function(e){var t=e.typed,n=e.sqrt,r=e.variance;return t("std",{"Array | Matrix":i,"Array | Matrix, string":i,"Array | Matrix, number | BigNumber":i,"Array | Matrix, number | BigNumber, string":i,"...":function(e){return i(e)}});function i(e,t){if(0===e.length)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{return n(r.apply(null,arguments))}catch(e){throw e instanceof TypeError&&-1!==e.message.indexOf(" variance")?new TypeError(e.message.replace(" variance"," std")):e}}}),$K="combinations",HK=kB($K,["typed"],function(e){return(0,e.typed)($K,{"number, number":Rj,"BigNumber, BigNumber":function(e,t){var n,r,i=e.constructor,o=e.minus(t),s=new i(1);if(!UK(e)||!UK(t))throw new TypeError("Positive integer value expected in function combinations");if(t.gt(e))throw new TypeError("k must be less than n in function combinations");if(n=s,t.lt(o))for(r=s;r.lte(o);r=r.plus(s))n=n.times(t.plus(r)).dividedBy(r);else for(r=s;r.lte(t);r=r.plus(s))n=n.times(o.plus(r)).dividedBy(r);return n}})});function UK(e){return e.isInteger()&&e.gte(0)}var qK="combinationsWithRep",VK=kB(qK,["typed"],function(e){return(0,e.typed)(qK,{"number, number":function(e,t){if(!BL(e)||e<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(!BL(t)||t<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(e<1)throw new TypeError("k must be less than or equal to n + k - 1");return t<e-1?_j(e,e+t-1)/_j(1,t):_j(t+1,e+t-1)/_j(1,e-1)},"BigNumber, BigNumber":function(e,t){var n,r,i=new(0,e.constructor)(1),o=e.minus(i);if(!WK(e)||!WK(t))throw new TypeError("Positive integer value expected in function combinationsWithRep");if(e.lt(i))throw new TypeError("k must be less than or equal to n + k - 1 in function combinationsWithRep");if(n=i,t.lt(o))for(r=i;r.lte(o);r=r.plus(i))n=n.times(t.plus(r)).dividedBy(r);else for(r=i;r.lte(t);r=r.plus(i))n=n.times(o.plus(r)).dividedBy(r);return n}})});function WK(e){return e.isInteger()&&e.gte(0)}var KK="gamma",GK=kB(KK,["typed","config","multiplyScalar","pow","BigNumber","Complex"],function(e){var t=e.typed,n=e.config,r=e.multiplyScalar,i=e.pow,o=e.BigNumber,s=e.Complex;return t(KK,{number:$j,Complex:function(e){if(0===e.im)return this(e.re);e=new s(e.re-1,e.im);for(var t=new s(Uj[0],0),n=1;n<Uj.length;++n){var o=e.re+n,a=o*o+e.im*e.im;0!==a?(t.re+=Uj[n]*o/a,t.im+=-Uj[n]*e.im/a):t.re=Uj[n]<0?-1/0:1/0}var l=new s(e.re+Hj+.5,e.im),c=Math.sqrt(2*Math.PI);e.re+=.5;var u=i(l,e);0===u.im?u.re*=c:(0===u.re||(u.re*=c),u.im*=c);var d=Math.exp(-l.re);return l.re=d*Math.cos(-l.im),l.im=d*Math.sin(-l.im),r(r(u,l),t)},BigNumber:function(e){if(e.isInteger())return e.isNegative()||e.isZero()?new o(1/0):a(e.minus(1));if(!e.isFinite())return new o(e.isNegative()?NaN:1/0);throw new Error("Integer BigNumber expected")},"Array | Matrix":function(e){return KP(e,this)}});function a(e){if(e<8)return new o([1,1,2,6,24,120,720,5040][e]);var t=n.precision+(0|Math.log(e.toNumber())),r=o.clone({precision:t});if(e%2==1)return e.times(a(new o(e-1)));for(var i=e,s=new r(e),l=e.toNumber();i>2;)l+=i-=2,s=s.times(l);return new o(s.toPrecision(o.precision))}}),JK="factorial",YK=kB(JK,["typed","gamma"],function(e){var t=e.typed,n=e.gamma;return t(JK,{number:function(e){if(e<0)throw new Error("Value must be non-negative");return n(e+1)},BigNumber:function(e){if(e.isNegative())throw new Error("Value must be non-negative");return n(e.plus(1))},"Array | Matrix":function(e){return KP(e,this)}})}),ZK="kldivergence",XK=kB(ZK,["typed","matrix","divide","sum","multiply","dotDivide","log","isNumeric"],function(e){var t=e.typed,n=e.matrix,r=e.divide,i=e.sum,o=e.multiply,s=e.dotDivide,a=e.log,l=e.isNumeric;return t(ZK,{"Array, Array":function(e,t){return c(n(e),n(t))},"Matrix, Array":function(e,t){return c(e,n(t))},"Array, Matrix":function(e,t){return c(n(e),t)},"Matrix, Matrix":function(e,t){return c(e,t)}});function c(e,t){var n=t.size().length,c=e.size().length;if(n>1)throw new Error("first object must be one dimensional");if(c>1)throw new Error("second object must be one dimensional");if(n!==c)throw new Error("Length of two vectors must be equal");if(0===i(e))throw new Error("Sum of elements in first object must be non zero");if(0===i(t))throw new Error("Sum of elements in second object must be non zero");var u=r(e,i(e)),d=r(t,i(t)),p=i(o(u,a(s(u,d))));return l(p)?p:Number.NaN}}),QK="multinomial",eG=kB(QK,["typed","add","divide","multiply","factorial","isInteger","isPositive"],function(e){var t=e.typed,n=e.add,r=e.divide,i=e.multiply,o=e.factorial,s=e.isInteger,a=e.isPositive;return t(QK,{"Array | Matrix":function(e){var t=0,l=1;return WP(e,function(e){if(!s(e)||!a(e))throw new TypeError("Positive integer value expected in function multinomial");t=n(t,e),l=i(l,o(e))}),r(o(t),l)}})}),tG="permutations",nG=kB(tG,["typed","factorial"],function(e){var t=e.typed,n=e.factorial;return t(tG,{"number | BigNumber":n,"number, number":function(e,t){if(!BL(e)||e<0)throw new TypeError("Positive integer value expected in function permutations");if(!BL(t)||t<0)throw new TypeError("Positive integer value expected in function permutations");if(t>e)throw new TypeError("second argument k must be less than or equal to first argument n");return _j(e-t+1,e)},"BigNumber, BigNumber":function(e,t){var n,r;if(!rG(e)||!rG(t))throw new TypeError("Positive integer value expected in function permutations");if(t.gt(e))throw new TypeError("second argument k must be less than or equal to first argument n");for(n=e.mul(0).add(1),r=e.minus(t).plus(1);r.lte(e);r=r.plus(1))n=n.times(r);return n}})});function rG(e){return e.isInteger()&&e.gte(0)}var iG={exports:{}};!function(e){var t=256,n=[],r=void 0===xr?window:xr,i=Math.pow(t,6),o=Math.pow(2,52),s=2*o,a=255,l=Math.random;function c(e){var n,r=e.length,i=this,o=0,s=i.i=i.j=0,l=i.S=[];for(r||(e=[r++]);o<t;)l[o]=o++;for(o=0;o<t;o++)l[o]=l[s=a&s+e[o%r]+(n=l[o])],l[s]=n;(i.g=function(e){for(var n,r=0,o=i.i,s=i.j,l=i.S;e--;)n=l[o=a&o+1],r=r*t+l[a&(l[o]=l[s=a&s+n])+(l[s]=n)];return i.i=o,i.j=s,r})(t)}function u(e,t){var n,r=[],i=(typeof e)[0];if(t&&"o"==i)for(n in e)try{r.push(u(e[n],t-1))}catch(e){}return r.length?r:"s"==i?e:e+"\0"}function d(e,t){for(var n,r=e+"",i=0;i<r.length;)t[a&i]=a&(n^=19*t[a&i])+r.charCodeAt(i++);return p(t)}function p(e){return String.fromCharCode.apply(0,e)}e.exports=function(a,l){if(l&&!0===l.global)return l.global=!1,Math.random=e.exports(a,l),l.global=!0,Math.random;var h=[];d(u(l&&l.entropy||!1?[a,p(n)]:0 in arguments?a:function(e){try{return r.crypto.getRandomValues(e=new Uint8Array(t)),p(e)}catch(e){return[+new Date,r,r.navigator&&r.navigator.plugins,r.screen,p(n)]}}(),3),h);var f=new c(h);return d(p(f.S),n),function(){for(var e=f.g(6),n=i,r=0;e<o;)e=(e+r)*t,n*=t,r=f.g(1);for(;e>=s;)e/=2,n/=2,r>>>=1;return(e+r)/n}},e.exports.resetGlobal=function(){Math.random=l},d(Math.random(),n)}(iG);var oG=iG.exports,sG=oG();function aG(e){var t,n;return t=null===(n=e)?sG:oG(String(n)),function(){return t()}}var lG=kB("pickRandom",["typed","config","?on"],function(e){var t=e.typed,n=e.config,r=e.on,i=aG(n.randomSeed);return r&&r("config",function(e,t){e.randomSeed!==t.randomSeed&&(i=aG(e.randomSeed))}),t({"Array | Matrix":function(e){return o(e)},"Array | Matrix, number":function(e,t){return o(e,t,void 0)},"Array | Matrix, Array":function(e,t){return o(e,void 0,t)},"Array | Matrix, Array | Matrix, number":function(e,t,n){return o(e,n,t)},"Array | Matrix, number, Array | Matrix":function(e,t,n){return o(e,t,n)}});function o(e,t,n){var r=void 0===t;r&&(t=1),e=SB(e.valueOf()).valueOf(),n&&(n=n.valueOf());var o=0;if(void 0!==n){if(n.length!==e.length)throw new Error("Weights must have the same length as possibles");for(var s=0,a=n.length;s<a;s++){if(!HI(n[s])||n[s]<0)throw new Error("Weights must be an array of positive numbers");o+=n[s]}}var l=e.length;if(0===l)return[];if(t>=l)return t>1?e:e[0];for(var c,u=[];u.length<t;){if(void 0===n)c=e[Math.floor(i()*l)];else for(var d=i()*o,p=0,h=e.length;p<h;p++)if((d-=n[p])<0){c=e[p];break}-1===u.indexOf(c)&&u.push(c)}return r?u[0]:u}});function cG(e,t){var n=[];if((e=e.slice(0)).length>1)for(var r=0,i=e.shift();r<i;r++)n.push(cG(e,t));else for(var o=0,s=e.shift();o<s;o++)n.push(t());return n}var uG="random",dG=kB(uG,["typed","config","?on"],function(e){var t=e.typed,n=e.config,r=e.on,i=aG(n.randomSeed);return r&&r("config",function(e,t){e.randomSeed!==t.randomSeed&&(i=aG(e.randomSeed))}),t(uG,{"":function(){return s(0,1)},number:function(e){return s(0,e)},"number, number":function(e,t){return s(e,t)},"Array | Matrix":function(e){return o(e,0,1)},"Array | Matrix, number":function(e,t){return o(e,0,t)},"Array | Matrix, number, number":function(e,t,n){return o(e,t,n)}});function o(e,t,n){var r=cG(e.valueOf(),function(){return s(t,n)});return JI(e)?e.create(r):r}function s(e,t){return e+i()*(t-e)}});kB(uG,["typed","config","?on"],function(e){var t=e.typed,n=e.config,r=e.on;e.matrix;var i=aG(n.randomSeed);return r&&r("config",function(e,t){e.randomSeed!==t.randomSeed&&(i=aG(e.randomSeed))}),t(uG,{"":function(){return o(0,1)},number:function(e){return o(0,e)},"number, number":function(e,t){return o(e,t)}});function o(e,t){return e+i()*(t-e)}});var pG="randomInt",hG=kB(pG,["typed","config","?on"],function(e){var t=e.typed,n=e.config,r=e.on,i=aG(n.randomSeed);return r&&r("config",function(e,t){e.randomSeed!==t.randomSeed&&(i=aG(e.randomSeed))}),t(pG,{"":function(){return s(0,1)},number:function(e){return s(0,e)},"number, number":function(e,t){return s(e,t)},"Array | Matrix":function(e){return o(e,0,1)},"Array | Matrix, number":function(e,t){return o(e,0,t)},"Array | Matrix, number, number":function(e,t,n){return o(e,t,n)}});function o(e,t,n){var r=cG(e.valueOf(),function(){return s(t,n)});return JI(e)?e.create(r):r}function s(e,t){return Math.floor(e+i()*(t-e))}}),fG="stirlingS2",mG=kB(fG,["typed","addScalar","subtract","multiplyScalar","divideScalar","pow","factorial","combinations","isNegative","isInteger","larger"],function(e){var t=e.typed,n=e.addScalar,r=e.subtract,i=e.multiplyScalar,o=e.divideScalar,s=e.pow,a=e.factorial,l=e.combinations,c=e.isNegative,u=e.isInteger,d=e.larger;return t(fG,{"number | BigNumber, number | BigNumber":function(e,t){if(!u(e)||c(e)||!u(t)||c(t))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(d(t,e))throw new TypeError("k must be less than or equal to n in function stirlingS2");for(var p=a(t),h=0,f=0;f<=t;f++){var m=s(-1,r(t,f)),g=l(t,f),y=s(f,e);h=n(h,i(i(g,y),m))}return o(h,p)}})}),gG="bellNumbers",yG=kB(gG,["typed","addScalar","isNegative","isInteger","stirlingS2"],function(e){var t=e.typed,n=e.addScalar,r=e.isNegative,i=e.isInteger,o=e.stirlingS2;return t(gG,{"number | BigNumber":function(e){if(!i(e)||r(e))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var t=0,s=0;s<=e;s++)t=n(t,o(e,s));return t}})}),vG="catalan",bG=kB(vG,["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],function(e){var t=e.typed,n=e.addScalar,r=e.divideScalar,i=e.multiplyScalar,o=e.combinations,s=e.isNegative,a=e.isInteger;return t(vG,{"number | BigNumber":function(e){if(!a(e)||s(e))throw new TypeError("Non-negative integer value expected in function catalan");return r(o(i(e,2),e),n(e,1))}})}),wG="composition",xG=kB(wG,["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],function(e){var t=e.typed,n=e.addScalar,r=e.combinations,i=e.isPositive;e.isNegative;var o=e.isInteger,s=e.larger;return t(wG,{"number | BigNumber, number | BigNumber":function(e,t){if(!(o(e)&&i(e)&&o(t)&&i(t)))throw new TypeError("Positive integer value expected in function composition");if(s(t,e))throw new TypeError("k must be less than or equal to n in function composition");return r(n(e,-1),n(t,-1))}})}),MG=kB("replacer",[],function(){return function(e,t){return"number"!=typeof t||isFinite(t)&&!isNaN(t)?t:{mathjs:"number",value:String(t)}}}),SG=kB("true",[],function(){return!0}),EG=kB("false",[],function(){return!1}),CG=kB("null",[],function(){return null}),NG=FG("Infinity",["config","?BigNumber"],function(e){var t=e.config,n=e.BigNumber;return"BigNumber"===t.number?new n(1/0):1/0}),AG=FG("NaN",["config","?BigNumber"],function(e){var t=e.config,n=e.BigNumber;return"BigNumber"===t.number?new n(NaN):NaN}),kG=FG("pi",["config","?BigNumber"],function(e){var t=e.config,n=e.BigNumber;return"BigNumber"===t.number?SV(n):Dj}),TG=FG("tau",["config","?BigNumber"],function(e){var t=e.config,n=e.BigNumber;return"BigNumber"===t.number?EV(n):Ij}),OG=FG("e",["config","?BigNumber"],function(e){var t=e.config,n=e.BigNumber;return"BigNumber"===t.number?xV(n):Lj}),_G=FG("phi",["config","?BigNumber"],function(e){var t=e.config,n=e.BigNumber;return"BigNumber"===t.number?MV(n):1.618033988749895}),RG=FG("LN2",["config","?BigNumber"],function(e){var t=e.config,n=e.BigNumber;return"BigNumber"===t.number?new n(2).ln():Math.LN2}),DG=FG("LN10",["config","?BigNumber"],function(e){var t=e.config,n=e.BigNumber;return"BigNumber"===t.number?new n(10).ln():Math.LN10}),IG=FG("LOG2E",["config","?BigNumber"],function(e){var t=e.config,n=e.BigNumber;return"BigNumber"===t.number?new n(1).div(new n(2).ln()):Math.LOG2E}),LG=FG("LOG10E",["config","?BigNumber"],function(e){var t=e.config,n=e.BigNumber;return"BigNumber"===t.number?new n(1).div(new n(10).ln()):Math.LOG10E}),BG=FG("SQRT1_2",["config","?BigNumber"],function(e){var t=e.config,n=e.BigNumber;return"BigNumber"===t.number?new n("0.5").sqrt():Math.SQRT1_2}),zG=FG("SQRT2",["config","?BigNumber"],function(e){var t=e.config,n=e.BigNumber;return"BigNumber"===t.number?new n(2).sqrt():Math.SQRT2}),PG=FG("i",["Complex"],function(e){return e.Complex.I});kB("PI",["pi"],function(e){return e.pi}),kB("E",["e"],function(e){return e.e});var jG=kB("version",[],function(){return"7.6.0"});function FG(e,t,n){return kB(e,t,n,{recreateOnConfigChange:!0})}var $G=zJ("speedOfLight","299792458","m s^-1"),HG=zJ("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),UG=zJ("planckConstant","6.62607015e-34","J s"),qG=zJ("reducedPlanckConstant","1.0545718176461565e-34","J s"),VG=zJ("magneticConstant","1.25663706212e-6","N A^-2"),WG=zJ("electricConstant","8.8541878128e-12","F m^-1"),KG=zJ("vacuumImpedance","376.730313667","ohm"),GG=zJ("coulomb","8.987551792261171e9","N m^2 C^-2"),JG=zJ("elementaryCharge","1.602176634e-19","C"),YG=zJ("bohrMagneton","9.2740100783e-24","J T^-1"),ZG=zJ("conductanceQuantum","7.748091729863649e-5","S"),XG=zJ("inverseConductanceQuantum","12906.403729652257","ohm"),QG=zJ("magneticFluxQuantum","2.0678338484619295e-15","Wb"),eJ=zJ("nuclearMagneton","5.0507837461e-27","J T^-1"),tJ=zJ("klitzing","25812.807459304513","ohm");zJ("josephson","4.835978484169836e14 Hz V","Hz V^-1");var nJ=zJ("bohrRadius","5.29177210903e-11","m"),rJ=zJ("classicalElectronRadius","2.8179403262e-15","m"),iJ=zJ("electronMass","9.1093837015e-31","kg"),oJ=zJ("fermiCoupling","1.1663787e-5","GeV^-2"),sJ=PJ("fineStructure",.0072973525693),aJ=zJ("hartreeEnergy","4.3597447222071e-18","J"),lJ=zJ("protonMass","1.67262192369e-27","kg"),cJ=zJ("deuteronMass","3.3435830926e-27","kg"),uJ=zJ("neutronMass","1.6749271613e-27","kg"),dJ=zJ("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),pJ=zJ("rydberg","10973731.568160","m^-1"),hJ=zJ("thomsonCrossSection","6.6524587321e-29","m^2"),fJ=PJ("weakMixingAngle",.2229),mJ=PJ("efimovFactor",22.7),gJ=zJ("atomicMass","1.66053906660e-27","kg"),yJ=zJ("avogadro","6.02214076e23","mol^-1"),vJ=zJ("boltzmann","1.380649e-23","J K^-1"),bJ=zJ("faraday","96485.33212331001","C mol^-1"),wJ=zJ("firstRadiation","3.7417718521927573e-16","W m^2"),xJ=zJ("loschmidt","2.686780111798444e25","m^-3"),MJ=zJ("gasConstant","8.31446261815324","J K^-1 mol^-1"),SJ=zJ("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),EJ=zJ("molarVolume","0.022413969545014137","m^3 mol^-1"),CJ=PJ("sackurTetrode",-1.16487052358),NJ=zJ("secondRadiation","0.014387768775039337","m K"),AJ=zJ("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),kJ=zJ("wienDisplacement","2.897771955e-3","m K"),TJ=zJ("molarMass","0.99999999965e-3","kg mol^-1"),OJ=zJ("molarMassC12","11.9999999958e-3","kg mol^-1"),_J=zJ("gravity","9.80665","m s^-2"),RJ=zJ("planckLength","1.616255e-35","m"),DJ=zJ("planckMass","2.176435e-8","kg"),IJ=zJ("planckTime","5.391245e-44","s"),LJ=zJ("planckCharge","1.87554603778e-18","C"),BJ=zJ("planckTemperature","1.416785e+32","K");function zJ(e,t,n){return kB(e,["config","Unit","BigNumber"],function(e){var r=e.config,i=e.Unit,o=e.BigNumber,s=new i("BigNumber"===r.number?new o(t):parseFloat(t),n);return s.fixPrefix=!0,s})}function PJ(e,t){return kB(e,["config","BigNumber"],function(e){var n=e.config,r=e.BigNumber;return"BigNumber"===n.number?new r(t):t})}zB({});var jJ=kP({});FP({}),EG({}),CG({}),SG({});var FJ=vP({config:DL}),$J=$P({});MG({}),PG({Complex:jJ}),DG({BigNumber:FJ,config:DL}),LG({BigNumber:FJ,config:DL}),AG({BigNumber:FJ,config:DL}),kG({BigNumber:FJ,config:DL}),BG({BigNumber:FJ,config:DL}),TG({BigNumber:FJ,config:DL}),mJ({BigNumber:FJ,config:DL}),sJ({BigNumber:FJ,config:DL}),CJ({BigNumber:FJ,config:DL}),fJ({BigNumber:FJ,config:DL});var HJ=jP({});OG({BigNumber:FJ,config:DL}),NG({BigNumber:FJ,config:DL}),IG({BigNumber:FJ,config:DL}),jG({});var UJ=HP({Matrix:$J});_G({BigNumber:FJ,config:DL});var qJ=_B({BigNumber:FJ,Complex:jJ,DenseMatrix:UJ,Fraction:HJ}),VJ=XP({typed:qJ}),WJ=mF({typed:qJ}),KJ=bF({typed:qJ}),GJ=SF({typed:qJ}),JJ=kF({config:DL,typed:qJ}),YJ=OF({typed:qJ});IF({typed:qJ});var ZJ=BF({Complex:jJ,typed:qJ});$F({typed:qJ}),VF({BigNumber:FJ,config:DL,typed:qJ});var XJ=GF({isInteger:VJ,typed:qJ});s$({typed:qJ}),c$({Complex:jJ,typed:qJ}),S$({Complex:jJ,config:DL,typed:qJ});var QJ=O$({typed:qJ}),eY=B$({BigNumber:FJ,Fraction:HJ,complex:ZJ,typed:qJ});j$({typed:qJ}),oH({typed:qJ}),dH({typed:qJ}),fH({typed:qJ});var tY=gH({typed:qJ});_H({typed:qJ}),BH({typed:qJ});var nY=qH({typed:qJ});OU({typed:qJ});var rY=HU({typed:qJ});KU({typed:qJ}),YU({typed:qJ}),eq({typed:qJ}),jV({Complex:jJ,config:DL,typed:qJ}),UV({BigNumber:FJ,typed:qJ}),KV({BigNumber:FJ,Complex:jJ,config:DL,typed:qJ}),ZV({BigNumber:FJ,Complex:jJ,config:DL,typed:qJ}),tW({Complex:jJ,config:DL,typed:qJ});var iY=rW({typed:qJ});aW({Complex:jJ,config:DL,typed:qJ}),uW({typed:qJ}),hW({BigNumber:FJ,typed:qJ}),gW({BigNumber:FJ,typed:qJ}),bW({BigNumber:FJ,typed:qJ}),MW({typed:qJ}),EW({typed:qJ});var oY=HK({typed:qJ});lG({config:DL,typed:qJ}),hG({config:DL,typed:qJ}),RG({BigNumber:FJ,config:DL}),qP({typed:qJ}),yF({isNumeric:WJ,typed:qJ}),CF({typed:qJ}),RF({typed:qJ});var sY=zF({Fraction:HJ,typed:qJ}),aY=UF({typed:qJ}),lY=ZF({typed:qJ});a$({typed:qJ}),C$({Complex:jJ,config:DL,typed:qJ});var cY=z$({Complex:jJ,config:DL,typed:qJ}),uY=hH({typed:qJ});jH({typed:qJ}),zU({isNaN:GJ,isNumeric:WJ,typed:qJ}),WU({typed:qJ}),$V({Complex:jJ,config:DL,typed:qJ}),JV({BigNumber:FJ,typed:qJ}),nW({typed:qJ});var dY=lW({typed:qJ});fW({BigNumber:FJ,typed:qJ});var pY=wW({typed:qJ});VK({typed:qJ}),dG({config:DL,typed:qJ}),zG({BigNumber:FJ,config:DL});var hY=hF({typed:qJ}),fY=TF({Matrix:$J,equalScalar:JJ,typed:qJ}),mY=jF({DenseMatrix:UJ,Matrix:$J,SparseMatrix:fY,typed:qJ});QF({BigNumber:FJ,Complex:jJ,Fraction:HJ,config:DL,isNegative:hY,matrix:mY,typed:qJ,unaryMinus:aY}),v$({BigNumber:FJ,DenseMatrix:UJ,equalScalar:JJ,matrix:mY,typed:qJ}),T$({DenseMatrix:UJ,equalScalar:JJ,matrix:mY,typed:qJ}),I$({BigNumber:FJ,equalScalar:JJ,matrix:mY,typed:qJ}),q$({BigNumber:FJ,config:DL,matrix:mY,typed:qJ}),rH({equalScalar:JJ,matrix:mY,typed:qJ}),uH({DenseMatrix:UJ,matrix:mY,typed:qJ}),yH({DenseMatrix:UJ,equalScalar:JJ,matrix:mY,typed:qJ});var gY=wH({isInteger:VJ,matrix:mY,typed:qJ});AH({DenseMatrix:UJ,SparseMatrix:fY,matrix:mY,typed:qJ});var yY=$H({BigNumber:FJ,DenseMatrix:UJ,SparseMatrix:fY,config:DL,matrix:mY,typed:qJ});GH({BigNumber:FJ,config:DL,matrix:mY,typed:qJ}),tU({isInteger:VJ,matrix:mY,typed:qJ});var vY=uU({matrix:mY,config:DL,typed:qJ}),bY=wU({matrix:mY,typed:qJ}),wY=TU({BigNumber:FJ,config:DL,matrix:mY,typed:qJ});GU({typed:qJ});var xY=uq({BigNumber:FJ,DenseMatrix:UJ,equalScalar:JJ,matrix:mY,typed:qJ,zeros:wY});Bq({DenseMatrix:UJ,equalScalar:JJ,matrix:mY,typed:qJ,zeros:wY}),Fq({DenseMatrix:UJ,equalScalar:JJ,matrix:mY,typed:qJ,zeros:wY});var MY=Uq({BigNumber:FJ,DenseMatrix:UJ,Fraction:HJ,config:DL,equalScalar:JJ,matrix:mY,typed:qJ}),SY=Gq({matrix:mY,typed:qJ}),EY=eV({DenseMatrix:UJ,config:DL,matrix:mY,typed:qJ}),CY=iV({DenseMatrix:UJ,config:DL,matrix:mY,typed:qJ});uV({DenseMatrix:UJ,config:DL,equalScalar:JJ,matrix:mY,typed:qJ});var NY=yV({DenseMatrix:UJ,smaller:EY}),AY=bV({larger:CY,smaller:EY});LV({SparseMatrix:fY,typed:qJ}),VV({BigNumber:FJ,Complex:jJ,config:DL,typed:qJ}),oW({BigNumber:FJ,DenseMatrix:UJ,equalScalar:JJ,matrix:mY,typed:qJ}),yW({BigNumber:FJ,typed:qJ});var kY=VW({DenseMatrix:UJ,SparseMatrix:fY,addScalar:lY,equalScalar:JJ,matrix:mY,typed:qJ}),TY=YW({addScalar:lY,conj:uY,multiplyScalar:QJ,size:vY,typed:qJ});xG({addScalar:lY,combinations:oY,isInteger:VJ,isNegative:hY,isPositive:KJ,larger:CY,typed:qJ});var OY=xF({typed:qJ}),_Y=WF({typed:qJ}),RY=h$({config:DL,equalScalar:JJ,matrix:mY,round:xY,typed:qJ}),DY=R$({addScalar:lY,dot:TY,equalScalar:JJ,matrix:mY,multiplyScalar:QJ,typed:qJ});K$({equalScalar:JJ,matrix:mY,multiplyScalar:QJ,typed:qJ}),mH({typed:qJ}),IH({matrix:mY,typed:qJ}),rU({config:DL,matrix:mY}),pU({matrix:mY,typed:qJ}),XU({matrix:mY,typed:qJ});var IY=iq({Complex:jJ,config:DL,fraction:sY,identity:yY,matrix:mY,multiply:DY,number:YJ,typed:qJ});vq({DenseMatrix:UJ,equalScalar:JJ,matrix:mY,pow:IY,typed:qJ}),Pq({DenseMatrix:UJ,equalScalar:JJ,matrix:mY,typed:qJ,zeros:wY});var LY=Wq({compare:MY,typed:qJ});Xq({compareText:SY,isZero:OY,typed:qJ});var BY=sV({DenseMatrix:UJ,config:DL,matrix:mY,typed:qJ}),zY=pV({compare:MY,isNaN:GJ,isNumeric:WJ,typed:qJ}),PY=vV({ImmutableDenseMatrix:NY});QV({BigNumber:FJ,Complex:jJ,config:DL,typed:qJ}),SW({typed:qJ});var jY=kW({DenseMatrix:UJ,Index:PY,compareNatural:LY,size:vY,subset:bY,typed:qJ}),FY=RW({DenseMatrix:UJ,Index:PY,compareNatural:LY,size:vY,subset:bY,typed:qJ});BW({Index:PY,compareNatural:LY,size:vY,subset:bY,typed:qJ}),FW({compareNatural:LY,typed:qJ}),ZW({add:kY,matrix:mY,typed:qJ}),jK({add:kY,compare:MY,multiply:DY,partitionSelect:zY,typed:qJ});var $Y=GK({BigNumber:FJ,Complex:jJ,config:DL,multiplyScalar:QJ,pow:IY,typed:qJ}),HY=LF({BigNumber:FJ,typed:qJ});x$({equalScalar:JJ,matrix:mY,typed:qJ}),aH({DenseMatrix:UJ,equalScalar:JJ,matrix:mY,typed:qJ}),UH({matrix:mY,multiplyScalar:QJ,typed:qJ});var UY=CU({matrix:mY,typed:qJ}),qY=tq({bignumber:HY,fraction:sY,number:YJ});$q({equalScalar:JJ,matrix:mY,not:tY,typed:qJ,zeros:wY});var VY=nV({DenseMatrix:UJ,config:DL,matrix:mY,typed:qJ});fV({compare:MY,compareNatural:LY,matrix:mY,typed:qJ}),gV({config:DL,numeric:qY,smaller:EY,typed:qJ}),dW({BigNumber:FJ,typed:qJ}),OW({DenseMatrix:UJ,Index:PY,compareNatural:LY,size:vY,subset:bY,typed:qJ}),PW({Index:PY,compareNatural:LY,size:vY,subset:bY,typed:qJ}),QW({Index:PY,typed:qJ});var WY=OK({add:kY,config:DL,numeric:qY,typed:qJ}),KY=YK({gamma:$Y,typed:qJ});nG({factorial:KY,typed:qJ});var GY=i$({config:DL,equalScalar:JJ,matrix:mY,round:xY,typed:qJ}),JY=$$({DenseMatrix:UJ,addScalar:lY,equalScalar:JJ,matrix:mY,typed:qJ,unaryMinus:aY});CH({matrix:mY,multiply:DY,subtract:JY,typed:qJ});var YY=QH({bignumber:HY,matrix:mY,config:DL,larger:CY,largerEq:BY,smaller:EY,smallerEq:VY,typed:qJ});lU({Index:PY,matrix:mY,range:YY,typed:qJ}),FU({config:DL,multiplyScalar:QJ,numeric:qY,typed:qJ});var ZY=Yq({DenseMatrix:UJ,equalScalar:JJ,matrix:mY,typed:qJ}),XY=mV({config:DL,larger:CY,numeric:qY,typed:qJ});NW({DenseMatrix:UJ,Index:PY,compareNatural:LY,size:vY,subset:bY,typed:qJ});var QY=HW({Index:PY,concat:gY,setDifference:jY,size:vY,subset:bY,typed:qJ}),eZ=u$({Complex:jJ,ceil:GY,floor:RY,matrix:mY,typed:qJ});SH({Index:PY,matrix:mY,range:YY,typed:qJ});var tZ=AU({conj:uY,transpose:UY,typed:qJ});lV({equal:ZY,typed:qJ}),IW({Index:PY,compareNatural:LY,size:vY,subset:bY,typed:qJ}),vH({DenseMatrix:UJ,matrix:mY,typed:qJ});var nZ=rq({numeric:qY,typed:qJ});gq({Complex:jJ,config:DL,divideScalar:nZ,typed:qJ});var rZ=Sq({DenseMatrix:UJ,divideScalar:nZ,equalScalar:JJ,matrix:mY,multiplyScalar:QJ,subtract:JY,typed:qJ});Tq({DenseMatrix:UJ,divideScalar:nZ,equalScalar:JJ,matrix:mY,multiplyScalar:QJ,subtract:JY,typed:qJ});var iZ=wV({FibonacciHeap:AY,addScalar:lY,equalScalar:JJ});qW({Index:PY,concat:gY,setIntersect:FY,setSymDifference:QY,size:vY,subset:bY,typed:qJ});var oZ=eK({DenseMatrix:UJ,Spa:iZ,SparseMatrix:fY,abs:_Y,addScalar:lY,divideScalar:nZ,equalScalar:JJ,larger:CY,matrix:mY,multiplyScalar:QJ,subtract:JY,typed:qJ,unaryMinus:aY}),sZ=mK({SparseMatrix:fY,abs:_Y,add:kY,divideScalar:nZ,larger:CY,largerEq:BY,multiply:DY,subtract:JY,transpose:UY,typed:qJ}),aZ=bK({lup:oZ,matrix:mY,multiply:DY,subtract:JY,typed:qJ,unaryMinus:aY});kK({abs:_Y,addScalar:lY,divideScalar:nZ,multiplyScalar:QJ,sqrt:cY,subtract:JY,typed:qJ,unaryMinus:aY});var lZ=mG({addScalar:lY,combinations:oY,divideScalar:nZ,factorial:KY,isInteger:VJ,isNegative:hY,larger:CY,multiplyScalar:QJ,pow:IY,subtract:JY,typed:qJ});bG({addScalar:lY,combinations:oY,divideScalar:nZ,isInteger:VJ,isNegative:hY,multiplyScalar:QJ,typed:qJ}),KH({matrix:mY,number:YJ,subtract:JY,typed:qJ});var cZ=pq({Complex:jJ,config:DL,divideScalar:nZ,typed:qJ}),uZ=wq({DenseMatrix:UJ,divideScalar:nZ,equalScalar:JJ,matrix:mY,typed:qJ});Dq({DenseMatrix:UJ,divideScalar:nZ,equalScalar:JJ,matrix:mY,multiplyScalar:QJ,subtract:JY,typed:qJ}),KW({abs:_Y,addScalar:lY,divideScalar:nZ,isPositive:KJ,multiplyScalar:QJ,smaller:EY,sqrt:cY,typed:qJ}),nK({addScalar:lY,complex:ZJ,conj:uY,divideScalar:nZ,equal:ZY,identity:yY,isZero:OY,matrix:mY,multiplyScalar:QJ,sign:eY,sqrt:cY,subtract:JY,typed:qJ,unaryMinus:aY,zeros:wY});var dZ=wK({abs:_Y,addScalar:lY,det:aZ,divideScalar:nZ,identity:yY,matrix:mY,multiply:DY,typed:qJ,unaryMinus:aY});SK({abs:_Y,add:kY,identity:yY,inv:dZ,multiply:DY,typed:qJ});var pZ=NK({divideScalar:nZ,equalScalar:JJ,inv:dZ,matrix:mY,multiply:DY,typed:qJ});RK({add:kY,divide:pZ,typed:qJ});var hZ=PK({add:kY,apply:XJ,divide:pZ,isNaN:GJ,multiply:DY,subtract:JY,typed:qJ});XK({divide:pZ,dotDivide:uZ,isNumeric:WJ,log:cZ,matrix:mY,multiply:DY,sum:WY,typed:qJ}),yG({addScalar:lY,isInteger:VJ,isNegative:hY,stirlingS2:lZ,typed:qJ}),fq({Complex:jJ,config:DL,divideScalar:nZ,log:cZ,typed:qJ});var fZ=_V({BigNumber:FJ,Complex:jJ,Fraction:HJ,abs:_Y,addScalar:lY,config:DL,divideScalar:nZ,equal:ZY,fix:eZ,format:rY,isNumeric:WJ,multiplyScalar:QJ,number:YJ,pow:IY,round:xY,subtract:JY});zV({Unit:fZ,typed:qJ});var mZ=xK({abs:_Y,add:kY,addScalar:lY,atan:iY,bignumber:HY,config:DL,cos:dY,equal:ZY,inv:dZ,matrix:mY,multiply:DY,multiplyScalar:QJ,sin:pY,subtract:JY,typed:qJ});TK({abs:_Y,add:kY,addScalar:lY,config:DL,divideScalar:nZ,equalScalar:JJ,matrix:mY,multiply:DY,multiplyScalar:QJ,smaller:EY,subtract:JY,typed:qJ}),FK({sqrt:cY,typed:qJ,variance:hZ}),gJ({BigNumber:FJ,Unit:fZ,config:DL}),YG({BigNumber:FJ,Unit:fZ,config:DL}),vJ({BigNumber:FJ,Unit:fZ,config:DL}),ZG({BigNumber:FJ,Unit:fZ,config:DL}),cJ({BigNumber:FJ,Unit:fZ,config:DL}),iJ({BigNumber:FJ,Unit:fZ,config:DL}),bJ({BigNumber:FJ,Unit:fZ,config:DL}),wJ({BigNumber:FJ,Unit:fZ,config:DL}),HG({BigNumber:FJ,Unit:fZ,config:DL}),aJ({BigNumber:FJ,Unit:fZ,config:DL}),tJ({BigNumber:FJ,Unit:fZ,config:DL}),VG({BigNumber:FJ,Unit:fZ,config:DL}),TJ({BigNumber:FJ,Unit:fZ,config:DL}),SJ({BigNumber:FJ,Unit:fZ,config:DL}),uJ({BigNumber:FJ,Unit:fZ,config:DL}),LJ({BigNumber:FJ,Unit:fZ,config:DL}),RJ({BigNumber:FJ,Unit:fZ,config:DL}),BJ({BigNumber:FJ,Unit:fZ,config:DL}),lJ({BigNumber:FJ,Unit:fZ,config:DL}),qG({BigNumber:FJ,Unit:fZ,config:DL}),NJ({BigNumber:FJ,Unit:fZ,config:DL}),AJ({BigNumber:FJ,Unit:fZ,config:DL}),KG({BigNumber:FJ,Unit:fZ,config:DL});var gZ=Cq({DenseMatrix:UJ,divideScalar:nZ,equalScalar:JJ,matrix:mY,multiplyScalar:QJ,subtract:JY,typed:qJ}),yZ=JW({abs:_Y,add:kY,conj:uY,ctranspose:tZ,eigs:mZ,equalScalar:JJ,larger:CY,matrix:mY,multiply:DY,pow:IY,smaller:EY,sqrt:cY,typed:qJ});vK({DenseMatrix:UJ,lsolve:rZ,lup:oZ,matrix:mY,slu:sZ,typed:qJ,usolve:gZ}),CK({abs:_Y,add:kY,identity:yY,inv:dZ,max:XY,multiply:DY,size:vY,sqrt:cY,subtract:JY,typed:qJ}),eG({add:kY,divide:pZ,factorial:KY,isInteger:VJ,isPositive:KJ,multiply:DY,typed:qJ}),yJ({BigNumber:FJ,Unit:fZ,config:DL}),rJ({BigNumber:FJ,Unit:fZ,config:DL}),WG({BigNumber:FJ,Unit:fZ,config:DL}),oJ({BigNumber:FJ,Unit:fZ,config:DL}),_J({BigNumber:FJ,Unit:fZ,config:DL}),xJ({BigNumber:FJ,Unit:fZ,config:DL}),OJ({BigNumber:FJ,Unit:fZ,config:DL}),eJ({BigNumber:FJ,Unit:fZ,config:DL}),DJ({BigNumber:FJ,Unit:fZ,config:DL}),dJ({BigNumber:FJ,Unit:fZ,config:DL}),$G({BigNumber:FJ,Unit:fZ,config:DL}),kJ({BigNumber:FJ,Unit:fZ,config:DL});var vZ=aU({BigNumber:FJ,DenseMatrix:UJ,SparseMatrix:fY,addScalar:lY,config:DL,cos:dY,matrix:mY,multiplyScalar:QJ,norm:yZ,sin:pY,typed:qJ,unaryMinus:aY}),bZ=IK({add:kY,compare:MY,divide:pZ,partitionSelect:zY,typed:qJ});nJ({BigNumber:FJ,Unit:fZ,config:DL}),JG({BigNumber:FJ,Unit:fZ,config:DL}),XG({BigNumber:FJ,Unit:fZ,config:DL}),EJ({BigNumber:FJ,Unit:fZ,config:DL}),IJ({BigNumber:FJ,Unit:fZ,config:DL}),hJ({BigNumber:FJ,Unit:fZ,config:DL}),oU({multiply:DY,rotationMatrix:vZ,typed:qJ}),LK({abs:_Y,map:nY,median:bZ,subtract:JY,typed:qJ}),GG({BigNumber:FJ,Unit:fZ,config:DL}),QG({BigNumber:FJ,Unit:fZ,config:DL}),pJ({BigNumber:FJ,Unit:fZ,config:DL}),DV({Unit:fZ,typed:qJ}),MJ({BigNumber:FJ,Unit:fZ,config:DL}),UG({BigNumber:FJ,Unit:fZ,config:DL});const wZ=i,xZ=e,{TextField:MZ}=n,{IconButton:SZ}=n,{InputAdornment:EZ}=n,{styled:CZ}=r,{Remove:NZ}=o,{Add:AZ}=o,kZ=CZ(MZ)(()=>({"& input[type=number]":{MozAppearance:"textfield"},"& input[type=number]::-webkit-outer-spin-button":{WebkitAppearance:"none",margin:0},"& input[type=number]::-webkit-inner-spin-button":{WebkitAppearance:"none",margin:0}})),TZ=CZ(SZ)(()=>({padding:"2px"}));class OZ extends xZ.Component{static __initStatic(){this.propTypes={className:wZ.string,customValues:wZ.array,disabled:wZ.bool,error:wZ.bool,inputClassName:wZ.string,helperText:wZ.string,onChange:wZ.func.isRequired,onlyIntegersAllowed:wZ.bool,value:wZ.any,min:wZ.number,max:wZ.number,step:wZ.number,label:wZ.string,disableUnderline:wZ.bool,textAlign:wZ.string,variant:wZ.string,type:wZ.string}}static __initStatic2(){this.defaultProps={step:1,customValues:[],textAlign:"center",variant:"standard",onlyIntegersAllowed:!1}}constructor(e){super(e),OZ.prototype.__init.call(this),OZ.prototype.__init2.call(this),OZ.prototype.__init3.call(this),OZ.prototype.__init4.call(this),OZ.prototype.__init5.call(this),OZ.prototype.__init6.call(this);const{value:t,currentIndex:n}=this.normalizeValueAndIndex(e.customValues,e.value);this.state={value:t,currentIndex:n},t!==e.value&&this.props.onChange({},t),this.onChange=this.onChange.bind(this)}UNSAFE_componentWillReceiveProps(e){const{value:t,currentIndex:n}=this.normalizeValueAndIndex(e.customValues,e.value,e.min,e.max);this.setState({value:t,currentIndex:n})}clamp(e,t=this.props.min,n=this.props.max){const{customValues:r}=this.props;return(r||[]).length>0?e:cr(e)?(cr(n)&&(e=Math.min(e,n)),cr(t)&&(e=Math.max(e,t)),e):((e,t)=>cr(e)||cr(t)?!cr(e)&&cr(t)?t:cr(e)?e:void 0:0)(t,n)}__init(){this.normalizeValueAndIndex=(e,t,n,r)=>{const{type:i}=this.props,o=this.clamp(t,n,r),s=(e||[]).findIndex(e=>e===o);if((e||[]).length>0&&-1===s){const t="text"===i?this.getClosestFractionValue(e,o):this.getClosestValue(e,o);return{value:t.value,currentIndex:t.index}}return{value:o,currentIndex:s}}}__init2(){this.getClosestValue=(e,t)=>e.reduce((e,n,r)=>Math.abs(n-t)<Math.abs(e.value-t)?{value:n,index:r}:e,{value:e[0],index:0})}__init3(){this.getClosestFractionValue=(e,t)=>e.reduce((e,n,r)=>Math.abs(YJ(sY(n))-YJ(sY(t)))<Math.abs(YJ(sY(e.value))-YJ(sY(t)))?{value:n,index:r}:e,{value:e[0],index:0})}__init4(){this.getValidFraction=e=>{if(this.isPositiveInteger(e.trim()))return e.trim();if(""===e.trim()||2!==e.trim().split("/").length)return!1;let[t,n]=e.trim().split("/");return!isNaN(t)&&!isNaN(n)&&(t=parseFloat(t),n=parseFloat(n),!(!Number.isInteger(t)||!Number.isInteger(n))&&(!(t<0||n<1)&&t+"/"+n))}}__init5(){this.isPositiveInteger=e=>e>>>0===parseFloat(e)}__init6(){this.onBlur=e=>{const{customValues:t,onlyIntegersAllowed:n,type:r}=this.props;let{value:i}=e.target;if("text"===r){let e=this.getValidFraction(i);i=e||this.props.value}let o=n?Math.round(parseFloat(i)):parseFloat(i);"text"===r&&(o=i.trim());const{value:s,currentIndex:a}=this.normalizeValueAndIndex(t,o);this.setState({value:s.toString(),currentIndex:a},()=>this.props.onChange(e,s))}}onChange(e){const{type:t}=this.props,{value:n}=e.target;"text"!==t&&"string"==typeof n&&""===n.trim()||this.setState({value:n})}changeValue(e,t=1,n=!1){e.preventDefault();const{customValues:r,step:i,onlyIntegersAllowed:o,onChange:s}=this.props,{currentIndex:a,value:l}=this.state,c=a+1*t;let u;if(r.length>0){if(c<0||c>=r.length)return;u=r[c]}else{const e=(1e4*(o?parseInt(l):parseFloat(l))+i*t*1e4)/1e4;u=this.clamp(e)}this.setState({value:u.toString(),currentIndex:c},()=>{n&&s(e,u)})}render(){const{className:e,label:t,disabled:n,error:r,min:i,max:o,customValues:s,inputClassName:a,disableUnderline:l,helperText:c,variant:u,textAlign:d,type:p="number"}=this.props,{value:h}=this.state,f=e;let m=!1,g=!1;return s.length>0?(m=h===s[0],g=h===s[s.length-1]):cr(i)&&cr(o)&&(m=h===i,g=h===o),xZ.createElement(kZ,{variant:u,inputRef:e=>this.inputRef=e,disabled:n,label:t,value:h,error:r,helperText:c,onChange:this.onChange,onBlur:this.onBlur,onKeyPress:e=>{"Enter"===e.key&&this.inputRef&&this.inputRef.blur()},onKeyDown:e=>{"ArrowUp"===e.key&&this.changeValue(e),"ArrowDown"===e.key&&this.changeValue(e,-1)},title:"",type:p,className:f,InputProps:{className:a,disableUnderline:l,startAdornment:xZ.createElement(EZ,{position:"start"},xZ.createElement(TZ,{disabled:n||m,onClick:e=>this.changeValue(e,-1,!0),size:"large"},xZ.createElement(NZ,{fontSize:"small"}))),endAdornment:xZ.createElement(EZ,{position:"end"},xZ.createElement(TZ,{disabled:n||g,onClick:e=>this.changeValue(e,1,!0),size:"large"},xZ.createElement(AZ,{fontSize:"small"})))},inputProps:{style:{textAlign:d},min:i,max:o}})}}OZ.__initStatic(),OZ.__initStatic2();const{InputContainer:_Z}=a,RZ=i,DZ=e,{styled:IZ}=r,LZ=IZ("div")(({theme:e,direction:t})=>({display:"flex",flexWrap:"wrap",paddingLeft:0,marginTop:e.spacing(1),..."vertical"===t&&{flexDirection:"column"}}));class BZ extends DZ.Component{constructor(...e){super(...e),BZ.prototype.__init.call(this)}static __initStatic(){this.propTypes={header:RZ.string.isRequired,className:RZ.string,customLabel:RZ.func,opts:RZ.array.isRequired,value:RZ.string,onChange:RZ.func.isRequired,direction:RZ.oneOf(["horizontal","vertical"])}}__init(){this.handleChange=e=>{this.props.onChange(e.currentTarget.value)}}render(){const{header:e,className:t,customLabel:n,opts:r,value:i,direction:o}=this.props,s=r.map(e=>"string"==typeof e?{label:e,value:e}:e),a=n||UR;return DZ.createElement(_Z,{label:e,className:t},DZ.createElement(LZ,{direction:o},s.map((e,t)=>DZ.createElement(a,{value:e.value,key:t,checked:e.value===i,onChange:this.handleChange,label:e.label}))))}}BZ.__initStatic();const zZ=RZ.shape({label:RZ.string,value:RZ.string});class PZ extends DZ.Component{static __initStatic2(){this.propTypes={header:RZ.string.isRequired,value:RZ.string.isRequired,onChange:RZ.func.isRequired,one:RZ.oneOfType([zZ,RZ.string]),two:RZ.oneOfType([zZ,RZ.string]),className:RZ.string,customLabel:RZ.func}}render(){const{one:e,two:t,header:n,className:r,customLabel:i,value:o,onChange:s}=this.props,a=[e,t];return DZ.createElement(BZ,{customLabel:i,header:n,className:r,opts:a,value:o,onChange:s})}}PZ.__initStatic2();const jZ=e,FZ=i,{styled:$Z}=r,HZ=l("pie-elements:config-ui:mui-box"),UZ=$Z("div")(({theme:e,focused:t})=>{const n="light"===e.palette.mode?"rgba(0, 0, 0, 0.42)":"rgba(255, 255, 255, 0.7)";return HZ(e.palette.primary[e.palette.mode||"light"]),{paddingTop:e.spacing(1),paddingBottom:e.spacing(1),position:"relative","&:before":{left:0,right:0,bottom:0,height:"1px",content:'""',position:"absolute",transition:"background-color 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",pointerEvents:"none",backgroundColor:n},"&:hover:before":{height:"2px"},"&:after":{left:0,right:0,bottom:0,height:"2px",content:'""',position:"absolute",transform:t?"scaleX(1)":"scaleX(0)",transition:"transform 200ms cubic-bezier(0.0, 0, 0.2, 1) 0ms",pointerEvents:"none",backgroundColor:e.palette.primary[e.palette.mode]}}}),qZ=({children:e,focused:t})=>jZ.createElement(UZ,{focused:t},e);qZ.propTypes={children:FZ.oneOfType([FZ.arrayOf(FZ.node),FZ.node]).isRequired,focused:FZ.bool.isRequired};const VZ=e,WZ=i,{styled:KZ}=r,{Chip:GZ}=n,JZ=KZ(GZ)(()=>({padding:"0px",margin:"1px"})),YZ=({label:e,onDelete:t})=>VZ.createElement(JZ,{label:e,onDelete:t});YZ.propTypes={label:WZ.string.isRequired,onDelete:WZ.func.isRequired};const ZZ=KZ("div")(({theme:e})=>({border:`0px solid ${e.palette.background.paper}`,display:"flex",flexWrap:"wrap"})),XZ=KZ("input")(({theme:e})=>({padding:"2px",margin:"1px",minWidth:"30px",width:"100%",flex:"1",border:`0px solid ${e.palette.background.paper}`,height:"28px",fontSize:e.typography.fontSize,fontFamily:e.typography.fontFamily,outline:"none","&:focus":{outline:"none"}}));class QZ extends VZ.Component{static __initStatic(){this.propTypes={tags:WZ.arrayOf(WZ.string).isRequired,onChange:WZ.func.isRequired}}constructor(e){super(e),QZ.prototype.__init.call(this),QZ.prototype.__init2.call(this),this.state={value:"",focused:!1},this.onKeyDown=e=>{if(13===e.keyCode&&""!==this.state.value){const e=this.state.value.trim(),t=wr(this.props.tags.concat([e]));t.length!==this.props.tags.length&&(this.props.onChange(t),this.setState({value:""}))}},this.onChange=e=>{this.setState({value:e.target.value})},this.deleteTag=e=>{const{tags:t}=this.props,n=t.indexOf(e);-1!==n&&(t.splice(n,1),this.props.onChange(t),this.input.focus())}}__init(){this.onFocus=()=>{this.setState({focused:!0})}}__init2(){this.onBlur=()=>{this.setState({focused:!1})}}render(){const{tags:e}=this.props;return VZ.createElement(qZ,{focused:this.state.focused},VZ.createElement(ZZ,null,(e||[]).map((e,t)=>VZ.createElement(YZ,{key:t,label:e,onDelete:()=>this.deleteTag(e)})),VZ.createElement(XZ,{ref:e=>this.input=e,onKeyDown:this.onKeyDown,onChange:this.onChange,value:this.state.value,onFocus:this.onFocus,onBlur:this.onBlur,type:"text"})))}}QZ.__initStatic();const{Menu:eX}=n,{MenuItem:tX}=n,{IconButton:nX}=n,{Feedback:rX}=o,iX=i,oX=e;class sX extends oX.Component{static __initStatic(){this.propTypes={opts:iX.object,onClick:iX.func.isRequired,iconButtonElement:iX.any}}constructor(e){super(e),sX.prototype.__init.call(this),sX.prototype.__init2.call(this),this.state={anchorEl:void 0,open:!1}}__init(){this.handleClick=e=>{this.setState({open:!0,anchorEl:e.currentTarget})}}__init2(){this.handleRequestClose=()=>{this.setState({open:!1})}}render(){const{opts:e,onClick:t}=this.props,n=Object.keys(e),r=e=>()=>{t(e),this.handleRequestClose()};return oX.createElement("div",null,oX.createElement("div",{onClick:this.handleClick},this.props.iconButtonElement),oX.createElement(eX,{id:"simple-menu",anchorEl:this.state.anchorEl,open:this.state.open,onClose:this.handleRequestClose,transitionDuration:{enter:225,exit:195}},n.map((t,n)=>oX.createElement(tX,{key:n,onClick:r(t)},e[t]))))}}sX.__initStatic();class aX extends oX.Component{static __initStatic2(){this.propTypes={value:iX.object,onChange:iX.func.isRequired,classes:iX.object.isRequired}}static __initStatic3(){this.defaultProps={classes:{}}}render(){const{value:e,onChange:t,classes:n}=this.props,r=e&&e.type,i="custom"===r||"default"===r?"primary":"disabled",o="custom"===r?"Custom Feedback":"default"===r?"Default Feedback":"Feedback disabled",s=oX.createElement(nX,{className:n.icon,"aria-label":o,size:"large"},oX.createElement(rX,{color:i}));return oX.createElement(sX,{iconButtonElement:s,onClick:e=>t(e),opts:{none:"No Feedback",default:"Default",custom:"Custom"}})}}aX.__initStatic2(),aX.__initStatic3();const lX=e,cX=i,{styled:uX}=r,{TextField:dX}=n,{IconButton:pX}=n,{Delete:hX}=o,{SubdirectoryArrowRight:fX}=o,{InputContainer:mX}=a;let gX;"undefined"!=typeof window&&(gX=require("@pie-lib/editable-html-tip-tap").default);const yX=uX("div")(({theme:e})=>({marginTop:e.spacing(2)})),vX=({label:e,onChange:t,value:n,className:r,imageSupport:i,disableImageAlignmentButtons:o,disabled:s,spellCheck:a,nonEmpty:l,pluginOpts:c,toolbarOpts:u,error:d,maxImageWidth:p,maxImageHeight:h,uploadSoundSupport:f,mathMlOptions:m={}})=>lX.createElement(mX,{label:e,className:r},lX.createElement(yX,null,lX.createElement(gX,{markup:n||"",disabled:s,spellCheck:a,nonEmpty:l,onChange:t,imageSupport:i,disableImageAlignmentButtons:o,pluginProps:c||{},toolbarOpts:u,error:d,maxImageWidth:p,maxImageHeight:h,uploadSoundSupport:f,languageCharactersProps:[{language:"spanish"},{language:"special"}],mathMlOptions:m}))),bX=uX("div")(()=>({position:"relative"})),wX=uX(fX)(({theme:e})=>({fill:e.palette.grey[400],left:-56,position:"absolute",top:40})),xX=uX(dX)(({theme:e})=>({width:"100%",marginTop:e.spacing(2)})),MX=uX(vX)(({theme:e})=>({width:"100%",marginTop:e.spacing(2)})),SX=({value:e,onChange:t,type:n,correct:r,defaults:i,toolbarOpts:o,mathMlOptions:s={}})=>n&&"none"!==n?"default"===n?lX.createElement(bX,null,lX.createElement(wX,null),lX.createElement(xX,{label:"Feedback Text",value:r?i.correct:i.incorrect,variant:"standard"})):lX.createElement(bX,null,lX.createElement(wX,null),lX.createElement(MX,{label:"Feedback Text",value:e,onChange:t,toolbarOpts:o,mathMlOptions:s})):null,EX=uX("span")(({theme:e})=>({paddingRight:e.spacing(1),paddingTop:e.spacing(3)})),CX=uX("div")(()=>({display:"flex",alignItems:"center"})),NX=uX("div")(({theme:e})=>({flex:"0 1 auto",paddingTop:e.spacing(.5),paddingBottom:0,marginRight:0,marginLeft:e.spacing(1)})),AX=uX("div")(({theme:e})=>({flex:"0 1 auto",paddingTop:e.spacing(2),paddingLeft:0,marginLeft:0,marginRight:e.spacing(1)})),kX=uX("div")(()=>({margin:0,width:"inherit"})),TX=uX("div")(()=>({margin:0,width:"inherit"})),OX=uX("div")(({theme:e})=>({flex:"0 1 auto",paddingTop:e.spacing(2),paddingLeft:0,marginLeft:0})),_X=uX("div")(({theme:e})=>({display:"flex",flex:1,flexDirection:"column",marginRight:e.spacing(1)})),RX=uX("div")(({theme:e})=>({fontSize:e.typography.fontSize-2,color:e.palette.error.main}));class DX extends lX.Component{constructor(...e){super(...e),DX.prototype.__init.call(this),DX.prototype.__init2.call(this),DX.prototype.__init3.call(this),DX.prototype.__init4.call(this),DX.prototype.__init5.call(this)}static __initStatic(){this.propTypes={noLabels:cX.bool,useLetterOrdering:cX.bool,className:cX.string,error:cX.string,mode:cX.oneOf(["checkbox","radio"]),defaultFeedback:cX.object.isRequired,disabled:cX.bool,nonEmpty:cX.bool,data:cX.shape({label:cX.string.isRequired,value:cX.string.isRequired,correct:cX.bool,feedback:cX.shape({type:cX.string,value:cX.string})}),onDelete:cX.func,onChange:cX.func,index:cX.number,imageSupport:cX.shape({add:cX.func.isRequired,delete:cX.func.isRequired}),disableImageAlignmentButtons:cX.bool,allowFeedBack:cX.bool,allowDelete:cX.bool,noCorrectAnswerError:cX.string,spellCheck:cX.bool,pluginOpts:cX.object,toolbarOpts:cX.object,uploadSoundSupport:cX.object,maxImageWidth:cX.number,maxImageHeight:cX.number}}static __initStatic2(){this.defaultProps={index:-1,noLabels:!1,useLetterOrdering:!1,allowFeedBack:!0,allowDelete:!0}}__init(){this._changeFn=e=>t=>{const{data:n,onChange:r}=this.props;r&&r({...n,[e]:t})}}__init2(){this.onLabelChange=this._changeFn("label")}__init3(){this.onCheckedChange=e=>{const t=e.target.checked,{data:n,onChange:r}=this.props;r&&r({...n,correct:t})}}__init4(){this.onFeedbackValueChange=e=>{const{data:t,onChange:n}=this.props;if("custom"!==t.feedback.type)return;const r={...t.feedback,value:e};n&&n({...t,feedback:r})}}__init5(){this.onFeedbackTypeChange=e=>{const{data:t,onChange:n}=this.props,r={...t.feedback,type:e};"custom"!==r.type&&(r.value=void 0),n&&n({...t,feedback:r})}}render(){const{data:e,mode:t,onDelete:n,defaultFeedback:r,index:i,className:o,noLabels:s,useLetterOrdering:a,imageSupport:l,disableImageAlignmentButtons:c,disabled:u,spellCheck:d,nonEmpty:p,allowFeedBack:h,allowDelete:f,pluginOpts:m,toolbarOpts:g,error:y,noCorrectAnswerError:v,uploadSoundSupport:b,maxImageWidth:w,maxImageHeight:x,mathMlOptions:M={}}=this.props,S="checkbox"===t?RD:ID;return lX.createElement(CX,null,i>0&&lX.createElement(EX,{type:"title"},a?String.fromCharCode(96+i).toUpperCase():i),lX.createElement(NX,null,lX.createElement(S,{onChange:this.onCheckedChange,label:s?"":"Correct",checked:!!e.correct,error:v})),lX.createElement(_X,null,lX.createElement(vX,{label:s?"":"Label",value:e.label,onChange:this.onLabelChange,imageSupport:l,disableImageAlignmentButtons:c,disabled:u,spellCheck:d,nonEmpty:p,pluginOpts:m,toolbarOpts:g,error:y,uploadSoundSupport:b,mathMlOptions:M,maxImageWidth:w,maxImageHeight:x}),y&&lX.createElement(RX,null,y),h&&lX.createElement(SX,{...e.feedback,correct:e.correct,defaults:r,onChange:this.onFeedbackValueChange,toolbarOpts:g})),h&&lX.createElement(AX,null,lX.createElement(mX,{label:s?"":"Feedback"},lX.createElement(kX,null,lX.createElement(aX,{onChange:this.onFeedbackTypeChange,value:e.feedback})))),f&&lX.createElement(OX,null,lX.createElement(mX,{label:s?"":"Delete"},lX.createElement(TX,null,lX.createElement(pX,{"aria-label":"delete",onClick:n,size:"large"},lX.createElement(hX,null))))))}}function IX(){return IX=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},IX.apply(null,arguments)}function LX(e,t){return LX=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},LX(e,t)}DX.__initStatic(),DX.__initStatic2();var BX=function(){if("undefined"!=typeof Map)return Map;function e(e,t){var n=-1;return e.some(function(e,r){return e[0]===t&&(n=r,!0)}),n}return function(){function t(){this.__entries__=[]}return Object.defineProperty(t.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),t.prototype.get=function(t){var n=e(this.__entries__,t),r=this.__entries__[n];return r&&r[1]},t.prototype.set=function(t,n){var r=e(this.__entries__,t);~r?this.__entries__[r][1]=n:this.__entries__.push([t,n])},t.prototype.delete=function(t){var n=this.__entries__,r=e(n,t);~r&&n.splice(r,1)},t.prototype.has=function(t){return!!~e(this.__entries__,t)},t.prototype.clear=function(){this.__entries__.splice(0)},t.prototype.forEach=function(e,t){void 0===t&&(t=null);for(var n=0,r=this.__entries__;n<r.length;n++){var i=r[n];e.call(t,i[1],i[0])}},t}()}(),zX="undefined"!=typeof window&&"undefined"!=typeof document&&window.document===document,PX="undefined"!=typeof global&&global.Math===Math?global:"undefined"!=typeof self&&self.Math===Math?self:"undefined"!=typeof window&&window.Math===Math?window:Function("return this")(),jX="function"==typeof requestAnimationFrame?requestAnimationFrame.bind(PX):function(e){return setTimeout(function(){return e(Date.now())},1e3/60)};var FX=["top","right","bottom","left","width","height","size","weight"],$X="undefined"!=typeof MutationObserver,HX=function(){function e(){this.connected_=!1,this.mutationEventsAdded_=!1,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=function(e,t){var n=!1,r=!1,i=0;function o(){n&&(n=!1,e()),r&&a()}function s(){jX(o)}function a(){var e=Date.now();if(n){if(e-i<2)return;r=!0}else n=!0,r=!1,setTimeout(s,t);i=e}return a}(this.refresh.bind(this),20)}return e.prototype.addObserver=function(e){~this.observers_.indexOf(e)||this.observers_.push(e),this.connected_||this.connect_()},e.prototype.removeObserver=function(e){var t=this.observers_,n=t.indexOf(e);~n&&t.splice(n,1),!t.length&&this.connected_&&this.disconnect_()},e.prototype.refresh=function(){this.updateObservers_()&&this.refresh()},e.prototype.updateObservers_=function(){var e=this.observers_.filter(function(e){return e.gatherActive(),e.hasActive()});return e.forEach(function(e){return e.broadcastActive()}),e.length>0},e.prototype.connect_=function(){zX&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),$X?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},e.prototype.disconnect_=function(){zX&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},e.prototype.onTransitionEnd_=function(e){var t=e.propertyName,n=void 0===t?"":t,r=FX.some(function(e){return!!~n.indexOf(e)});r&&this.refresh()},e.getInstance=function(){return this.instance_||(this.instance_=new e),this.instance_},e.instance_=null,e}(),UX=function(e,t){for(var n=0,r=Object.keys(t);n<r.length;n++){var i=r[n];Object.defineProperty(e,i,{value:t[i],enumerable:!1,writable:!1,configurable:!0})}return e},qX=function(e){return e&&e.ownerDocument&&e.ownerDocument.defaultView||PX},VX=ZX(0,0,0,0);function WX(e){return parseFloat(e)||0}function KX(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return t.reduce(function(t,n){return t+WX(e["border-"+n+"-width"])},0)}function GX(e){var t=e.clientWidth,n=e.clientHeight;if(!t&&!n)return VX;var r=qX(e).getComputedStyle(e),i=function(e){for(var t={},n=0,r=["top","right","bottom","left"];n<r.length;n++){var i=r[n],o=e["padding-"+i];t[i]=WX(o)}return t}(r),o=i.left+i.right,s=i.top+i.bottom,a=WX(r.width),l=WX(r.height);if("border-box"===r.boxSizing&&(Math.round(a+o)!==t&&(a-=KX(r,"left","right")+o),Math.round(l+s)!==n&&(l-=KX(r,"top","bottom")+s)),!function(e){return e===qX(e).document.documentElement}(e)){var c=Math.round(a+o)-t,u=Math.round(l+s)-n;1!==Math.abs(c)&&(a-=c),1!==Math.abs(u)&&(l-=u)}return ZX(i.left,i.top,a,l)}var JX="undefined"!=typeof SVGGraphicsElement?function(e){return e instanceof qX(e).SVGGraphicsElement}:function(e){return e instanceof qX(e).SVGElement&&"function"==typeof e.getBBox};function YX(e){return zX?JX(e)?function(e){var t=e.getBBox();return ZX(0,0,t.width,t.height)}(e):GX(e):VX}function ZX(e,t,n,r){return{x:e,y:t,width:n,height:r}}var XX=function(){function e(e){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=ZX(0,0,0,0),this.target=e}return e.prototype.isActive=function(){var e=YX(this.target);return this.contentRect_=e,e.width!==this.broadcastWidth||e.height!==this.broadcastHeight},e.prototype.broadcastRect=function(){var e=this.contentRect_;return this.broadcastWidth=e.width,this.broadcastHeight=e.height,e},e}(),QX=function(e,t){var n,r,i,o,s,a,l,c=(r=(n=t).x,i=n.y,o=n.width,s=n.height,a="undefined"!=typeof DOMRectReadOnly?DOMRectReadOnly:Object,l=Object.create(a.prototype),UX(l,{x:r,y:i,width:o,height:s,top:i,right:r+o,bottom:s+i,left:r}),l);UX(this,{target:e,contentRect:c})},eQ=function(){function e(e,t,n){if(this.activeObservations_=[],this.observations_=new BX,"function"!=typeof e)throw new TypeError("The callback provided as parameter 1 is not a function.");this.callback_=e,this.controller_=t,this.callbackCtx_=n}return e.prototype.observe=function(e){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if("undefined"!=typeof Element&&Element instanceof Object){if(!(e instanceof qX(e).Element))throw new TypeError('parameter 1 is not of type "Element".');var t=this.observations_;t.has(e)||(t.set(e,new XX(e)),this.controller_.addObserver(this),this.controller_.refresh())}},e.prototype.unobserve=function(e){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if("undefined"!=typeof Element&&Element instanceof Object){if(!(e instanceof qX(e).Element))throw new TypeError('parameter 1 is not of type "Element".');var t=this.observations_;t.has(e)&&(t.delete(e),t.size||this.controller_.removeObserver(this))}},e.prototype.disconnect=function(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)},e.prototype.gatherActive=function(){var e=this;this.clearActive(),this.observations_.forEach(function(t){t.isActive()&&e.activeObservations_.push(t)})},e.prototype.broadcastActive=function(){if(this.hasActive()){var e=this.callbackCtx_,t=this.activeObservations_.map(function(e){return new QX(e.target,e.broadcastRect())});this.callback_.call(e,t,e),this.clearActive()}},e.prototype.clearActive=function(){this.activeObservations_.splice(0)},e.prototype.hasActive=function(){return this.activeObservations_.length>0},e}(),tQ="undefined"!=typeof WeakMap?new WeakMap:new BX,nQ=function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var n=HX.getInstance(),r=new eQ(t,n,this);tQ.set(this,r)};["observe","unobserve","disconnect"].forEach(function(e){nQ.prototype[e]=function(){var t;return(t=tQ.get(this))[e].apply(t,arguments)}});var rQ=void 0!==PX.ResizeObserver?PX.ResizeObserver:nQ;const{Component:iQ}=e,{createElement:oQ}=e,sQ=i;var aQ=["client","offset","scroll","bounds","margin"];function lQ(e){var t=[];return aQ.forEach(function(n){e[n]&&t.push(n)}),t}function cQ(e,t){var n={};if(t.indexOf("client")>-1&&(n.client={top:e.clientTop,left:e.clientLeft,width:e.clientWidth,height:e.clientHeight}),t.indexOf("offset")>-1&&(n.offset={top:e.offsetTop,left:e.offsetLeft,width:e.offsetWidth,height:e.offsetHeight}),t.indexOf("scroll")>-1&&(n.scroll={top:e.scrollTop,left:e.scrollLeft,width:e.scrollWidth,height:e.scrollHeight}),t.indexOf("bounds")>-1){var r=e.getBoundingClientRect();n.bounds={top:r.top,right:r.right,bottom:r.bottom,left:r.left,width:r.width,height:r.height}}if(t.indexOf("margin")>-1){var i=getComputedStyle(e);n.margin={top:i?parseInt(i.marginTop):0,right:i?parseInt(i.marginRight):0,bottom:i?parseInt(i.marginBottom):0,left:i?parseInt(i.marginLeft):0}}return n}function uQ(e){return function(t){var n,r;return r=n=function(n){var r,i;function o(){for(var t,r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return(t=n.call.apply(n,[this].concat(i))||this).state={contentRect:{entry:{},client:{},offset:{},scroll:{},bounds:{},margin:{}}},t._animationFrameID=null,t._resizeObserver=null,t._node=null,t._window=null,t.measure=function(n){var r=cQ(t._node,e||lQ(t.props));n&&(r.entry=n[0].contentRect),t._animationFrameID=t._window.requestAnimationFrame(function(){null!==t._resizeObserver&&(t.setState({contentRect:r}),"function"==typeof t.props.onResize&&t.props.onResize(r))})},t._handleRef=function(e){var n;null!==t._resizeObserver&&null!==t._node&&t._resizeObserver.unobserve(t._node),t._node=e,t._window=(n=t._node)&&n.ownerDocument&&n.ownerDocument.defaultView||window;var r=t.props.innerRef;r&&("function"==typeof r?r(t._node):r.current=t._node),null!==t._resizeObserver&&null!==t._node&&t._resizeObserver.observe(t._node)},t}i=n,(r=o).prototype=Object.create(i.prototype),r.prototype.constructor=r,LX(r,i);var s=o.prototype;return s.componentDidMount=function(){this._resizeObserver=null!==this._window&&this._window.ResizeObserver?new this._window.ResizeObserver(this.measure):new rQ(this.measure),null!==this._node&&(this._resizeObserver.observe(this._node),"function"==typeof this.props.onResize&&this.props.onResize(cQ(this._node,e||lQ(this.props))))},s.componentWillUnmount=function(){null!==this._window&&this._window.cancelAnimationFrame(this._animationFrameID),null!==this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null)},s.render=function(){var e=this.props;e.innerRef,e.onResize;var n=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,["innerRef","onResize"]);return oQ(t,IX({},n,{measureRef:this._handleRef,measure:this.measure,contentRect:this.state.contentRect}))},o}(iQ),n.propTypes={client:sQ.bool,offset:sQ.bool,scroll:sQ.bool,bounds:sQ.bool,margin:sQ.bool,innerRef:sQ.oneOfType([sQ.object,sQ.func]),onResize:sQ.func},r}}var dQ=uQ()(function(e){var t=e.measure,n=e.measureRef,r=e.contentRect;return(0,e.children)({measure:t,measureRef:n,contentRect:r})});dQ.displayName="Measure",dQ.propTypes.children=sQ.func;const pQ=e,hQ=i,{styled:fQ}=r;function mQ(e){let t,n=e[0],r=1;for(;r<e.length;){const i=e[r],o=e[r+1];if(r+=2,("optionalAccess"===i||"optionalCall"===i)&&null==n)return;"access"===i||"optionalAccess"===i?(t=n,n=o(n)):"call"!==i&&"optionalCall"!==i||(n=o((...e)=>n.call(t,...e)),t=void 0)}return n}const gQ=fQ("div")(()=>({display:"flex",flexDirection:"column",position:"relative"})),yQ=fQ("div")(()=>({display:"flex",justifyContent:"space-between"})),vQ=fQ("div")(({theme:e})=>({padding:`${e.spacing(2)} 0`})),bQ=fQ("div")(()=>({flex:"1"})),wQ=fQ("div")(({theme:e})=>({marginLeft:e.spacing(2)}));class xQ extends pQ.Component{constructor(...e){super(...e),xQ.prototype.__init.call(this)}static __initStatic(){this.propTypes={mode:hQ.oneOf(["tabbed","inline"]),secondary:hQ.oneOfType([hQ.arrayOf(hQ.node),hQ.node]),children:hQ.oneOfType([hQ.arrayOf(hQ.node),hQ.node]),dimensions:hQ.object}}__init(){this.getConfiguration=()=>{const{secondary:e}=this.props;return mQ([e,"optionalAccess",e=>e.props,"optionalAccess",e=>e.configuration])||mQ([e,"optionalAccess",e=>e.props,"optionalAccess",e=>e.children,"optionalAccess",e=>e.props,"optionalAccess",e=>e.configuration])||void 0}}render(){const{mode:e,secondary:t,children:n,dimensions:r}=this.props,{minHeight:i,minWidth:o,maxHeight:s,maxWidth:a}=r||{},l=this.getConfiguration();let c=Object.entries(l||{}).some(([,e])=>!!mQ([e,"optionalAccess",e=>e.settings]));if(!c)try{c=mQ([JSON,"access",e=>e.stringify,"call",e=>e(l),"optionalAccess",e=>e.match,"call",e=>e(/settings":true/),"optionalAccess",e=>e.length])}catch(e){console.log(e.toString())}return pQ.createElement(gQ,{style:{minHeight:i,minWidth:o,maxHeight:s,maxWidth:a}},"inline"===e&&pQ.createElement(yQ,null,pQ.createElement(bQ,{className:"design-container"},n),c&&pQ.createElement(wQ,{className:"settings-container"},t)),"tabbed"===e&&c&&pQ.createElement(eI,{onChange:this.onTabsChange,contentClassName:"content-container",indicatorColor:"primary"},pQ.createElement(vQ,{title:"Design",className:"design-container"},n),pQ.createElement(vQ,{title:"Settings",className:"settings-container"},t)),"tabbed"===e&&!c&&pQ.createElement(vQ,{className:"design-container"},n))}}xQ.__initStatic();const MQ=e,SQ=i,{styled:EQ}=r,CQ=EQ("div")(({theme:e})=>({backgroundColor:e.palette.background.paper,border:`2px solid ${e.palette.grey[200]}`,display:"flex",flexDirection:"column",justifyContent:"flex-start",minWidth:"275px",maxWidth:"300px",padding:"20px 4px 4px 20px",zIndex:99}));class NQ extends MQ.Component{static __initStatic(){this.propTypes={className:SQ.string,children:SQ.oneOfType([SQ.arrayOf(SQ.node),SQ.node]).isRequired}}static __initStatic2(){this.defaultProps={}}render(){const{className:e,children:t}=this.props;return MQ.createElement(CQ,{className:e},t)}}NQ.__initStatic(),NQ.__initStatic2();const AQ=e,{createTheme:kQ}=r,{StyledEngineProvider:TQ}=r,{ThemeProvider:OQ}=r,_Q=i;const RQ=kQ({typography:{fontFamily:"inherit"},components:{MuiButton:{styleOverrides:{contained:{backgroundColor:"#e0e0e0",color:"#000000","&:hover":{backgroundColor:"#bdbdbd"}}}}}});class DQ extends AQ.Component{static __initStatic(){this.propTypes={children:_Q.oneOfType([_Q.string,_Q.arrayOf(_Q.element),_Q.element]),className:_Q.string,dimensions:_Q.object,settings:_Q.element,sidePanelMinWidth:_Q.number,hideSettings:_Q.bool,extraCSSRules:_Q.shape({names:_Q.arrayOf(_Q.string),rules:_Q.string})}}static __initStatic2(){this.defaultProps={sidePanelMinWidth:1135,hideSettings:!1,dimensions:{}}}constructor(...e){super(...e),DQ.prototype.__init.call(this),this.state={layoutMode:void 0}}__init(){this.onResize=e=>{const{bounds:t}=e,{sidePanelMinWidth:n,dimensions:r}=this.props,{maxWidth:i}=r||{},o=t.width>n&&(!i||i>n)?"inline":"tabbed";o!==this.state.layoutMode&&this.setState({layoutMode:o})}}render(){return AQ.createElement(TQ,{injectFirst:!0},AQ.createElement(OQ,{theme:RQ},AQ.createElement(dQ,{bounds:!0,onResize:this.onResize},({measureRef:e})=>{const{children:t,settings:n,hideSettings:r,dimensions:i,extraCSSRules:o}=this.props,{layoutMode:s}=this.state,a="inline"===s?AQ.createElement(NQ,{className:"settings-box"},n):n,l=r?null:a;return AQ.createElement("div",{ref:e,className:"main-container extraCSSRules"},function(e){let t,n=e[0],r=1;for(;r<e.length;){const i=e[r],o=e[r+1];if(r+=2,("optionalAccess"===i||"optionalCall"===i)&&null==n)return;"access"===i||"optionalAccess"===i?(t=n,n=o(n)):"call"!==i&&"optionalCall"!==i||(n=o((...e)=>n.call(t,...e)),t=void 0)}return n}([o,"optionalAccess",e=>e.rules])?AQ.createElement("style",{dangerouslySetInnerHTML:{__html:`.extraCSSRules { ${o.rules} }`}}):null,AQ.createElement(xQ,{mode:s,secondary:l,dimensions:i},t))})))}}DQ.__initStatic(),DQ.__initStatic2(),uQ("bounds")(DQ);const IQ=e,LQ=i,{InputLabel:BQ}=n,{Switch:zQ}=n,{styled:PQ}=r,{color:jQ}=a,FQ=PQ("div")(()=>({display:"flex",width:"100%",justifyContent:"space-between"})),$Q=PQ(BQ)(({theme:e})=>({color:"rgba(0, 0, 0, 0.89)",fontSize:e.typography.fontSize,paddingTop:e.spacing(2)})),HQ=PQ(zQ)(({checked:e})=>({"&.Mui-checked .MuiSwitch-thumb":{color:`${jQ.tertiary()} !important`},"&.Mui-checked .MuiSwitch-track":{backgroundColor:`${jQ.tertiaryLight()} !important`},"& .MuiSwitch-track":{backgroundColor:e?`${jQ.tertiaryLight()} !important`:void 0}})),UQ=({checked:e,disabled:t,label:n,toggle:r})=>IQ.createElement(FQ,null,IQ.createElement($Q,null,n),IQ.createElement(HQ,{checked:e,disabled:t,onChange:e=>r(e.target.checked)}));UQ.propTypes={checked:LQ.bool,disabled:LQ.bool,label:LQ.string.isRequired,toggle:LQ.func.isRequired};const qQ=i,{styled:VQ}=r;VQ("div")(({theme:e})=>({display:"flex",paddingTop:e.spacing(1)})),qQ.shape({width:qQ.number.isRequired,height:qQ.number.isRequired}).isRequired,qQ.string.isRequired,qQ.func;const{FormControlLabel:WQ}=n,{Radio:KQ}=n,GQ=e,JQ=i,{styled:YQ}=r,{color:ZQ}=a,XQ=YQ(WQ)(({theme:e})=>({"& .MuiFormControlLabel-label":{color:"rgba(0, 0, 0, 0.89)",fontSize:e.typography.fontSize-2,left:"-5px",position:"relative"}})),QQ=YQ(KQ)(()=>({color:`${ZQ.tertiary()} !important`})),e0=({label:e,value:t,checked:n,onChange:r})=>GQ.createElement(XQ,{value:t,control:GQ.createElement(QQ,{checked:n,onChange:r}),label:e});e0.propTypes={label:JQ.string,value:JQ.string,checked:JQ.bool,onChange:JQ.func};const t0=e,n0=i,{styled:r0}=r,{Select:i0}=n,{Input:o0}=n,{MenuItem:s0}=n,{Typography:a0}=n,l0=l("pie-lib:config-ui:settings:panel"),c0={label:n0.string,value:n0.string},u0={label:n0.string,value:n0.string,onChange:n0.func},d0=({label:e,value:t,onChange:n})=>t0.createElement(cI,{checked:t,label:e,onChange:e=>{n(e.target.checked)}});d0.propTypes={label:n0.string,value:n0.bool,onChange:n0.func};const p0=r0(BZ)(({theme:e})=>({marginTop:e.spacing(.5),paddingBottom:e.spacing(.5),width:"100%","& > label":{color:"rgba(0, 0, 0, 0.89)",transform:"translate(0, 10px) scale(1)",fontSize:"18px",marginTop:e.spacing(2.5)},"& > div":{marginTop:e.spacing(2.5)}})),h0=({label:e,value:t,onChange:n,choices:r})=>t0.createElement(p0,{direction:"horizontal",customLabel:e0,value:t,header:e,opts:r,onChange:n});h0.propTypes={...u0,choices:n0.arrayOf(n0.shape(c0))};const f0=h0,m0=r0("p")(({theme:e})=>({margin:0,fontSize:e.typography.fontSize})),g0=r0(i0)(({theme:e})=>({marginTop:e.spacing(.5),border:"2px solid lightgrey",padding:`0 ${e.spacing(1)}`,borderRadius:"4px"})),y0=({label:e,value:t,onChange:n,choices:r=[]})=>{const i=e=>"string"==typeof e?e:e.value;return t0.createElement("div",null,e&&t0.createElement(m0,null,e),t0.createElement(g0,{value:t||r&&r[0],onChange:({target:e})=>n(e.value),input:t0.createElement(o0,{id:`dropdown-${e}`}),disableUnderline:!0,MenuProps:{transitionDuration:{enter:225,exit:195}}},r.map((e,t)=>t0.createElement(s0,{key:t,value:i(e)},(e=>"string"==typeof e?e:e.label)(e)))))};y0.propTypes={...u0,choices:n0.arrayOf(n0.string)};const v0=r0(a0)(({theme:e})=>({marginRight:e.spacing(3),marginTop:e.spacing(1)})),b0=({label:e})=>t0.createElement(v0,null,e),w0=r0(jI)(({theme:e})=>({width:"35%",marginRight:e.spacing(3),marginTop:e.spacing(1),"& .MuiInputBase-root":{marginTop:e.spacing(.5),border:"2px solid lightgrey",borderRadius:"4px",padding:`0 ${e.spacing(1)}`,backgroundColor:"transparent"}})),x0=({label:e,value:t,onChange:n=()=>{},suffix:r,min:i,max:o})=>t0.createElement(w0,{variant:"standard",label:e||"Label",value:t,max:o,min:i,onChange:(e,t)=>n(t),suffix:r,showErrorWhenOutsideRange:!0,disableUnderline:!0});x0.propTypes={...u0,suffix:n0.string,min:n0.number,max:n0.number,value:n0.number},b0.propTypes={...u0};const M0=({disabled:e,label:t,value:n,onChange:r})=>t0.createElement(UQ,{label:t,checked:!!n,disabled:!!e,toggle:r});M0.propTypes={...u0,value:n0.bool};const S0={toggle:M0,radio:f0,dropdown:y0,numberField:x0,checkbox:d0,textField:b0},E0=r0("div")(({theme:e})=>({margin:`0 0 ${e.spacing(2)} 0`})),C0=r0("div")(({theme:e})=>({color:"#495B8F",fontSize:e.typography.fontSize+2,fontWeight:600,marginBottom:e.spacing(1)})),N0=r0("p")(({theme:e})=>({fontSize:e.typography.fontSize,marginBottom:0})),A0=e=>{const{model:t,label:n,group:r,configuration:i,onChange:o}=e,s=(e,n,r)=>{const{isConfigProperty:s,...a}=Et(e,r||n),l=Et(s?i:t,n),c={...a,key:n,value:l},u=S0[c.type];return t0.createElement(u,{key:n,...c,onChange:e=>o(n,e,s)})};return t0.createElement(E0,null,t0.createElement(C0,null,n),Object.keys(r).map(e=>((e,t)=>{const n=e[t];if(!n)return null;const{type:r,label:i,fields:o,choices:a}=n;return"numberFields"===r?t0.createElement("div",{key:`numberField-${i}`},t0.createElement(N0,null,i),Object.keys(o).map(n=>s(e,`${t}.${n}`,`${t}.fields.${n}`))):"checkboxes"===r?t0.createElement("div",{key:`checkbox-${i}`},t0.createElement("p",null,i),Object.keys(a).map(n=>s(e,`${t}.${n}`,`${t}.choices.${n}`))):s(e,t)})(r,e)))};A0.propTypes={model:n0.object,label:n0.string,group:n0.object,configuration:n0.object,onChange:n0.func};class k0 extends t0.Component{constructor(...e){super(...e),k0.prototype.__init.call(this)}static __initStatic(){this.propTypes={model:n0.object,configuration:n0.object,groups:n0.object,onChangeModel:n0.func,onChangeConfiguration:n0.func,modal:n0.object}}static __initStatic2(){this.defaultProps={onChangeModel:()=>{},onChangeConfiguration:()=>{}}}__init(){this.change=(e,t,n=!1)=>{l0("[changeModel]",e,t);const{onChangeModel:r,onChangeConfiguration:i}=this.props,o={...this.props.model},s={...this.props.configuration};n?(vr(s,e,t),i(s,e)):(vr(o,e,t),r(o,e))}}render(){const{groups:e,model:t,configuration:n,modal:r}=this.props;l0("render:",t);const i=Object.keys(e||{}).map(r=>Object.entries(e[r]).some(([,e])=>!!e)?t0.createElement(A0,{label:r,key:r,model:t,configuration:n,group:e[r],onChange:this.change}):null);return t0.createElement("div",null,i,r)}}k0.__initStatic(),k0.__initStatic2();const{InputContainer:T0}=a,O0=e,{styled:_0}=r,R0=i,D0=_0("div")({padding:"10px 120px 10px 16px",backgroundColor:"rgba(0, 0, 0, 0.06)",border:"1px solid #ccc",borderRadius:"4px",overflowY:"scroll",lineHeight:"36px",whiteSpace:"pre-wrap",overflowWrap:"break-word","& p":{margin:0},"& span[data-latex]":{userSelect:"none","-webkit-user-select":"none","-moz-user-select":"none","-ms-user-select":"none"}}),I0=_0("div")({width:"230px"}),L0=_0("div")({position:"relative",overflowX:"hidden",display:"flex"}),B0=_0(T0)(({theme:e})=>({paddingTop:e.spacing(2),marginBottom:e.spacing(2),marginTop:e.spacing(2),width:"100%"}));if(!document.getElementById("annotation-editor-styles")){const e=document.createElement("style");e.id="annotation-editor-styles",e.textContent='\n .sideAnnotation:before {\n position: absolute;\n right: var(--before-right, 100%);\n top: var(--before-top, 5px);\n border: solid transparent;\n content: "";\n height: 0;\n width: 0;\n pointer-events: none;\n border-width: var(--before-border-width, 7px);\n border-right-color: var(--before-border-color, rgb(153, 255, 153));\n }\n',document.head.appendChild(e)}class z0 extends O0.Component{static __initStatic(){this.propTypes={text:R0.string,comment:R0.string,annotations:R0.array,predefinedAnnotations:R0.array,onChange:R0.func.isRequired,onCommentChange:R0.func.isRequired,width:R0.number,height:R0.number,maxHeight:R0.string,disabled:R0.bool,disabledMath:R0.bool,customKeys:R0.array,keypadMode:R0.string}}constructor(e){super(e),z0.prototype.__init.call(this),z0.prototype.__init2.call(this),z0.prototype.__init3.call(this),z0.prototype.__init4.call(this),z0.prototype.__init5.call(this),z0.prototype.__init6.call(this),z0.prototype.__init7.call(this),z0.prototype.__init8.call(this),z0.prototype.__init9.call(this),z0.prototype.__init10.call(this),z0.prototype.__init11.call(this),z0.prototype.__init12.call(this),z0.prototype.__init13.call(this),z0.prototype.__init14.call(this),z0.prototype.__init15.call(this),this.state={anchorEl:null,openedMenu:!1,openedEditor:!1,selectedElems:[],labelElem:null,selectionDetails:null,annotation:null,annotationIndex:null}}componentDidMount(){const{annotations:e,text:t}=this.props;t&&e.forEach(e=>{const[t,n]=((e,t,n)=>{const r=nR(n,t),i=[];let o=0;return r.forEach(n=>{const r=o+n.textContent.length;[e,t].forEach(e=>{o<=e&&e<r&&i.push({node:n,offset:e-o})}),o=r}),i})(e.start,e.end,this.textRef);if(t&&n){const r=document.createRange();r.setStart(t.node,t.offset),r.setEnd(n.node,n.offset);const i=oR(r);this.createDOMAnnotation(i,e)}}),this.textRef&&(this.adjustAnnotationsPosition(),this.textRef.addEventListener("scroll",this.adjustAnnotationsPosition))}__init(){this.adjustAnnotationsPosition=()=>{if(this.textRef&&this.labelsRef){const e=this.textRef.offsetLeft+this.textRef.offsetWidth+8;Array.from(this.labelsRef.children).forEach(t=>{const n=cR(t.dataset.annId),r=(n[0].offsetTop?n[0].offsetTop:n[0].offsetParent.offsetTop)-this.textRef.scrollTop-6;t.style.top=`${r}px`,t.style.left=`${e}px`})}}}__init2(){this.handleClick=e=>{const{annotations:t}=this.props,{selectionDetails:n}=this.state;if(n)return;const{id:r,annId:i}=e.target.dataset,o=r||i,s=cR(o),a=uR(o),l=t.findIndex(e=>e.id===o),c=a.hasAttribute("data-freeform");c&&(a.style.zIndex="10"),this.setState({anchorEl:s[0],openedMenu:!!r||!!i&&!c,openedEditor:!!i&&c,selectedElems:s,labelElem:a,annotationIndex:l,annotation:t[l],selectionDetails:null})}}__init3(){this.handleHover=e=>{const{id:t,annId:n}=e.target.dataset,r=t||n,i=cR(r),o=uR(r),s=o.hasAttribute("data-freeform");i.forEach(e=>{e.style.zIndex="20",e.classList.contains("positive")?e.style.backgroundColor="rgb(51, 255, 51, 0.7)":e.classList.contains("negative")&&(e.style.backgroundColor="rgba(255, 102, 204, 0.55)")}),s?(o.style.zIndex="20",o.classList.contains("positive")?(o.style.backgroundColor="rgb(128, 255, 128)",o.style.setProperty("--before-border-color","rgb(153, 255, 153)")):o.classList.contains("negative")&&(o.style.backgroundColor="rgb(255, 179, 230)",o.style.setProperty("--before-border-color","rgb(255, 179, 230)"))):(o.style.zIndex="20",o.classList.contains("positive")?o.style.color="rgb(0, 77, 0)":o.classList.contains("negative")&&(o.style.color="rgb(153, 0, 102)"))}}__init4(){this.handleCancelHover=e=>{const{id:t,annId:n}=e.target.dataset,r=t||n,i=cR(r),o=uR(r),s=o.hasAttribute("data-freeform");i.forEach(e=>{e.style.zIndex="",e.classList.contains("positive")?e.style.backgroundColor="rgb(51, 255, 51, 0.5)":e.classList.contains("negative")&&(e.style.backgroundColor="rgba(255, 102, 204, 0.4)")}),s?(o.style.zIndex="",o.classList.contains("positive")?(o.style.backgroundColor="rgb(153, 255, 153)",o.style.removeProperty("--before-border-color")):o.classList.contains("negative")&&(o.style.backgroundColor="rgb(255, 204, 238)",o.style.removeProperty("--before-border-color"))):(o.style.zIndex="",o.classList.contains("positive")?o.style.color="rgb(0, 128, 0)":o.classList.contains("negative")&&(o.style.color="rgb(204, 0, 136)"))}}__init5(){this.handleClose=e=>{const{selectedElems:t,labelElem:n}=this.state;t.length&&!t[0].hasAttribute("data-id")&&sR(t,this.textRef),n&&(n.style.zIndex=""),this.setState({anchorEl:null,openedMenu:!1,openedEditor:!1,selectedElems:[],labelElem:null,selectionDetails:null,annotationIndex:null,annotation:null}),aR()}}__init6(){this.handleSelection=e=>{const t=window.getSelection();if(e.detail>2)aR();else if(t&&t.rangeCount>0){const e=t.getRangeAt(0),n=e.toString(),r=this.textRef.contains(e.commonAncestorContainer);if(!t.isCollapsed&&""!==n&&r){const t=((e,t)=>{const n=document.createRange();n.setStart(t,0),n.setEnd(e.startContainer,e.startOffset);const[,r]=rR(n),[,i]=rR(e),o=r.length;return{quote:i,start:o,end:o+i.length}})(e,this.textRef),n=oR(e);this.setState({anchorEl:n[0],openedMenu:!0,selectedElems:n,selectionDetails:t})}}}}__init7(){this.deleteAnnotation=()=>{const{annotations:e,onChange:t}=this.props,{selectedElems:n,labelElem:r,annotationIndex:i,annotation:o}=this.state;(lR(o.label)?this.labelsRef:n[0]).removeChild(r),sR(n,this.textRef),e.splice(i,1),t(e),this.handleClose()}}__init8(){this.createDOMAnnotation=(e,t)=>{const{disabled:n}=this.props,{id:r,label:i,type:o}=t;(e||[]).forEach(e=>{e.dataset.id=r,e.className=`annotation ${o}`,e.style.position="relative",e.style.cursor="pointer","positive"===o?e.style.backgroundColor="rgb(51, 255, 51, 0.5)":"negative"===o&&(e.style.backgroundColor="rgba(255, 102, 204, 0.4)"),e.onclick=!n&&this.handleClick,e.onmouseover=this.handleHover,e.onmouseout=this.handleCancelHover});const s=e&&e[0]||{},a=document.createElement("SPAN");if(a.dataset.annId=r,a.innerHTML=i,a.onclick=!n&&this.handleClick,a.onmouseover=this.handleHover,a.onmouseout=this.handleCancelHover,lR(i)){const e=(s.offsetTop?s.offsetTop:s.offsetParent.offsetTop)-this.textRef.scrollTop,t=this.textRef.offsetLeft+this.textRef.offsetWidth+8;a.dataset.freeform=!0,a.className=`sideAnnotation ${o}`,a.style.position="absolute",a.style.padding="4px",a.style.borderRadius="4px",a.style.marginLeft="8px",a.style.width="180px",a.style.whiteSpace="pre-wrap",a.style.wordBreak="break-word",a.style.border="2px solid #ffffff",a.style.fontSize="14px",a.style.fontStyle="normal",a.style.fontWeight="normal",a.style.top=`${e}px`,a.style.left=`${t}px`,"negative"===o?a.style.backgroundColor="rgb(255, 204, 238)":"positive"===o&&(a.style.backgroundColor="rgb(153, 255, 153)"),a.style.setProperty("--before-border-width","7px"),a.style.setProperty("--before-top","5px"),a.style.setProperty("--before-right","100%"),"negative"===o?a.style.setProperty("--before-border-color","rgb(255, 204, 238)"):"positive"===o&&a.style.setProperty("--before-border-color","rgb(153, 255, 153)"),this.labelsRef.appendChild(a)}else a.className=`annotationLabel ${o}`,a.style.backgroundColor="rgb(242, 242, 242)",a.style.padding="2px",a.style.position="absolute",a.style.userSelect="none",a.style.whiteSpace="nowrap",a.style.top="-10px",a.style.left="-2px",a.style.fontSize="12px",a.style.fontStyle="normal",a.style.fontWeight="normal",a.style.lineHeight="6px",a.style.webkitUserSelect="none",a.style.mozUserSelect="none",a.style.msUserSelect="none","positive"===o?a.style.color="rgb(0, 128, 0)":"negative"===o&&(a.style.color="rgb(204, 0, 136)"),s.appendChild(a)}}__init9(){this.createNewAnnotation=(e,t)=>{const{selectedElems:n,selectionDetails:r}=this.state,i={id:[r.start,r.end,(new Date).getTime()].join("-"),label:e,type:t,...r};return this.createDOMAnnotation(n,i),i}}__init10(){this.handleMenuClick=e=>{const{annotations:t,onChange:n}=this.props,{annotation:r,annotationIndex:i}=this.state,{type:o,text:s}=e;if(r){const e={...r,label:s,type:o},{type:n,label:a}=r;this.updateLabel(a,e,o!==n&&n),t.splice(i,1,e)}else{const e=this.createNewAnnotation(s,o);t.push(e)}n(t),this.handleClose()}}__init11(){this.editAnnotation=()=>{this.setState({openedMenu:!1,openedEditor:!0})}}__init12(){this.addAnnotation=e=>{const{annotations:t,onChange:n}=this.props,r=this.createNewAnnotation("",e),i=uR(r.id);t.push(r),this.setState({openedMenu:!1,openedEditor:!0,annotationIndex:t.length-1,annotation:r,labelElem:i}),n(t)}}__init13(){this.updateLabel=(e,t,n)=>{const{selectedElems:r,labelElem:i}=this.state,{label:o,type:s}=t;lR(o)&&lR(e)||!lR(o)&&!lR(e)?(i.innerHTML=o,n&&(i.classList.remove(n),i.classList.add(s),r.forEach(e=>{e.classList.remove(n),e.classList.add(s)}))):lR(o)&&!lR(e)?(r[0].removeChild(i),this.createDOMAnnotation(r,t)):!lR(o)&&lR(e)&&(this.labelsRef.removeChild(i),this.createDOMAnnotation(r,t))}}__init14(){this.changeAnnotationType=e=>{const{annotations:t,onChange:n}=this.props,{annotationIndex:r,selectedElems:i}=this.state,{type:o,label:s}=t[r],a="positive"===o?"negative":"positive",l={...t[r],type:a,label:e};i.forEach(e=>{e.classList.remove(o),e.classList.add(a)}),this.updateLabel(s,l,o),t.splice(r,1,l),n(t),this.handleClose()}}__init15(){this.updateAnnotation=(e,t)=>{const{annotations:n,onChange:r}=this.props,{annotationIndex:i}=this.state,o={...n[i],label:t};this.updateLabel(e,o),n.splice(i,1,o),r(n)}}componentWillUnmount(){this.textRef.removeEventListener("scroll",this.adjustAnnotationsPosition)}render(){const{comment:e,customKeys:t,disabled:n,disabledMath:r,keypadMode:i,height:o,width:s,maxHeight:a,onCommentChange:l,predefinedAnnotations:c,text:u}=this.props,{anchorEl:d,annotation:p,openedMenu:h,openedEditor:f,selectionDetails:m}=this.state,g=d&&(d.offsetTop?d.offsetTop:d.offsetParent.offsetTop),y=this.textRef&&g?g-this.textRef.scrollTop-8:0;return O0.createElement("div",null,O0.createElement(L0,null,O0.createElement(D0,{style:{width:s-34,minHeight:o,maxHeight:a},ref:e=>this.textRef=e,onMouseDown:n?()=>{}:aR,onMouseUp:n?()=>{}:this.handleSelection,dangerouslySetInnerHTML:{__html:u}}),O0.createElement(I0,{ref:e=>this.labelsRef=e})),O0.createElement(B0,{label:"Comment"},O0.createElement(eR,{className:"prompt",markup:e||"",onChange:l,width:s&&(s+104).toString(),disabled:n,pluginProps:{math:{disabled:r,customKeys:t,keypadMode:i,controlledKeypadMode:!1},video:{disabled:!0},audio:{disabled:!0},textAlign:{disabled:!0},h3:{disabled:!0}}})),O0.createElement(OR,{anchorEl:d,open:h&&!n,annotations:c,isNewAnnotation:!!m,onClose:this.handleClose,onDelete:this.deleteAnnotation,onEdit:this.editAnnotation,onWrite:this.addAnnotation,onAnnotate:this.handleMenuClick}),O0.createElement(wR,{anchorEl:this.textRef,open:f&&!n,offset:y,value:p&&p.label||"",type:p&&p.type,onClose:this.handleClose,onDelete:this.deleteAnnotation,onSave:this.updateAnnotation,onTypeChange:this.changeAnnotationType}))}}z0.__initStatic();const P0=e,j0=i,F0=l,{Typography:$0}=n,{styled:H0}=r,{color:U0}=a,{Feedback:q0}=a,{Collapsible:V0}=a,{PreviewPrompt:W0}=a,{UiLayout:K0}=a,G0=F0("@pie-ui:extended-text-entry"),J0=H0(K0)({backgroundColor:U0.background(),color:U0.text()}),Y0=H0($0)(({theme:e})=>({width:"100%",color:U0.text(),marginBottom:e.spacing(2),fontSize:"inherit"})),Z0=H0("div")(({theme:e})=>({marginBottom:e.spacing(2)})),X0=H0(eR)(({theme:e})=>({marginBottom:e.spacing(2),borderRadius:"4px"})),Q0=H0("h2")({position:"absolute",left:"-10000px",top:"auto",width:"1px",height:"1px",overflow:"hidden"});class e1 extends P0.Component{constructor(...e){super(...e),e1.prototype.__init.call(this),e1.prototype.__init2.call(this)}static __initStatic(){this.propTypes={onValueChange:j0.func.isRequired,onAnnotationsChange:j0.func.isRequired,onCommentChange:j0.func.isRequired,model:j0.object,session:j0.shape({value:j0.string,annotations:j0.array,comment:j0.string}).isRequired}}__init(){this.changeSessionValue=Qn(this.props.onValueChange,1500)}__init2(){this.changeSessionComment=Qn(this.props.onCommentChange,1500)}render(){const{model:e,session:t,onAnnotationsChange:n}=this.props,{animationsDisabled:r,annotatorMode:i,customKeys:o,dimensions:s,disabled:a,disabledAnnotator:l,equationEditor:c,extraCSSRules:u,feedback:d,mathInput:p,playersToolbarPosition:h,predefinedAnnotations:f,prompt:m,spanishInput:g,specialInput:y,spellCheckEnabled:v,teacherInstructions:b}=e,{annotations:w,comment:x,value:M}=t,{width:S,height:E}=s||{},C="40vh",N={position:"top"===h?"top":"bottom"};G0("[render] disabled? ",a);const A=P0.createElement(W0,{defaultClassName:"teacher-instructions",prompt:b}),k=[];return g&&k.push({language:"spanish"}),y&&k.push({language:"special"}),P0.createElement(J0,{extraCSSRules:u,ref:e=>{this.containerRef=e}},P0.createElement(Q0,null,"Constructed Response Question"),b&&P0.createElement(Z0,null,r?A:P0.createElement(V0,{labels:{hidden:"Show Teacher Instructions",visible:"Hide Teacher Instructions"}},A)),m&&P0.createElement(Y0,{component:"span"},P0.createElement(W0,{defaultClassName:"prompt",prompt:e.prompt})),i?P0.createElement(z0,{text:M||"",annotations:w||[],comment:x||"",predefinedAnnotations:f||[],onChange:n,onCommentChange:this.changeSessionComment,width:S,height:E,maxHeight:C,disabled:l,disabledMath:!p,customKeys:o,keypadMode:c}):P0.createElement(X0,{className:"response-area-editor",onChange:this.changeSessionValue,markup:M||"",maxWidth:S&&S.toString(),minWidth:"100px",minHeight:E&&E.toString(),maxHeight:C,disabled:a,highlightShape:!0,toolbarOpts:N,spellCheck:v,charactersLimit:5e4,autoWidthToolbar:!0,pluginProps:{math:{disabled:!p,customKeys:this.props.model.customKeys,keypadMode:this.props.model.equationEditor,controlledKeypadMode:!1},video:{disabled:!0},audio:{disabled:!0},table:{disabled:!0},textAlign:{disabled:!0},h3:{disabled:!0},separateParagraphs:{disabled:!1},ul_list:{disabled:!0},ol_list:{disabled:!0}},languageCharactersProps:k}),d&&P0.createElement(q0,{correctness:"correct",feedback:d}))}}e1.__initStatic();var t1,n1=t;t1=n1.createRoot,n1.hydrateRoot;var r1={};Object.defineProperty(r1,"__esModule",{value:!0});class i1 extends CustomEvent{constructor(e,t,n){super(i1.TYPE,{bubbles:!0,composed:!0,detail:{complete:t,component:e,hasModel:n}}),this.component=e,this.complete=t}}i1.TYPE="model-set";var o1=r1.ModelSetEvent=i1;class s1 extends CustomEvent{constructor(e,t){super(s1.TYPE,{bubbles:!0,composed:!0,detail:{complete:t,component:e}}),this.component=e,this.complete=t}}s1.TYPE="session-changed";var a1=r1.SessionChangedEvent=s1;const l1=e,c1=l,{renderMath:u1}=u,d1=c1("@pie-elements:extended-text-entry"),p1=void 0!==typeof window?new DOMParser:{parseFromString:e=>e};function h1(e){if("string"==typeof e)try{const t=p1.parseFromString(e,"text/html");return t.body.textContent}catch(t){return d1("tried to parse as dom and failed",e),e}}function f1(e){const t=h1(e);return void 0!==t&&t.length>0}class m1 extends HTMLElement{constructor(){super(),this._model=null,this._session=null,this._root=null}setLangAttribute(){const e=this._model&&(this._model.language,1)?this._model.language:"",t=e?e.slice(0,2):"en";this.setAttribute("lang",t)}set model(e){this._model=e,this.dispatchEvent(new o1(this.tagName.toLowerCase(),!1,!!this._model)),this.render()}set session(e){this._session=e,this.render()}get session(){return this._session}valueChange(e){this._session.value=e,this.dispatchEvent(new a1(this.tagName.toLowerCase(),f1(e))),this.render()}annotationsChange(e){this._session.annotations=e,this.dispatchEvent(new a1(this.tagName.toLowerCase(),!0)),this.render()}commentChange(e){this._session.comment=e,this.dispatchEvent(new a1(this.tagName.toLowerCase(),f1(e))),this.render()}connectedCallback(){this.setAttribute("aria-label","Written Response Question"),this.setAttribute("role","region"),this.render()}render(){if(this._model&&this._session){let e=l1.createElement(e1,{model:this._model,session:this._session,onValueChange:this.valueChange.bind(this),onAnnotationsChange:this.annotationsChange.bind(this),onCommentChange:this.commentChange.bind(this)});this.setLangAttribute(),this._root||(this._root=t1(this)),this._root.render(e),queueMicrotask(()=>{u1(this)})}}disconnectedCallback(){this._root&&this._root.unmount()}}export{m1 as default,f1 as isComplete,h1 as textContent};