@pie-element/extended-text-entry 14.2.0-next.8 → 15.0.0

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.
package/module/element.js CHANGED
@@ -1 +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_debug as s,_dll_mui__material_collapse as a,_dll_classnames as l}from"../../../@pie-lib/shared-module@^4.1.0/module/index.js";import{_dll_pie_lib__math_rendering as c}from"../../../@pie-lib/math-rendering-module@^4.1.0/module/index.js";import{green as u,orange as d,red as p,indigo as h,pink as f,grey as m}from"@mui/material/colors";import{_dll_pie_lib__math_input as g,_dll_pie_lib__math_toolbar as y}from"../../../@pie-lib/math-edit-module@^3.2.0/module/index.js";import v from"@mui/material/Input";var b="object"==typeof global&&global&&global.Object===Object&&global,x="object"==typeof self&&self&&self.Object===Object&&self,w=b||x||Function("return this")(),E=w.Symbol,M=Object.prototype,S=M.hasOwnProperty,C=M.toString,N=E?E.toStringTag:void 0;var A=Object.prototype.toString;var k=E?E.toStringTag:void 0;function T(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":k&&k in Object(e)?function(e){var t=S.call(e,N),n=e[N];try{e[N]=void 0;var r=!0}catch(e){}var i=C.call(e);return r&&(t?e[N]=n:delete e[N]),i}(e):function(e){return A.call(e)}(e)}function O(e){return null!=e&&"object"==typeof e}function _(e){return"symbol"==typeof e||O(e)&&"[object Symbol]"==T(e)}function R(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 D=Array.isArray,I=E?E.prototype:void 0,L=I?I.toString:void 0;function B(e){if("string"==typeof e)return e;if(D(e))return R(e,B)+"";if(_(e))return L?L.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}var z=/\s/;var P=/^\s+/;function F(e){return e?e.slice(0,function(e){for(var t=e.length;t--&&z.test(e.charAt(t)););return t}(e)+1).replace(P,""):e}function j(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}var $=/^[-+]0x[0-9a-f]+$/i,H=/^0b[01]+$/i,U=/^0o[0-7]+$/i,q=parseInt;function V(e){if("number"==typeof e)return e;if(_(e))return NaN;if(j(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=j(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=F(e);var n=H.test(e);return n||U.test(e)?q(e.slice(2),n?2:8):$.test(e)?NaN:+e}function W(e){return e}function K(e){if(!j(e))return!1;var t=T(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var G,J=w["__core-js_shared__"],Y=(G=/[^.]+$/.exec(J&&J.keys&&J.keys.IE_PROTO||""))?"Symbol(src)_1."+G:"";var Z=Function.prototype.toString;function X(e){if(null!=e){try{return Z.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var Q=/^\[object .+?Constructor\]$/,ee=Function.prototype,te=Object.prototype,ne=ee.toString,re=te.hasOwnProperty,ie=RegExp("^"+ne.call(re).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function oe(e){return!(!j(e)||(t=e,Y&&Y in t))&&(K(e)?ie:Q).test(X(e));var t}function se(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return oe(n)?n:void 0}var ae=se(w,"WeakMap"),le=Object.create,ce=function(){function e(){}return function(t){if(!j(t))return{};if(le)return le(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function ue(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}var de=Date.now;var pe,he,fe,me=function(){try{var e=se(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),ge=me,ye=ge?function(e,t){return ge(e,"toString",{configurable:!0,enumerable:!1,value:(n=t,function(){return n}),writable:!0});var n}:W,ve=(pe=ye,he=0,fe=0,function(){var e=de(),t=16-(e-fe);if(fe=e,t>0){if(++he>=800)return arguments[0]}else he=0;return pe.apply(void 0,arguments)});function be(e){return e!=e}function xe(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,be,n)}(e,t,0)>-1}var we=/^(?:0|[1-9]\d*)$/;function Ee(e,t){var n=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==n||"symbol"!=n&&we.test(e))&&e>-1&&e%1==0&&e<t}function Me(e,t,n){"__proto__"==t&&ge?ge(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function Se(e,t){return e===t||e!=e&&t!=t}var Ce=Object.prototype.hasOwnProperty;function Ne(e,t,n){var r=e[t];Ce.call(e,t)&&Se(r,n)&&(void 0!==n||t in e)||Me(e,t,n)}function Ae(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?Me(n,a,l):Ne(n,a,l)}return n}var ke=Math.max;function Te(e,t,n){return t=ke(void 0===t?e.length-1:t,0),function(){for(var r=arguments,i=-1,o=ke(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 Oe(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}function _e(e){return null!=e&&Oe(e.length)&&!K(e)}var Re=Object.prototype;function De(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Re)}function Ie(e){return O(e)&&"[object Arguments]"==T(e)}var Le=Object.prototype,Be=Le.hasOwnProperty,ze=Le.propertyIsEnumerable,Pe=Ie(function(){return arguments}())?Ie:function(e){return O(e)&&Be.call(e,"callee")&&!ze.call(e,"callee")};var Fe="object"==typeof exports&&exports&&!exports.nodeType&&exports,je=Fe&&"object"==typeof module&&module&&!module.nodeType&&module,$e=je&&je.exports===Fe?w.Buffer:void 0,He=($e?$e.isBuffer:void 0)||function(){return!1},Ue={};function qe(e){return function(t){return e(t)}}Ue["[object Float32Array]"]=Ue["[object Float64Array]"]=Ue["[object Int8Array]"]=Ue["[object Int16Array]"]=Ue["[object Int32Array]"]=Ue["[object Uint8Array]"]=Ue["[object Uint8ClampedArray]"]=Ue["[object Uint16Array]"]=Ue["[object Uint32Array]"]=!0,Ue["[object Arguments]"]=Ue["[object Array]"]=Ue["[object ArrayBuffer]"]=Ue["[object Boolean]"]=Ue["[object DataView]"]=Ue["[object Date]"]=Ue["[object Error]"]=Ue["[object Function]"]=Ue["[object Map]"]=Ue["[object Number]"]=Ue["[object Object]"]=Ue["[object RegExp]"]=Ue["[object Set]"]=Ue["[object String]"]=Ue["[object WeakMap]"]=!1;var Ve="object"==typeof exports&&exports&&!exports.nodeType&&exports,We=Ve&&"object"==typeof module&&module&&!module.nodeType&&module,Ke=We&&We.exports===Ve&&b.process,Ge=function(){try{var e=We&&We.require&&We.require("util").types;return e||Ke&&Ke.binding&&Ke.binding("util")}catch(e){}}(),Je=Ge,Ye=Je&&Je.isTypedArray,Ze=Ye?qe(Ye):function(e){return O(e)&&Oe(e.length)&&!!Ue[T(e)]},Xe=Object.prototype.hasOwnProperty;function Qe(e,t){var n=D(e),r=!n&&Pe(e),i=!n&&!r&&He(e),o=!n&&!r&&!i&&Ze(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&&!Xe.call(e,c)||s&&("length"==c||i&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||Ee(c,l))||a.push(c);return a}function et(e,t){return function(n){return e(t(n))}}var tt=et(Object.keys,Object),nt=Object.prototype.hasOwnProperty;function rt(e){if(!De(e))return tt(e);var t=[];for(var n in Object(e))nt.call(e,n)&&"constructor"!=n&&t.push(n);return t}function it(e){return _e(e)?Qe(e):rt(e)}var ot=Object.prototype.hasOwnProperty;function st(e){if(!j(e))return function(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t}(e);var t=De(e),n=[];for(var r in e)("constructor"!=r||!t&&ot.call(e,r))&&n.push(r);return n}function at(e){return _e(e)?Qe(e,!0):st(e)}var lt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ct=/^\w*$/;var ut=se(Object,"create");var dt=Object.prototype.hasOwnProperty;var pt=Object.prototype.hasOwnProperty;function ht(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 ft(e,t){for(var n=e.length;n--;)if(Se(e[n][0],t))return n;return-1}ht.prototype.clear=function(){this.__data__=ut?ut(null):{},this.size=0},ht.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},ht.prototype.get=function(e){var t=this.__data__;if(ut){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return dt.call(t,e)?t[e]:void 0},ht.prototype.has=function(e){var t=this.__data__;return ut?void 0!==t[e]:pt.call(t,e)},ht.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=ut&&void 0===t?"__lodash_hash_undefined__":t,this};var mt=Array.prototype.splice;function gt(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])}}gt.prototype.clear=function(){this.__data__=[],this.size=0},gt.prototype.delete=function(e){var t=this.__data__,n=ft(t,e);return!(n<0)&&(n==t.length-1?t.pop():mt.call(t,n,1),--this.size,!0)},gt.prototype.get=function(e){var t=this.__data__,n=ft(t,e);return n<0?void 0:t[n][1]},gt.prototype.has=function(e){return ft(this.__data__,e)>-1},gt.prototype.set=function(e,t){var n=this.__data__,r=ft(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this};var yt=se(w,"Map");function vt(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 bt(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])}}bt.prototype.clear=function(){this.size=0,this.__data__={hash:new ht,map:new(yt||gt),string:new ht}},bt.prototype.delete=function(e){var t=vt(this,e).delete(e);return this.size-=t?1:0,t},bt.prototype.get=function(e){return vt(this,e).get(e)},bt.prototype.has=function(e){return vt(this,e).has(e)},bt.prototype.set=function(e,t){var n=vt(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this};function xt(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(xt.Cache||bt),n}xt.Cache=bt;var wt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Et=/\\(\\)?/g,Mt=function(e){var t=xt(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(wt,function(e,n,r,i){t.push(r?i.replace(Et,"$1"):n||e)}),t}),St=Mt;function Ct(e,t){return D(e)?e:function(e,t){if(D(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!_(e))||ct.test(e)||!lt.test(e)||null!=t&&e in Object(t)}(e,t)?[e]:St(function(e){return null==e?"":B(e)}(e))}function Nt(e){if("string"==typeof e||_(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function At(e,t){for(var n=0,r=(t=Ct(t,e)).length;null!=e&&n<r;)e=e[Nt(t[n++])];return n&&n==r?e:void 0}function kt(e,t,n){var r=null==e?void 0:At(e,t);return void 0===r?n:r}function Tt(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}var Ot=E?E.isConcatSpreadable:void 0;function _t(e){return D(e)||Pe(e)||!!(Ot&&e&&e[Ot])}function Rt(e,t,n,r,i){var o=-1,s=e.length;for(n||(n=_t),i||(i=[]);++o<s;){var a=e[o];t>0&&n(a)?t>1?Rt(a,t-1,n,r,i):Tt(i,a):r||(i[i.length]=a)}return i}function Dt(e){return(null==e?0:e.length)?Rt(e,1):[]}var It=et(Object.getPrototypeOf,Object),Lt=Function.prototype,Bt=Object.prototype,zt=Lt.toString,Pt=Bt.hasOwnProperty,Ft=zt.call(Object);function jt(e){if(!O(e)||"[object Object]"!=T(e))return!1;var t=It(e);if(null===t)return!0;var n=Pt.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&zt.call(n)==Ft}function $t(e){var t=this.__data__=new gt(e);this.size=t.size}$t.prototype.clear=function(){this.__data__=new gt,this.size=0},$t.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},$t.prototype.get=function(e){return this.__data__.get(e)},$t.prototype.has=function(e){return this.__data__.has(e)},$t.prototype.set=function(e,t){var n=this.__data__;if(n instanceof gt){var r=n.__data__;if(!yt||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new bt(r)}return n.set(e,t),this.size=n.size,this};var Ht="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ut=Ht&&"object"==typeof module&&module&&!module.nodeType&&module,qt=Ut&&Ut.exports===Ht?w.Buffer:void 0,Vt=qt?qt.allocUnsafe:void 0;function Wt(e,t){if(t)return e.slice();var n=e.length,r=Vt?Vt(n):new e.constructor(n);return e.copy(r),r}function Kt(){return[]}var Gt=Object.prototype.propertyIsEnumerable,Jt=Object.getOwnPropertySymbols,Yt=Jt?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}(Jt(e),function(t){return Gt.call(e,t)}))}:Kt,Zt=Yt;var Xt=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)Tt(t,Zt(e)),e=It(e);return t}:Kt;function Qt(e,t,n){var r=t(e);return D(e)?r:Tt(r,n(e))}function en(e){return Qt(e,it,Zt)}function tn(e){return Qt(e,at,Xt)}var nn=se(w,"DataView"),rn=se(w,"Promise"),on=se(w,"Set"),sn="[object Map]",an="[object Promise]",ln="[object Set]",cn="[object WeakMap]",un="[object DataView]",dn=X(nn),pn=X(yt),hn=X(rn),fn=X(on),mn=X(ae),gn=T;(nn&&gn(new nn(new ArrayBuffer(1)))!=un||yt&&gn(new yt)!=sn||rn&&gn(rn.resolve())!=an||on&&gn(new on)!=ln||ae&&gn(new ae)!=cn)&&(gn=function(e){var t=T(e),n="[object Object]"==t?e.constructor:void 0,r=n?X(n):"";if(r)switch(r){case dn:return un;case pn:return sn;case hn:return an;case fn:return ln;case mn:return cn}return t});var yn=gn,vn=Object.prototype.hasOwnProperty;var bn=w.Uint8Array;function xn(e){var t=new e.constructor(e.byteLength);return new bn(t).set(new bn(e)),t}var wn=/\w*$/;var En=E?E.prototype:void 0,Mn=En?En.valueOf:void 0;function Sn(e,t){var n=t?xn(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Cn(e,t,n){var r,i,o,s=e.constructor;switch(t){case"[object ArrayBuffer]":return xn(e);case"[object Boolean]":case"[object Date]":return new s(+e);case"[object DataView]":return function(e,t){var n=t?xn(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 Sn(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,wn.exec(i))).lastIndex=i.lastIndex,o;case"[object Symbol]":return r=e,Mn?Object(Mn.call(r)):{}}}function Nn(e){return"function"!=typeof e.constructor||De(e)?{}:ce(It(e))}var An=Je&&Je.isMap,kn=An?qe(An):function(e){return O(e)&&"[object Map]"==yn(e)};var Tn=Je&&Je.isSet,On=Tn?qe(Tn):function(e){return O(e)&&"[object Set]"==yn(e)},_n="[object Arguments]",Rn="[object Function]",Dn="[object Object]",In={};function Ln(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(!j(e))return e;var u=D(e);if(u){if(s=function(e){var t=e.length,n=new e.constructor(t);return t&&"string"==typeof e[0]&&vn.call(e,"index")&&(n.index=e.index,n.input=e.input),n}(e),!a)return ue(e,s)}else{var d=yn(e),p=d==Rn||"[object GeneratorFunction]"==d;if(He(e))return Wt(e,a);if(d==Dn||d==_n||p&&!i){if(s=l||p?{}:Nn(e),!a)return l?function(e,t){return Ae(e,Xt(e),t)}(e,function(e,t){return e&&Ae(t,at(t),e)}(s,e)):function(e,t){return Ae(e,Zt(e),t)}(e,function(e,t){return e&&Ae(t,it(t),e)}(s,e))}else{if(!In[d])return i?e:{};s=Cn(e,d,a)}}o||(o=new $t);var h=o.get(e);if(h)return h;o.set(e,s),On(e)?e.forEach(function(r){s.add(Ln(r,t,n,r,e,o))}):kn(e)&&e.forEach(function(r,i){s.set(i,Ln(r,t,n,i,e,o))});var f=u?void 0:(c?l?tn:en:l?at:it)(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]),Ne(s,i,Ln(r,t,n,i,e,o))}),s}In[_n]=In["[object Array]"]=In["[object ArrayBuffer]"]=In["[object DataView]"]=In["[object Boolean]"]=In["[object Date]"]=In["[object Float32Array]"]=In["[object Float64Array]"]=In["[object Int8Array]"]=In["[object Int16Array]"]=In["[object Int32Array]"]=In["[object Map]"]=In["[object Number]"]=In[Dn]=In["[object RegExp]"]=In["[object Set]"]=In["[object String]"]=In["[object Symbol]"]=In["[object Uint8Array]"]=In["[object Uint8ClampedArray]"]=In["[object Uint16Array]"]=In["[object Uint32Array]"]=!0,In["[object Error]"]=In[Rn]=In["[object WeakMap]"]=!1;function Bn(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new bt;++t<n;)this.add(e[t])}function zn(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 Pn(e,t){return e.has(t)}Bn.prototype.add=Bn.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},Bn.prototype.has=function(e){return this.__data__.has(e)};function Fn(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 Bn: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(!zn(t,function(e,t){if(!Pn(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 jn(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function $n(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}var Hn=E?E.prototype:void 0,Un=Hn?Hn.valueOf:void 0;var qn=Object.prototype.hasOwnProperty;var Vn="[object Arguments]",Wn="[object Array]",Kn="[object Object]",Gn=Object.prototype.hasOwnProperty;function Jn(e,t,n,r,i,o){var s=D(e),a=D(t),l=s?Wn:yn(e),c=a?Wn:yn(t),u=(l=l==Vn?Kn:l)==Kn,d=(c=c==Vn?Kn:c)==Kn,p=l==c;if(p&&He(e)){if(!He(t))return!1;s=!0,u=!1}if(p&&!u)return o||(o=new $t),s||Ze(e)?Fn(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 bn(e),new bn(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return Se(+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=jn;case"[object Set]":var l=1&r;if(a||(a=$n),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=Fn(a(e),a(t),r,i,o,s);return s.delete(e),u;case"[object Symbol]":if(Un)return Un.call(e)==Un.call(t)}return!1}(e,t,l,n,r,i,o);if(!(1&n)){var h=u&&Gn.call(e,"__wrapped__"),f=d&&Gn.call(t,"__wrapped__");if(h||f){var m=h?e.value():e,g=f?t.value():t;return o||(o=new $t),i(m,g,n,r,o)}}return!!p&&(o||(o=new $t),function(e,t,n,r,i,o){var s=1&n,a=en(e),l=a.length;if(l!=en(t).length&&!s)return!1;for(var c=l;c--;){var u=a[c];if(!(s?u in t:qn.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 Yn(e,t,n,r,i){return e===t||(null==e||null==t||!O(e)&&!O(t)?e!=e&&t!=t:Jn(e,t,n,r,Yn,i))}var Zn,Xn=function(e,t,n){for(var r=-1,i=Object(e),o=n(e),s=o.length;s--;){var a=o[Zn?s:++r];if(!1===t(i[a],a,i))break}return e},Qn=Xn,er=function(){return w.Date.now()},tr=Math.max,nr=Math.min;function rr(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=er();if(f(e))return g(e);a=setTimeout(m,function(e){var n=t-(e-l);return d?nr(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=er(),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=V(t)||0,j(n)&&(u=!!n.leading,o=(d="maxWait"in n)?tr(V(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(er())},y}function ir(e,t,n){(void 0!==n&&!Se(e[t],n)||void 0===n&&!(t in e))&&Me(e,t,n)}function or(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}function sr(e,t,n,r,i,o,s){var a=or(e,n),l=or(t,n),c=s.get(l);if(c)ir(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=D(l),f=!h&&He(l),m=!h&&!f&&Ze(l);d=l,h||f||m?D(a)?d=a:O(u=a)&&_e(u)?d=ue(a):f?(p=!1,d=Wt(l,!0)):m?(p=!1,d=Sn(l,!0)):d=[]:jt(l)||Pe(l)?(d=a,Pe(a)?d=function(e){return Ae(e,at(e))}(a):j(a)&&!K(a)||(d=Nn(l))):p=!1}p&&(s.set(l,d),i(d,l,r,o,s),s.delete(l)),ir(e,n,d)}}function ar(e,t,n,r,i){e!==t&&Qn(t,function(o,s){if(i||(i=new $t),j(o))sr(e,t,s,n,ar,r,i);else{var a=r?r(or(e,s),o,s+"",e,t,i):void 0;void 0===a&&(a=o),ir(e,s,a)}},at)}function lr(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 cr(e,t){return t.length<2?e:At(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 ur=Object.prototype.hasOwnProperty;var dr=w.isFinite;function pr(e){return"number"==typeof e&&dr(e)}var hr,fr=(hr=function(e,t,n){ar(e,t,n)},function(e,t){return ve(Te(e,t,W),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=hr.length>3&&"function"==typeof i?(r--,i):void 0,o&&function(e,t,n){if(!j(n))return!1;var r=typeof t;return!!("number"==r?_e(n)&&Ee(t,n.length):"string"==r&&t in n)&&Se(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&&hr(e,s,n,i)}return e})),mr=fr,gr=Object.prototype.hasOwnProperty;function yr(e,t){var n=-1,r=(t=Ct(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&&!gr.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=cr(e,t);return null==s||delete s[Nt(function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}(t))]}function vr(e){return jt(e)?void 0:e}var br=function(e){return ve(Te(e,void 0,Dt),e+"")}(function(e,t){var n={};if(null==e)return n;var r=!1;t=R(t,function(t){return t=Ct(t,e),r||(r=t.length>1),t}),Ae(e,tn(e),n),r&&(n=Ln(n,7,vr));for(var i=t.length;i--;)yr(n,t[i]);return n}),xr=br;function wr(e,t,n){return null==e?e:function(e,t,n,r){if(!j(e))return e;for(var i=-1,o=(t=Ct(t,e)).length,s=o-1,a=e;null!=a&&++i<o;){var l=Nt(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=j(u)?u:Ee(t[i+1])?[]:{})}Ne(a,l,c),a=a[l]}return e}(e,t,n)}var Er=on&&1/$n(new on([,-0]))[1]==1/0?function(e){return new on(e)}:function(){},Mr=Er;function Sr(e){return e&&e.length?function(e,t,n){var r=-1,i=xe,o=e.length,s=!0,a=[],l=a;if(n)s=!1,i=lr;else if(o>=200){var c=t?null:Mr(e);if(c)return $n(c);s=!1,i=Pn,l=new Bn}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 Cr="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},Nr={exports:{}},Ar={};var kr=e;var Tr="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},Or=kr.useState,_r=kr.useEffect,Rr=kr.useLayoutEffect,Dr=kr.useDebugValue;function Ir(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Tr(e,n)}catch(e){return!0}}var Lr="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),r=Or({inst:{value:n,getSnapshot:t}}),i=r[0].inst,o=r[1];return Rr(function(){i.value=n,i.getSnapshot=t,Ir(i)&&o({inst:i})},[e,n,t]),_r(function(){return Ir(i)&&o({inst:i}),e(function(){Ir(i)&&o({inst:i})})},[e]),Dr(n),n};Ar.useSyncExternalStore=void 0!==kr.useSyncExternalStore?kr.useSyncExternalStore:Lr,Nr.exports=Ar;var Br={exports:{}},zr={};var Pr=e,Fr=Symbol.for("react.element"),jr=Symbol.for("react.fragment"),$r=Object.prototype.hasOwnProperty,Hr=Pr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Ur={key:!0,ref:!0,__self:!0,__source:!0};function qr(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)$r.call(t,r)&&!Ur.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:Fr,type:e,key:o,ref:s,props:i,_owner:Hr.current}}function Vr(e){this.content=e}function Wr(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=Wr(i.content,o.content,n+1);if(null!=e)return e}n+=i.nodeSize}else n+=i.nodeSize}}function Kr(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=Kr(s.content,a.content,n-1,r-1);if(e)return e}n-=l,r-=l}else n-=l,r-=l}}zr.Fragment=jr,zr.jsx=qr,zr.jsxs=qr,Br.exports=zr,Vr.prototype={constructor:Vr,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 Vr(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 Vr(n)},addToStart:function(e,t){return new Vr([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new Vr(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 Vr(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=Vr.from(e)).size?new Vr(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=Vr.from(e)).size?new Vr(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=Vr.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}},Vr.from=function(e){if(e instanceof Vr)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new Vr(t)};class Gr{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 Gr(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 Gr(n,r)}cutByIndex(e,t){return e==t?Gr.empty:0==e&&t==this.content.length?this:new Gr(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 Gr(r,i)}addToStart(e){return new Gr([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Gr(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 Wr(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Kr(this,e,t,n)}findIndex(e){if(0==e)return Yr(0,e);if(e==this.size)return Yr(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?Yr(t+1,r):Yr(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 Gr.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new Gr(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Gr.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 Gr(t||e,n)}static from(e){if(!e)return Gr.empty;if(e instanceof Gr)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new Gr([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Gr.empty=new Gr([],0);const Jr={index:0,offset:0};function Yr(e,t){return Jr.index=e,Jr.offset=t,Jr}function Zr(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(!Zr(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!Zr(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}class Xr{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&&Zr(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 Xr.none;if(e instanceof Xr)return[e];let t=e.slice();return t.sort((e,t)=>e.type.rank-t.type.rank),t}}Xr.none=[];class Qr extends Error{}class ei{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=ni(this.content,e+this.openStart,t);return n&&new ei(n,this.openStart,this.openEnd)}removeBetween(e,t){return new ei(ti(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 ei.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 ei(Gr.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 ei(e,n,r)}}function ti(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(ti(o.content,t-i-1,n-i-1)))}function ni(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=ni(s.content,t-o-1,n,s);return a&&e.replaceChild(i,s.copy(a))}function ri(e,t,n){if(n.openStart>e.depth)throw new Qr("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Qr("Inconsistent open depths");return ii(e,t,n,0)}function ii(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=ii(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(Gr.from(i));return{start:i.resolveNoCache(e.openStart+n),end:i.resolveNoCache(i.content.size-e.openEnd-n)}}(n,e);return ci(o,ui(e,i,s,t,r))}{let r=e.parent,i=r.content;return ci(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}}return ci(o,di(e,t,r))}function oi(e,t){if(!t.type.compatibleContent(e.type))throw new Qr("Cannot join "+t.type.name+" onto "+e.type.name)}function si(e,t,n){let r=e.node(n);return oi(r,t.node(n)),r}function ai(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 li(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&&(ai(e.nodeAfter,r),o++));for(let e=o;e<s;e++)ai(i.child(e),r);t&&t.depth==n&&t.textOffset&&ai(t.nodeBefore,r)}function ci(e,t){return e.type.checkContent(t),e.copy(t)}function ui(e,t,n,r,i){let o=e.depth>i&&si(e,t,i+1),s=r.depth>i&&si(n,r,i+1),a=[];return li(null,e,i,a),o&&s&&t.index(i)==n.index(i)?(oi(o,s),ai(ci(o,ui(e,t,n,r,i+1)),a)):(o&&ai(ci(o,di(e,t,i+1)),a),li(t,n,i,a),s&&ai(ci(s,di(n,r,i+1)),a)),li(r,null,i,a),new Gr(a)}function di(e,t,n){let r=[];if(li(null,e,n,r),e.depth>n){ai(ci(si(e,t,n+1),di(e,t,n+1)),r)}return li(t,null,n,r),new Gr(r)}ei.empty=new ei(Gr.empty,0,0);class pi{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 Xr.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 gi(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 pi(t,n,i)}static resolveCached(e,t){let n=mi.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 mi.set(e,n=new hi);let r=n.elts[n.i]=pi.resolve(e,t);return n.i=(n.i+1)%fi,r}}class hi{constructor(){this.elts=[],this.i=0}}const fi=12,mi=new WeakMap;class gi{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 yi=Object.create(null);class vi{constructor(e,t,n,r=Xr.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||Gr.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&&Zr(this.attrs,t||e.defaultAttrs||yi)&&Xr.sameSet(this.marks,n||Xr.none)}copy(e=null){return e==this.content?this:new vi(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new vi(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 ei.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 ei(a,r.depth-o,i.depth-o)}replace(e,t,n){return ri(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 pi.resolveCached(this,e)}resolveNoCache(e){return pi.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()+")"),xi(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=Gr.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=Xr.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(!Xr.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=Gr.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}}vi.prototype.text=void 0;class bi extends vi{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):xi(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 bi(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new bi(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 xi(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class wi{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new Ei(e,t);if(null==n.next)return wi.empty;let r=Mi(n);n.next&&n.err("Unexpected trailing text");let i=function(e){let t=Object.create(null);return n(Ti(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]);Ti(e,n).forEach(e=>{r||i.push([t,r=[]]),-1==r.indexOf(e)&&r.push(e)})})});let o=t[r.join(",")]=new wi(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(ki);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 Gr.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")}}wi.empty=new wi(!0);class Ei{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 Mi(e){let t=[];do{t.push(Si(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function Si(e){let t=[];do{t.push(Ci(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function Ci(e){let t=function(e){if(e.eat("(")){let t=Mi(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=Ai(e,t)}return t}function Ni(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function Ai(e,t){let n=Ni(e),r=n;return e.eat(",")&&(r="}"!=e.next?Ni(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}function ki(e,t){return t-e}function Ti(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(ki)}function Oi(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 _i(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 Ri(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 Di(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new Li(e,r,t[r]);return n}class Ii{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=Di(e,n.attrs),this.defaultAttrs=Oi(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==wi.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:_i(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new vi(this,this.computeAttrs(e),Gr.from(t),Xr.setFrom(n))}createChecked(e=null,t,n){return t=Gr.from(t),this.checkContent(t),new vi(this,this.computeAttrs(e),t,Xr.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=Gr.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(Gr.empty,!0);return i?new vi(this,e,t.append(i),Xr.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){Ri(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:Xr.none:e}static compile(e,t){let n=Object.create(null);e.forEach((e,r)=>n[e]=new Ii(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 Li{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 Bi{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=Di(e,r.attrs),this.excluded=null;let i=Oi(this.attrs);this.instance=i?new Xr(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Xr(this,_i(this.attrs,e))}static compile(e,t){let n=Object.create(null),r=0;return e.forEach((e,i)=>n[e]=new Bi(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){Ri(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class zi{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=Vr.from(e.nodes),t.marks=Vr.from(e.marks||{}),this.nodes=Ii.compile(this.spec.nodes,this),this.marks=Bi.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]=wi.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?Pi(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?[]:Pi(this,n.split(" "))}this.nodeFromJSON=e=>vi.fromJSON(this,e),this.markFromJSON=e=>Xr.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 Ii))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 bi(n,n.defaultAttrs,e,Xr.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 Pi(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 Fi{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 Vi(this,t,!1);return n.addAll(e,Xr.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Vi(this,t,!0);return n.addAll(e,Xr.none,t.from,t.to),ei.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(Wi(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=Ki(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=Ki(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Fi(e,Fi.schemaRules(e)))}}const ji={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},$i={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Hi={ol:!0,ul:!0};function Ui(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}class qi{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=Xr.none,this.match=i||(4&o?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(Gr.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=Gr.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(Gr.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&&!ji.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Vi{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=Ui(null,t.preserveWhitespace,0)|(n?4:0);r=i?new qi(i.type,i.attrs,Xr.none,!0,t.topMatch||i.type.contentMatch,o):new qi(n?null:e.schema.topNodeType,null,Xr.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();Hi.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&&Hi.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:$i.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(ji.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=Xr.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):Gi(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=Ui(e,i,o.options);4&o.options&&0==o.content.length&&(s|=4);let a=Xr.none;return n=n.filter(t=>!(o.type?o.type.allowsMarkType(t.type):Gi(t.type,e))||(a=t.addToSet(a),!1)),this.nodes.push(new qi(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 Wi(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Ki(e){let t={};for(let n in e)t[n]=e[n];return t}function Gi(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 Ji{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=Zi(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}=eo(Zi(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&&eo(Zi(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return eo(e,t,n,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Ji(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Yi(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return Yi(e.marks)}}function Yi(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function Zi(e){return e.document||window.document}const Xi=new WeakMap;function Qi(e){let t=Xi.get(e);return void 0===t&&Xi.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 eo(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=Qi(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}=eo(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 to=Math.pow(2,16);function no(e,t){return e+t*to}function ro(e){return 65535&e}class io{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 oo{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&oo.empty)return oo.empty}recover(e){let t=0,n=ro(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))/to}(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:no(s/3,e-a),d=e==a?2:e==u?1:4;return(t<0?e!=a:e!=u)&&(d|=8),new io(i,d,o)}r+=c-l}return n?e+r:new io(e+r,0,null)}touches(e,t){let n=0,r=ro(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 oo(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?oo.empty:new oo(e<0?[0,-e,0]:[0,0,e])}}oo.empty=new oo([]);class so{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 so(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 so;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 io(e,r,null)}}const ao=Object.create(null);class lo{getMap(){return oo.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=ao[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 ao)throw new RangeError("Duplicate use of step JSON ID "+e);return ao[e]=t,t.prototype.jsonID=e,t}}class co{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new co(e,null)}static fail(e){return new co(null,e)}static fromReplace(e,t,n,r){try{return co.ok(e.replace(t,n,r))}catch(e){if(e instanceof Qr)return co.fail(e.message);throw e}}}function uo(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let o=e.child(i);o.content.size&&(o=o.copy(uo(o.content,t,o))),o.isInline&&(o=t(o,n,i)),r.push(o)}return Gr.fromArray(r)}class po extends lo{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 ei(uo(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 co.fromReplace(e,this.from,this.to,i)}invert(){return new ho(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 po(t.pos,n.pos,this.mark)}merge(e){return e instanceof po&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new po(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 po(t.from,t.to,e.markFromJSON(t.mark))}}lo.jsonID("addMark",po);class ho extends lo{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 ei(uo(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return co.fromReplace(e,this.from,this.to,n)}invert(){return new po(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 ho(t.pos,n.pos,this.mark)}merge(e){return e instanceof ho&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ho(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 ho(t.from,t.to,e.markFromJSON(t.mark))}}lo.jsonID("removeMark",ho);class fo extends lo{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return co.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return co.fromReplace(e,this.pos,this.pos+1,new ei(Gr.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 fo(this.pos,t.marks[n]);return new fo(this.pos,this.mark)}}return new mo(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new fo(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 fo(t.pos,e.markFromJSON(t.mark))}}lo.jsonID("addNodeMark",fo);class mo extends lo{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return co.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return co.fromReplace(e,this.pos,this.pos+1,new ei(Gr.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new fo(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new mo(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 mo(t.pos,e.markFromJSON(t.mark))}}lo.jsonID("removeNodeMark",mo);class go extends lo{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&vo(e,this.from,this.to)?co.fail("Structure replace would overwrite content"):co.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new oo([this.from,this.to-this.from,this.slice.size])}invert(e){return new go(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 go(t.pos,Math.max(t.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof go)||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?ei.empty:new ei(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new go(e.from,this.to,t,this.structure)}}{let t=this.slice.size+e.slice.size==0?ei.empty:new ei(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new go(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 go(t.from,t.to,ei.fromJSON(e,t.slice),!!t.structure)}}lo.jsonID("replace",go);class yo extends lo{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&&(vo(e,this.from,this.gapFrom)||vo(e,this.gapTo,this.to)))return co.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return co.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?co.fromReplace(e,this.from,this.to,n):co.fail("Content does not fit in gap")}getMap(){return new oo([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 yo(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 yo(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 yo(t.from,t.to,t.gapFrom,t.gapTo,ei.fromJSON(e,t.slice),t.insert,!!t.structure)}}function vo(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 bo(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 ho(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 ei(Gr.from(n.schema.text(" ",n.allowedMarks(l.marks))),0,0)),s.push(new go(a+e.index,a+e.index+e[0].length,t))}}else s.push(new go(a,c,ei.empty));a=c}if(!r.validEnd){let t=r.fillBefore(Gr.empty,!0);e.replace(a,a,new ei(t,0,0))}for(let t=s.length-1;t>=0;t--)e.step(s[t])}function xo(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function wo(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||!xo(o,s,a))break;s&&(r=1),a<o.childCount&&(i=1)}return null}function Eo(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(Mo).concat({type:t,attrs:n}).concat(o.map(Mo)):null}function Mo(e){return{type:e,attrs:null}}function So(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 Co(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 No(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 Ao(e,t){let n=e.resolve(t),r=n.index();return ko(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function ko(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 To(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&&ko(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 Oo(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 _o(e,t,n=t,r=ei.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),o=e.resolve(n);return Ro(i,o,r)?new go(t,n,r):new Do(i,o,r).fit()}function Ro(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}lo.jsonID("replaceAround",yo);class Do{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=Gr.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=Gr.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 ei(i,o,s);return e>-1?new yo(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new go(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=Bo(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(Gr.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=Bo(e,t);return!(!r.childCount||r.firstChild.isLeaf)&&(this.unplaced=new ei(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=Bo(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new ei(Io(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new ei(Io(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(zo(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=Lo(this.placed,t,Gr.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?ei.empty:new ei(Io(o.content,e-1,1),e-1,p<0?o.openEnd:e-1):new ei(Io(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||!Po(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=Po(e,t,r,n,i);if(o){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],i=Po(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=Lo(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=Lo(this.placed,this.depth,Gr.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(Gr.empty,!0);e.childCount&&(this.placed=Lo(this.placed,this.frontier.length,e))}}function Io(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(Io(e.firstChild.content,t-1,n)))}function Lo(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Lo(e.lastChild.content,t-1,n)))}function Bo(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function zo(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,zo(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(Gr.empty,!0)))),e.copy(r)}function Po(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 Fo(e){return e.spec.defining||e.spec.definingForContent}function jo(e,t,n,r,i){if(t<n){let i=e.firstChild;e=e.replaceChild(0,i.copy(jo(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(Gr.empty,!0))}return e}function $o(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 Ho extends lo{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 co.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 co.fromReplace(e,this.pos,this.pos+1,new ei(Gr.from(r),0,t.isLeaf?0:1))}getMap(){return oo.empty}invert(e){return new Ho(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 Ho(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 Ho(t.pos,t.attr,t.value)}}lo.jsonID("attr",Ho);class Uo extends lo{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 co.ok(n)}getMap(){return oo.empty}invert(e){return new Uo(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 Uo(t.attr,t.value)}}lo.jsonID("docAttr",Uo);let qo=class extends Error{};qo=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},(qo.prototype=Object.create(Error.prototype)).constructor=qo,qo.prototype.name="TransformError";class Vo{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new so}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new qo(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=ei.empty){let r=_o(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new ei(Gr.from(n),0,0))}delete(e,t){return this.replace(e,t,ei.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(Ro(i,o,r))return e.step(new go(t,n,r));let s=$o(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=Fo(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 ei(jo(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 ei(Gr.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=$o(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=Gr.empty,d=0;for(let e=o,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=Gr.from(r.node(e).copy(u)),d++):l--;let p=Gr.empty,h=0;for(let e=o,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,p=Gr.from(i.node(e).copy(p)),h++):c++;e.step(new yo(l,c,s,a,new ei(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);Co(e,r.node(),r.before(),a)}s.inlineContent&&bo(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 go(c,l.map(t+n,-1),ei.empty,!0)),!0===r){let t=e.doc.resolve(c);So(e,t.node(),t.before(),e.steps.length)}}(this,e,t),this}wrap(e,t){return function(e,t,n){let r=Gr.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=Gr.from(n[e].type.create(n[e].attrs,r))}let i=t.start,o=t.end;e.step(new yo(i,o,i,o,new ei(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&&Co(e,t,n,o),bo(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 yo(l,c,l+1,c-1,new ei(Gr.from(r.create(s,null,t.marks)),0,0),1,!0)),!0===i&&So(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 yo(t,t+o.nodeSize,t+1,t+o.nodeSize-1,new ei(Gr.from(s),0,0),1,!0))}(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new Ho(e,t,n)),this}setDocAttribute(e,t){return this.step(new Uo(e,t)),this}addNodeMark(e,t){return this.step(new fo(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 Xr)t.isInSet(n.marks)&&this.step(new mo(e,t));else{let r,i=n.marks,o=[];for(;r=t.isInSet(i);)o.push(new mo(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=Gr.empty,s=Gr.empty;for(let e=i.depth,t=i.depth-n,a=n-1;e>t;e--,a--){o=Gr.from(i.node(e).copy(o));let t=r&&r[a];s=Gr.from(t?t.type.create(t.attrs,s):i.node(e).copy(s))}e.step(new go(t,t,new ei(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 ho(c,d,u[e])));o&&o.to==c?o.to=d:a.push(o=new po(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 Bi){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 ho(t.from,t.to,t.style)))}(this,e,t,n),this}clearIncompatible(e,t,n){return bo(this,e,t,n),this}}const Wo=Object.create(null);class Ko{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Go(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=ei.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?ei.empty:t),0==s&&is(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),is(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new Zo(e):rs(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?rs(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):rs(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 ts(e.node(0))}static atStart(e){return rs(e,e,0,0,1)||new ts(e)}static atEnd(e){return rs(e,e,e.content.size,e.childCount,-1)||new ts(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Wo[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 Wo)throw new RangeError("Duplicate use of selection JSON ID "+e);return Wo[e]=t,t.prototype.jsonID=e,t}getBookmark(){return Zo.between(this.$anchor,this.$head).getBookmark()}}Ko.prototype.visible=!0;class Go{constructor(e,t){this.$from=e,this.$to=t}}let Jo=!1;function Yo(e){Jo||e.parent.inlineContent||(Jo=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class Zo extends Ko{constructor(e,t=e){Yo(e),Yo(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 Ko.near(n);let r=e.resolve(t.map(this.anchor));return new Zo(r.parent.inlineContent?r:n,n)}replace(e,t=ei.empty){if(super.replace(e,t),t==ei.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof Zo&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Xo(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 Zo(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=Ko.findFrom(t,n,!0)||Ko.findFrom(t,-n,!0);if(!e)return Ko.near(t,n);t=e.$head}return e.parent.inlineContent||(0==r||(e=(Ko.findFrom(e,-n,!0)||Ko.findFrom(e,n,!0)).$anchor).pos<t.pos!=r<0)&&(e=t),new Zo(e,t)}}Ko.jsonID("text",Zo);class Xo{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Xo(e.map(this.anchor),e.map(this.head))}resolve(e){return Zo.between(e.resolve(this.anchor),e.resolve(this.head))}}class Qo extends Ko{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?Ko.near(i):new Qo(i)}content(){return new ei(Gr.from(this.node),0,0)}eq(e){return e instanceof Qo&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new es(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Qo(e.resolve(t.anchor))}static create(e,t){return new Qo(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}Qo.prototype.visible=!1,Ko.jsonID("node",Qo);class es{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new Xo(n,n):new es(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&Qo.isSelectable(n)?new Qo(t):Ko.near(t)}}class ts extends Ko{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=ei.empty){if(t==ei.empty){e.delete(0,e.doc.content.size);let t=Ko.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new ts(e)}map(e){return new ts(e)}eq(e){return e instanceof ts}getBookmark(){return ns}}Ko.jsonID("all",ts);const ns={map(){return this},resolve:e=>new ts(e)};function rs(e,t,n,r,i,o=!1){if(t.inlineContent)return Zo.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&&Qo.isSelectable(r))return Qo.create(e,n-(i<0?r.nodeSize:0))}else{let t=rs(e,r,n+i,i<0?r.childCount:0,i,o);if(t)return t}n+=r.nodeSize*i}return null}function is(e,t,n){let r=e.steps.length-1;if(r<t)return;let i,o=e.steps[r];(o instanceof go||o instanceof yo)&&(e.mapping.maps[r].forEach((e,t,n,r)=>{null==i&&(i=r)}),e.setSelection(Ko.near(e.doc.resolve(i),n)))}class ss extends Vo{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 Xr.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)||Xr.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(Ko.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 as(e,t){return t&&e?e.bind(t):e}class ls{constructor(e,t,n){this.name=e,this.init=as(t.init,n),this.apply=as(t.apply,n)}}const cs=[new ls("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new ls("selection",{init:(e,t)=>e.selection||Ko.atStart(t.doc),apply:e=>e.selection}),new ls("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,r)=>r.selection.$cursor?e.storedMarks:null}),new ls("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class us{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=cs.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 ls(e.key,e.spec.state,e))})}}class ds{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 ds(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 ss(this)}static create(e){let t=new us(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new ds(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 us(this.schema,e.plugins),n=t.fields,r=new ds(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 us(e.schema,e.plugins),i=new ds(r);return r.fields.forEach(r=>{if("doc"==r.name)i.doc=vi.fromJSON(e.schema,t.doc);else if("selection"==r.name)i.selection=Ko.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 ps(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):"handleDOMEvents"==r&&(i=ps(i,t,{})),n[r]=i}return n}class hs{constructor(e){this.spec=e,this.props={},e.props&&ps(e.props,this,this.props),this.key=e.key?e.key.key:ms("plugin")}getState(e){return e[this.key]}}const fs=Object.create(null);function ms(e){return e in fs?e+"$"+ ++fs[e]:(fs[e]=0,e+"$")}class gs{constructor(e="key"){this.key=ms(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const ys=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},vs=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t};let bs=null;const xs=function(e,t,n){let r=bs||(bs=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},ws=function(e,t,n,r){return n&&(Ms(e,t,n,r,-1)||Ms(e,t,n,r,1))},Es=/^(img|br|input|textarea|hr)$/i;function Ms(e,t,n,r,i){for(var o;;){if(e==n&&t==r)return!0;if(t==(i<0?0:Ss(e))){let n=e.parentNode;if(!n||1!=n.nodeType||Cs(e)||Es.test(e.nodeName)||"false"==e.contentEditable)return!1;t=ys(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?Ss(e):0}}}}function Ss(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Cs(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 Ns=function(e){return e.focusNode&&ws(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function As(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}const ks="undefined"!=typeof navigator?navigator:null,Ts="undefined"!=typeof document?document:null,Os=ks&&ks.userAgent||"",_s=/Edge\/(\d+)/.exec(Os),Rs=/MSIE \d/.exec(Os),Ds=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Os),Is=!!(Rs||Ds||_s),Ls=Rs?document.documentMode:Ds?+Ds[1]:_s?+_s[1]:0,Bs=!Is&&/gecko\/(\d+)/i.test(Os);Bs&&(/Firefox\/(\d+)/.exec(Os)||[0,0])[1];const zs=!Is&&/Chrome\/(\d+)/.exec(Os),Ps=!!zs,Fs=zs?+zs[1]:0,js=!Is&&!!ks&&/Apple Computer/.test(ks.vendor),$s=js&&(/Mobile\/\w+/.test(Os)||!!ks&&ks.maxTouchPoints>2),Hs=$s||!!ks&&/Mac/.test(ks.platform),Us=!!ks&&/Win/.test(ks.platform),qs=/Android \d/.test(Os),Vs=!!Ts&&"webkitFontSmoothing"in Ts.documentElement.style,Ws=Vs?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Ks(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 Gs(e,t){return"number"==typeof e?e:e[t]}function Js(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 Ys(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=vs(s);continue}let e=s,n=e==o.body,a=n?Ks(o):Js(e),l=0,c=0;if(t.top<a.top+Gs(r,"top")?c=-(a.top-t.top+Gs(i,"top")):t.bottom>a.bottom-Gs(r,"bottom")&&(c=t.bottom-t.top>a.bottom-a.top?t.top+Gs(i,"top")-a.top:t.bottom-a.bottom+Gs(i,"bottom")),t.left<a.left+Gs(r,"left")?l=-(a.left-t.left+Gs(i,"left")):t.right>a.right-Gs(r,"right")&&(l=t.right-a.right+Gs(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:vs(s)}}function Zs(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=vs(r));return t}function Xs(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 Qs=null;function ea(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=xs(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=oa(i,1);if(r.top!=r.bottom&&ta(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}:ea(n,r)}function ta(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function na(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(ta(t,i))return na(n,t,i)}}if((o=(o+1)%r)==i)break}return e}function ra(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(Ss(r.offsetNode),r.offset)}}catch(e){}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(Ss(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(!ta(t,n))return null;if(a=na(e.dom,t,n),!a)return null}if(js)for(let e=a;n&&e;e=vs(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(Bs&&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;Vs&&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}=ea(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 ia(e){return e.top<e.bottom||e.left<e.right}function oa(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(ia(e))return e}return Array.prototype.find.call(n,ia)||e.getBoundingClientRect()}const sa=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function aa(e,t,n){let{node:r,offset:i,atom:o}=e.docView.domFromPos(t,n<0?-1:1),s=Vs||Bs;if(3==r.nodeType){if(!s||!sa.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++,la(oa(xs(r,e,t),o),o<0)}{let e=oa(xs(r,i,i),n);if(Bs&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let t=oa(xs(r,i-1,i-1),-1);if(t.top==e.top){let n=oa(xs(r,i,i+1),-1);if(n.top!=e.top)return la(n,n.left<t.left)}}return e}}if(!e.state.doc.resolve(t-(o||0)).parent.inlineContent){if(null==o&&i&&(n<0||i==Ss(r))){let e=r.childNodes[i-1];if(1==e.nodeType)return ca(e.getBoundingClientRect(),!1)}if(null==o&&i<Ss(r)){let e=r.childNodes[i];if(1==e.nodeType)return ca(e.getBoundingClientRect(),!0)}return ca(r.getBoundingClientRect(),n>=0)}if(null==o&&i&&(n<0||i==Ss(r))){let e=r.childNodes[i-1],t=3==e.nodeType?xs(e,Ss(e)-(s?0:1)):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return la(oa(t,1),!1)}if(null==o&&i<Ss(r)){let e=r.childNodes[i];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?xs(e,0,s?0:1):1==e.nodeType?e:null:null;if(t)return la(oa(t,-1),!0)}return la(oa(3==r.nodeType?xs(r):r,-n),n>=0)}function la(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 ca(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 ua(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 da=/[\u0590-\u08ac]/;let pa=null,ha=null,fa=!1;function ma(e,t,n){return pa==t&&ha==n?fa:(pa=t,ha=n,fa="up"==n||"down"==n?function(e,t,n){let r=t.selection,i="up"==n?r.$from:r.$to;return ua(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=aa(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=xs(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?da.test(r.parent.textContent)&&a.modify?ua(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 ga{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>ys(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 Ma){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 ya&&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?ys(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?ys(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=ys(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=ys(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((Bs||js)&&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:ys(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(Bs&&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&&js)&&ws(s.node,s.offset,c.anchorNode,c.anchorOffset)&&ws(a.node,a.offset,c.focusNode,c.focusOffset))return;let d=!1;if((l.extend||e==t)&&(!u||!Bs)){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 ya extends ga{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 va extends ga{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 ba extends ga{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=Ji.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new ba(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=ba.create(this.parent,this.mark,!0,n),i=this.children,o=this.size;t<o&&(i=Ba(i,t,o,n)),e>0&&(i=Ba(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 xa extends ga{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=Ji.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=_a(c,n,t),l?s=new Sa(e,t,n,r,c,u||null,d,l,i,o+1):t.isText?new Ea(e,t,n,r,c,d,i):new xa(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=()=>Gr.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)&&Ra(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 Ia(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(La);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?Xr.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),Ca(this.contentDOM,this.children,e),$s&&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 Zo)||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 va(this,i,t,r);e.input.compositionNodes.push(o),this.children=Ba(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(Ra(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=Ta(this.dom,this.nodeDOM,ka(this.outerDeco,this.node,t),ka(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 wa(e,t,n,r,i){_a(r,t,e);let o=new xa(void 0,e,t,n,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}class Ea extends xa{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 Ea(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 Ma extends ga{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 Sa extends xa{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 Ca(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=Da(r),i=!0;r=r.nextSibling}else i=!0,e.insertBefore(a,r);if(s instanceof ba){let t=r?r.previousSibling:e.lastChild;Ca(s.contentDOM,s.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=Da(r),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}const Na=function(e){e&&(this.nodeName=e)};Na.prototype=Object.create(null);const Aa=[new Na];function ka(e,t,n){if(0==e.length)return Aa;let r=n?Aa[0]:new Na,i=[r];for(let o=0;o<e.length;o++){let s=e[o].type.attrs;if(s){s.nodeName&&i.push(r=new Na(s.nodeName));for(let e in s){let o=s[e];null!=o&&(n&&1==i.length&&i.push(r=new Na(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 Ta(e,t,n,r){if(n==Aa&&r==Aa)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=Aa[0]),i=t}Oa(i,s||Aa[0],o)}return i}function Oa(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 _a(e,t,n){return Ta(e,e,Aa,ka(t,n,1!=e.nodeType))}function Ra(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 Da(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class Ia{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 ba)){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=ba.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 xa){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&&Ra(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)||!Ra(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let s=xa.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=xa.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 ya(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 ba;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Ea)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((js||Ps)&&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 Ma(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 La(e,t){return e.type.side-t.type.side}function Ba(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 za(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(Ns(n)){for(a=s;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&Qo.isSelectable(e)&&i.parent&&(!e.isInline||!function(e,t,n){for(let r=0==t,i=t==Ss(e);r||i;){if(e==n)return!0;let t=ys(e);if(!(e=e.parentNode))return!1;r=r&&0==t,i=i&&t==Ss(e)}}(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new Qo(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=Wa(e,u,c,"pointer"==t||e.state.selection.head<c.pos&&!o?1:-1)}return l}function Pa(e){return e.editable?e.hasFocus():Ga(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function Fa(e,t=!1){let n=e.state.selection;if(qa(e,n),Pa(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&Ps){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&ws(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,ys(n)+1):t.collapse(n,0);!r&&!e.state.selection.visible&&Is&&Ls<=11&&(n.disabled=!0,n.disabled=!1)}(e);else{let r,i,{anchor:o,head:s}=n;!ja||n instanceof Zo||(n.$from.parent.inlineContent||(r=$a(e,n.from)),n.empty||n.$from.parent.inlineContent||(i=$a(e,n.to))),e.docView.setSelection(o,s,e,t),ja&&(r&&Ua(r),i&&Ua(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(()=>{Pa(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")},20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const ja=js||Ps&&Fs<63;function $a(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(js&&i&&"false"==i.contentEditable)return Ha(i);if(!(i&&"false"!=i.contentEditable||o&&"false"!=o.contentEditable)){if(i)return Ha(i);if(o)return Ha(o)}}function Ha(e){return e.contentEditable="true",js&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function Ua(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function qa(e,t){if(t instanceof Qo){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(Va(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else Va(e)}function Va(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Wa(e,t,n,r){return e.someProp("createSelectionBetween",r=>r(e,t,n))||Zo.between(t,n,r)}function Ka(e){return!(e.editable&&!e.hasFocus())&&Ga(e)}function Ga(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 Ja(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&&Ko.findFrom(o,t)}function Ya(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Za(e,t,n){let r=e.state.selection;if(!(r instanceof Zo)){if(r instanceof Qo&&r.node.isInline)return Ya(e,new Zo(t>0?r.$to:r.$from));{let n=Ja(e.state,t);return!!n&&Ya(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 Ya(e,new Zo(r.$anchor,o))}if(!r.empty)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){let n=Ja(e.state,t);return!!(n&&n instanceof Qo)&&Ya(e,n)}if(!(Hs&&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)&&(Qo.isSelectable(o)?Ya(e,new Qo(t<0?e.state.doc.resolve(i.pos-o.nodeSize):i)):!!Vs&&Ya(e,new Zo(e.state.doc.resolve(t<0?s:s+o.nodeSize))))}}function Xa(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Qa(e,t){let n=e.pmViewDesc;return n&&0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function el(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;Bs&&1==n.nodeType&&r<Xa(n)&&Qa(n.childNodes[r],-1)&&(s=!0);for(;;)if(r>0){if(1!=n.nodeType)break;{let e=n.childNodes[r-1];if(Qa(e,-1))i=n,o=--r;else{if(3!=e.nodeType)break;n=e,r=n.nodeValue.length}}}else{if(tl(n))break;{let t=n.previousSibling;for(;t&&Qa(t,-1);)i=n.parentNode,o=ys(t),t=t.previousSibling;if(t)n=t,r=Xa(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}s?nl(e,n,r):i&&nl(e,i,o)}(e):function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,o,s=Xa(n);for(;;)if(r<s){if(1!=n.nodeType)break;if(!Qa(n.childNodes[r],1))break;i=n,o=++r}else{if(tl(n))break;{let t=n.nextSibling;for(;t&&Qa(t,1);)i=t.parentNode,o=ys(t)+1,t=t.nextSibling;if(t)n=t,r=0,s=Xa(n);else{if(n=n.parentNode,n==e.dom)break;r=s=0}}}i&&nl(e,i,o)}(e)}function tl(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function nl(e,t,n){if(3!=t.nodeType){let e,r;(r=function(e,t){for(;e&&t==e.childNodes.length&&!Cs(e);)t=ys(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&&!Cs(e);)t=ys(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(Ns(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&&Fa(e)},50)}function rl(e,t){let n=e.state.doc.resolve(t);if(!Ps&&!Us&&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 il(e,t,n){let r=e.state.selection;if(r instanceof Zo&&!r.empty||n.indexOf("s")>-1)return!1;if(Hs&&n.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=Ja(e.state,t);if(n&&n instanceof Qo)return Ya(e,n)}if(!i.parent.inlineContent){let n=t<0?i:o,s=r instanceof ts?Ko.near(n,t):Ko.findFrom(n,t);return!!s&&Ya(e,s)}return!1}function ol(e,t){if(!(e.state.selection instanceof Zo))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 sl(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function al(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||Hs&&72==n&&"c"==r)return ol(e,-1)||el(e,-1);if(46==n&&!t.shiftKey||Hs&&68==n&&"c"==r)return ol(e,1)||el(e,1);if(13==n||27==n)return!0;if(37==n||Hs&&66==n&&"c"==r){let t=37==n?"ltr"==rl(e,e.state.selection.from)?-1:1:-1;return Za(e,t,r)||el(e,t)}if(39==n||Hs&&70==n&&"c"==r){let t=39==n?"ltr"==rl(e,e.state.selection.from)?1:-1:1;return Za(e,t,r)||el(e,t)}return 38==n||Hs&&80==n&&"c"==r?il(e,-1,r)||el(e,-1):40==n||Hs&&78==n&&"c"==r?function(e){if(!js||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;sl(e,n,"true"),setTimeout(()=>sl(e,n,"false"),20)}return!1}(e)||il(e,1,r)||el(e,1):r==(Hs?"m":"c")&&(66==n||73==n||89==n||90==n)}function ll(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")||Ji.fromSchema(e.state.schema),a=vl(),l=a.createElement("div");l.appendChild(s.serializeFragment(r,{document:a}));let c,u=l.firstChild,d=0;for(;u&&1==u.nodeType&&(c=gl[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 cl(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 ei(Gr.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=Ji.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=vl().createElement("div"),i=/<([a-z][^>\s]+)/i.exec(e);(n=i&&gl[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;bl||(bl=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:e=>e}));return bl.createHTML(e)}(e),n)for(let e=0;e<n.length;e++)r=r.querySelector(n[e])||r;return r}(n),Vs&&function(e){let t=e.querySelectorAll(Ps?"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")||Fi.fromSchema(e.state.schema);s=t.parseSlice(o,{preserveWhitespace:!(!l&&!u),context:i,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||ul.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=Gr.from(t.create(n[e+1],i)),o++,s++}return new ei(i,o,s)}(ml(s,+u[1],+u[2]),u[4]);else if(s=ei.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&&pl(n,r,e,o[o.length-1],0))o[o.length-1]=t;else{o.length&&(o[o.length-1]=hl(o[o.length-1],r.length));let t=dl(e,n);o.push(t),i=i.matchType(t.type),r=n}}),o)return Gr.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=ml(s,e,t)}return e.someProp("transformPasted",t=>{s=t(s,e,l)}),s}const ul=/^(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 dl(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,Gr.from(e));return e}function pl(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let o=pl(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(Gr.from(dl(n,e,i+1))))}}function hl(e,t){if(0==t)return e;let n=e.content.replaceChild(e.childCount-1,hl(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(Gr.empty,!0);return e.copy(n.append(r))}function fl(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=fl(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(Gr.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,s.copy(a))}function ml(e,t,n){return t<e.openStart&&(e=new ei(fl(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new ei(fl(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const gl={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 yl=null;function vl(){return yl||(yl=document.implementation.createHTMLDocument("title"))}let bl=null;const xl={},wl={},El={touchstart:!0,touchmove:!0};class Ml{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 Sl(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Cl(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>Nl(e,t))})}function Nl(e,t){return e.someProp("handleDOMEvents",n=>{let r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)})}function Al(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 kl(e){return{left:e.clientX,top:e.clientY}}function Tl(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 Ol(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 _l(e,t,n,r,i){return Tl(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 Qo&&(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(Qo.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&&(Ol(e,Qo.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&&Qo.isSelectable(r))&&(Ol(e,new Qo(n),"pointer"),!0)}(e,n))}function Rl(e,t,n,r){return Tl(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",n=>n(e,t,r))}function Dl(e,t,n,r){return Tl(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&&(Ol(e,Zo.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)Ol(e,Zo.create(r,o+1,o+1+n.content.size),"pointer");else{if(!Qo.isSelectable(n))continue;Ol(e,Qo.create(r,o),"pointer")}return!0}}(e,n,r)}function Il(e){return Hl(e)}wl.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!zl(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!qs||!Ps||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!$s||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",t=>t(e,n))||al(e,n)?n.preventDefault():Sl(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,As(13,"Enter"))),e.input.lastIOSEnter=0)},200)}},wl.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},wl.keypress=(e,t)=>{let n=t;if(zl(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||Hs&&n.metaKey)return;if(e.someProp("handleKeyPress",t=>t(e,n)))return void n.preventDefault();let r=e.state.selection;if(!(r instanceof Zo&&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 Ll=Hs?"metaKey":"ctrlKey";xl.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=Il(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[Ll]&&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(kl(n));s&&("singleClick"==o?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new Bl(e,s,n,!!r)):("doubleClick"==o?Rl:Dl)(e,s.pos,s.inside,n)?n.preventDefault():Sl(e,"pointer"))};class Bl{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[Ll],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 Qo&&l.from<=o&&l.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!Bs||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)),Sl(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(()=>Fa(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(kl(e))),this.updateAllowDefault(e),this.allowDefault||!t?Sl(this.view,"pointer"):_l(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||js&&this.mightDrag&&!this.mightDrag.node.isAtom||Ps&&!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)?(Ol(this.view,Ko.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Sl(this.view,"pointer")}move(e){this.updateAllowDefault(e),Sl(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 zl(e,t){return!!e.composing||!!(js&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}xl.touchstart=e=>{e.input.lastTouch=Date.now(),Il(e),Sl(e,"pointer")},xl.touchmove=e=>{e.input.lastTouch=Date.now(),Sl(e,"pointer")},xl.contextmenu=e=>Il(e);const Pl=qs?5e3:-1;function Fl(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Hl(e),t))}function jl(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 $l(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=Ss(e=e.childNodes[t-1])}else{if(!e.parentNode||Cs(e))return null;t=ys(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||Cs(e))return null;t=ys(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 Hl(e,t=!1){if(!(qs&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),jl(e),t||e.docView&&e.docView.dirty){let n=za(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}}wl.compositionstart=wl.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof Zo&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>!1===e.type.spec.inclusive)||Ps&&Us&&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(),Hl(e,!0),e.markCursor=null;else if(Hl(e,!t.selection.empty),Bs&&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}Fl(e,Pl)},wl.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++,Fl(e,20))};const Ul=Is&&Ls<15||$s&&Ws<604;function ql(e,t,n,r,i){let o=cl(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",t=>t(e,i,o||ei.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 Vl(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," "):""}xl.copy=wl.cut=(e,t)=>{let n=t,r=e.state.selection,i="cut"==n.type;if(r.empty)return;let o=Ul?null:n.clipboardData,s=r.content(),{dom:a,text:l}=ll(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"))},wl.paste=(e,t)=>{let n=t;if(e.composing&&!qs)return;let r=Ul?null:n.clipboardData,i=e.input.shiftKey&&45!=e.input.lastKeyCode;r&&ql(e,Vl(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?ql(e,r.value,null,i,t):ql(e,r.textContent,r.innerHTML,i,t)},50)}(e,n)};class Wl{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const Kl=Hs?"altKey":"ctrlKey";function Gl(e,t){let n=e.someProp("dragCopies",e=>!e(t));return null!=n?n:!t[Kl]}xl.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(kl(n));if(s&&s.pos>=o.from&&s.pos<=(o instanceof Qo?o.to-1:o.to));else if(r&&r.mightDrag)i=Qo.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=Qo.create(e.state.doc,t.posBefore))}let a=(i||e.state.selection).content(),{dom:l,text:c,slice:u}=ll(e,a);(!n.dataTransfer.files.length||!Ps||Fs>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Ul?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",Ul||n.dataTransfer.setData("text/plain",c),e.dragging=new Wl(u,Gl(e,n),i)},xl.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},wl.dragover=wl.dragenter=(e,t)=>t.preventDefault(),wl.drop=(e,t)=>{try{!function(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(kl(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=cl(e,Vl(t.dataTransfer),Ul?null:t.dataTransfer.getData("text/html"),!1,i);let s=!(!n||!Gl(e,t));if(e.someProp("handleDrop",n=>n(e,t,o||ei.empty,s)))return void t.preventDefault();if(!o)return;t.preventDefault();let a=o?Oo(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&&Qo.isSelectable(o.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(o.content.firstChild))l.setSelection(new Qo(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(Wa(e,p,l.doc.resolve(t)))}e.focus(),e.dispatch(l.setMeta("uiEvent","drop"))}(e,t,e.dragging)}finally{e.dragging=null}},xl.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())&&Fa(e)},20))},xl.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)},xl.beforeinput=(e,t)=>{if(Ps&&qs&&"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,As(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 wl)xl[e]=wl[e];function Jl(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 Yl{constructor(e,t){this.toDOM=e,this.spec=t||tc,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 Ql(i-n,i-n,this)}valid(){return!0}eq(e){return this==e||e instanceof Yl&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Jl(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Zl{constructor(e,t){this.attrs=e,this.spec=t||tc}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 Ql(i,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Zl&&Jl(this.attrs,e.attrs)&&Jl(this.spec,e.spec)}static is(e){return e.type instanceof Zl}destroy(){}}class Xl{constructor(e,t){this.attrs=e,this.spec=t||tc}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 Ql(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 Xl&&Jl(this.attrs,e.attrs)&&Jl(this.spec,e.spec)}destroy(){}}class Ql{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new Ql(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 Ql(e,e,new Yl(t,n))}static inline(e,t,n,r){return new Ql(e,t,new Zl(n,r))}static node(e,t,n,r){return new Ql(e,t,new Xl(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof Zl}get widget(){return this.type instanceof Yl}}const ec=[],tc={};class nc{constructor(e,t){this.local=e.length?e:ec,this.children=t.length?t:ec}static create(e,t){return t.length?lc(t,e,0,tc):rc}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==rc||0==e.maps.length?this:this.mapInner(e,t,0,0,n||tc)}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!=rc?(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=lc(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 nc(t.sort(cc),a)}(this.children,o||[],e,t,n,r,i):o?new nc(o.sort(cc),ec):rc}add(e,t){return t.length?this==rc?nc.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=sc(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,lc(s,e,a+1,tc)),i+=3}});let o=oc(i?ac(t):t,-n);for(let t=0;t<o.length;t++)o[t].type.valid(e,o[t])||o.splice(t--,1);return new nc(o.length?this.local.concat(o).sort(cc):this.local,r||this.children)}remove(e){return 0==e.length||this==rc?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!=rc?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 nc(r,n):rc}forChild(e,t){if(this==rc)return this;if(t.isLeaf)return nc.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 Zl){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 nc(r.sort(cc),ec);return n?new ic([e,n]):e}return n||rc}eq(e){if(this==e)return!0;if(!(e instanceof nc)||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 uc(this.localsInner(e))}localsInner(e){if(this==rc)return ec;if(e.inlineContent||!this.local.some(Zl.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof Zl||t.push(this.local[e]);return t}forEachSet(e){e(this)}}nc.empty=new nc([],[]),nc.removeOverlap=uc;const rc=nc.empty;class ic{constructor(e){this.members=e}map(e,t){const n=this.members.map(n=>n.map(e,t,tc));return ic.from(n)}forChild(e,t){if(t.isLeaf)return nc.empty;let n=[];for(let r=0;r<this.members.length;r++){let i=this.members[r].forChild(e,t);i!=rc&&(i instanceof ic?n=n.concat(i.members):n.push(i))}return ic.from(n)}eq(e){if(!(e instanceof ic)||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?uc(n?t:t.sort(cc)):ec}static from(e){switch(e.length){case 0:return rc;case 1:return e[0];default:return new ic(e.every(e=>e instanceof nc)?e:e.reduce((e,t)=>e.concat(t instanceof nc?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function oc(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 Ql(i.from+t,i.to+t,i.type))}return n}function sc(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 ac(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function lc(e,t,n,r){let i=[],o=!1;t.forEach((t,s)=>{let a=sc(e,t,s+n);if(a){o=!0;let e=lc(a,t,n+s+1,r);e!=rc&&i.push(s,s+t.nodeSize,e)}});let s=oc(o?ac(e):e,-n).sort(cc);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 nc(s,i):rc}function cc(e,t){return e.from-t.from||e.to-t.to}function uc(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),dc(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),dc(t,i+1,o.copy(r.to,o.to)))}}return t}function dc(e,t,n){for(;t<e.length&&cc(n,e[t])>0;)t++;e.splice(t,0,n)}function pc(e){let t=[];return e.someProp("decorations",n=>{let r=n(e.state);r&&r!=rc&&t.push(r)}),e.cursorWrapper&&t.push(nc.create(e.state.doc,[e.cursorWrapper.deco])),ic.from(t)}const hc={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},fc=Is&&Ls<=11;class mc{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 gc{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new mc,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]);Is&&Ls<=11&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():js&&e.composing&&t.some(e=>"childList"==e.type&&"TR"==e.target.nodeName)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),fc&&(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,hc)),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(Ka(this.view)){if(this.suppressingSelectionUpdates)return Fa(this.view);if(Is&&Ls<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&ws(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=vs(t))n.add(t);for(let r=e.anchorNode;r;r=vs(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)&&Ka(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(Bs&&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&&xc(e,n)==t||r.remove()}}}else if((Ps||js)&&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&&Ns(n)&&(l=za(e))&&l.eq(Ko.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Fa(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,o),function(e){if(yc.has(e))return;if(yc.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)){if(e.requiresGeckoHackNode=Bs,vc)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."),vc=!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)||Fa(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(Is&&Ls<=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?ys(r)+1:0,s=n.localPosFromDOM(e.target,o,-1),a=i&&i.parentNode==e.target?ys(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 yc=new WeakMap,vc=!1;function bc(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,o=t.endOffset,s=e.domAtPos(e.state.selection.anchor);return ws(s.node,s.offset,i,o)&&([n,r,i,o]=[i,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}}function xc(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 wc(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(js&&/^(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||js&&/^(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 Ec=/^(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 Mc(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=za(e,t);if(n&&!e.state.selection.eq(n)){if(Ps&&qs&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",t=>t(e,As(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}],Ns(c)||r.push({node:c.focusNode,offset:c.focusOffset})),Ps&&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")||Fi.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:wc,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&&Nc(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&&Nc(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++,($s&&e.input.lastIOSEnter>Date.now()-225||qs)&&i.some(e=>1==e.nodeType&&!Ec.test(e.nodeName))&&(!f||f.endA>=f.endB)&&e.someProp("handleKeyDown",t=>t(e,As(13,"Enter"))))return void(e.input.lastIOSEnter=0);if(!f){if(!(r&&u instanceof Zo&&!u.empty&&u.$head.sameParent(u.$anchor))||e.composing||d.sel&&d.sel.anchor!=d.sel.head){if(d.sel){let t=Sc(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 Zo&&(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)),Is&&Ls<=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(($s&&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,As(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||Cc(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(Cc(o,!0,!0));return!(!s.parent.isTextblock||s.pos>n||Cc(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,As(8,"Backspace"))))return void(qs&&Ps&&e.domObserver.suppressSelectionUpdates());Ps&&f.endB==f.start&&(e.input.lastChromeDelete=Date.now()),qs&&!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,As(13,"Enter"))})},20));let b,x=f.start,w=f.endA,E=t=>{let n=t||e.state.tr.replace(x,w,d.doc.slice(f.start-d.from,f.endB-d.from));if(d.sel){let t=Sc(e,n.doc,d.sel);t&&!(Ps&&e.composing&&t.empty&&(f.start!=f.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==x||t.head==n.mapping.map(w)-1)||Is&&t.empty&&t.head==x)&&n.setSelection(t)}return o&&n.setMeta("composition",o),n.scrollIntoView()};if(v)if(m.pos==g.pos){Is&&Ls<=11&&0==m.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>Fa(e),20));let t=E(e.state.tr.delete(x,w)),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(Gr.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=E(e.state.tr);"add"==b.type?t.addMark(x,w,b.mark):t.removeMark(x,w,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=()=>E(e.state.tr.insertText(t,x,w));e.someProp("handleTextInput",r=>r(e,x,w,t,n))||e.dispatch(n())}else e.dispatch(E());else e.dispatch(E())}function Sc(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Wa(e,t.resolve(n.anchor),t.resolve(n.head))}function Cc(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 Nc(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 Ac{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 Ml,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Rc),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=Oc(this),Tc(this),this.nodeViews=_c(this),this.docView=wa(this.state.doc,kc(this),pc(this),this.dom,this),this.domObserver=new gc(this,(e,t,n,r)=>Mc(this,e,t,n,r)),this.domObserver.start(),function(e){for(let t in xl){let n=xl[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!Al(e,t)||Nl(e,t)||!e.editable&&t.type in wl||n(e,t)},El[t]?{passive:!0}:void 0)}js&&e.dom.addEventListener("input",()=>null),Cl(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&&Cl(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Rc),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&&(jl(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=_c(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)&&Cl(this),this.editable=Oc(this),Tc(this);let a=pc(this),l=kc(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:Zs(e.dom)}}(this);if(o){this.domObserver.stop();let t=u&&(Is||Ps)&&!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=Ps?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=$l(this)),!i&&this.docView.update(e.doc,l,a,this)||(this.docView.updateOuterDeco(l),this.docView.destroy(),this.docView=wa(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 ws(t.node,t.offset,n.anchorNode,n.anchorOffset)}(this))?Fa(this,t):(qa(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;Xs(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 Qo){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&Ys(this,t.getBoundingClientRect(),e)}else Ys(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 Wl(e.slice,e.move,r<0?void 0:Qo.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(Is){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(Qs)return e.focus(Qs);let t=Zs(e);e.focus(null==Qs?{get preventScroll(){return Qs={preventScroll:!0},!0}}:void 0),Qs||(Qs=!1,Xs(t,0))}(this.dom),Fa(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 ra(this,e)}coordsAtPos(e,t=1){return aa(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 ma(this,t||this.state,e)}pasteHTML(e,t){return ql(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return ql(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return ll(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,[],pc(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,bs=null)}get isDestroyed(){return null==this.docView}dispatchEvent(e){return function(e,t){Nl(e,t)||!xl[t.type]||!e.editable&&t.type in wl||xl[t.type](e,t)}(this,e)}domSelectionRange(){let e=this.domSelection();return e?js&&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 bc(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?bc(e,n):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function kc(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"),[Ql.node(0,e.state.doc.content.size,t)]}function Tc(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:Ql.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Oc(e){return!e.someProp("editable",t=>!1===t(e.state))}function _c(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 Rc(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")}Ac.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};for(var Dc={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:"'"},Ic={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Lc="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Bc="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),zc=0;zc<10;zc++)Dc[48+zc]=Dc[96+zc]=String(zc);for(zc=1;zc<=24;zc++)Dc[zc+111]="F"+zc;for(zc=65;zc<=90;zc++)Dc[zc]=String.fromCharCode(zc+32),Ic[zc]=String.fromCharCode(zc);for(var Pc in Dc)Ic.hasOwnProperty(Pc)||(Ic[Pc]=Dc[Pc]);const Fc="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),jc="undefined"!=typeof navigator&&/Win/.test(navigator.platform);function $c(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);Fc?i=!0:n=!0}}return t&&(s="Alt-"+s),n&&(s="Ctrl-"+s),i&&(s="Meta-"+s),r&&(s="Shift-"+s),s}function Hc(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 Uc(e){let t=function(e){let t=Object.create(null);for(let n in e)t[$c(n)]=e[n];return t}(e);return function(e,n){let r,i=function(e){var t=!(Lc&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Bc&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?Ic:Dc)[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[Hc(i,n)];if(o&&o(e.state,e.dispatch,e))return!0;if(1==i.length&&" "!=i){if(n.shiftKey){let r=t[Hc(i,n,!1)];if(r&&r(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(jc&&n.ctrlKey&&n.altKey)&&(r=Dc[n.keyCode])&&r!=i){let i=t[Hc(r,n)];if(i&&i(e.state,e.dispatch,e))return!0}}return!1}}const qc=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function Vc(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}const Wc=(e,t,n)=>{let r=Vc(e,n);if(!r)return!1;let i=Xc(r);if(!i){let n=r.blockRange(),i=n&&wo(n);return null!=i&&(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let o=i.nodeBefore;if(pu(e,i,t,-1))return!0;if(0==r.parent.content.size&&(Yc(o,"end")||Qo.isSelectable(o)))for(let n=r.depth;;n--){let s=_o(e.doc,r.before(n),r.after(n),ei.empty);if(s&&s.slice.size<s.to-s.from){if(t){let n=e.tr.step(s);n.setSelection(Yc(o,"end")?Ko.findFrom(n.doc.resolve(n.mapping.map(i.pos,-1)),-1):Qo.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)},Kc=(e,t,n)=>{let r=Vc(e,n);if(!r)return!1;let i=Xc(r);return!!i&&Jc(e,i,t)},Gc=(e,t,n)=>{let r=Qc(e,n);if(!r)return!1;let i=nu(r);return!!i&&Jc(e,i,t)};function Jc(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=_o(e.doc,i,s,ei.empty);if(!a||a.from!=i||a instanceof go&&a.slice.size>=s-i)return!1;if(n){let t=e.tr.step(a);t.setSelection(Zo.create(t.doc,i)),n(t.scrollIntoView())}return!0}function Yc(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 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("backward",e):r.parentOffset>0)return!1;o=Xc(r)}let s=o&&o.nodeBefore;return!(!s||!Qo.isSelectable(s))&&(t&&t(e.tr.setSelection(Qo.create(e.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function Xc(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 Qc(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}const eu=(e,t,n)=>{let r=Qc(e,n);if(!r)return!1;let i=nu(r);if(!i)return!1;let o=i.nodeAfter;if(pu(e,i,t,1))return!0;if(0==r.parent.content.size&&(Yc(o,"start")||Qo.isSelectable(o))){let n=_o(e.doc,r.before(),r.after(),ei.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(Yc(o,"start")?Ko.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):Qo.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)},tu=(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=nu(r)}let s=o&&o.nodeAfter;return!(!s||!Qo.isSelectable(s))&&(t&&t(e.tr.setSelection(Qo.create(e.doc,o.pos)).scrollIntoView()),!0)};function nu(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 ru=(e,t)=>{let n,r=e.selection,i=r instanceof Qo;if(i){if(r.node.isTextblock||!Ao(e.doc,r.from))return!1;n=r.from}else if(n=To(e.doc,r.from,-1),null==n)return!1;if(t){let r=e.tr.join(n);i&&r.setSelection(Qo.create(r.doc,n-e.doc.resolve(n).nodeBefore.nodeSize)),t(r.scrollIntoView())}return!0},iu=(e,t)=>{let n,r=e.selection;if(r instanceof Qo){if(r.node.isTextblock||!Ao(e.doc,r.to))return!1;n=r.to}else if(n=To(e.doc,r.to,1),null==n)return!1;return t&&t(e.tr.join(n).scrollIntoView()),!0},ou=(e,t)=>{let{$from:n,$to:r}=e.selection,i=n.blockRange(r),o=i&&wo(i);return null!=o&&(t&&t(e.tr.lift(i,o).scrollIntoView()),!0)},su=(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 au(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 lu=(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=au(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(Ko.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},cu=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof ts||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=au(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(Zo.create(s.doc,n+1)),t(s.scrollIntoView())}return!0},uu=(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(No(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&wo(r);return null!=i&&(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)},du=(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(Qo.create(e.doc,n))),!0)};function pu(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&&!Ao(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=Gr.empty;for(let e=i.length-1;e>=0;e--)o=Gr.from(i[e].create(null,o));o=Gr.from(s.copy(o));let l=e.tr.step(new yo(t.pos-1,r,t.pos,r,new ei(o,1,0),i.length,!0)),c=l.doc.resolve(r+2*i.length);c.nodeAfter&&c.nodeAfter.type==s.type&&Ao(l.doc,c.pos)&&l.join(c.pos),n(l.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&l?null:Ko.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),p=d&&wo(d);if(null!=p&&p>=t.depth)return n&&n(e.tr.lift(d,p).scrollIntoView()),!0;if(c&&Yc(a,"start",!0)&&Yc(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=Gr.empty;for(let e=i.length-1;e>=0;e--)r=Gr.from(i[e].copy(r));n(e.tr.step(new yo(t.pos-i.length,t.pos+a.nodeSize,t.pos+l,t.pos+a.nodeSize-l,new ei(r,i.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function hu(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(Zo.create(t.doc,e<0?i.start(o):i.end(o)))),!0)}}const fu=hu(-1),mu=hu(1);function gu(e,t=null){return function(n,r){let{$from:i,$to:o}=n.selection,s=i.blockRange(o),a=s&&Eo(s,e,t);return!!a&&(r&&r(n.tr.wrap(s,a).scrollIntoView()),!0)}}function yu(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 vu(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 gi(e,e,t.depth),t.endIndex<t.parent.childCount&&(t=new gi(t.$from,s.resolve(t.$to.end(t.depth)),t.depth)),i=!0}let a=Eo(o,n,r,t);if(!a)return!1;e&&function(e,t,n,r,i){let o=Gr.empty;for(let e=n.length-1;e>=0;e--)o=Gr.from(n[e].type.create(n[e].attrs,o));e.step(new yo(t.start-(r?2:0),t.end,t.start,t.end,new ei(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&&No(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 bu(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 yo(o-1,s,o,s,new ei(Gr.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new gi(i.doc.resolve(r.$from.pos),i.doc.resolve(s),r.depth));const a=wo(r);if(null==a)return!1;i.lift(r,a);let l=i.doc.resolve(i.mapping.map(o,-1)-1);Ao(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?Gr.empty:Gr.from(i))))return!1;let d=o.pos,p=d+s.nodeSize;return r.step(new yo(d-(a?1:0),p+(l?1:0),d+1,p-1,new ei((a?Gr.empty:Gr.from(i.copy(Gr.empty))).append(l?Gr.empty:Gr.from(i.copy(Gr.empty))),a?0:1,l?0:1),a?0:1)),t(r.scrollIntoView()),!0}(t,n,o)))}}function xu(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=Gr.from(r?e.create():null),s=new ei(Gr.from(e.create(null,Gr.from(a.type.create(null,i)))),r?3:1,0),c=o.start,u=o.end;n(t.tr.step(new yo(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 wu=Object.defineProperty,Eu=(e,t)=>{for(var n in t)wu(e,n,{get:t[n],enumerable:!0})};function Mu(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 Su=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:Mu({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}},Cu=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 Nu=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&&Nu(r)}return e};function Au(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 Nu(n)}function ku(e,t,n){if(e instanceof vi||e instanceof Gr)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 Gr.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),ku("",t,n)}if(r){if(n.errorOnInvalidContent){let r=!1,i="";const o=new zi({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?Fi.fromSchema(o).parseSlice(Au(e),n.parseOptions):Fi.fromSchema(o).parse(Au(e),n.parseOptions),n.errorOnInvalidContent&&r)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${i}`)})}const r=Fi.fromSchema(t);return n.slice?r.parseSlice(Au(e),n.parseOptions).content:r.parse(Au(e),n.parseOptions)}return ku("",t,n)}function Tu(e,t,n={},r={}){return ku(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}function Ou(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 _u(e){return t=>Ou(t.$from,e)}function Ru(e,t,n){if(void 0===e.config[t]&&e.parent)return Ru(e.parent,t,n);if("function"==typeof e.config[t]){return e.config[t].bind({...n,parent:e.parent?Ru(e.parent,t,n):null})}return e.config[t]}function Du(e){return e.map(e=>{const t=Ru(e,"addExtensions",{name:e.name,options:e.options,storage:e.storage});return t?[e,...Du(t())]:e}).flat(10)}function Iu(e,t){const n=Ji.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function Lu(e){return"function"==typeof e}function Bu(e,t=void 0,...n){return Lu(e)?t?e.bind(t)(...n):e(...n):e}function zu(e){return{baseExtensions:e.filter(e=>"extension"===e.type),nodeExtensions:e.filter(e=>"node"===e.type),markExtensions:e.filter(e=>"mark"===e.type)}}function Pu(e){const t=[],{nodeExtensions:n,markExtensions:r}=zu(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=Ru(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=Ru(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 Fu(...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 ju(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)=>Fu(e,t),{})}function $u(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 Hu(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 Uu(e){return e.sort((e,t)=>{const n=Ru(e,"priority")||100,r=Ru(t,"priority")||100;return n>r?-1:n<r?1:0})}function qu(e){const t=Uu(Du(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 Vu(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 Wu(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function Ku(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 Gu(e,t){const n=Ku(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 Ju(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 Yu(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function Zu(e,t){const n=Yu("string"==typeof t?t:t.name,e.schema);return"node"===n?function(e,t){const n=Ju(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?Gu(e,t):{}}function Xu(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 Qu(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function ed(e,t,n={strict:!0}){const r=Object.keys(t);return!r.length||r.every(r=>n.strict?t[r]===e[r]:Qu(t[r])?t[r].test(e[r]):t[r]===e[r])}function td(e,t,n={}){return e.find(e=>e.type===t&&ed(Object.fromEntries(Object.keys(n).map(t=>[t,e.attrs[t]])),n))}function nd(e,t,n={}){return!!td(e,t,n)}function rd(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(!td([...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&&nd([...e.parent.child(o-1).marks],t,n);)o-=1,s-=e.parent.child(o).nodeSize;for(;a<e.parent.childCount&&nd([...e.parent.child(a).marks],t,n);)l+=e.parent.child(a).nodeSize,a+=1;return{from:s,to:l}}function id(e,t){return t.nodes[e]||t.marks[e]||null}function od(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 sd(e,t,n={}){const{empty:r,ranges:i}=e.selection,o=t?Ku(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>!o||o.name===e.type.name).find(e=>ed(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=>ed(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 ad(e,t,n={}){const{from:r,to:i,empty:o}=e.selection,s=t?Ju(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=>ed(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 ld(e,t){return Array.isArray(t)?t.some(t=>("string"==typeof t?t:t.name)===e.name):t}function cd(e,t){const{nodeExtensions:n}=zu(t),r=n.find(t=>t.name===e);if(!r)return!1;const i=Bu(Ru(r,"group",{name:r.name,options:r.options,storage:r.storage}));return"string"==typeof i&&i.split(" ").includes("list")}function ud(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&&(ud(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function dd(e){return e instanceof Zo}function pd(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function hd(e,t=null){if(!t)return null;const n=Ko.atStart(e),r=Ko.atEnd(e);if("start"===t||!0===t)return n;if("end"===t)return r;const i=n.from,o=r.to;return"all"===t?Zo.create(e,pd(0,i,o),pd(e.content.size,i,o)):Zo.create(e,pd(t,i,o),pd(t,i,o))}var fd=class{constructor(e){this.find=e.find,this.handler=e.handler}};function md(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(Qu(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=Mu({state:l.state,transaction:s}),p={from:r-(t[0].length-o.length),to:i},{commands:h,chain:f,can:m}=new Su({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 gd(e){const{editor:t,rules:n}=e,r=new hs({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=Iu(Gr.from(e),o.schema));const{from:i}=a,s=i+e.length;md({editor:t,from:i,to:s,text:e,rules:n,plugin:r})}),e.selectionSet||e.docChanged?null:i}},props:{handleTextInput:(e,i,o,s)=>md({editor:t,from:i,to:o,text:s,rules:n,plugin:r}),handleDOMEvents:{compositionend:e=>(setTimeout(()=>{const{$cursor:i}=e.state.selection;i&&md({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&&md({editor:t,from:o.pos,to:o.pos,text:"\n",rules:n,plugin:r})}},isInputRules:!0});return r}function yd(e){return"Object"===function(e){return Object.prototype.toString.call(e).slice(8,-1)}(e)&&(e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype)}function vd(e,t){const n={...e};return yd(e)&&yd(t)&&Object.keys(t).forEach(r=>{yd(t[r])&&yd(e[r])?n[r]=vd(e[r],t[r]):n[r]=t[r]}),n}var bd=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{...Bu(Ru(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Bu(Ru(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(e={}){const t=this.extend({...this.config,addOptions:()=>vd(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}},xd=class e extends bd{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 wd(e){const{editor:t,state:n,from:r,to:i,rule:o,pasteEvent:s,dropEvent:a}=e,{commands:l,chain:c,can:u}=new Su({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(Qu(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 Ed=null;function Md(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=Mu({state:e,transaction:l});if(wd({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}},c=n.map(e=>new hs({view(e){const n=n=>{var r;i=(null==(r=e.dom.parentElement)?void 0:r.contains(n.target))?e.dom.parentElement:null,i&&(Ed=t)},r=()=>{Ed&&(Ed=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=Ed;(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=Iu(Gr.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}}));return c}var Sd=class{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=qu(e),this.schema=function(e,t){var n;const r=Pu(e),{nodeExtensions:i,markExtensions:o}=zu(e),s=null==(n=i.find(e=>Ru(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=Ru(t,"extendNodeSchema",o);return{...e,...r?r(n):{}}},{}),a=Hu({...s,content:Bu(Ru(n,"content",o)),marks:Bu(Ru(n,"marks",o)),group:Bu(Ru(n,"group",o)),inline:Bu(Ru(n,"inline",o)),atom:Bu(Ru(n,"atom",o)),selectable:Bu(Ru(n,"selectable",o)),draggable:Bu(Ru(n,"draggable",o)),code:Bu(Ru(n,"code",o)),whitespace:Bu(Ru(n,"whitespace",o)),linebreakReplacement:Bu(Ru(n,"linebreakReplacement",o)),defining:Bu(Ru(n,"defining",o)),isolating:Bu(Ru(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=Bu(Ru(n,"parseHTML",o));l&&(a.parseDOM=l.map(e=>$u(e,i)));const c=Ru(n,"renderHTML",o);c&&(a.toDOM=e=>c({node:e,HTMLAttributes:ju(e,i)}));const u=Ru(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=Ru(t,"extendMarkSchema",o);return{...e,...r?r(n):{}}},{}),a=Hu({...s,inclusive:Bu(Ru(n,"inclusive",o)),excludes:Bu(Ru(n,"excludes",o)),group:Bu(Ru(n,"group",o)),spanning:Bu(Ru(n,"spanning",o)),code:Bu(Ru(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=Bu(Ru(n,"parseHTML",o));l&&(a.parseDOM=l.map(e=>$u(e,i)));const c=Ru(n,"renderHTML",o);return c&&(a.toDOM=e=>c({mark:e,HTMLAttributes:ju(e,i)})),[n.name,a]}));return new zi({topNode:s,nodes:a,marks:l})}(this.extensions,t),this.setupExtensions()}get commands(){return this.extensions.reduce((e,t)=>{const n=Ru(t,"addCommands",{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:id(t.name,this.schema)});return n?{...e,...n()}:e},{})}get plugins(){const{editor:e}=this,t=Uu([...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:id(t.name,this.schema)},o=[],s=Ru(t,"addKeyboardShortcuts",i);let a={};if("mark"===t.type&&Ru(t,"exitable",i)&&(a.ArrowRight=()=>xd.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 hs({props:{handleKeyDown:Uc(a)}});o.push(l);const c=Ru(t,"addInputRules",i);ld(t,e.options.enableInputRules)&&c&&n.push(...c());const u=Ru(t,"addPasteRules",i);ld(t,e.options.enablePasteRules)&&u&&r.push(...u());const d=Ru(t,"addProseMirrorPlugins",i);if(d){const e=d();o.push(...e)}return o}).flat();return[gd({editor:e,rules:n}),...Md({editor:e,rules:r}),...i]}get attributes(){return Pu(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=zu(this.extensions);return Object.fromEntries(t.filter(e=>!!Ru(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:Ju(t.name,this.schema)},i=Ru(t,"addNodeView",r);if(!i)return[];return[t.name,(r,o,s,a,l)=>{const c=ju(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}=zu(this.extensions);return Object.fromEntries(t.filter(e=>!!Ru(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:Ku(t.name,this.schema)},i=Ru(t,"addMarkView",r);if(!i)return[];return[t.name,(r,o,s)=>{const a=ju(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:id(e.name,this.schema)};if("mark"===e.type){(null==(t=Bu(Ru(e,"keepOnSplit",n)))||t)&&this.splittableMarks.push(e.name)}const r=Ru(e,"onBeforeCreate",n),i=Ru(e,"onCreate",n),o=Ru(e,"onUpdate",n),s=Ru(e,"onSelectionUpdate",n),a=Ru(e,"onTransaction",n),l=Ru(e,"onFocus",n),c=Ru(e,"onBlur",n),u=Ru(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)})}};Sd.resolve=qu,Sd.sort=Uu,Sd.flatten=Du;Eu({},{ClipboardTextSerializer:()=>Nd,Commands:()=>Fp,Delete:()=>jp,Drop:()=>$p,Editable:()=>Hp,FocusEvents:()=>qp,Keymap:()=>Vp,Paste:()=>Wp,Tabindex:()=>Kp,focusEventsPluginKey:()=>Up});var Cd=class e extends bd{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)}},Nd=Cd.create({name:"clipboardTextSerializer",addOptions:()=>({blockSeparator:void 0}),addProseMirrorPlugins(){return[new hs({key:new gs("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=Wu(n);return Vu(r,{from:s,to:a},{...void 0!==this.options.blockSeparator?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),Ad={};Eu(Ad,{blur:()=>kd,clearContent:()=>Td,clearNodes:()=>Od,command:()=>_d,createParagraphNear:()=>Rd,cut:()=>Dd,deleteCurrentNode:()=>Id,deleteNode:()=>Ld,deleteRange:()=>Bd,deleteSelection:()=>zd,enter:()=>Pd,exitCode:()=>Fd,extendMarkRange:()=>jd,first:()=>$d,focus:()=>qd,forEach:()=>Vd,insertContent:()=>Wd,insertContentAt:()=>Kd,joinBackward:()=>Yd,joinDown:()=>Jd,joinForward:()=>Zd,joinItemBackward:()=>Xd,joinItemForward:()=>Qd,joinTextblockBackward:()=>ep,joinTextblockForward:()=>tp,joinUp:()=>Gd,keyboardShortcut:()=>rp,lift:()=>ip,liftEmptyBlock:()=>op,liftListItem:()=>sp,newlineInCode:()=>ap,resetAttributes:()=>cp,scrollIntoView:()=>up,selectAll:()=>dp,selectNodeBackward:()=>pp,selectNodeForward:()=>hp,selectParentNode:()=>fp,selectTextblockEnd:()=>mp,selectTextblockStart:()=>gp,setContent:()=>yp,setMark:()=>vp,setMeta:()=>bp,setNode:()=>xp,setNodeSelection:()=>wp,setTextSelection:()=>Ep,sinkListItem:()=>Mp,splitBlock:()=>Cp,splitListItem:()=>Np,toggleList:()=>Tp,toggleMark:()=>Op,toggleNode:()=>_p,toggleWrap:()=>Rp,undoInputRule:()=>Dp,unsetAllMarks:()=>Ip,unsetMark:()=>Lp,updateAttributes:()=>Bp,wrapIn:()=>zp,wrapInList:()=>Pp});var kd=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(t.dom.blur(),null==(n=null==window?void 0:window.getSelection())||n.removeAllRanges())}),!0),Td=(e=!0)=>({commands:t})=>t.setContent("",{emitUpdate:e}),Od=()=>({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=wo(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)},_d=e=>t=>e(t),Rd=()=>({state:e,dispatch:t})=>cu(e,t),Dd=(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 Zo(r.doc.resolve(Math.max(s-1,0)))),!0},Id=()=>({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},Ld=e=>({tr:t,state:n,dispatch:r})=>{const i=Ju(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},Bd=e=>({tr:t,dispatch:n})=>{const{from:r,to:i}=e;return n&&t.delete(r,i),!0},zd=()=>({state:e,dispatch:t})=>qc(e,t),Pd=()=>({commands:e})=>e.keyboardShortcut("Enter"),Fd=()=>({state:e,dispatch:t})=>lu(e,t),jd=(e,t={})=>({tr:n,state:r,dispatch:i})=>{const o=Ku(e,r.schema),{doc:s,selection:a}=n,{$from:l,from:c,to:u}=a;if(i){const e=rd(l,o,t);if(e&&e.from<=c&&e.to>=u){const t=Zo.create(s,e.from,e.to);n.setSelection(t)}}return!0},$d=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 Hd(){return"Android"===navigator.platform||/android/i.test(navigator.userAgent)}function Ud(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var qd=(e=null,t={})=>({editor:n,view:r,tr:i,dispatch:o})=>{t={scrollIntoView:!0,...t};const s=()=>{(Ud()||Hd())&&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&&!dd(n.state.selection))return s(),!0;const a=hd(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},Vd=(e,t)=>n=>e.every((e,r)=>t(e,{...n,index:r})),Wd=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),Kd=(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{ku(t,o.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(e){l(e)}try{i=ku(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 Gr){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 go||i instanceof yo))return;const o=e.mapping.maps[r];let s=0;o.forEach((e,t,n,r)=>{0===s&&(s=r)}),e.setSelection(Ko.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},Gd=()=>({state:e,dispatch:t})=>ru(e,t),Jd=()=>({state:e,dispatch:t})=>iu(e,t),Yd=()=>({state:e,dispatch:t})=>Wc(e,t),Zd=()=>({state:e,dispatch:t})=>eu(e,t),Xd=()=>({state:e,dispatch:t,tr:n})=>{try{const r=To(e.doc,e.selection.$from.pos,-1);return null!=r&&(n.join(r,2),t&&t(n),!0)}catch(e){return!1}},Qd=()=>({state:e,dispatch:t,tr:n})=>{try{const r=To(e.doc,e.selection.$from.pos,1);return null!=r&&(n.join(r,2),t&&t(n),!0)}catch(e){return!1}},ep=()=>({state:e,dispatch:t})=>Kc(e,t),tp=()=>({state:e,dispatch:t})=>Gc(e,t);function np(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}var rp=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}`);Ud()||np()?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},ip=(e,t={})=>({state:n,dispatch:r})=>!!ad(n,Ju(e,n.schema),t)&&ou(n,r),op=()=>({state:e,dispatch:t})=>uu(e,t),sp=e=>({state:t,dispatch:n})=>bu(Ju(e,t.schema))(t,n),ap=()=>({state:e,dispatch:t})=>su(e,t);function lp(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 cp=(e,t)=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null;const a=Yu("string"==typeof e?e:e.name,r.schema);return!!a&&("node"===a&&(o=Ju(e,r.schema)),"mark"===a&&(s=Ku(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,lp(e.attrs,t)),s&&e.marks.length&&e.marks.forEach(i=>{s===i.type&&n.addMark(r,r+e.nodeSize,s.create(lp(i.attrs,t)))})})}),!0)},up=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),dp=()=>({tr:e,dispatch:t})=>{if(t){const t=new ts(e.doc);e.setSelection(t)}return!0},pp=()=>({state:e,dispatch:t})=>Zc(e,t),hp=()=>({state:e,dispatch:t})=>tu(e,t),fp=()=>({state:e,dispatch:t})=>du(e,t),mp=()=>({state:e,dispatch:t})=>mu(e,t),gp=()=>({state:e,dispatch:t})=>fu(e,t),yp=(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=Tu(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 vp=(e,t={})=>({tr:n,state:r,dispatch:i})=>{const{selection:o}=n,{empty:s,ranges:a}=o,l=Ku(e,r.schema);if(i)if(s){const e=Gu(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(dd(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)},bp=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),xp=(e,t={})=>({state:n,dispatch:r,chain:i})=>{const o=Ju(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})=>!!yu(o,{...s,...t})(n)||e.clearNodes()).command(({state:e})=>yu(o,{...s,...t})(e,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},wp=e=>({tr:t,dispatch:n})=>{if(n){const{doc:n}=t,r=pd(e,0,n.content.size),i=Qo.create(n,r);t.setSelection(i)}return!0},Ep=e=>({tr:t,dispatch:n})=>{if(n){const{doc:n}=t,{from:r,to:i}="number"==typeof e?{from:e,to:e}:e,o=Zo.atStart(n).from,s=Zo.atEnd(n).to,a=pd(r,o,s),l=pd(i,o,s),c=Zo.create(n,a,l);t.setSelection(c)}return!0},Mp=e=>({state:t,dispatch:n})=>xu(Ju(e,t.schema))(t,n);function Sp(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 Cp=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:i})=>{const{selection:o,doc:s}=t,{$from:a,$to:l}=o,c=od(i.extensionManager.attributes,a.node().type.name,a.node().attrs);if(o instanceof Qo&&o.node.isBlock)return!(!a.parentOffset||!No(s,a.pos))&&(r&&(e&&Sp(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=No(t.doc,t.mapping.map(a.pos),1,p);if(p||h||!No(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 Zo&&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&&Sp(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return h},Np=(e,t={})=>({tr:n,state:r,dispatch:i,editor:o})=>{var s;const a=Ju(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=Gr.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=Gr.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={...od(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(Gr.from(a.createAndFill(null,c)||void 0));const u=l.before(l.depth-(r-1));n.replace(u,l.after(-i),new ei(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(Zo.near(n.doc.resolve(d))),n.scrollIntoView()}return!0}const h=c.pos===l.end()?d.contentMatchAt(0).defaultType:null,f={...od(p,d.type.name,d.attrs),...t},m={...od(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(!No(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},Ap=(e,t)=>{const n=_u(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)||!Ao(e.doc,n.pos)||(e.join(n.pos),!0)},kp=(e,t)=>{const n=_u(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)||!Ao(e.doc,r)||(e.join(r),!0)},Tp=(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=Ju(e,s.schema),f=Ju(t,s.schema),{selection:m,storedMarks:g}=s,{$from:y,$to:v}=m,b=y.blockRange(v),x=g||m.$to.parentOffset&&m.$from.marks();if(!b)return!1;const w=_u(e=>cd(e.type.name,d))(m);if(b.depth>=1&&w&&b.depth-w.depth<=1){if(w.node.type===h)return c.liftListItem(f);if(cd(w.node.type.name,d)&&h.validContent(w.node.content)&&a)return l().command(()=>(o.setNodeMarkup(w.pos,h),!0)).command(()=>Ap(o,h)).command(()=>kp(o,h)).run()}return n&&x&&a?l().command(()=>{const e=u().wrapInList(h,r),t=x.filter(e=>p.includes(e.type.name));return o.ensureMarks(t),!!e||c.clearNodes()}).wrapInList(h,r).command(()=>Ap(o,h)).command(()=>kp(o,h)).run():l().command(()=>!!u().wrapInList(h,r)||c.clearNodes()).wrapInList(h,r).command(()=>Ap(o,h)).command(()=>kp(o,h)).run()},Op=(e,t={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:o=!1}=n,s=Ku(e,r.schema);return sd(r,s,t)?i.unsetMark(s,{extendEmptyMarkRange:o}):i.setMark(s,t)},_p=(e,t,n={})=>({state:r,commands:i})=>{const o=Ju(e,r.schema),s=Ju(t,r.schema),a=ad(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})},Rp=(e,t={})=>({state:n,commands:r})=>{const i=Ju(e,n.schema);return ad(n,i,t)?r.lift(i):r.wrapIn(i,t)},Dp=()=>({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},Ip=()=>({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},Lp=(e,t={})=>({tr:n,state:r,dispatch:i})=>{var o;const{extendEmptyMarkRange:s=!1}=t,{selection:a}=n,l=Ku(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=rd(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},Bp=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null;const a=Yu("string"==typeof e?e:e.name,r.schema);return!!a&&("node"===a&&(o=Ju(e,r.schema)),"mark"===a&&(s=Ku(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)},zp=(e,t={})=>({state:n,dispatch:r})=>gu(Ju(e,n.schema),t)(n,r),Pp=(e,t={})=>({state:n,dispatch:r})=>vu(Ju(e,n.schema),t)(n,r),Fp=Cd.create({name:"commands",addCommands:()=>({...Ad})}),jp=Cd.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 Vo(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}})})}),Xu(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 ho){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()}}),$p=Cd.create({name:"drop",addProseMirrorPlugins(){return[new hs({key:new gs("tiptapDrop"),props:{handleDrop:(e,t,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),Hp=Cd.create({name:"editable",addProseMirrorPlugins(){return[new hs({key:new gs("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Up=new gs("focusEvents"),qp=Cd.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:e}=this;return[new hs({key:Up,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}}}})]}}),Vp=Cd.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:Ko.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 Ud()||np()?i:r},addProseMirrorPlugins(){return[new hs({key:new gs("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=Ko.atStart(t.doc).from,c=Ko.atEnd(t.doc).to;if(o||!(s===l&&a===c))return;if(!ud(n.doc))return;const u=n.tr,d=Mu({state:n,transaction:u}),{commands:p}=new Su({editor:this.editor,state:d});return p.clearNodes(),u.steps.length?u:void 0}})]}}),Wp=Cd.create({name:"paste",addProseMirrorPlugins(){return[new hs({key:new gs("tiptapPaste"),props:{handlePaste:(e,t,n)=>{this.editor.emit("paste",{editor:this.editor,event:t,slice:n})}}})]}}),Kp=Cd.create({name:"tabindex",addProseMirrorPlugins(){return[new hs({key:new gs("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Gp=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 Jp=class extends Cu{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=hd(t,this.options.autofocus);this.editorState=ds.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=Lu(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?[Hp,Nd.configure({blockSeparator:null==(t=null==(e=this.options.coreExtensionOptions)?void 0:e.clipboardTextSerializer)?void 0:t.blockSeparator}),Fp,qp,Vp,Kp,$p,Wp,jp].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 Sd(n,this)}createCommandManager(){this.commandManager=new Su({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=Tu(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=Tu(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return e}createView(e){var t;this.editorView=new Ac(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 Zu(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 ad(e,null,n)||sd(e,null,n);const r=Yu(t,e.schema);return"node"===r?ad(e,t,n):"mark"===r&&sd(e,t,n)}(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Iu(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t="\n\n",textSerializers:n={}}=e||{};return function(e,t){return Vu(e,{from:0,to:e.content.size},t)}(this.state.doc,{blockSeparator:t,textSerializers:{...Wu(this.schema),...n}})}get isEmpty(){return ud(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 Gp(t,this)}get $doc(){return this.$pos(0)}};function Yp(e){return new fd({find:e.find,handler:({state:t,range:n,match:r})=>{const i=Bu(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 Zp=class e extends bd{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)}},Xp=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=Qo.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=Qo.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&&(Ud()||Hd())&&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})}},Qp=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},eh={exports:{}},th={};var nh=e,rh=Nr.exports;var ih="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},oh=rh.useSyncExternalStore,sh=nh.useRef,ah=nh.useEffect,lh=nh.useMemo,ch=nh.useDebugValue;th.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var o=sh(null);if(null===o.current){var s={hasValue:!1,value:null};o.current=s}else s=o.current;o=lh(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,ih(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=oh(e,o[0],o[1]);return ah(function(){s.hasValue=!0,s.value=a},[a]),ch(a),a},eh.exports=th;const uh=e,dh=e,ph=e,{createContext:hh}=e,{forwardRef:fh}=e,{useDebugValue:mh}=e,{useEffect:gh}=e,{useRef:yh}=e,{useState:vh}=e,{useDebugValue:bh}=e,{useEffect:xh}=e,{useLayoutEffect:wh}=e,{useState:Eh}=e,{createContext:Mh}=e,{useContext:Sh}=e,{version:Ch}=e,{createElement:Nh}=e,{createRef:Ah}=e,{memo:kh}=e,Th=t,{flushSync:Oh}=t;var _h=(...e)=>t=>{e.forEach(e=>{"function"==typeof e?e(t):e&&(e.current=t)})},Rh=({contentComponent:e})=>{const t=Nr.exports.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getServerSnapshot);return Br.exports.jsx(Br.exports.Fragment,{children:Object.values(t)})};var Dh=class extends uh.Component{constructor(e){var t;super(e),this.editorContentRef=uh.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]:Th.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 Br.exports.jsxs(Br.exports.Fragment,{children:[Br.exports.jsx("div",{ref:_h(t,this.editorContentRef),...n}),(null==e?void 0:e.contentComponent)&&Br.exports.jsx(Rh,{contentComponent:e.contentComponent})]})}},Ih=fh((e,t)=>{const n=uh.useMemo(()=>Math.floor(4294967295*Math.random()).toString(),[e.editor]);return uh.createElement(Dh,{key:n,innerRef:t,...e})}),Lh=uh.memo(Ih),Bh="undefined"!=typeof window?wh:xh,zh=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 Ph(e){var t;const[n]=Eh(()=>new zh(e.editor)),r=eh.exports.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,e.selector,null!=(t=e.equalityFn)?t:Qp);return Bh(()=>n.watch(e.editor),[e.editor,n]),bh(r),r}var Fh="undefined"==typeof window,jh=Fh||Boolean("undefined"!=typeof window&&window.next),$h=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?Fh||jh?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 Jp(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)}};hh({editor:null}).Consumer;var Hh=Mh({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),Uh=dh.forwardRef((e,t)=>{const{onDragStart:n}=Sh(Hh),r=e.as||"div";return Br.exports.jsx(r,{...e,ref:t,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...e.style}})});function qh(e){return!("function"!=typeof e||!e.prototype||!e.prototype.isReactComponent)}function Vh(e){return!("object"!=typeof e||!e.$$typeof||"Symbol(react.forward_ref)"!==e.$$typeof.toString()&&"react.forward_ref"!==e.$$typeof.description)}var Wh=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?Oh(()=>{this.render()}):queueMicrotask(()=>{this.render()})}render(){var e;const t=this.component,n=this.props,r=this.editor,i=function(){try{if(Ch)return parseInt(Ch.split(".")[0],10)>=19}catch(e){}return!1}(),o=function(e){if(qh(e))return!0;if(Vh(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 qh(t)||Vh(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=Br.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])})}};ph.createContext({markViewContentRef:()=>{}});var Kh=class extends Xp{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:Ah()};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=kh(e=>Br.exports.jsx(Hh.Provider,{value:t,children:Nh(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 Wh(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=ju(this.node,t);e=this.options.attrs({node:this.node,HTMLAttributes:n})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}};function Gh(e,t){return n=>n.editor.contentComponent?new Kh(e,n,t):{}}var Jh=Object.defineProperty,Yh=(e,t)=>{for(var n in t)Jh(e,n,{get:t[n],enumerable:!0})};function Zh(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 Xh=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:Zh({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}},Qh={};Yh(Qh,{blur:()=>ef,clearContent:()=>tf,clearNodes:()=>nf,command:()=>rf,createParagraphNear:()=>of,cut:()=>sf,deleteCurrentNode:()=>af,deleteNode:()=>cf,deleteRange:()=>uf,deleteSelection:()=>df,enter:()=>pf,exitCode:()=>hf,extendMarkRange:()=>bf,first:()=>xf,focus:()=>Cf,forEach:()=>Nf,insertContent:()=>Af,insertContentAt:()=>_f,joinBackward:()=>If,joinDown:()=>Df,joinForward:()=>Lf,joinItemBackward:()=>Bf,joinItemForward:()=>zf,joinTextblockBackward:()=>Pf,joinTextblockForward:()=>Ff,joinUp:()=>Rf,keyboardShortcut:()=>$f,lift:()=>Uf,liftEmptyBlock:()=>qf,liftListItem:()=>Vf,newlineInCode:()=>Wf,resetAttributes:()=>Jf,scrollIntoView:()=>Yf,selectAll:()=>Zf,selectNodeBackward:()=>Xf,selectNodeForward:()=>Qf,selectParentNode:()=>em,selectTextblockEnd:()=>tm,selectTextblockStart:()=>nm,setContent:()=>rm,setMark:()=>bm,setMeta:()=>xm,setNode:()=>wm,setNodeSelection:()=>Em,setTextDirection:()=>Mm,setTextSelection:()=>Sm,sinkListItem:()=>Cm,splitBlock:()=>Am,splitListItem:()=>km,toggleList:()=>_m,toggleMark:()=>Rm,toggleNode:()=>Dm,toggleWrap:()=>Im,undoInputRule:()=>Lm,unsetAllMarks:()=>Bm,unsetMark:()=>zm,unsetTextDirection:()=>Pm,updateAttributes:()=>Fm,wrapIn:()=>jm,wrapInList:()=>$m});var ef=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(t.dom.blur(),null==(n=null==window?void 0:window.getSelection())||n.removeAllRanges())}),!0),tf=(e=!0)=>({commands:t})=>t.setContent("",{emitUpdate:e}),nf=()=>({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=wo(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)},rf=e=>t=>e(t),of=()=>({state:e,dispatch:t})=>cu(e,t),sf=(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 Zo(r.doc.resolve(Math.max(s-1,0)))),!0},af=()=>({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 lf(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 cf=e=>({tr:t,state:n,dispatch:r})=>{const i=lf(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},uf=e=>({tr:t,dispatch:n})=>{const{from:r,to:i}=e;return n&&t.delete(r,i),!0},df=()=>({state:e,dispatch:t})=>qc(e,t),pf=()=>({commands:e})=>e.keyboardShortcut("Enter"),hf=()=>({state:e,dispatch:t})=>lu(e,t);function ff(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 mf(e,t,n={}){return e.find(e=>e.type===t&&ff(Object.fromEntries(Object.keys(n).map(t=>[t,e.attrs[t]])),n))}function gf(e,t,n={}){return!!mf(e,t,n)}function yf(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(!mf([...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&&gf([...e.parent.child(o-1).marks],t,n);)o-=1,s-=e.parent.child(o).nodeSize;for(;a<e.parent.childCount&&gf([...e.parent.child(a).marks],t,n);)l+=e.parent.child(a).nodeSize,a+=1;return{from:s,to:l}}function vf(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 bf=(e,t={})=>({tr:n,state:r,dispatch:i})=>{const o=vf(e,r.schema),{doc:s,selection:a}=n,{$from:l,from:c,to:u}=a;if(i){const e=yf(l,o,t);if(e&&e.from<=c&&e.to>=u){const t=Zo.create(s,e.from,e.to);n.setSelection(t)}}return!0},xf=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 wf(e){return e instanceof Zo}function Ef(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function Mf(){return"Android"===navigator.platform||/android/i.test(navigator.userAgent)}function Sf(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var Cf=(e=null,t={})=>({editor:n,view:r,tr:i,dispatch:o})=>{t={scrollIntoView:!0,...t};const s=()=>{(Sf()||Mf())&&r.dom.focus(),"undefined"==typeof navigator||!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)||Sf()||Mf()||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&&!wf(n.state.selection))return s(),!0;const a=function(e,t=null){if(!t)return null;const n=Ko.atStart(e),r=Ko.atEnd(e);if("start"===t||!0===t)return n;if("end"===t)return r;const i=n.from,o=r.to;return"all"===t?Zo.create(e,Ef(0,i,o),Ef(e.content.size,i,o)):Zo.create(e,Ef(t,i,o),Ef(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},Nf=(e,t)=>n=>e.every((e,r)=>t(e,{...n,index:r})),Af=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),kf=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&&kf(r)}return e};function Tf(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 kf(n)}function Of(e,t,n){if(e instanceof vi||e instanceof Gr)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 Gr.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),Of("",t,n)}if(r){if(n.errorOnInvalidContent){let r=!1,i="";const o=new zi({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?Fi.fromSchema(o).parseSlice(Tf(e),n.parseOptions):Fi.fromSchema(o).parse(Tf(e),n.parseOptions),n.errorOnInvalidContent&&r)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${i}`)})}const r=Fi.fromSchema(t);return n.slice?r.parseSlice(Tf(e),n.parseOptions).content:r.parse(Tf(e),n.parseOptions)}return Of("",t,n)}var _f=(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{Of(t,o.schema,{parseOptions:l,errorOnInvalidContent:!0})}catch(e){a(e)}try{i=Of(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 Gr){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 go||i instanceof yo))return;const o=e.mapping.maps[r];let s=0;o.forEach((e,t,n,r)=>{0===s&&(s=r)}),e.setSelection(Ko.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},Rf=()=>({state:e,dispatch:t})=>ru(e,t),Df=()=>({state:e,dispatch:t})=>iu(e,t),If=()=>({state:e,dispatch:t})=>Wc(e,t),Lf=()=>({state:e,dispatch:t})=>eu(e,t),Bf=()=>({state:e,dispatch:t,tr:n})=>{try{const r=To(e.doc,e.selection.$from.pos,-1);return null!=r&&(n.join(r,2),t&&t(n),!0)}catch(e){return!1}},zf=()=>({state:e,dispatch:t,tr:n})=>{try{const r=To(e.doc,e.selection.$from.pos,1);return null!=r&&(n.join(r,2),t&&t(n),!0)}catch(e){return!1}},Pf=()=>({state:e,dispatch:t})=>Kc(e,t),Ff=()=>({state:e,dispatch:t})=>Gc(e,t);function jf(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}var $f=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}`);Sf()||jf()?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 Hf(e,t,n={}){const{from:r,to:i,empty:o}=e.selection,s=t?lf(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=>ff(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 Uf=(e,t={})=>({state:n,dispatch:r})=>!!Hf(n,lf(e,n.schema),t)&&ou(n,r),qf=()=>({state:e,dispatch:t})=>uu(e,t),Vf=e=>({state:t,dispatch:n})=>bu(lf(e,t.schema))(t,n),Wf=()=>({state:e,dispatch:t})=>su(e,t);function Kf(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function Gf(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 Jf=(e,t)=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null;const a=Kf("string"==typeof e?e:e.name,r.schema);if(!a)return!1;"node"===a&&(o=lf(e,r.schema)),"mark"===a&&(s=vf(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,Gf(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(Gf(o.attrs,t))))})})}),l},Yf=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),Zf=()=>({tr:e,dispatch:t})=>{if(t){const t=new ts(e.doc);e.setSelection(t)}return!0},Xf=()=>({state:e,dispatch:t})=>Zc(e,t),Qf=()=>({state:e,dispatch:t})=>tu(e,t),em=()=>({state:e,dispatch:t})=>du(e,t),tm=()=>({state:e,dispatch:t})=>mu(e,t),nm=()=>({state:e,dispatch:t})=>fu(e,t);var rm=(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 Of(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 im(e,t){const n=vf(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 om(e,t){const n=new Vo(e);return t.forEach(e=>{e.steps.forEach(e=>{n.step(e)})}),n}function sm(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 am(e,t,n){if(void 0===e.config[t]&&e.parent)return am(e.parent,t,n);if("function"==typeof e.config[t]){return e.config[t].bind({...n,parent:e.parent?am(e.parent,t,n):null})}return e.config[t]}function lm(e,t=void 0,...n){return function(e){return"function"==typeof e}(e)?t?e.bind(t)(...n):e(...n):e}function cm(e){return{baseExtensions:e.filter(e=>"extension"===e.type),nodeExtensions:e.filter(e=>"node"===e.type),markExtensions:e.filter(e=>"mark"===e.type)}}function um(...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 dm(e,t){const n=Kf("string"==typeof t?t:t.name,e.schema);return"node"===n?function(e,t){const n=lf(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?im(e,t):{}}function pm(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 hm(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}})})}),pm(r)}function fm(e,t,n){const r=[];return e===t?n.resolve(e).marks().forEach(t=>{const i=yf(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 mm(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 gm(e,t){const{nodeExtensions:n}=cm(t),r=n.find(t=>t.name===e);if(!r)return!1;const i=lm(am(r,"group",{name:r.name,options:r.options,storage:r.storage}));return"string"==typeof i&&i.split(" ").includes("list")}function ym(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&&(ym(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function vm(e){return e instanceof Qo}var bm=(e,t={})=>({tr:n,state:r,dispatch:i})=>{const{selection:o}=n,{empty:s,ranges:a}=o,l=vf(e,r.schema);if(i)if(s){const e=im(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(wf(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)},xm=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),wm=(e,t={})=>({state:n,dispatch:r,chain:i})=>{const o=lf(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})=>!!yu(o,{...s,...t})(n)||e.clearNodes()).command(({state:e})=>yu(o,{...s,...t})(e,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Em=e=>({tr:t,dispatch:n})=>{if(n){const{doc:n}=t,r=Ef(e,0,n.content.size),i=Qo.create(n,r);t.setSelection(i)}return!0},Mm=(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},Sm=e=>({tr:t,dispatch:n})=>{if(n){const{doc:n}=t,{from:r,to:i}="number"==typeof e?{from:e,to:e}:e,o=Zo.atStart(n).from,s=Zo.atEnd(n).to,a=Ef(r,o,s),l=Ef(i,o,s),c=Zo.create(n,a,l);t.setSelection(c)}return!0},Cm=e=>({state:t,dispatch:n})=>xu(lf(e,t.schema))(t,n);function Nm(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 Am=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:i})=>{const{selection:o,doc:s}=t,{$from:a,$to:l}=o,c=mm(i.extensionManager.attributes,a.node().type.name,a.node().attrs);if(o instanceof Qo&&o.node.isBlock)return!(!a.parentOffset||!No(s,a.pos))&&(r&&(e&&Nm(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=No(t.doc,t.mapping.map(a.pos),1,p);if(p||h||!No(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 Zo&&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&&Nm(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return h},km=(e,t={})=>({tr:n,state:r,dispatch:i,editor:o})=>{var s;const a=lf(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=Gr.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=Gr.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={...mm(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(Gr.from(a.createAndFill(null,c)||void 0));const u=l.before(l.depth-(r-1));n.replace(u,l.after(-i),new ei(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(Zo.near(n.doc.resolve(d))),n.scrollIntoView()}return!0}const h=c.pos===l.end()?d.contentMatchAt(0).defaultType:null,f={...mm(p,d.type.name,d.attrs),...t},m={...mm(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(!No(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},Tm=(e,t)=>{const n=sm(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)||!Ao(e.doc,n.pos)||(e.join(n.pos),!0)},Om=(e,t)=>{const n=sm(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)||!Ao(e.doc,r)||(e.join(r),!0)},_m=(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=lf(e,s.schema),f=lf(t,s.schema),{selection:m,storedMarks:g}=s,{$from:y,$to:v}=m,b=y.blockRange(v),x=g||m.$to.parentOffset&&m.$from.marks();if(!b)return!1;const w=sm(e=>gm(e.type.name,d))(m);if(b.depth>=1&&w&&b.depth-w.depth<=1){if(w.node.type===h)return c.liftListItem(f);if(gm(w.node.type.name,d)&&h.validContent(w.node.content)&&a)return l().command(()=>(o.setNodeMarkup(w.pos,h),!0)).command(()=>Tm(o,h)).command(()=>Om(o,h)).run()}return n&&x&&a?l().command(()=>{const e=u().wrapInList(h,r),t=x.filter(e=>p.includes(e.type.name));return o.ensureMarks(t),!!e||c.clearNodes()}).wrapInList(h,r).command(()=>Tm(o,h)).command(()=>Om(o,h)).run():l().command(()=>!!u().wrapInList(h,r)||c.clearNodes()).wrapInList(h,r).command(()=>Tm(o,h)).command(()=>Om(o,h)).run()},Rm=(e,t={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:o=!1}=n,s=vf(e,r.schema),a=function(e,t,n={}){const{empty:r,ranges:i}=e.selection,o=t?vf(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>!o||o.name===e.type.name).find(e=>ff(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=>ff(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)},Dm=(e,t,n={})=>({state:r,commands:i})=>{const o=lf(e,r.schema),s=lf(t,r.schema),a=Hf(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})},Im=(e,t={})=>({state:n,commands:r})=>{const i=lf(e,n.schema);return Hf(n,i,t)?r.lift(i):r.wrapIn(i,t)},Lm=()=>({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},Bm=()=>({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},zm=(e,t={})=>({tr:n,state:r,dispatch:i})=>{var o;const{extendEmptyMarkRange:s=!1}=t,{selection:a}=n,l=vf(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=yf(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},Pm=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},Fm=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null;const a=Kf("string"==typeof e?e:e.name,r.schema);if(!a)return!1;"node"===a&&(o=lf(e,r.schema)),"mark"===a&&(s=vf(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},jm=(e,t={})=>({state:n,dispatch:r})=>gu(lf(e,n.schema),t)(n,r),$m=(e,t={})=>({state:n,dispatch:r})=>vu(lf(e,n.schema),t)(n,r),Hm=class{constructor(e){var t;this.find=e.find,this.handler=e.handler,this.undoable=null==(t=e.undoable)||t}};function Um(e){return"Object"===function(e){return Object.prototype.toString.call(e).slice(8,-1)}(e)&&(e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype)}function qm(e,t){const n={...e};return Um(e)&&Um(t)&&Object.keys(t).forEach(r=>{Um(t[r])&&Um(e[r])?n[r]=qm(e[r],t[r]):n[r]=t[r]}),n}var Vm=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{...lm(am(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...lm(am(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(e={}){const t=this.extend({...this.config,addOptions:()=>qm(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}},Wm=class e extends Vm{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)}},Km=class{constructor(e){this.find=e.find,this.handler=e.handler}};Yh({},{ClipboardTextSerializer:()=>Jm,Commands:()=>Ym,Delete:()=>Zm,Drop:()=>Xm,Editable:()=>Qm,FocusEvents:()=>tg,Keymap:()=>ng,Paste:()=>rg,Tabindex:()=>ig,TextDirection:()=>og,focusEventsPluginKey:()=>eg});var Gm=class e extends Vm{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)}},Jm=Gm.create({name:"clipboardTextSerializer",addOptions:()=>({blockSeparator:void 0}),addProseMirrorPlugins(){return[new hs({key:new gs("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})}}})]}}),Ym=Gm.create({name:"commands",addCommands:()=>({...Qh})}),Zm=Gm.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=om(e.before,[e,...t]);hm(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 ho){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()}}),Xm=Gm.create({name:"drop",addProseMirrorPlugins(){return[new hs({key:new gs("tiptapDrop"),props:{handleDrop:(e,t,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),Qm=Gm.create({name:"editable",addProseMirrorPlugins(){return[new hs({key:new gs("editable"),props:{editable:()=>this.editor.options.editable}})]}}),eg=new gs("focusEvents"),tg=Gm.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:e}=this;return[new hs({key:eg,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}}}})]}}),ng=Gm.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:Ko.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 Sf()||jf()?i:r},addProseMirrorPlugins(){return[new hs({key:new gs("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=Ko.atStart(t.doc).from,c=Ko.atEnd(t.doc).to;if(o||!(s===l&&a===c))return;if(!ym(n.doc))return;const u=n.tr,d=Zh({state:n,transaction:u}),{commands:p}=new Xh({editor:this.editor,state:d});return p.clearNodes(),u.steps.length?u:void 0}})]}}),rg=Gm.create({name:"paste",addProseMirrorPlugins(){return[new hs({key:new gs("tiptapPaste"),props:{handlePaste:(e,t,n)=>{this.editor.emit("paste",{editor:this.editor,event:t,slice:n})}}})]}}),ig=Gm.create({name:"tabindex",addProseMirrorPlugins(){return[new hs({key:new gs("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),og=Gm.create({name:"textDirection",addOptions:()=>({direction:void 0}),addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:e}=cm(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 hs({key:new gs("textDirection"),props:{attributes:()=>{const e=this.options.direction;return e?{dir:e}:{}}}})]}});function sg(e){return new Hm({find:e.find,handler:({state:t,range:n,match:r})=>{const i=lm(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(fm(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 ag(e){return new Hm({find:e.find,handler:({state:t,range:n,match:r})=>{const i=lm(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 lg(e){return new Hm({find:e.find,handler:({state:t,range:n,match:r})=>{const i=t.doc.resolve(n.from),o=lm(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 cg(e){return new Hm({find:e.find,handler:({state:t,range:n,match:r,chain:i})=>{const o=lm(e.getAttributes,void 0,r)||{},s=t.tr.delete(n.from,n.to),a=s.doc.resolve(n.from).blockRange(),l=a&&Eo(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&&Ao(s.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,c))&&s.join(n.from-1)},undoable:e.undoable})}function ug(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 dg(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 pg(e){const{nodeName:t,name:n,parseAttributes:r=ug,serializeAttributes:i=dg,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 hg(e){const{nodeName:t,name:n,getContent:r,parseAttributes:i=ug,serializeAttributes:o=dg,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 fg(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 mg(e){return Object.entries(e).filter(([,e])=>null!=e).map(([e,t])=>`${e}="${t}"`).join(" ")}function gg(e){const{nodeName:t,name:n,getContent:r,parseAttributes:i=fg,serializeAttributes:o=mg,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 yg(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 vg(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")}Yh({},{createAtomBlockMarkdownSpec:()=>pg,createBlockMarkdownSpec:()=>hg,createInlineMarkdownSpec:()=>gg,parseAttributes:()=>ug,parseIndentedBlocks:()=>yg,renderNestedMarkdownContent:()=>vg,serializeAttributes:()=>dg});var bg=class e extends Vm{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 xg(e){return new Km({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:i})=>{const o=lm(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(fm(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 wg=(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]},Eg=/^\s*>\s$/,Mg=bg.create({name:"blockquote",addOptions:()=>({HTMLAttributes:{}}),content:"block+",group:"block",defining:!0,parseHTML:()=>[{tag:"blockquote"}],renderHTML({HTMLAttributes:e}){return wg("blockquote",{...um(this.options.HTMLAttributes,e),children:wg("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[cg({find:Eg,type:this.type})]}}),Sg=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Cg=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Ng=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Ag=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,kg=Wm.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 wg("strong",{...um(this.options.HTMLAttributes,e),children:wg("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[sg({find:Sg,type:this.type}),sg({find:Ng,type:this.type})]},addPasteRules(){return[xg({find:Cg,type:this.type}),xg({find:Ag,type:this.type})]}}),Tg=/(^|[^`])`([^`]+)`(?!`)$/,Og=/(^|[^`])`([^`]+)`(?!`)/g,_g=Wm.create({name:"code",addOptions:()=>({HTMLAttributes:{}}),excludes:"_",code:!0,exitable:!0,parseHTML:()=>[{tag:"code"}],renderHTML({HTMLAttributes:e}){return["code",um(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[sg({find:Tg,type:this.type})]},addPasteRules(){return[xg({find:Og,type:this.type})]}}),Rg=/^```([a-z]+)?[\s\n]$/,Dg=/^~~~([a-z]+)?[\s\n]$/,Ig=bg.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",um(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(Zo.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(Ko.near(r.resolve(s))),!0)):e.commands.exitCode()}}},addInputRules(){return[lg({find:Rg,type:this.type,getAttributes:e=>({language:e[1]})}),lg({find:Dg,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new hs({key:new gs("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(Zo.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),e.dispatch(s),!0}}})]}}),Lg=bg.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,"\n\n"):""}),Bg=bg.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",um(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()}}}),zg=bg.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]}`,um(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=>lg({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),Pg=bg.create({name:"horizontalRule",addOptions:()=>({HTMLAttributes:{},nextNodeType:"paragraph"}),group:"block",parseHTML:()=>[{tag:"hr"}],renderHTML({HTMLAttributes:e}){return["hr",um(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 Qo){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 vm(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(Zo.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(Qo.create(t.doc,n.pos)):t.setSelection(Zo.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(Zo.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[ag({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Fg=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,jg=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,$g=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Hg=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Ug=Wm.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",um(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[sg({find:Fg,type:this.type}),sg({find:$g,type:this.type})]},addPasteRules(){return[xg({find:jg,type:this.type}),xg({find:Hg,type:this.type})]}});const qg="numeric",Vg="ascii",Wg="alpha",Kg="asciinumeric",Gg="alphanumeric",Jg="domain",Yg="emoji",Zg="scheme",Xg="slashscheme",Qg="whitespace";function ey(e,t){return e in t||(t[e]=[]),t[e]}function ty(e,t,n){t[qg]&&(t[Kg]=!0,t[Gg]=!0),t[Vg]&&(t[Kg]=!0,t[Wg]=!0),t[Kg]&&(t[Gg]=!0),t[Wg]&&(t[Gg]=!0),t[Gg]&&(t[Jg]=!0),t[Yg]&&(t[Jg]=!0);for(const r in t){const t=ey(r,n);t.indexOf(e)<0&&t.push(e)}}function ny(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}ny.groups={},ny.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||ny.groups,t&&t.j?i=t:(i=new ny(t),n&&r&&ty(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||ny.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 ny,Object.assign(s.j,a.j),s.jr.push.apply(s.jr,a.jr),s.jd=a.jd,s.t=a.t):s=new ny,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);ty(o,e,r)}else n&&ty(o,n,r);s.t=o}return i.j[e]=s,s}};const ry=(e,t,n,r,i)=>e.ta(t,n,r,i),iy=(e,t,n,r,i)=>e.tr(t,n,r,i),oy=(e,t,n,r,i)=>e.ts(t,n,r,i),sy=(e,t,n,r,i)=>e.tt(t,n,r,i),ay="WORD",ly="UWORD",cy="ASCIINUMERICAL",uy="ALPHANUMERICAL",dy="LOCALHOST",py="TLD",hy="UTLD",fy="SCHEME",my="SLASH_SCHEME",gy="NUM",yy="WS",vy="NL",by="OPENBRACE",xy="CLOSEBRACE",wy="OPENBRACKET",Ey="CLOSEBRACKET",My="OPENPAREN",Sy="CLOSEPAREN",Cy="OPENANGLEBRACKET",Ny="CLOSEANGLEBRACKET",Ay="FULLWIDTHLEFTPAREN",ky="FULLWIDTHRIGHTPAREN",Ty="LEFTCORNERBRACKET",Oy="RIGHTCORNERBRACKET",_y="LEFTWHITECORNERBRACKET",Ry="RIGHTWHITECORNERBRACKET",Dy="FULLWIDTHLESSTHAN",Iy="FULLWIDTHGREATERTHAN",Ly="AMPERSAND",By="APOSTROPHE",zy="ASTERISK",Py="AT",Fy="BACKSLASH",jy="BACKTICK",$y="CARET",Hy="COLON",Uy="COMMA",qy="DOLLAR",Vy="DOT",Wy="EQUALS",Ky="EXCLAMATION",Gy="HYPHEN",Jy="PERCENT",Yy="PIPE",Zy="PLUS",Xy="POUND",Qy="QUERY",ev="QUOTE",tv="FULLWIDTHMIDDLEDOT",nv="SEMI",rv="SLASH",iv="TILDE",ov="UNDERSCORE",sv="EMOJI",av="SYM";var lv=Object.freeze({__proto__:null,ALPHANUMERICAL:uy,AMPERSAND:Ly,APOSTROPHE:By,ASCIINUMERICAL:cy,ASTERISK:zy,AT:Py,BACKSLASH:Fy,BACKTICK:jy,CARET:$y,CLOSEANGLEBRACKET:Ny,CLOSEBRACE:xy,CLOSEBRACKET:Ey,CLOSEPAREN:Sy,COLON:Hy,COMMA:Uy,DOLLAR:qy,DOT:Vy,EMOJI:sv,EQUALS:Wy,EXCLAMATION:Ky,FULLWIDTHGREATERTHAN:Iy,FULLWIDTHLEFTPAREN:Ay,FULLWIDTHLESSTHAN:Dy,FULLWIDTHMIDDLEDOT:tv,FULLWIDTHRIGHTPAREN:ky,HYPHEN:Gy,LEFTCORNERBRACKET:Ty,LEFTWHITECORNERBRACKET:_y,LOCALHOST:dy,NL:vy,NUM:gy,OPENANGLEBRACKET:Cy,OPENBRACE:by,OPENBRACKET:wy,OPENPAREN:My,PERCENT:Jy,PIPE:Yy,PLUS:Zy,POUND:Xy,QUERY:Qy,QUOTE:ev,RIGHTCORNERBRACKET:Oy,RIGHTWHITECORNERBRACKET:Ry,SCHEME:fy,SEMI:nv,SLASH:rv,SLASH_SCHEME:my,SYM:av,TILDE:iv,TLD:py,UNDERSCORE:ov,UTLD:hy,UWORD:ly,WORD:ay,WS:yy});const cv=/[a-z]/,uv=/\p{L}/u,dv=/\p{Emoji}/u,pv=/\d/,hv=/\s/;Object.freeze({__proto__:null,ASCII_LETTER:cv,DIGIT:pv,EMOJI:dv,EMOJI_VARIATION:/\ufe0f/,LETTER:uv,SPACE:hv});let fv=null,mv=null;function gv(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 yv(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 ny(r),o.jr=i.slice(),e.j[s]=o),e=o}return o=new ny(n),o.jr=i.slice(),e.j[t[s-1]]=o,o}function vv(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 bv={defaultProtocol:"http",events:null,format:wv,formatHref:wv,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function xv(e,t=null){let n=Object.assign({},bv);e&&(n=Object.assign(n,e instanceof xv?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 wv(e){return e}function Ev(e,t){this.t="token",this.v=e,this.tk=t}function Mv(e,t){class n extends Ev{constructor(t,n){super(t,n),this.t=e}}for(const e in t)n.prototype[e]=t[e];return n.t=e,n}xv.prototype={o:bv,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]:bv[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:xv,defaults:bv}),Ev.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=bv.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 Sv=Mv("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Cv=Mv("text"),Nv=Mv("nl"),Av=Mv("url",{isLink:!0,toHref(e=bv.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){const e=this.tk;return e.length>=2&&e[0].t!==dy&&e[1].t===Hy}});Object.freeze({__proto__:null,Base:Ev,Email:Sv,MultiToken:Ev,Nl:Nv,Text:Cv,Url:Av,createTokenClass:Mv});const kv=e=>new ny(e);function Tv(e,t,n){const r=n[0].s,i=n[n.length-1].e;return new e(t.slice(r,i),n)}const Ov="undefined"!=typeof console&&console&&console.warn||(()=>{}),_v={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Rv(e,t=!1){if(_v.initialized&&Ov(`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');_v.customSchemes.push([e,t])}function Dv(){_v.scanner=function(e=[]){const t={};ny.groups=t;const n=new ny;null==fv&&(fv=vv("aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2")),null==mv&&(mv=vv("ελ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")),sy(n,"'",By),sy(n,"{",by),sy(n,"}",xy),sy(n,"[",wy),sy(n,"]",Ey),sy(n,"(",My),sy(n,")",Sy),sy(n,"<",Cy),sy(n,">",Ny),sy(n,"(",Ay),sy(n,")",ky),sy(n,"「",Ty),sy(n,"」",Oy),sy(n,"『",_y),sy(n,"』",Ry),sy(n,"<",Dy),sy(n,">",Iy),sy(n,"&",Ly),sy(n,"*",zy),sy(n,"@",Py),sy(n,"`",jy),sy(n,"^",$y),sy(n,":",Hy),sy(n,",",Uy),sy(n,"$",qy),sy(n,".",Vy),sy(n,"=",Wy),sy(n,"!",Ky),sy(n,"-",Gy),sy(n,"%",Jy),sy(n,"|",Yy),sy(n,"+",Zy),sy(n,"#",Xy),sy(n,"?",Qy),sy(n,'"',ev),sy(n,"/",rv),sy(n,";",nv),sy(n,"~",iv),sy(n,"_",ov),sy(n,"\\",Fy),sy(n,"・",tv);const r=iy(n,pv,gy,{[qg]:!0});iy(r,pv,r);const i=iy(r,cv,cy,{[Kg]:!0}),o=iy(r,uv,uy,{[Gg]:!0}),s=iy(n,cv,ay,{[Vg]:!0});iy(s,pv,i),iy(s,cv,s),iy(i,pv,i),iy(i,cv,i);const a=iy(n,uv,ly,{[Wg]:!0});iy(a,cv),iy(a,pv,o),iy(a,uv,a),iy(o,pv,o),iy(o,cv),iy(o,uv,o);const l=sy(n,"\n",vy,{[Qg]:!0}),c=sy(n,"\r",yy,{[Qg]:!0}),u=iy(n,hv,yy,{[Qg]:!0});sy(n,"",u),sy(c,"\n",l),sy(c,"",u),iy(c,hv,u),sy(u,"\r"),sy(u,"\n"),iy(u,hv,u),sy(u,"",u);const d=iy(n,dv,sv,{[Yg]:!0});sy(d,"#"),iy(d,dv,d),sy(d,"️",d);const p=sy(d,"‍");sy(p,"#"),iy(p,dv,d);const h=[[cv,s],[pv,i]],f=[[cv,null],[uv,a],[pv,o]];for(let e=0;e<fv.length;e++)yv(n,fv[e],py,ay,h);for(let e=0;e<mv.length;e++)yv(n,mv[e],hy,ly,f);ty(py,{tld:!0,ascii:!0},t),ty(hy,{utld:!0,alpha:!0},t),yv(n,"file",fy,ay,h),yv(n,"mailto",fy,ay,h),yv(n,"http",my,ay,h),yv(n,"https",my,ay,h),yv(n,"ftp",my,ay,h),yv(n,"ftps",my,ay,h),ty(fy,{scheme:!0,ascii:!0},t),ty(my,{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]?{[Zg]:!0}:{[Xg]:!0};r.indexOf("-")>=0?i[Jg]=!0:cv.test(r)?pv.test(r)?i[Kg]=!0:i[Vg]=!0:i[qg]=!0,oy(n,r,r,i)}return oy(n,"localhost",dy,{ascii:!0}),n.jd=new ny(av),{start:n,tokens:Object.assign({groups:t},lv)}}(_v.customSchemes);for(let e=0;e<_v.tokenQueue.length;e++)_v.tokenQueue[e][1]({scanner:_v.scanner});_v.parser=function({groups:e}){const t=e.domain.concat([Ly,zy,Py,Fy,jy,$y,qy,Wy,Gy,gy,Jy,Yy,Zy,Xy,rv,av,iv,ov]),n=[By,Hy,Uy,Vy,Ky,Jy,Qy,ev,nv,Cy,Ny,by,xy,Ey,wy,My,Sy,Ay,ky,Ty,Oy,_y,Ry,Dy,Iy],r=[Ly,By,zy,Fy,jy,$y,qy,Wy,Gy,by,xy,Jy,Yy,Zy,Xy,Qy,rv,av,iv,ov],i=kv(),o=sy(i,iv);ry(o,r,o),ry(o,e.domain,o);const s=kv(),a=kv(),l=kv();ry(i,e.domain,s),ry(i,e.scheme,a),ry(i,e.slashscheme,l),ry(s,r,o),ry(s,e.domain,s);const c=sy(s,Py);sy(o,Py,c),sy(a,Py,c),sy(l,Py,c);const u=sy(o,Vy);ry(u,r,o),ry(u,e.domain,o);const d=kv();ry(c,e.domain,d),ry(d,e.domain,d);const p=sy(d,Vy);ry(p,e.domain,d);const h=kv(Sv);ry(p,e.tld,h),ry(p,e.utld,h),sy(c,dy,h);const f=sy(d,Gy);sy(f,Gy,f),ry(f,e.domain,d),ry(h,e.domain,d),sy(h,Vy,p),sy(h,Gy,f);const m=sy(h,Hy);ry(m,e.numeric,Sv);const g=sy(s,Gy),y=sy(s,Vy);sy(g,Gy,g),ry(g,e.domain,s),ry(y,r,o),ry(y,e.domain,s);const v=kv(Av);ry(y,e.tld,v),ry(y,e.utld,v),ry(v,e.domain,s),ry(v,r,o),sy(v,Vy,y),sy(v,Gy,g),sy(v,Py,c);const b=sy(v,Hy),x=kv(Av);ry(b,e.numeric,x);const w=kv(Av),E=kv();ry(w,t,w),ry(w,n,E),ry(E,t,w),ry(E,n,E),sy(v,rv,w),sy(x,rv,w);const M=sy(a,Hy),S=sy(l,Hy),C=sy(S,rv),N=sy(C,rv);ry(a,e.domain,s),sy(a,Vy,y),sy(a,Gy,g),ry(l,e.domain,s),sy(l,Vy,y),sy(l,Gy,g),ry(M,e.domain,w),sy(M,rv,w),sy(M,Qy,w),ry(N,e.domain,w),ry(N,t,w),sy(N,rv,w);const A=[[by,xy],[wy,Ey],[My,Sy],[Cy,Ny],[Ay,ky],[Ty,Oy],[_y,Ry],[Dy,Iy]];for(let e=0;e<A.length;e++){const[r,i]=A[e],o=sy(w,r);sy(E,r,o),sy(o,i,w);const s=kv(Av);ry(o,t,s);const a=kv();ry(o,n),ry(s,t,s),ry(s,n,a),ry(a,t,s),ry(a,n,a),sy(s,i,w),sy(a,i,w)}return sy(i,dy,v),sy(i,vy,Nv),{start:i,tokens:lv}}(_v.scanner.tokens);for(let e=0;e<_v.pluginQueue.length;e++)_v.pluginQueue[e][1]({scanner:_v.scanner,parser:_v.parser});return _v.initialized=!0,_v}function Iv(e){return _v.initialized||Dv(),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(Tv(Cv,t,s)),s=[]),i-=p,u-=p;const e=d.t,r=n.slice(i-u,i);o.push(Tv(e,t,r))}}return s.length>0&&o.push(Tv(Cv,t,s)),o}(_v.parser.start,e,gv(_v.scanner.start,e))}function Lv(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 xv(n),i=Iv(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}Iv.scan=gv;var Bv="[\0-   ᠎ -\u2029  ]",zv=new RegExp(Bv),Pv=new RegExp(`${Bv}$`),Fv=new RegExp(Bv,"g");function jv(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(Fv,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var $v=Wm.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?Rv(e.scheme,e.optionalSlashes):Rv(e)})},onDestroy(){ny.groups={},_v.scanner=null,_v.parser=null,_v.tokenQueue=[],_v.pluginQueue=[],_v.customSchemes=[],_v.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)=>!!jv(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=>!!jv(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}))&&null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!jv(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",um(this.options.HTMLAttributes,e),0]:["a",um(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=>!!jv(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=>!!jv(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[xg({find:e=>{const t=[];if(e){const{protocols:n,defaultProtocol:r}=this.options,i=Lv(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!jv(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=>!!jv(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink},new hs({key:new gs("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 hm(om(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(!Pv.test(r))return;i=t[0],o=n.doc.textBetween(i.pos,e.to,void 0," ")}if(i&&o){const e=o.split(zv).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=Iv(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=>{fm(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 hs({key:new gs("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=dm(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 hs({key:new gs("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=Lv(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}}),Hv=Object.defineProperty,Uv="textStyle",qv=/^\s*([-+*])\s$/,Vv=bg.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",um(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(Uv)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=cg({find:qv,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=cg({find:qv,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Uv),editor:this.editor})),[e]}}),Wv=bg.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:e}){return["li",um(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)=>vg(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)Hv(e,n,{get:t[n],enumerable:!0})})({},{findListItemPos:()=>Kv,getNextListDepth:()=>Gv,handleBackspace:()=>Xv,handleDelete:()=>tb,hasListBefore:()=>Jv,hasListItemAfter:()=>nb,hasListItemBefore:()=>Yv,listItemHasSubList:()=>Zv,nextListIsDeeper:()=>Qv,nextListIsHigher:()=>eb});var Kv=(e,t)=>{const{$from:n}=t.selection,r=lf(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}},Gv=(e,t)=>{const n=Kv(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},Jv=(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))},Yv=(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},Zv=(e,t,n)=>{if(!n)return!1;const r=lf(e,t.schema);let i=!1;return n.descendants(e=>{e.type===r&&(i=!0)}),i},Xv=(e,t,n)=>{if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!Hf(e.state,t)&&Jv(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(!Hf(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=Kv(t,e.state);if(!r)return!1;const i=e.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=Zv(t,e.state,i);return Yv(t,e.state)&&!o?e.commands.joinItemBackward():e.chain().liftListItem(t).run()},Qv=(e,t)=>{const n=Gv(e,t),r=Kv(e,t);return!(!r||!n)&&n>r.depth},eb=(e,t)=>{const n=Gv(e,t),r=Kv(e,t);return!(!r||!n)&&n<r.depth},tb=(e,t)=>{if(!Hf(e.state,t))return!1;if(!((e,t)=>{const{$from:n,$to:r,$anchor:i}=e.selection;if(t){const n=sm(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))&&(Qv(t,e.state)?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():eb(t,e.state)?e.chain().joinForward().joinBackward().run():e.commands.joinItemForward())},nb=(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},rb=Gm.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]&&tb(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]&&tb(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]&&Xv(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]&&Xv(e,n,r)&&(t=!0)}),t}}}}),ib=/^(\s*)(\d+)\.\s+(.*)$/,ob=/^\s/;function sb(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=sb(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 ab="textStyle",lb=/^(\d+)\.\s$/,cb=bg.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",um(this.options.HTMLAttributes,n),0]:["ol",um(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(ib);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(ib))break;if(""===t.trim())p.push(t),u+="\n",d+=1;else{if(!t.match(ob))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=sb(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(ab)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=cg({find:lb,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=cg({find:lb,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(ab)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[e]}}),ub=/^\s*(\[([( |x])?\])\s$/,db=bg.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",um(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 vg(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)=>um(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[cg({find:ub,type:this.type,getAttributes:e=>({checked:"x"===e[e.length-1]})})]}}),pb=bg.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",um(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=yg(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=yg(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()}}});Gm.create({name:"listKit",addExtensions(){const e=[];return!1!==this.options.bulletList&&e.push(Vv.configure(this.options.bulletList)),!1!==this.options.listItem&&e.push(Wv.configure(this.options.listItem)),!1!==this.options.listKeymap&&e.push(rb.configure(this.options.listKeymap)),!1!==this.options.orderedList&&e.push(cb.configure(this.options.orderedList)),!1!==this.options.taskItem&&e.push(db.configure(this.options.taskItem)),!1!==this.options.taskList&&e.push(pb.configure(this.options.taskList)),e}});var hb=bg.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:e}){return["p",um(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()}}}),fb=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,mb=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,gb=Wm.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",um(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[sg({find:fb,type:this.type})]},addPasteRules(){return[xg({find:mb,type:this.type})]}}),yb=bg.create({name:"text",group:"inline",parseMarkdown:e=>({type:"text",text:e.text||""}),renderMarkdown:e=>e.text||""}),vb=Wm.create({name:"underline",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:e=>!!e.includes("underline")&&{}}],renderHTML({HTMLAttributes:e}){return["u",um(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 bb(e={}){return new hs({view:t=>new xb(t,e)})}class xb{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=Oo(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 wb extends Ko{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return wb.valid(n)?new wb(n):Ko.near(n)}content(){return ei.empty}eq(e){return e instanceof wb&&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 wb(e.resolve(t.pos))}getBookmark(){return new Eb(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||Mb(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||Mb(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&&wb.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(wb.valid(s))return s}for(;;){let o=t>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!Qo.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(wb.valid(s))return s}return null}}}wb.prototype.visible=!1,wb.findFrom=wb.findGapCursorFrom,Ko.jsonID("gapcursor",wb);class Eb{constructor(e){this.pos=e}map(e){return new Eb(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return wb.valid(t)?new wb(t):Ko.near(t)}}function Mb(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}const Sb=Uc({ArrowLeft:Cb("horiz",-1),ArrowRight:Cb("horiz",1),ArrowUp:Cb("vert",-1),ArrowDown:Cb("vert",1)});function Cb(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 Zo){if(!i.endOfTextblock(n)||0==s.depth)return!1;a=!1,s=e.doc.resolve(t>0?s.after():s.before())}let l=wb.findGapCursorFrom(s,t,a);return!!l&&(r&&r(e.tr.setSelection(new wb(l))),!0)}}function Nb(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!wb.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return!(i&&i.inside>-1&&Qo.isSelectable(e.state.doc.nodeAt(i.inside)))&&(e.dispatch(e.state.tr.setSelection(new wb(r))),!0)}function Ab(e,t){if("insertCompositionText"!=t.inputType||!(e.state.selection instanceof wb))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=Gr.empty;for(let e=r.length-1;e>=0;e--)i=Gr.from(r[e].createAndFill(null,i));let o=e.state.tr.replace(n.pos,n.pos,new ei(i,0,0));return o.setSelection(Zo.near(o.doc.resolve(n.pos+1))),e.dispatch(o),!1}function kb(e){if(!(e.selection instanceof wb))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",nc.create(e.doc,[Ql.widget(e.selection.head,t,{key:"gapcursor"})])}var Tb=200,Ob=function(){};Ob.prototype.append=function(e){return e.length?(e=Ob.from(e),!this.length&&e||e.length<Tb&&this.leafAppend(e)||this.length<Tb&&e.leafPrepend(this)||this.appendInner(e)):this},Ob.prototype.prepend=function(e){return e.length?Ob.from(e).append(this):this},Ob.prototype.appendInner=function(e){return new Rb(this,e)},Ob.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?Ob.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Ob.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Ob.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)},Ob.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},Ob.from=function(e){return e instanceof Ob?e:e&&e.length?new _b(e):Ob.empty};var _b=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<=Tb)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=Tb)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}(Ob);Ob.empty=new _b([]);var Rb=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}(Ob);class Db{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 Ib(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 Ib(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 Db(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 Ib(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>Bb&&(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 Db(s.append(i),o)}remapping(e,t){let n=new so;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 Db(this.items.append(e.map(e=>new Ib(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 Ib(l,o,c))}else n.push(new Ib(l))},r);let l=[];for(let e=t;e<o;e++)l.push(new Ib(i.maps[e]));let c=this.items.slice(0,r).append(l).append(n),u=new Db(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 Ib(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 Db(Ob.from(r.reverse()),i)}}Db.empty=new Db(Ob.empty,0);class Ib{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 Ib(t.getMap().invert(),t,this.selection)}}}class Lb{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}}const Bb=20;function zb(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 Pb(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 Fb=!1,jb=null;function $b(e){let t=e.plugins;if(jb!=t){Fb=!1,jb=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){Fb=!0;break}}return Fb}const Hb=new gs("history"),Ub=new gs("closeHistory");function qb(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new hs({key:Hb,state:{init:()=>new Lb(Db.empty,Db.empty,null,0,-1),apply:(t,n,r)=>function(e,t,n,r){let i,o=n.getMeta(Hb);if(o)return o.historyState;n.getMeta(Ub)&&(e=new Lb(e.done,e.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(s&&s.getMeta(Hb))return s.getMeta(Hb).redo?new Lb(e.done.addTransform(n,void 0,r,$b(t)),e.undone,zb(n.mapping.maps),e.prevTime,e.prevComposition):new Lb(e.done,e.undone.addTransform(n,void 0,r,$b(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return(i=n.getMeta("rebased"))?new Lb(e.done.rebased(n,i),e.undone.rebased(n,i),Pb(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new Lb(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),Pb(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?Pb(e.prevRanges,n.mapping):zb(n.mapping.maps);return new Lb(e.done.addTransform(n,o?t.selection.getBookmark():void 0,r,$b(t)),Db.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?Wb:"historyRedo"==n?Kb:null;return!(!r||!e.editable)&&(t.preventDefault(),r(e.state,e.dispatch))}}}})}function Vb(e,t){return(n,r)=>{let i=Hb.getState(n);if(!i||0==(e?i.undone:i.done).eventCount)return!1;if(r){let o=function(e,t,n){let r=$b(t),i=Hb.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 Lb(n?a:o.remaining,n?o.remaining:a,null,0,-1);return o.transform.setSelection(s).setMeta(Hb,{redo:n,historyState:l})}(i,n,e);o&&r(t?o.scrollIntoView():o)}return!0}}const Wb=Vb(!1,!0),Kb=Vb(!0,!0);var Gb=Gm.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 hs({key:new gs("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)}})]}}),Jb=Gm.create({name:"dropCursor",addOptions:()=>({color:"currentColor",width:1,class:void 0}),addProseMirrorPlugins(){return[bb(this.options)]}});Gm.create({name:"focus",addOptions:()=>({className:"has-focus",mode:"all"}),addProseMirrorPlugins(){return[new hs({key:new gs("focus"),props:{decorations:({doc:e,selection:t})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,o=[];if(!n||!r)return nc.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(Ql.node(t,t+e.nodeSize,{class:this.options.className}))}),nc.create(e,o)}}})]}});var Yb=Gm.create({name:"gapCursor",addProseMirrorPlugins:()=>[new hs({props:{decorations:kb,createSelectionBetween:(e,t,n)=>t.pos==n.pos&&wb.valid(n)?new wb(n):null,handleClick:Nb,handleKeyDown:Sb,handleDOMEvents:{beforeinput:Ab}}})],extendNodeSchema(e){var t;return{allowGapCursor:null!=(t=lm(am(e,"allowGapCursor",{name:e.name,options:e.options,storage:e.storage})))?t:null}}}),Zb=Gm.create({name:"placeholder",addOptions:()=>({emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}),addProseMirrorPlugins(){return[new hs({key:new gs("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&&ym(e);if((n||!this.options.showOnlyCurrent)&&s){const r=[this.options.emptyNodeClass];o&&r.push(this.options.emptyEditorClass);const s=Ql.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}),nc.create(e,i)}}})]}});function Xb({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||(null==t?void 0:t.type)===e}Gm.create({name:"selection",addOptions:()=>({className:"selection"}),addProseMirrorPlugins(){const{editor:e,options:t}=this;return[new hs({key:new gs("selection"),props:{decorations:n=>n.selection.empty||e.isFocused||!e.isEditable||vm(n.selection)||e.view.dragging?null:nc.create(n.doc,[Ql.inline(n.selection.from,n.selection.to,{class:t.className})])}})]}});var Qb=Gm.create({name:"trailingNode",addOptions:()=>({node:void 0,notAfter:[]}),addProseMirrorPlugins(){var e;const t=new gs(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 hs({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)=>!Xb({node:t.tr.doc.lastChild,types:r}),apply:(e,t)=>{if(!e.docChanged)return t;if(e.getMeta("__uniqueIDTransaction"))return t;return!Xb({node:e.doc.lastChild,types:r})}}})]}}),ex=Gm.create({name:"undoRedo",addOptions:()=>({depth:100,newGroupDelay:500}),addCommands:()=>({undo:()=>({state:e,dispatch:t})=>Wb(e,t),redo:()=>({state:e,dispatch:t})=>Kb(e,t)}),addProseMirrorPlugins(){return[qb(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()}}}),tx=Gm.create({name:"starterKit",addExtensions(){var e,t,n,r;const i=[];return!1!==this.options.bold&&i.push(kg.configure(this.options.bold)),!1!==this.options.blockquote&&i.push(Mg.configure(this.options.blockquote)),!1!==this.options.bulletList&&i.push(Vv.configure(this.options.bulletList)),!1!==this.options.code&&i.push(_g.configure(this.options.code)),!1!==this.options.codeBlock&&i.push(Ig.configure(this.options.codeBlock)),!1!==this.options.document&&i.push(Lg.configure(this.options.document)),!1!==this.options.dropcursor&&i.push(Jb.configure(this.options.dropcursor)),!1!==this.options.gapcursor&&i.push(Yb.configure(this.options.gapcursor)),!1!==this.options.hardBreak&&i.push(Bg.configure(this.options.hardBreak)),!1!==this.options.heading&&i.push(zg.configure(this.options.heading)),!1!==this.options.undoRedo&&i.push(ex.configure(this.options.undoRedo)),!1!==this.options.horizontalRule&&i.push(Pg.configure(this.options.horizontalRule)),!1!==this.options.italic&&i.push(Ug.configure(this.options.italic)),!1!==this.options.listItem&&i.push(Wv.configure(this.options.listItem)),!1!==this.options.listKeymap&&i.push(rb.configure(null==(e=this.options)?void 0:e.listKeymap)),!1!==this.options.link&&i.push($v.configure(null==(t=this.options)?void 0:t.link)),!1!==this.options.orderedList&&i.push(cb.configure(this.options.orderedList)),!1!==this.options.paragraph&&i.push(hb.configure(this.options.paragraph)),!1!==this.options.strike&&i.push(gb.configure(this.options.strike)),!1!==this.options.text&&i.push(yb.configure(this.options.text)),!1!==this.options.underline&&i.push(vb.configure(null==(n=this.options)?void 0:n.underline)),!1!==this.options.trailingNode&&i.push(Qb.configure(null==(r=this.options)?void 0:r.trailingNode)),i}}),nx=xd.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",Fu(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}}}}),rx=Cd.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()})}),ix=Cd.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()})}),ox=Cd.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()})}),sx=Cd.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()})}),ax=Cd.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()})}),lx=Cd.create({name:"textStyleKit",addExtensions(){const e=[];return!1!==this.options.backgroundColor&&e.push(rx.configure(this.options.backgroundColor)),!1!==this.options.color&&e.push(ix.configure(this.options.color)),!1!==this.options.fontFamily&&e.push(ox.configure(this.options.fontFamily)),!1!==this.options.fontSize&&e.push(sx.configure(this.options.fontSize)),!1!==this.options.lineHeight&&e.push(ax.configure(this.options.lineHeight)),!1!==this.options.textStyle&&e.push(nx.configure(this.options.textStyle)),e}}),cx=xd.create({name:"superscript",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"sup"},{style:"vertical-align",getAttrs:e=>"super"===e&&null}],renderHTML({HTMLAttributes:e}){return["sup",Fu(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()}}}),ux=xd.create({name:"subscript",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"sub"},{style:"vertical-align",getAttrs:e=>"sub"===e&&null}],renderHTML({HTMLAttributes:e}){return["sub",Fu(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()}}}),dx=Cd.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")}}}),px=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,hx=Zp.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",Fu(this.options.HTMLAttributes,e)]},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[Yp({find:px,type:this.type,getAttributes:e=>{const[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}}),fx=hx,mx=Zb;const gx=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 yx,vx;if("undefined"!=typeof WeakMap){let e=new WeakMap;yx=t=>e.get(t),vx=(t,n)=>(e.set(t,n),n)}else{const e=[],t=10;let n=0;yx=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},vx=(r,i)=>(n==t&&(n=0),e[n++]=r,e[n++]=i)}var bx=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 yx(e)||vx(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 bx(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=xx(l)))[n]=r)}a&&e.problems.unshift({type:"colwidth mismatch",pos:o,colwidth:a})}}(a,s,e);return a}(e))}};function xx(e){if(e.colwidth)return e.colwidth.slice();const t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function wx(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 Ex=new gs("selectingCells");function Mx(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 Sx(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 Cx(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=Mx(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 Nx(e){return"row"==e.parent.type.spec.tableRole&&!!e.nodeAfter}function Ax(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function kx(e,t,n){const r=e.node(-1),i=bx.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 Tx(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 Ox(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 _x=class e extends Ko{constructor(e,t=e){const n=e.node(-1),r=bx.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 Go(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(Nx(r)&&Nx(i)&&Ax(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 Zo.between(r,i)}content(){const e=this.$anchorCell.node(-1),t=bx.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=Tx(e,0,c)),u>0&&(e=Tx(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(Gr.from(s)))}const s=this.isColSelection()&&this.isRowSelection()?e:o;return new ei(Gr.from(s),1,1)}replace(e,t=ei.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?ei.empty:t)}const i=Ko.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new ei(Gr.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),n=bx.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=bx.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=bx.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=bx.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 Rx(this.$anchorCell.pos,this.$headCell.pos)}};_x.prototype.visible=!1,Ko.jsonID("cell",_x);var Rx=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&&Ax(t,n)?new _x(t,n):Ko.near(n,1)}};function Dx(e){if(!(e.selection instanceof _x))return null;const t=[];return e.selection.forEachCell((e,n)=>{t.push(Ql.node(n,n+e.nodeSize,{class:"selectedCell"}))}),nc.create(e.doc,t)}const Ix=new gs("fix-tables");function Lx(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)?Lx(e.child(a),o,n+1,r):o.nodesBetween(0,o.content.size,r,n+1),n+=o.nodeSize}}function Bx(e,t){let n;const r=(t,r)=>{"table"==t.type.spec.tableRole&&(n=function(e,t,n,r){const i=bx.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,Tx(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=wx(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(Ix,{fixTables:!0})}(e,t,r,n))};return t?t.doc!=e.doc&&Lx(t.doc,e.doc,0,r):e.doc.descendants(r),n}function zx(e){const t=e.selection,n=Cx(e),r=n.node(-1),i=n.start(-1),o=bx.get(r);return{...t instanceof _x?o.rectBetween(t.$anchorCell.pos-i,t.$headCell.pos-i):o.findCell(n.pos-i),tableStart:i,map:o,table:r}}function Px(e,{map:t,tableStart:n,table:r},i){let o=i>0?-1:0;(function(e,t,n){const r=wx(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,Ox(l.attrs,i-t.colCount(o))),s+=l.attrs.rowspan-1}else{const l=null==o?wx(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 Fx(e,t){if(!Sx(e))return!1;if(t){const n=zx(e);t(Px(e.tr,n,n.left))}return!0}function jx(e,t){if(!Sx(e))return!1;if(t){const n=zx(e);t(Px(e.tr,n,n.right))}return!0}function $x(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,Tx(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 Hx(e,t){if(!Sx(e))return!1;if(t){const n=zx(e),r=e.tr;if(0==n.left&&n.right==n.map.width)return!1;for(let e=n.right-1;$x(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=bx.get(e)}t(r)}return!0}function Ux(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=wx(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?wx(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,wx(r.type.schema).row.create(null,s)),e}function qx(e,t){if(!Sx(e))return!1;if(t){const n=zx(e);t(Ux(e.tr,n,n.top))}return!0}function Vx(e,t){if(!Sx(e))return!1;if(t){const n=zx(e);t(Ux(e.tr,n,n.bottom))}return!0}function Wx(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 Kx(e,t){if(!Sx(e))return!1;if(t){const n=zx(e),r=e.tr;if(0==n.top&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;Wx(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=bx.get(n.table)}t(r)}return!0}function Gx(e){const t=e.content;return 1==t.childCount&&t.child(0).isTextblock&&0==t.child(0).childCount}function Jx(e,t){const n=e.selection;if(!(n instanceof _x)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=zx(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=Gr.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{Gx(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,{...Ox(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=Gx(a)?s+1:e;n.replaceWith(t+r.tableStart,e+r.tableStart,l)}n.setSelection(new _x(n.doc.resolve(s+r.tableStart))),t(n)}return!0}function Yx(e,t){const n=wx(e.schema);return(r=({node:e})=>n[e.type.spec.tableRole],(e,t)=>{const n=e.selection;let i,o;if(n instanceof _x){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=Mx(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=zx(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 _x&&u.setSelection(new _x(u.doc.resolve(n.$anchorCell.pos),d?u.doc.resolve(d):void 0)),t(u)}return!0})(e,t);var r}function Zx(e,t){return function(n,r){if(!Sx(n))return!1;const i=Cx(n);if(i.nodeAfter.attrs[e]===t)return!1;if(r){const o=n.tr;n.selection instanceof _x?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 Xx(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 Qx(e,t){return(t=t||{useDeprecatedLogic:!1}).useDeprecatedLogic?function(e){return function(t,n){if(!Sx(t))return!1;if(n){const r=wx(t.schema),i=zx(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(!Sx(t))return!1;if(n){const r=wx(t.schema),i=zx(t),o=t.tr,s=Xx("row",i,r),a=Xx("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}}Qx("row",{useDeprecatedLogic:!0}),Qx("column",{useDeprecatedLogic:!0});const ew=Qx("cell",{useDeprecatedLogic:!0});function tw(e){return function(t,n){if(!Sx(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}(Cx(t),e);if(null==r)return!1;if(n){const e=t.doc.resolve(r);n(t.tr.setSelection(Zo.between(e,(i=e,i.node(0).resolve(i.pos+i.nodeAfter.nodeSize)))).scrollIntoView())}var i;return!0}}function nw(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 rw(e,t){const n=e.selection;if(!(n instanceof _x))return!1;if(t){const r=e.tr,i=wx(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 ei(i,0,0))}),r.docChanged&&t(r)}return!0}function iw(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=ow(wx(s).row,new ei(i,o,l)).content),a.push(i)}else{if("cell"!=o&&"header_cell"!=o)return null;a.push(n||r?ow(wx(s).row,new ei(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(Gr.empty),n[i]<r){const o=wx(e).cell.createAndFill(),s=[];for(let e=n[i];e<r;e++)s.push(o);t[i]=t[i].append(Gr.from(s))}return{height:t.length,width:r,rows:t}}(s,a)}function ow(e,t){const n=e.createAndFill();return new Vo(n).replace(0,n.content.size,t).doc}function sw(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 aw(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,Tx(i.attrs,s-u,i.attrs.colspan-(s-u))),e.insert(d+i.nodeSize,i.type.createAndFill(Tx(i.attrs,0,s-u))),c+=i.attrs.rowspan-1}}return l}function lw(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=bx.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=bx.get(o),p=d.mapping.maps.length}(function(e,t,n,r,i,o,s){const a=wx(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,Gr.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(),sw(d,s,o,n,l,c,a,p)&&h(),sw(d,s,o,n,l,c,u,p)&&h(),aw(d,s,o,n,a,u,l,p)&&h(),aw(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 ei(i.rows[e-a],0,0))}h(),d.setSelection(new _x(d.doc.resolve(n+s.positionAt(a,l,o)),d.doc.resolve(n+s.positionAt(u-1,c-1,o)))),t(d)}const cw=Uc({ArrowLeft:dw("horiz",-1),ArrowRight:dw("horiz",1),ArrowUp:dw("vert",-1),ArrowDown:dw("vert",1),"Shift-ArrowLeft":pw("horiz",-1),"Shift-ArrowRight":pw("horiz",1),"Shift-ArrowUp":pw("vert",-1),"Shift-ArrowDown":pw("vert",1),Backspace:rw,"Mod-Backspace":rw,Delete:rw,"Mod-Delete":rw});function uw(e,t,n){return!n.eq(e.selection)&&(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function dw(e,t){return(n,r,i)=>{if(!i)return!1;const o=n.selection;if(o instanceof _x)return uw(n,r,Ko.near(o.$headCell,t));if("horiz"!=e&&!o.empty)return!1;const s=gw(i,e,t);if(null==s)return!1;if("horiz"==e)return uw(n,r,Ko.near(n.doc.resolve(o.head+t),t));{const i=n.doc.resolve(s),o=kx(i,e,t);let a;return a=o?Ko.near(o,1):t<0?Ko.near(n.doc.resolve(i.before(-1)),-1):Ko.near(n.doc.resolve(i.after(-1)),1),uw(n,r,a)}}}function pw(e,t){return(n,r,i)=>{if(!i)return!1;const o=n.selection;let s;if(o instanceof _x)s=o;else{const r=gw(i,e,t);if(null==r)return!1;s=new _x(n.doc.resolve(r))}const a=kx(s.$headCell,e,t);return!!a&&uw(n,r,new _x(s.$anchorCell,a))}}function hw(e,t){const n=Mx(e.state.doc.resolve(t));return!!n&&(e.dispatch(e.state.tr.setSelection(new _x(n))),!0)}function fw(e,t,n){if(!Sx(e.state))return!1;let r=iw(n);const i=e.state.selection;if(i instanceof _x){r||(r={width:1,height:1,rows:[Gr.from(ow(wx(e.state.schema).cell,n))]});const t=i.$anchorCell.node(-1),o=i.$anchorCell.start(-1),s=bx.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(Tx(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(Gr.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(Gr.from(s))}n=e,t=i}return{width:e,height:t,rows:n}}(r,s.right-s.left,s.bottom-s.top),lw(e.state,e.dispatch,o,s,r),!0}if(r){const t=Cx(e.state),n=t.start(-1);return lw(e.state,e.dispatch,n,bx.get(t.node(-1)).findCell(t.pos-n),r),!0}return!1}function mw(e,t){var n;if(0!=t.button)return;if(t.ctrlKey||t.metaKey)return;const r=yw(e,t.target);let i;if(t.shiftKey&&e.state.selection instanceof _x)o(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&r&&null!=(i=Mx(e.state.selection.$anchor))&&(null===(n=vw(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=vw(e,n);const i=null==Ex.getState(e.state);if(!r||!Ax(t,r)){if(!i)return;r=t}const o=new _x(t,r);if(i||!e.state.selection.eq(o)){const n=e.state.tr.setSelection(o);i&&n.setMeta(Ex,t.pos),e.dispatch(n)}}function s(){e.root.removeEventListener("mouseup",s),e.root.removeEventListener("dragstart",s),e.root.removeEventListener("mousemove",a),null!=Ex.getState(e.state)&&e.dispatch(e.state.tr.setMeta(Ex,-1))}function a(n){const i=n,a=Ex.getState(e.state);let l;if(null!=a)l=e.state.doc.resolve(a);else if(yw(e,i.target)!=r&&(l=vw(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 gw(e,t,n){if(!(e.state.selection instanceof Zo))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 yw(e,t){for(;t&&t!=e.dom;t=t.parentNode)if("TD"==t.nodeName||"TH"==t.nodeName)return t;return null}function vw(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&&Mx(e.state.doc.resolve(r))||Mx(e.state.doc.resolve(i))}var bw=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")),xw(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,xw(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return"attributes"==e.type&&(e.target==this.table||this.colgroup.contains(e.target))}};function xw(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 ww=new gs("tableColumnResizing");function Ew({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=bw,lastColumnResizable:i=!0}={}){const o=new hs({key:ww,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=wx(t.schema).table.name;return r&&s&&(s[a]=(e,t)=>new r(e,n,t)),new Mw(-1,!1)},apply:(e,t)=>t.apply(e)},props:{attributes:e=>{const t=ww.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=ww.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=Sw(e,t,"left",n):i-t.clientX<=n&&(s=Sw(e,t,"right",n))}if(s!=i.activeHandle){if(!r&&-1!==s){const t=e.state.doc.resolve(s),n=t.node(-1),r=bx.get(n),i=t.start(-1);if(r.colCount(t.pos-i)+t.nodeAfter.attrs.colspan-1==r.width-1)return}Nw(e,s)}}}(t,n,e,i)},mouseleave:e=>{!function(e){if(!e.editable)return;const t=ww.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&Nw(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=ww.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=ww.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=bx.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():kw(c.colspan);d[u]=n,l.setNodeMarkup(s+r,null,{...c,colwidth:d})}l.docChanged&&e.dispatch(l)}(e,r.activeHandle,Cw(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(ww,{setDragging:null})))}function u(t){if(!t.which)return c(t);const i=ww.getState(e.state);if(i&&i.dragging){const o=Cw(i.dragging,t,n);Aw(e,i.activeHandle,o,r)}}e.dispatch(e.state.tr.setMeta(ww,{setDragging:{startX:t.clientX,startWidth:l}})),Aw(e,s.activeHandle,l,r),o.addEventListener("mouseup",c),o.addEventListener("mousemove",u),t.preventDefault()}(e,r,t,n)}},decorations:e=>{const t=ww.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 nc.empty;const o=bx.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=ww.getState(e))||void 0===l?void 0:l.dragging)&&n.push(Ql.node(s+t,s+t+i.nodeAt(t).nodeSize,{class:"column-resize-dragging"})),n.push(Ql.widget(a,c))}}return nc.create(e.doc,n)}(e,t.activeHandle)},nodeViews:{}}});return o}var Mw=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){const n=this,r=t.getMeta(ww);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 Nx(t.doc.resolve(r))||(r=-1),new e(r,n.dragging)}return n}};function Sw(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=Mx(e.state.doc.resolve(s));if(!a)return-1;if("right"==n)return a.pos;const l=bx.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 Cw(e,t,n){const r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function Nw(e,t){e.dispatch(e.state.tr.setMeta(ww,{setHandle:t}))}function Aw(e,t,n,r){const i=e.state.doc.resolve(t),o=i.node(-1),s=i.start(-1),a=bx.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&&xw(o,l.firstChild,l,r,a,n)}function kw(e){return Array(e).fill(0)}function Tw({allowTableNodeSelection:e=!1}={}){return new hs({key:Ex,state:{init:()=>null,apply(e,t){const n=e.getMeta(Ex);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:Dx,handleDOMEvents:{mousedown:mw},createSelectionBetween:e=>null!=Ex.getState(e.state)?e.state.selection:null,handleTripleClick:hw,handleKeyDown:cw,handlePaste:fw},appendTransaction:(t,n,r)=>function(e,t,n){const r=(t||e).selection,i=(t||e).doc;let o,s;if(r instanceof Qo&&(s=r.node.type.spec.tableRole)){if("cell"==s||"header_cell"==s)o=_x.create(i,r.from);else if("row"==s){const e=i.resolve(r.from+1);o=_x.rowSelection(e,e)}else if(!n){const e=bx.get(r.node),t=r.from+1,n=t+e.map[e.width*e.height-1];o=_x.create(i,t+1,n)}}else r instanceof Zo&&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=Zo.create(i,r.from):r instanceof Zo&&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=Zo.create(i,r.$from.start(),r.$from.end()));return o&&(t||(t=e.tr)).setSelection(o),t}(r,Bx(r,n),e)})}var Ow=Zp.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",Fu(this.options.HTMLAttributes,e),0]}}),_w=Zp.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",Fu(this.options.HTMLAttributes,e),0]}}),Rw=Zp.create({name:"tableRow",addOptions:()=>({HTMLAttributes:{}}),content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML:()=>[{tag:"tr"}],renderHTML({HTMLAttributes:e}){return["tr",Fu(this.options.HTMLAttributes,e),0]}});function Dw(e,t){return t?["width",`${Math.max(t,e)}px`]:["min-width",`${e}px`]}function Iw(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]=Dw(r,s);c.style.setProperty(e,t)}c=c.nextSibling}else{const e=document.createElement("col"),[n,i]=Dw(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 Lw=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")),Iw(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,Iw(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return"attributes"===e.type&&(e.target===this.table||this.colgroup.contains(e.target))}};function Bw(e,t){return t?e.createChecked(null,t):e.createAndFill()}function zw(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=Bw(o.cell,i);if(e&&a.push(e),r){const e=Bw(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 Pw=({editor:e})=>{const{selection:t}=e.state;if(!(t instanceof _x))return!1;let n=0;const r=Ou(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)},Fw=Zp.create({name:"table",addOptions:()=>({HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:Lw,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]=Dw(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",Fu(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=zw(o.schema,e,t,n);if(i){const e=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(Zo.near(r.doc.resolve(e)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>Fx(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>jx(e,t),deleteColumn:()=>({state:e,dispatch:t})=>Hx(e,t),addRowBefore:()=>({state:e,dispatch:t})=>qx(e,t),addRowAfter:()=>({state:e,dispatch:t})=>Vx(e,t),deleteRow:()=>({state:e,dispatch:t})=>Kx(e,t),deleteTable:()=>({state:e,dispatch:t})=>nw(e,t),mergeCells:()=>({state:e,dispatch:t})=>Jx(e,t),splitCell:()=>({state:e,dispatch:t})=>Yx(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>Qx("column")(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>Qx("row")(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>ew(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>!!Jx(e,t)||Yx(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>Zx(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>tw(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>tw(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&Bx(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){const n=_x.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:Pw,"Mod-Backspace":Pw,Delete:Pw,"Mod-Delete":Pw}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Ew({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Tw({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema:e=>({tableRole:Bu(Ru(e,"tableRole",{name:e.name,options:e.options,storage:e.storage}))})});Cd.create({name:"tableKit",addExtensions(){const e=[];return!1!==this.options.table&&e.push(Fw.configure(this.options.table)),!1!==this.options.tableCell&&e.push(Ow.configure(this.options.tableCell)),!1!==this.options.tableHeader&&e.push(_w.configure(this.options.tableHeader)),!1!==this.options.tableRow&&e.push(Rw.configure(this.options.tableRow)),e}});const jw=Fw.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 $w=Object.defineProperty,Hw=(e,t)=>{for(var n in t)$w(e,n,{get:t[n],enumerable:!0})};function Uw(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 qw=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:Uw({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 Vw=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&&Vw(r)}return e};function Ww(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 Vw(n)}function Kw(e,t,n){if(e instanceof vi||e instanceof Gr)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 Gr.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),Kw("",t,n)}if(r){if(n.errorOnInvalidContent){let r=!1,i="";const o=new zi({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?Fi.fromSchema(o).parseSlice(Ww(e),n.parseOptions):Fi.fromSchema(o).parse(Ww(e),n.parseOptions),n.errorOnInvalidContent&&r)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${i}`)})}const r=Fi.fromSchema(t);return n.slice?r.parseSlice(Ww(e),n.parseOptions).content:r.parse(Ww(e),n.parseOptions)}return Kw("",t,n)}function Gw(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 Jw(e){return t=>Gw(t.$from,e)}function Yw(e,t,n){if(void 0===e.config[t]&&e.parent)return Yw(e.parent,t,n);if("function"==typeof e.config[t]){return e.config[t].bind({...n,parent:e.parent?Yw(e.parent,t,n):null})}return e.config[t]}function Zw(e,t=void 0,...n){return function(e){return"function"==typeof e}(e)?t?e.bind(t)(...n):e(...n):e}function Xw(...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 Qw(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 eE(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 tE(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function nE(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 rE(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 iE(e,t,n={}){return e.find(e=>e.type===t&&rE(Object.fromEntries(Object.keys(n).map(t=>[t,e.attrs[t]])),n))}function oE(e,t,n={}){return!!iE(e,t,n)}function sE(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(!iE([...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&&oE([...e.parent.child(o-1).marks],t,n);)o-=1,s-=e.parent.child(o).nodeSize;for(;a<e.parent.childCount&&oE([...e.parent.child(a).marks],t,n);)l+=e.parent.child(a).nodeSize,a+=1;return{from:s,to:l}}function aE(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 lE(e,t,n={}){const{from:r,to:i,empty:o}=e.selection,s=t?eE(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=>rE(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 cE(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=Zw(Yw(r,"group",{name:r.name,options:r.options,storage:r.storage}));return"string"==typeof i&&i.split(" ").includes("list")}function uE(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&&(uE(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function dE(e){return e instanceof Zo}function pE(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function hE(e){return"Object"===function(e){return Object.prototype.toString.call(e).slice(8,-1)}(e)&&(e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype)}function fE(e,t){const n={...e};return hE(e)&&hE(t)&&Object.keys(t).forEach(r=>{hE(t[r])&&hE(e[r])?n[r]=fE(e[r],t[r]):n[r]=t[r]}),n}var mE=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{...Zw(Yw(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Zw(Yw(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(e={}){const t=this.extend({...this.config,addOptions:()=>fE(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}};Hw({},{ClipboardTextSerializer:()=>yE,Commands:()=>TM,Delete:()=>OM,Drop:()=>_M,Editable:()=>RM,FocusEvents:()=>IM,Keymap:()=>LM,Paste:()=>BM,Tabindex:()=>zM,focusEventsPluginKey:()=>DM});var gE=class e extends mE{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)}},yE=gE.create({name:"clipboardTextSerializer",addOptions:()=>({blockSeparator:void 0}),addProseMirrorPlugins(){return[new hs({key:new gs("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})}}})]}}),vE={};Hw(vE,{blur:()=>bE,clearContent:()=>xE,clearNodes:()=>wE,command:()=>EE,createParagraphNear:()=>ME,cut:()=>SE,deleteCurrentNode:()=>CE,deleteNode:()=>NE,deleteRange:()=>AE,deleteSelection:()=>kE,enter:()=>TE,exitCode:()=>OE,extendMarkRange:()=>_E,first:()=>RE,focus:()=>IE,forEach:()=>LE,insertContent:()=>BE,insertContentAt:()=>zE,joinBackward:()=>jE,joinDown:()=>FE,joinForward:()=>$E,joinItemBackward:()=>HE,joinItemForward:()=>UE,joinTextblockBackward:()=>qE,joinTextblockForward:()=>VE,joinUp:()=>PE,keyboardShortcut:()=>KE,lift:()=>GE,liftEmptyBlock:()=>JE,liftListItem:()=>YE,newlineInCode:()=>ZE,resetAttributes:()=>QE,scrollIntoView:()=>eM,selectAll:()=>tM,selectNodeBackward:()=>nM,selectNodeForward:()=>rM,selectParentNode:()=>iM,selectTextblockEnd:()=>oM,selectTextblockStart:()=>sM,setContent:()=>aM,setMark:()=>lM,setMeta:()=>cM,setNode:()=>uM,setNodeSelection:()=>dM,setTextSelection:()=>pM,sinkListItem:()=>hM,splitBlock:()=>mM,splitListItem:()=>gM,toggleList:()=>bM,toggleMark:()=>xM,toggleNode:()=>wM,toggleWrap:()=>EM,undoInputRule:()=>MM,unsetAllMarks:()=>SM,unsetMark:()=>CM,updateAttributes:()=>NM,wrapIn:()=>AM,wrapInList:()=>kM});var bE=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(t.dom.blur(),null==(n=null==window?void 0:window.getSelection())||n.removeAllRanges())}),!0),xE=(e=!0)=>({commands:t})=>t.setContent("",{emitUpdate:e}),wE=()=>({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=wo(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)},EE=e=>t=>e(t),ME=()=>({state:e,dispatch:t})=>cu(e,t),SE=(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 Zo(r.doc.resolve(Math.max(s-1,0)))),!0},CE=()=>({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},NE=e=>({tr:t,state:n,dispatch:r})=>{const i=eE(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},AE=e=>({tr:t,dispatch:n})=>{const{from:r,to:i}=e;return n&&t.delete(r,i),!0},kE=()=>({state:e,dispatch:t})=>qc(e,t),TE=()=>({commands:e})=>e.keyboardShortcut("Enter"),OE=()=>({state:e,dispatch:t})=>lu(e,t),_E=(e,t={})=>({tr:n,state:r,dispatch:i})=>{const o=Qw(e,r.schema),{doc:s,selection:a}=n,{$from:l,from:c,to:u}=a;if(i){const e=sE(l,o,t);if(e&&e.from<=c&&e.to>=u){const t=Zo.create(s,e.from,e.to);n.setSelection(t)}}return!0},RE=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 DE(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var IE=(e=null,t={})=>({editor:n,view:r,tr:i,dispatch:o})=>{t={scrollIntoView:!0,...t};const s=()=>{(DE()||"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&&!dE(n.state.selection))return s(),!0;const a=function(e,t=null){if(!t)return null;const n=Ko.atStart(e),r=Ko.atEnd(e);if("start"===t||!0===t)return n;if("end"===t)return r;const i=n.from,o=r.to;return"all"===t?Zo.create(e,pE(0,i,o),pE(e.content.size,i,o)):Zo.create(e,pE(t,i,o),pE(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},LE=(e,t)=>n=>e.every((e,r)=>t(e,{...n,index:r})),BE=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),zE=(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{Kw(t,o.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(e){l(e)}try{i=Kw(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 Gr){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 go||i instanceof yo))return;const o=e.mapping.maps[r];let s=0;o.forEach((e,t,n,r)=>{0===s&&(s=r)}),e.setSelection(Ko.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},PE=()=>({state:e,dispatch:t})=>ru(e,t),FE=()=>({state:e,dispatch:t})=>iu(e,t),jE=()=>({state:e,dispatch:t})=>Wc(e,t),$E=()=>({state:e,dispatch:t})=>eu(e,t),HE=()=>({state:e,dispatch:t,tr:n})=>{try{const r=To(e.doc,e.selection.$from.pos,-1);return null!=r&&(n.join(r,2),t&&t(n),!0)}catch(e){return!1}},UE=()=>({state:e,dispatch:t,tr:n})=>{try{const r=To(e.doc,e.selection.$from.pos,1);return null!=r&&(n.join(r,2),t&&t(n),!0)}catch(e){return!1}},qE=()=>({state:e,dispatch:t})=>Kc(e,t),VE=()=>({state:e,dispatch:t})=>Gc(e,t);function WE(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}var KE=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}`);DE()||WE()?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},GE=(e,t={})=>({state:n,dispatch:r})=>!!lE(n,eE(e,n.schema),t)&&ou(n,r),JE=()=>({state:e,dispatch:t})=>uu(e,t),YE=e=>({state:t,dispatch:n})=>bu(eE(e,t.schema))(t,n),ZE=()=>({state:e,dispatch:t})=>su(e,t);function XE(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 QE=(e,t)=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null;const a=tE("string"==typeof e?e:e.name,r.schema);return!!a&&("node"===a&&(o=eE(e,r.schema)),"mark"===a&&(s=Qw(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,XE(e.attrs,t)),s&&e.marks.length&&e.marks.forEach(i=>{s===i.type&&n.addMark(r,r+e.nodeSize,s.create(XE(i.attrs,t)))})})}),!0)},eM=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),tM=()=>({tr:e,dispatch:t})=>{if(t){const t=new ts(e.doc);e.setSelection(t)}return!0},nM=()=>({state:e,dispatch:t})=>Zc(e,t),rM=()=>({state:e,dispatch:t})=>tu(e,t),iM=()=>({state:e,dispatch:t})=>du(e,t),oM=()=>({state:e,dispatch:t})=>mu(e,t),sM=()=>({state:e,dispatch:t})=>fu(e,t),aM=(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 Kw(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 lM=(e,t={})=>({tr:n,state:r,dispatch:i})=>{const{selection:o}=n,{empty:s,ranges:a}=o,l=Qw(e,r.schema);if(i)if(s){const e=function(e,t){const n=Qw(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(dE(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)},cM=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),uM=(e,t={})=>({state:n,dispatch:r,chain:i})=>{const o=eE(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})=>!!yu(o,{...s,...t})(n)||e.clearNodes()).command(({state:e})=>yu(o,{...s,...t})(e,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},dM=e=>({tr:t,dispatch:n})=>{if(n){const{doc:n}=t,r=pE(e,0,n.content.size),i=Qo.create(n,r);t.setSelection(i)}return!0},pM=e=>({tr:t,dispatch:n})=>{if(n){const{doc:n}=t,{from:r,to:i}="number"==typeof e?{from:e,to:e}:e,o=Zo.atStart(n).from,s=Zo.atEnd(n).to,a=pE(r,o,s),l=pE(i,o,s),c=Zo.create(n,a,l);t.setSelection(c)}return!0},hM=e=>({state:t,dispatch:n})=>xu(eE(e,t.schema))(t,n);function fM(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 mM=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:i})=>{const{selection:o,doc:s}=t,{$from:a,$to:l}=o,c=aE(i.extensionManager.attributes,a.node().type.name,a.node().attrs);if(o instanceof Qo&&o.node.isBlock)return!(!a.parentOffset||!No(s,a.pos))&&(r&&(e&&fM(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=No(t.doc,t.mapping.map(a.pos),1,p);if(p||h||!No(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 Zo&&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&&fM(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return h},gM=(e,t={})=>({tr:n,state:r,dispatch:i,editor:o})=>{var s;const a=eE(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=Gr.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=Gr.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={...aE(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(Gr.from(a.createAndFill(null,c)||void 0));const u=l.before(l.depth-(r-1));n.replace(u,l.after(-i),new ei(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(Zo.near(n.doc.resolve(d))),n.scrollIntoView()}return!0}const h=c.pos===l.end()?d.contentMatchAt(0).defaultType:null,f={...aE(p,d.type.name,d.attrs),...t},m={...aE(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(!No(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},yM=(e,t)=>{const n=Jw(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)||!Ao(e.doc,n.pos)||(e.join(n.pos),!0)},vM=(e,t)=>{const n=Jw(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)||!Ao(e.doc,r)||(e.join(r),!0)},bM=(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=eE(e,s.schema),f=eE(t,s.schema),{selection:m,storedMarks:g}=s,{$from:y,$to:v}=m,b=y.blockRange(v),x=g||m.$to.parentOffset&&m.$from.marks();if(!b)return!1;const w=Jw(e=>cE(e.type.name,d))(m);if(b.depth>=1&&w&&b.depth-w.depth<=1){if(w.node.type===h)return c.liftListItem(f);if(cE(w.node.type.name,d)&&h.validContent(w.node.content)&&a)return l().command(()=>(o.setNodeMarkup(w.pos,h),!0)).command(()=>yM(o,h)).command(()=>vM(o,h)).run()}return n&&x&&a?l().command(()=>{const e=u().wrapInList(h,r),t=x.filter(e=>p.includes(e.type.name));return o.ensureMarks(t),!!e||c.clearNodes()}).wrapInList(h,r).command(()=>yM(o,h)).command(()=>vM(o,h)).run():l().command(()=>!!u().wrapInList(h,r)||c.clearNodes()).wrapInList(h,r).command(()=>yM(o,h)).command(()=>vM(o,h)).run()},xM=(e,t={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:o=!1}=n,s=Qw(e,r.schema),a=function(e,t,n={}){const{empty:r,ranges:i}=e.selection,o=t?Qw(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>!o||o.name===e.type.name).find(e=>rE(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=>rE(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)},wM=(e,t,n={})=>({state:r,commands:i})=>{const o=eE(e,r.schema),s=eE(t,r.schema),a=lE(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})},EM=(e,t={})=>({state:n,commands:r})=>{const i=eE(e,n.schema);return lE(n,i,t)?r.lift(i):r.wrapIn(i,t)},MM=()=>({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},SM=()=>({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},CM=(e,t={})=>({tr:n,state:r,dispatch:i})=>{var o;const{extendEmptyMarkRange:s=!1}=t,{selection:a}=n,l=Qw(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=sE(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},NM=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null;const a=tE("string"==typeof e?e:e.name,r.schema);return!!a&&("node"===a&&(o=eE(e,r.schema)),"mark"===a&&(s=Qw(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)},AM=(e,t={})=>({state:n,dispatch:r})=>gu(eE(e,n.schema),t)(n,r),kM=(e,t={})=>({state:n,dispatch:r})=>vu(eE(e,n.schema),t)(n,r),TM=gE.create({name:"commands",addCommands:()=>({...vE})}),OM=gE.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 Vo(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}})})}),nE(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 ho){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()}}),_M=gE.create({name:"drop",addProseMirrorPlugins(){return[new hs({key:new gs("tiptapDrop"),props:{handleDrop:(e,t,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),RM=gE.create({name:"editable",addProseMirrorPlugins(){return[new hs({key:new gs("editable"),props:{editable:()=>this.editor.options.editable}})]}}),DM=new gs("focusEvents"),IM=gE.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:e}=this;return[new hs({key:DM,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}}}})]}}),LM=gE.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:Ko.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 DE()||WE()?i:r},addProseMirrorPlugins(){return[new hs({key:new gs("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=Ko.atStart(t.doc).from,c=Ko.atEnd(t.doc).to;if(o||!(s===l&&a===c))return;if(!uE(n.doc))return;const u=n.tr,d=Uw({state:n,transaction:u}),{commands:p}=new qw({editor:this.editor,state:d});return p.clearNodes(),u.steps.length?u:void 0}})]}}),BM=gE.create({name:"paste",addProseMirrorPlugins(){return[new hs({key:new gs("tiptapPaste"),props:{handlePaste:(e,t,n)=>{this.editor.emit("paste",{editor:this.editor,event:t,slice:n})}}})]}}),zM=gE.create({name:"tabindex",addProseMirrorPlugins(){return[new hs({key:new gs("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),PM=class e extends mE{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)}},FM=PM.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",Xw(this.options.HTMLAttributes,e),0]}}),jM=PM.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",Xw(this.options.HTMLAttributes,e),0]}}),$M=PM.create({name:"tableRow",addOptions:()=>({HTMLAttributes:{}}),content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML:()=>[{tag:"tr"}],renderHTML({HTMLAttributes:e}){return["tr",Xw(this.options.HTMLAttributes,e),0]}});function HM(e,t){return t?["width",`${Math.max(t,e)}px`]:["min-width",`${e}px`]}function UM(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]=HM(r,s);c.style.setProperty(e,t)}c=c.nextSibling}else{const e=document.createElement("col"),[n,i]=HM(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 qM=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")),UM(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,UM(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return"attributes"===e.type&&(e.target===this.table||this.colgroup.contains(e.target))}};function VM(e,t){return t?e.createChecked(null,t):e.createAndFill()}function WM(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=VM(o.cell,i);if(e&&a.push(e),r){const e=VM(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 KM=({editor:e})=>{const{selection:t}=e.state;if(!(t instanceof _x))return!1;let n=0;const r=Gw(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)},GM=PM.create({name:"table",addOptions:()=>({HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:qM,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]=HM(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",Xw(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=WM(o.schema,e,t,n);if(i){const e=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(Zo.near(r.doc.resolve(e)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>Fx(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>jx(e,t),deleteColumn:()=>({state:e,dispatch:t})=>Hx(e,t),addRowBefore:()=>({state:e,dispatch:t})=>qx(e,t),addRowAfter:()=>({state:e,dispatch:t})=>Vx(e,t),deleteRow:()=>({state:e,dispatch:t})=>Kx(e,t),deleteTable:()=>({state:e,dispatch:t})=>nw(e,t),mergeCells:()=>({state:e,dispatch:t})=>Jx(e,t),splitCell:()=>({state:e,dispatch:t})=>Yx(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>Qx("column")(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>Qx("row")(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>ew(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>!!Jx(e,t)||Yx(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>Zx(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>tw(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>tw(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&Bx(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){const n=_x.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:KM,"Mod-Backspace":KM,Delete:KM,"Mod-Delete":KM}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Ew({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Tw({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema:e=>({tableRole:Zw(Yw(e,"tableRole",{name:e.name,options:e.options,storage:e.storage}))})});gE.create({name:"tableKit",addExtensions(){const e=[];return!1!==this.options.table&&e.push(GM.configure(this.options.table)),!1!==this.options.tableCell&&e.push(FM.configure(this.options.tableCell)),!1!==this.options.tableHeader&&e.push(jM.configure(this.options.tableHeader)),!1!==this.options.tableRow&&e.push($M.configure(this.options.tableRow)),e}});const JM="(div | paragraph | heading | bulletList | orderedList | blockquote | codeBlock | horizontalRule | image | imageUploadNode)+",YM=FM.extend({content:JM}),ZM=jM.extend({content:JM}),XM=Zp.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&&(!(e=>{for(let t=e.depth;t>=0;t-=1)if("listItem"===e.node(t).type.name)return!0;return!1})(t)&&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}}}}),QM=Cd.create({name:"ensureEmptyRootIsDiv",addProseMirrorPlugins(){const e=new gs(this.name);return[new hs({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())}})]}}),eS=Cd.create({name:"ensureListItemContentIsDiv",addProseMirrorPlugins(){const e=new gs(this.name);return[new hs({key:e,appendTransaction(e,t,n){if(!e.some(e=>e.docChanged))return null;const{doc:r,schema:i}=n,o=i.nodes.div;if(!o)return null;const s=[];if(r.descendants((e,t)=>{if("listItem"!==e.type.name)return;let n=1;e.forEach(e=>{"paragraph"===e.type.name&&s.push({pos:t+n,attrs:e.attrs}),n+=e.nodeSize})}),0===s.length)return null;const a=n.tr;return s.sort((e,t)=>t.pos-e.pos).forEach(({pos:e,attrs:t})=>a.setNodeMarkup(e,o,t)),a}})]}}),tS="pie-toolbar",nS=e,{IconButton:rS}=n,{Check:iS}=o,{styled:oS}=r,sS=i,aS=oS(rS)({verticalAlign:"top",width:"28px",height:"28px",color:"var(--editable-html-toolbar-check, #00bb00)",padding:"4px"}),lS=({onClick:e,doneButtonRef:t})=>nS.createElement(aS,{"aria-label":"Done",buttonRef:t,onClick:e},nS.createElement(iS,null));lS.propTypes={onClick:sS.func,doneButtonRef:sS.func};const cS=lS,uS=e,{IconButton:dS}=n,{Delete:pS}=o,{styled:hS}=r;const fS=hS("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"}})),mS=hS(dS)({width:"28px",height:"28px",padding:"4px",verticalAlign:"top"}),gS=hS("div")({display:"flex"});function yS(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 uS.createElement(fS,{className:tS,showDone:l,toolbarAlignment:r.alignment,isFocused:r.alwaysVisible||o,autoWidth:i,isHidden:!0===r.isHidden,style:{...d,...u}},t,uS.createElement(gS,null,n&&uS.createElement(mS,{"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)])},uS.createElement(pS,null)),l&&uS.createElement(cS,{doneButtonRef:s,onClick:c})))}const vS=e,{useEffect:bS}=e,{useRef:xS}=e,{useState:wS}=e,ES=t,MS=i;const SS=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]=wS(!1),h=l([n,u],t,()=>{}),f=xS(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 bS(()=>{const{selection:e}=t.state,r=e.from+n.nodeSize===e.to;o?r&&p(o):p(o)},[t,n,o]),bS(()=>{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]),vS.createElement(Uh,{className:"drag-in-the-blank","data-selected":o,style:{display:"inline-flex",minHeight:"55px",position:"relative",cursor:"pointer"}},vS.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&&vS.createElement("div",{ref:f,className:"absolute z-50 bg-white shadow-lg rounded p-2",style:{zIndex:1}},vS.createElement(h,null)),d&&t._tiptapContainerEl&&ES.createPortal(vS.createElement(yS,{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))};SS.propTypes={attributes:MS.object,error:MS.any,value:MS.string,isFocused:MS.bool};const{useMemo:CS}=e,{useLayoutEffect:NS}=e,{useEffect:AS}=e,{useRef:kS}=e,{useCallback:TS}=e,OS="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement;function _S(e){const t=Object.prototype.toString.call(e);return"[object Window]"===t||"[object global]"===t}function RS(e){return"nodeType"in e}function DS(e){var t,n;return e?_S(e)?e:RS(e)&&null!=(t=null==(n=e.ownerDocument)?void 0:n.defaultView)?t:window:window}function IS(e){const{Document:t}=DS(e);return e instanceof t}function LS(e){return!_S(e)&&e instanceof DS(e).HTMLElement}function BS(e){return e instanceof DS(e).SVGElement}function zS(e){return e?_S(e)?e.document:RS(e)?IS(e)?e:LS(e)||BS(e)?e.ownerDocument:document:document:document}const PS=OS?NS:AS;function FS(e){const t=kS(e);return PS(()=>{t.current=e}),TS(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 jS(e,t){void 0===t&&(t=[e]);const n=kS(e);return PS(()=>{n.current!==e&&(n.current=e)},t),n}function $S(e,t){const n=kS();return CS(()=>{const t=e(n.current);return n.current=t,t},[...t])}function HS(e){const t=FS(e),n=kS(null),r=TS(e=>{e!==n.current&&(null==t||t(e,n.current)),n.current=e},[]);return[n,r]}function US(e){const t=kS();return AS(()=>{t.current=e},[e]),t.current}let qS={};function VS(e,t){return CS(()=>{if(t)return t;const n=null==qS[e]?0:qS[e]+1;return qS[e]=n,e+"-"+n},[e,t])}function WS(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 KS=WS(1),GS=WS(-1);function JS(e){if(!e)return!1;const{KeyboardEvent:t}=DS(e.target);return t&&e instanceof t}function YS(e){if(function(e){if(!e)return!1;const{TouchEvent:t}=DS(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 ZS=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[ZS.Translate.toString(e),ZS.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),XS="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function QS(e){return e.matches(XS)?e:e.querySelector(XS)}const eC=e,{useState:tC}=e,{useCallback:nC}=e,rC={display:"none"};function iC(e){let{id:t,value:n}=e;return eC.createElement("div",{id:t,style:rC},n)}function oC(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;return eC.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 sC=e,{createContext:aC}=e,{useContext:lC}=e,{useEffect:cC}=e,{useState:uC}=e,{useCallback:dC}=e,{useMemo:pC}=e,{useRef:hC}=e,{memo:fC}=e,{useReducer:mC}=e,{cloneElement:gC}=e,{forwardRef:yC}=e,{createPortal:vC}=t,{unstable_batchedUpdates:bC}=t,xC=aC(null);const wC={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 "},EC={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 MC(e){let{announcements:t=EC,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=wC}=e;const{announce:o,announcement:s}=function(){const[e,t]=tC("");return{announce:nC(e=>{null!=e&&t(e)},[]),announcement:e}}(),a=VS("DndLiveRegion"),[l,c]=uC(!1);if(cC(()=>{c(!0)},[]),function(e){const t=lC(xC);cC(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}(pC(()=>({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=sC.createElement(sC.Fragment,null,sC.createElement(iC,{id:r,value:i.draggable}),sC.createElement(oC,{id:a,announcement:s}));return n?vC(u,n):u}var SC;function CC(){}!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"}(SC||(SC={}));const NC=Object.freeze({x:0,y:0});function AC(e,t){const n=YS(e);if(!n)return"0 0";return(n.x-t.left)/t.width*100+"% "+(n.y-t.top)/t.height*100+"%"}function kC(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function TC(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 OC=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=TC(o,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(kC)};function _C(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:NC}const RC=(DC=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+DC*t.y,bottom:e.bottom+DC*t.y,left:e.left+DC*t.x,right:e.right+DC*t.x}),{...e})});var DC;function IC(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 LC={ignoreTransform:!1};function BC(e,t){void 0===t&&(t=LC);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:t,transformOrigin:r}=DS(e).getComputedStyle(e);t&&(n=function(e,t,n){const r=IC(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 zC(e){return BC(e,{ignoreTransform:!0})}function PC(e,t){const n=[];return e?function r(i){if(null!=t&&n.length>=t)return n;if(!i)return n;if(IS(i)&&null!=i.scrollingElement&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!LS(i)||BS(i))return n;if(n.includes(i))return n;const o=DS(e).getComputedStyle(i);return i!==e&&function(e,t){void 0===t&&(t=DS(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=DS(e).getComputedStyle(e)),"fixed"===t.position}(i,o)?n:r(i.parentNode)}(e):n}function FC(e){const[t]=PC(e,1);return null!=t?t:null}function jC(e){return OS&&e?_S(e)?e:RS(e)?IS(e)||e===zS(e).scrollingElement?window:LS(e)?e:null:null:null}function $C(e){return _S(e)?e.scrollX:e.scrollLeft}function HC(e){return _S(e)?e.scrollY:e.scrollTop}function UC(e){return{x:$C(e),y:HC(e)}}var qC;function VC(e){return!(!OS||!e)&&e===document.scrollingElement}function WC(e){const t={x:0,y:0},n=VC(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"}(qC||(qC={}));const KC={x:.2,y:.2};function GC(e,t,n,r,i){let{top:o,left:s,right:a,bottom:l}=n;void 0===r&&(r=10),void 0===i&&(i=KC);const{isTop:c,isBottom:u,isLeft:d,isRight:p}=WC(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=qC.Backward,f.y=r*Math.abs((t.top+m-o)/m)):!u&&l>=t.bottom-m&&(h.y=qC.Forward,f.y=r*Math.abs((t.bottom-m-l)/m)),!p&&a>=t.right-g?(h.x=qC.Forward,f.x=r*Math.abs((t.right-g-a)/g)):!d&&s<=t.left+g&&(h.x=qC.Backward,f.x=r*Math.abs((t.left+g-s)/g)),{direction:h,speed:f}}function JC(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 YC(e){return e.reduce((e,t)=>KS(e,UC(t)),NC)}function ZC(e,t){if(void 0===t&&(t=BC),!e)return;const{top:n,left:r,bottom:i,right:o}=t(e);FC(e)&&(i<=0||o<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const XC=[["x",["left","right"],function(e){return e.reduce((e,t)=>e+$C(t),0)}],["y",["top","bottom"],function(e){return e.reduce((e,t)=>e+HC(t),0)}]];class QC{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=PC(t),r=YC(n);this.rect={...e},this.width=e.width,this.height=e.height;for(const[e,t,i]of XC)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 eN{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 tN(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 nN,rN;function iN(e){e.preventDefault()}function oN(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"}(nN||(nN={})),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"}(rN||(rN={}));const sN={start:[rN.Space,rN.Enter],cancel:[rN.Esc],end:[rN.Space,rN.Enter,rN.Tab]},aN=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case rN.Right:return{...n,x:n.x+25};case rN.Left:return{...n,x:n.x-25};case rN.Down:return{...n,y:n.y+25};case rN.Up:return{...n,y:n.y-25}}};class lN{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 eN(zS(t)),this.windowListeners=new eN(DS(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(nN.Resize,this.handleCancel),this.windowListeners.add(nN.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(nN.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&ZC(n),t(NC)}handleKeyDown(e){if(JS(e)){const{active:t,context:n,options:r}=this.props,{keyboardCodes:i=sN,coordinateGetter:o=aN,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}:NC;this.referenceCoordinates||(this.referenceCoordinates=c);const u=o(e,{active:t,context:n.current,currentCoordinates:c});if(u){const t=GS(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}=WC(n),h=JC(n),f={x:Math.min(i===rN.Right?h.right-h.width/2:h.right,Math.max(i===rN.Right?h.left:h.left+h.width/2,u.x)),y:Math.min(i===rN.Down?h.bottom-h.height/2:h.bottom,Math.max(i===rN.Down?h.top:h.top+h.height/2,u.y))},m=i===rN.Right&&!a||i===rN.Left&&!l,g=i===rN.Down&&!c||i===rN.Up&&!o;if(m&&f.x!==u.x){const e=n.scrollLeft+t.x,o=i===rN.Right&&e<=d.x||i===rN.Left&&e>=p.x;if(o&&!t.y)return void n.scrollTo({left:e,behavior:s});r.x=o?n.scrollLeft-e:i===rN.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===rN.Down&&e<=d.y||i===rN.Up&&e>=p.y;if(o&&!t.x)return void n.scrollTo({top:e,behavior:s});r.y=o?n.scrollTop-e:i===rN.Down?n.scrollTop-d.y:n.scrollTop-p.y,r.y&&n.scrollBy({top:-r.y,behavior:s});break}}this.handleMove(e,KS(GS(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 cN(e){return Boolean(e&&"distance"in e)}function uN(e){return Boolean(e&&"delay"in e)}lN.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=sN,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 dN{constructor(e,t,n){var r;void 0===n&&(n=function(e){const{EventTarget:t}=DS(e);return e instanceof t?e:zS(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=zS(o),this.documentListeners=new eN(this.document),this.listeners=new eN(n),this.windowListeners=new eN(DS(o)),this.initialCoordinates=null!=(r=YS(i))?r:NC,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(nN.Resize,this.handleCancel),this.windowListeners.add(nN.DragStart,iN),this.windowListeners.add(nN.VisibilityChange,this.handleCancel),this.windowListeners.add(nN.ContextMenu,iN),this.documentListeners.add(nN.Keydown,this.handleKeydown),t){if(null!=n&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(uN(t))return this.timeoutId=setTimeout(this.handleStart,t.delay),void this.handlePending(t);if(cN(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(nN.Click,oN,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(nN.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=YS(e))?t:NC,l=GS(r,a);if(!n&&s){if(cN(s)){if(null!=s.tolerance&&tN(l,s.tolerance))return this.handleCancel();if(tN(l,s.distance))return this.handleStart()}return uN(s)&&tN(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===rN.Esc&&this.handleCancel()}removeTextSelection(){var e;null==(e=this.document.getSelection())||e.removeAllRanges()}}const pN={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class hN extends dN{constructor(e){const{event:t}=e,n=zS(t.target);super(e,pN,n)}}hN.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 fN={move:{name:"mousemove"},end:{name:"mouseup"}};var mN;!function(e){e[e.RightClick=2]="RightClick"}(mN||(mN={}));(class extends dN{constructor(e){super(e,fN,zS(e.event.target))}}).activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button!==mN.RightClick&&(null==r||r({event:n}),!0)}}];const gN={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};var yN,vN;function bN(e){let{acceleration:t,activator:n=yN.Pointer,canScroll:r,draggingRect:i,enabled:o,interval:s=5,order:a=vN.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:u,delta:d,threshold:p}=e;const h=function(e){let{delta:t,disabled:n}=e;const r=US(t);return $S(e=>{if(n||!r||!e)return xN;const i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[qC.Backward]:e.x[qC.Backward]||-1===i.x,[qC.Forward]:e.x[qC.Forward]||1===i.x},y:{[qC.Backward]:e.y[qC.Backward]||-1===i.y,[qC.Forward]:e.y[qC.Forward]||1===i.y}}},[n,t,r])}({delta:d,disabled:!o}),[f,m]=function(){const e=kS(null);return[TS((t,n)=>{e.current=setInterval(t,n)},[]),TS(()=>{null!==e.current&&(clearInterval(e.current),e.current=null)},[])]}(),g=hC({x:0,y:0}),y=hC({x:0,y:0}),v=pC(()=>{switch(n){case yN.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case yN.DraggableRect:return i}},[n,i,l]),b=hC(null),x=dC(()=>{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)},[]),w=pC(()=>a===vN.TreeOrder?[...c].reverse():c,[a,c]);cC(()=>{if(o&&c.length&&v){for(const e of w){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}=GC(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(x,s),g.current=a,void(y.current=o)}g.current={x:0,y:0},y.current={x:0,y:0},m()}else m()},[t,x,r,m,o,s,JSON.stringify(v),JSON.stringify(h),f,c,w,u,JSON.stringify(p)])}(class extends dN{constructor(e){super(e,gN)}static setup(){return window.addEventListener(gN.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(gN.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"}(yN||(yN={})),function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"}(vN||(vN={}));const xN={x:{[qC.Backward]:!1,[qC.Forward]:!1},y:{[qC.Backward]:!1,[qC.Forward]:!1}};var wN,EN;!function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"}(wN||(wN={})),function(e){e.Optimized="optimized"}(EN||(EN={}));const MN=new Map;function SN(e,t){return $S(n=>e?n||("function"==typeof t?t(e):e):null,[t,e])}function CN(e){let{callback:t,disabled:n}=e;const r=FS(t),i=pC(()=>{if(n||"undefined"==typeof window||void 0===window.ResizeObserver)return;const{ResizeObserver:e}=window;return new e(r)},[n]);return cC(()=>()=>null==i?void 0:i.disconnect(),[i]),i}function NN(e){return new QC(BC(e),e)}function AN(e,t,n){void 0===t&&(t=NN);const[r,i]=uC(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=FS(t),i=pC(()=>{if(n||"undefined"==typeof window||void 0===window.MutationObserver)return;const{MutationObserver:e}=window;return new e(r)},[r,n]);return cC(()=>()=>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=CN({callback:o});return PS(()=>{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 kN=[];function TN(e,t){void 0===t&&(t=[]);const n=hC(null);return cC(()=>{n.current=null},t),cC(()=>{const t=e!==NC;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?GS(e,n.current):NC}function ON(e){return pC(()=>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 _N=[];function RN(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return LS(t)?t:e}const DN=[{sensor:hN,options:{}},{sensor:lN,options:{}}],IN={current:{}},LN={draggable:{measure:zC},droppable:{measure:zC,strategy:wN.WhileDragging,frequency:EN.Optimized},dragOverlay:{measure:BC}};class BN 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 zN={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new BN,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:CC},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:LN,measureDroppableContainers:CC,windowRect:null,measuringScheduled:!1},PN={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:CC,draggableNodes:new Map,over:null,measureDroppableContainers:CC},FN=aC(PN),jN=aC(zN);function $N(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new BN}}}function HN(e,t){switch(t.type){case SC.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case SC.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 SC.DragEnd:case SC.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case SC.RegisterDroppable:{const{element:n}=t,{id:r}=n,i=new BN(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case SC.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 BN(e.droppable.containers);return s.set(n,{...o,disabled:i}),{...e,droppable:{...e.droppable,containers:s}}}case SC.UnregisterDroppable:{const{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;const o=new BN(e.droppable.containers);return o.delete(n),{...e,droppable:{...e.droppable,containers:o}}}default:return e}}function UN(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:i}=lC(FN),o=US(r),s=US(null==n?void 0:n.id);return cC(()=>{if(!t&&!r&&o&&null!=s){if(!JS(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=QS(e);if(t){t.focus();break}}})}},[r,t,i,s,o]),null}function qN(e,t){let{transform:n,...r}=t;return null!=e&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}const VN=aC({...NC,scaleX:1,scaleY:1});var WN;!function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"}(WN||(WN={})),fC(function(e){var t,n,r,i;let{id:o,accessibility:s,autoScroll:a=!0,children:l,sensors:c=DN,collisionDetection:u=OC,measuring:d,modifiers:p,...h}=e;const f=mC(HN,void 0,$N),[m,g]=f,[y,v]=function(){const[e]=uC(()=>new Set),t=dC(t=>(e.add(t),()=>e.delete(t)),[e]);return[dC(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,x]=uC(WN.Uninitialized),w=b===WN.Initialized,{draggable:{active:E,nodes:M,translate:S},droppable:{containers:C}}=m,N=null!=E?M.get(E):null,A=hC({initial:null,translated:null}),k=pC(()=>{var e;return null!=E?{id:E,data:null!=(e=null==N?void 0:N.data)?e:IN,rect:A}:null},[E,N]),T=hC(null),[O,_]=uC(null),[R,D]=uC(null),I=jS(h,Object.values(h)),L=VS("DndDescribedBy",o),B=pC(()=>C.getEnabled(),[C]),z=function(e){return pC(()=>({draggable:{...LN.draggable,...null==e?void 0:e.draggable},droppable:{...LN.droppable,...null==e?void 0:e.droppable},dragOverlay:{...LN.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:F,measuringScheduled:j}=function(e,t){let{dragging:n,dependencies:r,config:i}=t;const[o,s]=uC(null),{frequency:a,measure:l,strategy:c}=i,u=hC(e),d=function(){switch(c){case wN.Always:return!1;case wN.BeforeDragging:return n;default:return!n}}(),p=jS(d),h=dC(function(e){void 0===e&&(e=[]),p.current||s(t=>null===t?e:t.concat(e.filter(e=>!t.includes(e))))},[p]),f=hC(null),m=$S(t=>{if(d&&!n)return MN;if(!t||t===MN||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 QC(l(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,o,n,d,l]);return cC(()=>{u.current=e},[e]),cC(()=>{d||h()},[n,d]),cC(()=>{o&&o.length>0&&s(null)},[JSON.stringify(o)]),cC(()=>{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:w,dependencies:[S.x,S.y],config:z.droppable}),$=function(e,t){const n=null!=t?e.get(t):void 0,r=n?n.node.current:null;return $S(e=>{var n;return null==t?null:null!=(n=null!=r?r:e)?n:null},[r,t])}(M,E),H=pC(()=>R?YS(R):null,[R]),U=function(){const e=!1===(null==O?void 0:O.autoScrollEnabled),t="object"==typeof a?!1===a.enabled:!1===a,n=w&&!e&&!t;if("object"==typeof a)return{...a,enabled:n};return{enabled:n}}(),q=function(e,t){return SN(e,t)}($,z.draggable.measure);!function(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e;const o=hC(!1),{x:s,y:a}="boolean"==typeof i?{x:i,y:i}:i;PS(()=>{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=_C(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=FC(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,s,a,r,n])}({activeNode:null!=E?M.get(E):null,config:U.layoutShiftCompensation,initialRect:q,measure:z.draggable.measure});const V=AN($,z.draggable.measure,q),W=AN($?$.parentElement:null),K=hC({activatorEvent:null,active:null,activeNode:$,collisionRect:null,collisions:null,droppableRects:P,draggableNodes:M,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]=uC(null),i=CN({callback:dC(e=>{for(const{target:n}of e)if(LS(n)){r(e=>{const r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),o=dC(e=>{const n=RN(e);null==i||i.disconnect(),n&&(null==i||i.observe(n)),r(n?t(n):null)},[t,i]),[s,a]=HS(o);return pC(()=>({nodeRef:s,rect:n,setRef:a}),[n,s,a])}({measure:z.dragOverlay.measure}),Y=null!=(n=J.nodeRef.current)?n:$,Z=w?null!=(r=J.rect)?r:V:null,X=Boolean(J.nodeRef.current&&J.rect),Q=_C(ee=X?null:V,SN(ee));var ee;const te=ON(Y?DS(Y):null),ne=function(e){const t=hC(e),n=$S(n=>e?n&&n!==kN&&e&&t.current&&e.parentNode===t.current.parentNode?n:PC(e):kN,[e]);return cC(()=>{t.current=e},[e]),n}(w?null!=G?G:$:null),re=function(e,t){void 0===t&&(t=BC);const[n]=e,r=ON(n?DS(n):null),[i,o]=uC(_N);function s(){o(()=>e.length?e.map(e=>VC(e)?r:new QC(t(e),e)):_N)}const a=CN({callback:s});return PS(()=>{null==a||a.disconnect(),s(),e.forEach(e=>null==a?void 0:a.observe(e))},[e]),i}(ne),ie=qN(p,{transform:{x:S.x-Q.x,y:S.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?KS(H,S):null,se=function(e){const[t,n]=uC(null),r=hC(e),i=dC(e=>{const t=jC(e.target);t&&n(e=>e?(e.set(t,UC(t)),new Map(e)):null)},[]);return cC(()=>{const t=r.current;if(e!==t){o(t);const s=e.map(e=>{const t=jC(e);return t?(t.addEventListener("scroll",i,{passive:!0}),[t,UC(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=jC(e);null==t||t.removeEventListener("scroll",i)})}},[i,e]),pC(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>KS(e,t),NC):YC(e):NC,[e,t])}(ne),ae=TN(se),le=TN(se,[V]),ce=KS(ie,ae),ue=Z?RC(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]=uC(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:KS(ie,le),null!=(i=null==he?void 0:he.rect)?i:null,V),ge=hC(null),ye=dC((e,t)=>{let{sensor:n,options:r}=t;if(null==T.current)return;const i=M.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(!M.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(!M.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=M.get(t);if(!n)return;const{onDragStart:r}=I.current,i={activatorEvent:o,active:{id:t,data:n.data,rect:A}};bC(()=>{null==r||r(i),x(WN.Initializing),g({type:SC.DragStart,initialCoordinates:e,active:t}),y({type:"onDragStart",event:i}),_(ge.current),D(o)})},onMove(e){g({type:SC.DragMove,coordinates:e})},onEnd:a(SC.DragEnd),onCancel:a(SC.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===SC.DragEnd&&"function"==typeof a){await Promise.resolve(a(s))&&(e=SC.DragCancel)}}T.current=null,bC(()=>{g({type:e}),x(WN.Uninitialized),fe(null),_(null),D(null),ge.current=null;const t=e===SC.DragEnd?"onDragEnd":"onDragCancel";if(s){const e=I.current[t];null==e||e(s),y({type:t,event:s})}})}}ge.current=s},[M]),ve=dC((e,t)=>(n,r)=>{const i=n.nativeEvent,o=M.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))},[M,ye]),be=function(e,t){return pC(()=>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){cC(()=>{if(!OS)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),PS(()=>{V&&b===WN.Initializing&&x(WN.Initialized)},[V,b]),cC(()=>{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};bC(()=>{null==e||e(o),y({type:"onDragMove",event:o})})},[ce.x,ce.y]),cC(()=>{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};bC(()=>{fe(a),null==o||o(l),y({type:"onDragOver",event:l})})},[pe]),PS(()=>{K.current={activatorEvent:R,active:k,activeNode:$,collisionRect:ue,collisions:de,droppableRects:P,draggableNodes:M,draggingNode:Y,draggingNodeRect:Z,droppableContainers:C,over:he,scrollableAncestors:ne,scrollAdjustedTranslate:ce},A.current={initial:Z,translated:ue}},[k,$,de,ue,M,Y,Z,P,C,he,ne,ce]),bN({...U,delta:S,draggingRect:ue,pointerCoordinates:oe,scrollableAncestors:ne,scrollableAncestorRects:re});const xe=pC(()=>({active:k,activeNode:$,activeNodeRect:V,activatorEvent:R,collisions:de,containerNodeRect:W,dragOverlay:J,draggableNodes:M,droppableContainers:C,droppableRects:P,over:he,measureDroppableContainers:F,scrollableAncestors:ne,scrollableAncestorRects:re,measuringConfiguration:z,measuringScheduled:j,windowRect:te}),[k,$,V,R,de,W,J,M,C,P,he,F,ne,re,z,j,te]),we=pC(()=>({activatorEvent:R,activators:be,active:k,activeNodeRect:V,ariaDescribedById:{draggable:L},dispatch:g,draggableNodes:M,over:he,measureDroppableContainers:F}),[R,be,k,V,g,L,M,he,F]);return sC.createElement(xC.Provider,{value:v},sC.createElement(FN.Provider,{value:we},sC.createElement(jN.Provider,{value:xe},sC.createElement(VN.Provider,{value:me},l)),sC.createElement(UN,{disabled:!1===(null==s?void 0:s.restoreFocus)})),sC.createElement(MC,{...s,hiddenTextDescribedById:L}))});const KN=aC(null),GN="button";function JN(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e;const o=VS("Draggable"),{activators:s,activatorEvent:a,active:l,activeNodeRect:c,ariaDescribedById:u,draggableNodes:d,over:p}=lC(FN),{role:h=GN,roleDescription:f="draggable",tabIndex:m=0}=null!=i?i:{},g=(null==l?void 0:l.id)===t,y=lC(g?VN:KN),[v,b]=HS(),[x,w]=HS(),E=function(e,t){return pC(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}(s,t),M=jS(n);PS(()=>(d.set(t,{id:t,key:o,node:v,activatorNode:x,data:M}),()=>{const e=d.get(t);e&&e.key===o&&d.delete(t)}),[d,t]);return{active:l,activatorEvent:a,activeNodeRect:c,attributes:pC(()=>({role:h,tabIndex:m,"aria-disabled":r,"aria-pressed":!(!g||h!==GN)||void 0,"aria-roledescription":f,"aria-describedby":u.draggable}),[r,h,m,g,f,u.draggable]),isDragging:g,listeners:r?void 0:E,node:v,over:p,setNodeRef:b,setActivatorNodeRef:w,transform:y}}const YN={timeout:25};function ZN(e){let{animation:t,children:n}=e;const[r,i]=uC(null),[o,s]=uC(null),a=US(n);return n||r||!a||i(a),PS(()=>{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]),sC.createElement(sC.Fragment,null,n,r?gC(r,{ref:s}):null)}const XN={x:0,y:0,scaleX:1,scaleY:1};function QN(e){let{children:t}=e;return sC.createElement(FN.Provider,{value:PN},sC.createElement(VN.Provider,{value:XN},t))}const eA={position:"fixed",touchAction:"none"},tA=e=>JS(e)?"transform 250ms ease":void 0,nA=yC((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:o,className:s,rect:a,style:l,transform:c,transition:u=tA}=e;if(!a)return null;const d=i?c:{...c,scaleX:1,scaleY:1},p={...eA,width:a.width,height:a.height,top:a.top,left:a.left,transform:ZS.Transform.toString(d),transformOrigin:i&&r?AC(r,a):void 0,transition:"function"==typeof u?u(r):u,...l};return sC.createElement(n,{className:s,style:p,ref:t},o)}),rA={duration:250,easing:"ease",keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:ZS.Transform.toString(t)},{transform:ZS.Transform.toString(n)}]},sideEffects:(iA={styles:{active:{opacity:"0"}}},e=>{let{active:t,dragOverlay:n}=e;const r={},{styles:i,className:o}=iA;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 iA;function oA(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return FS((e,o)=>{if(null===t)return;const s=n.get(e);if(!s)return;const a=s.node.current;if(!a)return;const l=RN(o);if(!l)return;const{transform:c}=DS(o).getComputedStyle(o),u=IC(c);if(!u)return;const d="function"==typeof t?t:function(e){const{duration:t,easing:n,sideEffects:r,keyframes:i}={...rA,...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 ZC(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 sA=0;function aA(e){return pC(()=>{if(null!=e)return sA++,sA},[e])}sC.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:x,windowRect:w}=lC(jN),E=lC(VN),M=aA(null==d?void 0:d.id),S=qN(s,{activatorEvent:u,active:d,activeNodeRect:p,containerNodeRect:h,draggingNodeRect:g.rect,over:y,overlayNodeRect:g.rect,scrollableAncestors:b,scrollableAncestorRects:x,transform:E,windowRect:w}),C=SN(p),N=oA({config:r,draggableNodes:f,droppableContainers:m,measuringConfiguration:v}),A=C?g.setRef:void 0;return sC.createElement(QN,null,sC.createElement(ZN,{animation:N},d&&M?sC.createElement(nA,{key:M,id:d.id,ref:A,as:a,activatorEvent:u,adjustScale:t,className:l,transition:o,rect:C,style:{zIndex:c,...i},transform:S},n):null))});const lA=e,cA=i,uA=e=>"string"==typeof e?e:"number"==typeof e?`${e}px`:"30px",dA=({size:e,children:t})=>{const n={height:e=uA(e),width:e,display:"inline-block",position:"relative"};return lA.createElement("div",{style:n},t)};dA.propTypes={size:cA.number,children:cA.oneOfType([cA.arrayOf(cA.node),cA.node]).isRequired};const pA=e,hA=i,fA=({size:e,children:t,sx:n})=>pA.createElement(dA,{size:e},pA.createElement("svg",{preserveAspectRatio:"xMinYMin meet",viewBox:"0 0 44 40",style:{enableBackground:"new 0 0 44 40",...n}},t));fA.propTypes={size:hA.oneOfType([hA.string,hA.number]),children:hA.oneOfType([hA.arrayOf(hA.node),hA.node]).isRequired,sx:hA.object},hA.string.isRequired;const mA=({fill:e})=>pA.createElement("polygon",{transform:"translate(2, 0)",points:"34.1,28.6 34.1,2.2 2,2.2 2,34.3 40.1,34.3",fill:e});mA.propTypes={fill:hA.string.isRequired};const gA=({fill:e})=>pA.createElement("path",{transform:"translate(1, 0)",d:"M31.2,29.1v-0.3c2.2-2.8,3.6-6.3,3.6-10.1c0-8.9-7.2-16.1-16.1-16.1c-8.8,0.1-16,7.3-16,16.2 s7.2,16.1,16.1,16.1h18.5L31.2,29.1z",fill:e});gA.propTypes={fill:hA.string.isRequired};const yA=({fill:e})=>pA.createElement("circle",{transform:"translate(-3,0)",cx:"23",cy:"20.4",r:"16",fill:e});yA.propTypes={fill:hA.string.isRequired};const vA=({fill:e})=>pA.createElement("rect",{x:"3.6",y:"4.1",width:"32",height:"32",fill:e});vA.propTypes={fill:hA.string.isRequired};const bA=i,xA=e;var wA=(e,t)=>{class n extends xA.Component{static __initStatic(){this.propTypes={iconSet:bA.oneOf(["emoji","check"]),shape:bA.oneOf(["round","square"]),category:bA.oneOf(["feedback",void 0]),open:bA.bool,size:bA.oneOfType([bA.number,bA.string]),fg:bA.string,bg:bA.string}}static __initStatic2(){this.defaultProps={iconSet:"check",shape:"round",category:void 0,open:!1,size:30,fg:"#4aaf46",bg:"#f8ffe2"}}render(){const{iconSet:n,shape:r,category:i,open:o,size:s,fg:a,bg:l}=this.props,c="check"===n?xA.createElement(e,{fill:a}):xA.createElement(t,{fill:a}),u="check"===n?xA.createElement(e,{fill:l}):xA.createElement(t,{fill:l});return o?xA.createElement(fA,{size:s},u):xA.createElement(fA,{size:s},"feedback"===i?"round"===r?xA.createElement(gA,{fill:l}):xA.createElement(mA,{fill:l}):"round"===r?xA.createElement(yA,{fill:l}):xA.createElement(vA,{fill:l}),c)}}return n.__initStatic(),n.__initStatic2(),n};const EA=i,MA=e,SA=({fill:e})=>MA.createElement("g",{transform:"translate(1, 0)"},MA.createElement("path",{d:"M24.7,22.1c-1.5,1.7-3.6,2.7-5.8,2.7s-4.5-1.1-5.8-2.7l-2.8,1.6c2,2.7,5.2,4.2,8.7,4.2 c3.4,0,6.6-1.6,8.7-4.2L24.7,22.1z",fill:e}),MA.createElement("rect",{x:"21.1",y:"13.1",width:"3.7",height:"4.7",fill:e}),MA.createElement("rect",{x:"12.7",y:"13.1",width:"3.7",height:"4.7",fill:e}));SA.propTypes={fill:EA.string.isRequired};const CA=({fill:e,x:t=0,y:n=0})=>MA.createElement("polygon",{transform:`translate(${t}, ${n})`,points:"19.1,28.6 11.8,22.3 14.4,19.2 17.9,22.1 23.9,11.4 27.5,13.4",fill:e});CA.propTypes={fill:EA.string.isRequired,x:EA.number,y:EA.number};const NA=wA(CA,SA);NA.propTypes={iconSet:EA.oneOf(["emoji","check"]),shape:EA.oneOf(["round","square"]),category:EA.oneOf(["feedback",void 0]),open:EA.bool,fg:EA.string,bg:EA.string,size:EA.oneOfType([EA.string,EA.number])},NA.defaultProps={iconSet:"check",shape:"round",category:void 0,open:!1,fg:"#4aaf46",bg:"#f8ffe2",size:30};const AA=i,{styled:kA}=r;AA.string.isRequired,AA.string.isRequired,AA.string.isRequired,AA.string.isRequired,AA.string.isRequired,kA("div")(({size:e})=>({width:e||"25px",height:e||"25px"})),AA.bool,AA.string;const TA=i,OA=e,_A=({fill:e})=>OA.createElement("g",{transform:"translate(0.5, 0.5)"},OA.createElement("rect",{x:"11",y:"17.3",transform:"matrix(0.7071 -0.7071 0.7071 0.7071 -7.852 19.2507)",width:"16.6",height:"3.7",fill:e}),OA.createElement("rect",{x:"17.4",y:"10.7",transform:"matrix(0.7071 -0.7071 0.7071 0.7071 -7.8175 19.209)",width:"3.7",height:"16.6",fill:e}));_A.propTypes={fill:TA.string.isRequired};const RA=({fill:e})=>OA.createElement("g",{transform:"translate(1,0)"},OA.createElement("rect",{x:"21",y:"12.9",width:"3.7",height:"4.7",fill:e}),OA.createElement("rect",{x:"12.7",y:"12.9",width:"3.7",height:"4.7",fill:e}),OA.createElement("rect",{x:"12.2",y:"22.5",width:"13",height:"3.3",fill:e}));RA.propTypes={fill:TA.string.isRequired};const DA=wA(_A,RA);DA.propTypes={iconSet:TA.oneOf(["emoji","check"]),shape:TA.oneOf(["round","square"]),category:TA.oneOf(["feedback",void 0]),open:TA.bool,fg:TA.string,bg:TA.string,size:TA.oneOfType([TA.string,TA.number])},DA.defaultProps={iconSet:"check",shape:"round",category:void 0,open:!1,fg:"#fcb733",bg:"#fbf2e3",size:30};const IA=i,LA=e,BA=()=>{const e={fill:"none",stroke:"#BCE2FF",strokeWidth:2,strokeMiterlimit:10};return LA.createElement("g",null,LA.createElement("line",{style:e,x1:"-98",y1:"142",x2:"-114.6",y2:"142"}),LA.createElement("line",{style:e,x1:"-98",y1:"146.3",x2:"-114.6",y2:"146.3"}),LA.createElement("line",{style:e,x1:"-104",y1:"150.7",x2:"-114.6",y2:"150.7"}))},zA=({children:e,size:t})=>LA.createElement(dA,{size:t},LA.createElement("svg",{version:"1.1",viewBox:"-128 129 31 31",style:{enableBackground:"new -128 129 31 31"}},e));zA.propTypes={children:IA.oneOfType([IA.arrayOf(IA.node),IA.node]).isRequired,size:IA.number};const PA=()=>LA.createElement("g",null,LA.createElement("rect",{x:"-123.9",y:"135.3",style:{fill:"#D0CAC5",stroke:"#E6E3E0",strokeWidth:.75,strokeLinejoin:"round",strokeMiterlimit:10},width:"4.1",height:"4.1"}),LA.createElement("polygon",{style:{fill:"#D0CAC5",stroke:"#E6E3E0",strokeWidth:.75,strokeLinejoin:"round",strokeMiterlimit:10},points:"-119.8,150.4 -119.8,142.2 -125,142.2 -125,144.9 -122.6,144.9 -122.6,150.4 -125.6,150.4 -125.6,153.2 -116.8,153.2 -116.8,150.4 "}),LA.createElement("rect",{x:"-124.7",y:"134.7",style:{fill:"#B3ABA4",stroke:"#CDC7C2",strokeWidth:.5,strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:10},width:"4.1",height:"4.1"}),LA.createElement("polygon",{style:{fill:"#B3ABA4",stroke:"#CDC7C2",strokeWidth:.5,strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:10},points:"-120.6,149.8 -120.6,141.5 -125.8,141.5 -125.8,144.3 -123.3,144.3 -123.3,149.8 -126.4,149.8 -126.4,152.5 -117.6,152.5 -117.6,149.8 "}),LA.createElement("rect",{x:"-125.5",y:"134",style:{fill:"#7FABC6"},width:"4.1",height:"4.1"}),LA.createElement("polygon",{style:{fill:"#7FABC6"},points:"-121.4,149.1 -121.4,140.9 -126.5,140.9 -126.5,143.6 -124.1,143.6 -124.1,149.1 -127.1,149.1 -127.1,151.9 -118.4,151.9 -118.4,149.1 "})),FA=()=>LA.createElement("g",null,LA.createElement("rect",{x:"-123.9",y:"135.3",style:{fill:"#D0CAC5",stroke:"#E6E3E0",strokeWidth:.75,strokeLinejoin:"round",strokeMiterlimit:10},width:"4.1",height:"4.1"}),LA.createElement("polygon",{style:{fill:"#D0CAC5",stroke:"#E6E3E0",strokeWidth:.75,strokeLinejoin:"round",strokeMiterlimit:10},points:"-119.8,150.4 -119.8,142.2 -125,142.2 -125,144.9 -122.6,144.9 -122.6,150.4 -125.6,150.4 -125.6,153.2 -116.8,153.2 -116.8,150.4 "}),LA.createElement("rect",{x:"-124.7",y:"134.7",style:{fill:"#B3ABA4",stroke:"#CDC7C2",strokeWidth:.5,strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:10},width:"4.1",height:"4.1"}),LA.createElement("polygon",{style:{fill:"#B3ABA4",stroke:"#CDC7C2",strokeWidth:.5,strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:10},points:"-120.6,149.8 -120.6,141.5 -125.8,141.5 -125.8,144.3 -123.3,144.3 -123.3,149.8 -126.4,149.8 -126.4,152.5 -117.6,152.5 -117.6,149.8 "}),LA.createElement("rect",{x:"-125.5",y:"134",style:{fill:"#1A9CFF"},width:"4.1",height:"4.1"}),LA.createElement("polygon",{style:{fill:"#1A9CFF"},points:"-121.4,149.1 -121.4,140.9 -126.5,140.9 -126.5,143.6 -124.1,143.6 -124.1,149.1 -127.1,149.1 -127.1,151.9 -118.4,151.9 -118.4,149.1 "}));class jA extends LA.Component{constructor(e){super(e)}render(){return!0===this.props.open?LA.createElement(zA,null,LA.createElement(PA,null),LA.createElement(BA,null)):LA.createElement(zA,null,LA.createElement(FA,null),LA.createElement(BA,null))}}jA.propTypes={open:IA.bool},jA.defaultProps={open:!1};const $A=i,HA=e,UA=({fill:e})=>HA.createElement("path",{fill:e,d:"M-130.4,142.1c0-2.1,1.7-3.9,3.9-3.9c0.3,0,0.5,0,0.8,0.1c-0.6-0.8-1.5-1.3-2.6-1.3c-1.8,0-3.3,1.5-3.3,3.3c0,1.1,0.5,2,1.3,2.6C-130.4,142.6-130.4,142.4-130.4,142.1z"});UA.propTypes={fill:$A.string};class qA extends HA.Component{static __initStatic(){this.propTypes={classes:$A.object.isRequired,size:$A.number}}render(){const{size:e}=this.props;return!0===this.props.open?HA.createElement(dA,{size:e},HA.createElement("svg",{preserveAspectRatio:"xMinYMin meet",viewBox:"-135 129 16 32"},HA.createElement("path",{fill:"#BCE2FF",d:"M-122,141.1c0-3.7-3.3-6.6-7.1-5.8c-2.4,0.5-4.3,2.4-4.7,4.8c-0.4,2.3,0.6,4.4,2.2,5.7c0.4,0.3,0.6,0.8,0.6,1.3v1.9h6.1v-1.9c0-0.5,0.2-1,0.6-1.3C-122.8,144.7-122,143-122,141.1z"}),HA.createElement("path",{fill:"#BCE2FF",d:"M-125.7,153h-4.5c-0.4,0-0.8-0.4-0.8-0.8v-1.6h6.1v1.6C-124.9,152.7-125.2,153-125.7,153z"}),HA.createElement(UA,{fill:"#1A9CFF"}))):HA.createElement(dA,{size:e},HA.createElement("svg",{preserveAspectRatio:"xMinYMin meet",viewBox:"-135 129 16 31"},HA.createElement("path",{fill:"#D0CAC5",stroke:"#E6E3E0",className:"st0",d:"M-120.7,142.4c0-3.7-3.3-6.6-7.1-5.8c-2.4,0.5-4.3,2.4-4.7,4.8c-0.4,2.3,0.6,4.4,2.2,5.7c0.4,0.3,0.6,0.8,0.6,1.3v1.9h6.1v-1.9c0-0.5,0.2-1,0.6-1.3C-121.6,146-120.7,144.3-120.7,142.4z"}),HA.createElement("path",{fill:"#D0CAC5",stroke:"#E6E3E0",className:"st0",d:"M-124.4,154.3h-4.5c-0.4,0-0.8-0.4-0.8-0.8v-1.6h6.1v1.6C-123.6,153.9-123.9,154.3-124.4,154.3z"}),HA.createElement("path",{fill:"#B3ABA4",stroke:"#CDC7C2",className:"st1",d:"M-121.3,141.8c0-3.7-3.3-6.6-7.1-5.8c-2.4,0.5-4.3,2.4-4.7,4.8c-0.4,2.3,0.6,4.4,2.2,5.7c0.4,0.3,0.6,0.8,0.6,1.3v1.9h6.1v-1.9c0-0.5,0.2-1,0.6-1.3C-122.2,145.3-121.3,143.7-121.3,141.8z"}),",",HA.createElement("path",{fill:"#B3ABA4",stroke:"#CDC7C2",className:"st1",d:"M-125,153.7h-4.5c-0.4,0-0.8-0.4-0.8-0.8v-1.6h6.1v1.6C-124.2,153.3-124.6,153.7-125,153.7z"}),HA.createElement("path",{fill:"#1A9CFF",d:"M-122,141.1c0-3.7-3.3-6.6-7.1-5.8c-2.4,0.5-4.3,2.4-4.7,4.8c-0.4,2.3,0.6,4.4,2.2,5.7c0.4,0.3,0.6,0.8,0.6,1.3v1.9h6.1v-1.9c0-0.5,0.2-1,0.6-1.3C-122.8,144.7-122,143-122,141.1z"}),HA.createElement("path",{fill:"#1A9CFF",d:"M-125.7,153h-4.5c-0.4,0-0.8-0.4-0.8-0.8v-1.6h6.1v1.6C-124.9,152.7-125.2,153-125.7,153z"}),HA.createElement(UA,{fill:"1A9CFF"})))}}qA.__initStatic(),qA.propTypes={open:$A.bool},qA.defaultProps={open:!1};const VA=i,WA=e,KA=({fill:e})=>WA.createElement("g",null,WA.createElement("rect",{x:"19.3",y:"10.3",width:"4.5",height:"12.7",fill:e}),WA.createElement("rect",{x:"19.3",y:"26.2",width:"4.5",height:"4.5",fill:e}));KA.propTypes={fill:VA.string.isRequired};const GA=({fill:e})=>WA.createElement("polygon",{points:"14.8,4.5 5.6,13.8 5.6,27 14.8,36.5 28.1,36.5 37.6,27 37.6,13.8 28.1,4.5",fill:e});GA.propTypes={fill:VA.string.isRequired};const JA=({fill:e})=>WA.createElement("g",null,WA.createElement("rect",{x:"23.8",y:"15",width:"3.5",height:"4.4",fill:e}),WA.createElement("rect",{x:"16",y:"15",width:"3.5",height:"4.4",fill:e}),WA.createElement("path",{d:"M24.2,27.1h-5.1c-0.8,0-1.5-0.7-1.5-1.5v0c0-0.8,0.7-1.5,1.5-1.5h5.1c0.8,0,1.5,0.7,1.5,1.5v0 C25.7,26.4,25,27.1,24.2,27.1z",fill:e}));JA.propTypes={fill:VA.string.isRequired};class YA extends WA.Component{constructor(e){super(e);const{fg:t="#464146",bg:n="white"}=this.props;this.icons={check:WA.createElement(fA,null,WA.createElement(GA,{fill:n}),WA.createElement(KA,{fill:t})),emoji:WA.createElement(fA,null,WA.createElement(GA,{fill:n}),WA.createElement(JA,{fill:t})),feedback:{check:WA.createElement(fA,null,WA.createElement(GA,{fill:n}),WA.createElement(JA,{fill:t})),emoji:WA.createElement(fA,null,WA.createElement(GA,{fill:n}),WA.createElement(JA,{fill:t})),square:{check:WA.createElement(fA,null,WA.createElement(GA,{fill:n}),WA.createElement(KA,{fill:t})),emoji:WA.createElement(fA,null,WA.createElement(GA,{fill:n}),WA.createElement(JA,{fill:t})),open:{check:WA.createElement(fA,null,WA.createElement(KA,{fill:n})),emoji:WA.createElement(fA,null,WA.createElement(JA,{fill:n}))}}}}}render(){const{iconSet:e,category:t,shape:n,open:r}=this.props;return void 0===t?this.icons[e]:void 0===n?this.icons.feedback[e]:!0===r?this.icons.feedback.square.open[e]:this.icons.feedback.square[e]}}YA.propTypes={iconSet:VA.oneOf(["emoji","check",void 0]),shape:VA.oneOf(["square",void 0]),category:VA.oneOf(["feedback",void 0]),open:VA.bool,fg:VA.string,bg:VA.string},YA.defaultProps={iconSet:"check",shape:void 0,category:void 0,open:!1,fg:"#464146",bg:"white"};const ZA=i,XA=e,QA=({fill:e})=>XA.createElement("g",{transform:"translate(0, 0)"},XA.createElement("polygon",{points:"27.5,13.4 23.9,11.4 15.9,25.8 19.1,28.6",fill:e}),XA.createElement("polygon",{points:"16.2,20.6 14.4,19.2 11.8,22.3 14.1,24.3",fill:e}));QA.propTypes={fill:ZA.string.isRequired};const ek=({fill:e})=>XA.createElement("g",{transform:"translate(2, 0)"},XA.createElement("rect",{x:"20.6",y:"11.8",width:"4",height:"5",fill:e}),XA.createElement("rect",{x:"11.5",y:"11.8",width:"4",height:"5",fill:e}),XA.createElement("rect",{x:"10.9",y:"22.9",transform:"matrix(0.9794 -0.2019 0.2019 0.9794 -4.6237 4.1559)",width:"14.3",height:"3.7",fill:e}));ek.propTypes={fill:ZA.string.isRequired};const tk=wA(QA,ek);tk.propTypes={iconSet:ZA.oneOf(["emoji","check"]),shape:ZA.oneOf(["round","square"]),category:ZA.oneOf(["feedback",void 0]),open:ZA.bool,fg:ZA.string,bg:ZA.string,size:ZA.oneOfType([ZA.string,ZA.number])},tk.defaultProps={iconSet:"check",shape:"round",category:void 0,open:!1,fg:"#4aaf46",bg:"#c1e1ac",size:30};const nk=i,rk=e,ik=({fill:e})=>rk.createElement("g",null,rk.createElement("rect",{x:"-115",y:"136.7",width:"3",height:"3",fill:e}),rk.createElement("polygon",{points:"-112,147.7 -112,141.7 -115.8,141.7 -115.8,143.7 -114,143.7 -114,147.7 -116.2,147.7 -116.2,149.7 -109.8,149.7 -109.8,147.7",fill:e}));ik.propTypes={fill:nk.string.isRequired};const ok=({fill:e})=>rk.createElement("path",{d:"M-113,158.5c-8,0-14.5-6.5-14.5-14.5s6.5-14.5,14.5-14.5s14.5,6.5,14.5,14.5S-105,158.5-113,158.5z M-113,130.5c-7.4,0-13.5,6.1-13.5,13.5s6.1,13.5,13.5,13.5s13.5-6.1,13.5-13.5S-105.6,130.5-113,130.5z",fill:e});ok.propTypes={fill:nk.string.isRequired};const sk=({fill:e="#FFFFFF"})=>rk.createElement("g",null,rk.createElement("path",{style:{fill:"#D0CAC5",stroke:"#E6E3E0",strokeWidth:.75,strokeMiterlimit:10},d:"M-111.7,160.9c-8.5,0-15.5-6.9-15.5-15.5c0-8.5,6.9-15.5,15.5-15.5s15.5,6.9,15.5,15.5C-96.2,154-103.1,160.9-111.7,160.9z"}),rk.createElement("path",{style:{fill:"#B3ABA4",stroke:"#CDC7C2",strokeWidth:.5,strokeMiterlimit:10},d:"M-112,159.5c-8,0-14.5-6.5-14.5-14.5s6.5-14.5,14.5-14.5s14.5,6.5,14.5,14.5S-104,159.5-112,159.5z"}),rk.createElement("circle",{cx:"-113",cy:"144",r:"14",fill:e}));sk.propTypes={fill:nk.string};const ak=({children:e,size:t})=>{const n=uA(t),r={height:n,width:n,display:"inline-block",position:"relative"};return rk.createElement("div",{style:r},rk.createElement("svg",{preserveAspectRatio:"xMinYMin meet",viewBox:"-129 128 34 34"},e))};ak.propTypes={children:nk.oneOfType([nk.arrayOf(nk.node),nk.node]).isRequired,size:nk.oneOfType([nk.string,nk.number])};class lk extends rk.Component{render(){const{iconSet:e,open:t,fg:n="#1a9cff",bg:r="#bce2ff",border:i="#bbe3fd"}=this.props,o=rk.createElement(ik,{fill:n}),s={check:rk.createElement(ak,{size:this.props.size},rk.createElement(sk,null),o,rk.createElement(ok,{fill:i})),emoji:rk.createElement(ak,{size:this.props.size},rk.createElement(sk,null),o,rk.createElement(ok,{fill:i})),open:{check:rk.createElement(ak,{size:this.props.size},rk.createElement("circle",{cx:"-113",cy:"144",r:"14",fill:"#FFFFFF"}),rk.createElement(ik,{fill:r}),rk.createElement(ok,{fill:"#FFFFFF"})),emoji:rk.createElement(ak,{size:this.props.size},rk.createElement("circle",{cx:"-113",cy:"144",r:"14",fill:"#FFFFFF"}),rk.createElement(ik,{fill:r}),rk.createElement(ok,{fill:i}))}};return!0===t?s.open[e]:s[e]}}function ck(){return ck=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},ck.apply(null,arguments)}function uk(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}function dk(e,t){return dk=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},dk(e,t)}function pk(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,dk(e,t)}function hk(e,t){return e.replace(new RegExp("(^|\\s)"+t+"(?:\\s|$)","g"),"$1").replace(/\s+/g," ").replace(/^\s*|\s*$/g,"")}lk.propTypes={iconSet:nk.oneOf(["emoji","check"]),open:nk.bool,fg:nk.string,bg:nk.string,border:nk.string,size:nk.oneOfType([nk.string,nk.number])},lk.defaultProps={iconSet:"check",open:!1,fg:"#1a9cff",bg:"#bce2ff",border:"#bbe3fd",size:30};var fk=!1;var mk=e.createContext(null),gk=function(e){return e.scrollTop};const yk=e,vk=t;var bk="unmounted",xk="exited",wk="entering",Ek="entered",Mk="exiting",Sk=function(e){function t(t,n){var r;r=e.call(this,t,n)||this;var i,o=n&&!n.isMounting?t.enter:t.appear;return r.appearStatus=null,t.in?o?(i=xk,r.appearStatus=wk):i=Ek:i=t.unmountOnExit||t.mountOnEnter?bk:xk,r.state={status:i},r.nextCallback=null,r}pk(t,e),t.getDerivedStateFromProps=function(e,t){return e.in&&t.status===bk?{status:xk}:null};var n=t.prototype;return n.componentDidMount=function(){this.updateStatus(!0,this.appearStatus)},n.componentDidUpdate=function(e){var t=null;if(e!==this.props){var n=this.state.status;this.props.in?n!==wk&&n!==Ek&&(t=wk):n!==wk&&n!==Ek||(t=Mk)}this.updateStatus(!1,t)},n.componentWillUnmount=function(){this.cancelNextCallback()},n.getTimeouts=function(){var e,t,n,r=this.props.timeout;return e=t=n=r,null!=r&&"number"!=typeof r&&(e=r.exit,t=r.enter,n=void 0!==r.appear?r.appear:t),{exit:e,enter:t,appear:n}},n.updateStatus=function(e,t){if(void 0===e&&(e=!1),null!==t)if(this.cancelNextCallback(),t===wk){if(this.props.unmountOnExit||this.props.mountOnEnter){var n=this.props.nodeRef?this.props.nodeRef.current:vk.findDOMNode(this);n&&gk(n)}this.performEnter(e)}else this.performExit();else this.props.unmountOnExit&&this.state.status===xk&&this.setState({status:bk})},n.performEnter=function(e){var t=this,n=this.props.enter,r=this.context?this.context.isMounting:e,i=this.props.nodeRef?[r]:[vk.findDOMNode(this),r],o=i[0],s=i[1],a=this.getTimeouts(),l=r?a.appear:a.enter;!e&&!n||fk?this.safeSetState({status:Ek},function(){t.props.onEntered(o)}):(this.props.onEnter(o,s),this.safeSetState({status:wk},function(){t.props.onEntering(o,s),t.onTransitionEnd(l,function(){t.safeSetState({status:Ek},function(){t.props.onEntered(o,s)})})}))},n.performExit=function(){var e=this,t=this.props.exit,n=this.getTimeouts(),r=this.props.nodeRef?void 0:vk.findDOMNode(this);t&&!fk?(this.props.onExit(r),this.safeSetState({status:Mk},function(){e.props.onExiting(r),e.onTransitionEnd(n.exit,function(){e.safeSetState({status:xk},function(){e.props.onExited(r)})})})):this.safeSetState({status:xk},function(){e.props.onExited(r)})},n.cancelNextCallback=function(){null!==this.nextCallback&&(this.nextCallback.cancel(),this.nextCallback=null)},n.safeSetState=function(e,t){t=this.setNextCallback(t),this.setState(e,t)},n.setNextCallback=function(e){var t=this,n=!0;return this.nextCallback=function(r){n&&(n=!1,t.nextCallback=null,e(r))},this.nextCallback.cancel=function(){n=!1},this.nextCallback},n.onTransitionEnd=function(e,t){this.setNextCallback(t);var n=this.props.nodeRef?this.props.nodeRef.current:vk.findDOMNode(this),r=null==e&&!this.props.addEndListener;if(n&&!r){if(this.props.addEndListener){var i=this.props.nodeRef?[this.nextCallback]:[n,this.nextCallback],o=i[0],s=i[1];this.props.addEndListener(o,s)}null!=e&&setTimeout(this.nextCallback,e)}else setTimeout(this.nextCallback,0)},n.render=function(){var e=this.state.status;if(e===bk)return null;var t=this.props,n=t.children;t.in,t.mountOnEnter,t.unmountOnExit,t.appear,t.enter,t.exit,t.timeout,t.addEndListener,t.onEnter,t.onEntering,t.onEntered,t.onExit,t.onExiting,t.onExited,t.nodeRef;var r=uk(t,["children","in","mountOnEnter","unmountOnExit","appear","enter","exit","timeout","addEndListener","onEnter","onEntering","onEntered","onExit","onExiting","onExited","nodeRef"]);return yk.createElement(mk.Provider,{value:null},"function"==typeof n?n(e,r):yk.cloneElement(yk.Children.only(n),r))},t}(yk.Component);function Ck(){}Sk.contextType=mk,Sk.propTypes={},Sk.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:Ck,onEntering:Ck,onEntered:Ck,onExit:Ck,onExiting:Ck,onExited:Ck},Sk.UNMOUNTED=bk,Sk.EXITED=xk,Sk.ENTERING=wk,Sk.ENTERED=Ek,Sk.EXITING=Mk;var Nk=Sk;const Ak=e;var kk=function(e,t){return e&&t&&t.split(" ").forEach(function(t){return r=t,void((n=e).classList?n.classList.add(r):function(e,t){return e.classList?!!t&&e.classList.contains(t):-1!==(" "+(e.className.baseVal||e.className)+" ").indexOf(" "+t+" ")}(n,r)||("string"==typeof n.className?n.className=n.className+" "+r:n.setAttribute("class",(n.className&&n.className.baseVal||"")+" "+r)));var n,r})},Tk=function(e,t){return e&&t&&t.split(" ").forEach(function(t){return r=t,void((n=e).classList?n.classList.remove(r):"string"==typeof n.className?n.className=hk(n.className,r):n.setAttribute("class",hk(n.className&&n.className.baseVal||"",r)));var n,r})},Ok=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(t=e.call.apply(e,[this].concat(r))||this).appliedClasses={appear:{},enter:{},exit:{}},t.onEnter=function(e,n){var r=t.resolveArguments(e,n),i=r[0],o=r[1];t.removeClasses(i,"exit"),t.addClass(i,o?"appear":"enter","base"),t.props.onEnter&&t.props.onEnter(e,n)},t.onEntering=function(e,n){var r=t.resolveArguments(e,n),i=r[0],o=r[1]?"appear":"enter";t.addClass(i,o,"active"),t.props.onEntering&&t.props.onEntering(e,n)},t.onEntered=function(e,n){var r=t.resolveArguments(e,n),i=r[0],o=r[1]?"appear":"enter";t.removeClasses(i,o),t.addClass(i,o,"done"),t.props.onEntered&&t.props.onEntered(e,n)},t.onExit=function(e){var n=t.resolveArguments(e)[0];t.removeClasses(n,"appear"),t.removeClasses(n,"enter"),t.addClass(n,"exit","base"),t.props.onExit&&t.props.onExit(e)},t.onExiting=function(e){var n=t.resolveArguments(e)[0];t.addClass(n,"exit","active"),t.props.onExiting&&t.props.onExiting(e)},t.onExited=function(e){var n=t.resolveArguments(e)[0];t.removeClasses(n,"exit"),t.addClass(n,"exit","done"),t.props.onExited&&t.props.onExited(e)},t.resolveArguments=function(e,n){return t.props.nodeRef?[t.props.nodeRef.current,e]:[e,n]},t.getClassNames=function(e){var n=t.props.classNames,r="string"==typeof n,i=r?""+(r&&n?n+"-":"")+e:n[e];return{baseClassName:i,activeClassName:r?i+"-active":n[e+"Active"],doneClassName:r?i+"-done":n[e+"Done"]}},t}pk(t,e);var n=t.prototype;return n.addClass=function(e,t,n){var r=this.getClassNames(t)[n+"ClassName"],i=this.getClassNames("enter").doneClassName;"appear"===t&&"done"===n&&i&&(r+=" "+i),"active"===n&&e&&gk(e),r&&(this.appliedClasses[t][n]=r,kk(e,r))},n.removeClasses=function(e,t){var n=this.appliedClasses[t],r=n.base,i=n.active,o=n.done;this.appliedClasses[t]={},r&&Tk(e,r),i&&Tk(e,i),o&&Tk(e,o)},n.render=function(){var e=this.props;e.classNames;var t=uk(e,["classNames"]);return Ak.createElement(Nk,ck({},t,{onEnter:this.onEnter,onEntered:this.onEntered,onEntering:this.onEntering,onExit:this.onExit,onExiting:this.onExiting,onExited:this.onExited}))},t}(Ak.Component);Ok.defaultProps={classNames:""},Ok.propTypes={};var _k=Ok;const{Children:Rk}=e,{cloneElement:Dk}=e,{isValidElement:Ik}=e;function Lk(e,t){var n=Object.create(null);return e&&Rk.map(e,function(e){return e}).forEach(function(e){n[e.key]=function(e){return t&&Ik(e)?t(e):e}(e)}),n}function Bk(e,t,n){return null!=n[t]?n[t]:e.props[t]}function zk(e,t,n){var r=Lk(e.children),i=function(e,t){function n(n){return n in t?t[n]:e[n]}e=e||{},t=t||{};var r,i=Object.create(null),o=[];for(var s in e)s in t?o.length&&(i[s]=o,o=[]):o.push(s);var a={};for(var l in t){if(i[l])for(r=0;r<i[l].length;r++){var c=i[l][r];a[i[l][r]]=n(c)}a[l]=n(l)}for(r=0;r<o.length;r++)a[o[r]]=n(o[r]);return a}(t,r);return Object.keys(i).forEach(function(o){var s=i[o];if(Ik(s)){var a=o in t,l=o in r,c=t[o],u=Ik(c)&&!c.props.in;!l||a&&!u?l||!a||u?l&&a&&Ik(c)&&(i[o]=Dk(s,{onExited:n.bind(null,s),in:c.props.in,exit:Bk(s,"exit",e),enter:Bk(s,"enter",e)})):i[o]=Dk(s,{in:!1}):i[o]=Dk(s,{onExited:n.bind(null,s),in:!0,exit:Bk(s,"exit",e),enter:Bk(s,"enter",e)})}}),i}const Pk=e;var Fk=Object.values||function(e){return Object.keys(e).map(function(t){return e[t]})},jk=function(e){function t(t,n){var r,i=(r=e.call(this,t,n)||this).handleExited.bind(function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(r));return r.state={contextValue:{isMounting:!0},handleExited:i,firstRender:!0},r}pk(t,e);var n=t.prototype;return n.componentDidMount=function(){this.mounted=!0,this.setState({contextValue:{isMounting:!1}})},n.componentWillUnmount=function(){this.mounted=!1},t.getDerivedStateFromProps=function(e,t){var n,r,i=t.children,o=t.handleExited;return{children:t.firstRender?(n=e,r=o,Lk(n.children,function(e){return Dk(e,{onExited:r.bind(null,e),in:!0,appear:Bk(e,"appear",n),enter:Bk(e,"enter",n),exit:Bk(e,"exit",n)})})):zk(e,i,o),firstRender:!1}},n.handleExited=function(e,t){var n=Lk(this.props.children);e.key in n||(e.props.onExited&&e.props.onExited(t),this.mounted&&this.setState(function(t){var n=ck({},t.children);return delete n[e.key],{children:n}}))},n.render=function(){var e=this.props,t=e.component,n=e.childFactory,r=uk(e,["component","childFactory"]),i=this.state.contextValue,o=Fk(this.state.children).map(n);return delete r.appear,delete r.enter,delete r.exit,null===t?Pk.createElement(mk.Provider,{value:i},o):Pk.createElement(mk.Provider,{value:i},Pk.createElement(t,r,o))},t}(Pk.Component);jk.propTypes={},jk.defaultProps={component:"div",childFactory:function(e){return e}};var $k=jk;const Hk={TEXT:"black",DISABLED:"grey",DISABLED_SECONDARY:"#ABABAB",CORRECT:u[500],CORRECT_SECONDARY:u[50],CORRECT_TERTIARY:"#0EA449",CORRECT_WITH_ICON:"#087D38",INCORRECT:d[500],INCORRECT_SECONDARY:p[50],INCORRECT_WITH_ICON:"#BF0D00",MISSING:p[700],MISSING_WITH_ICON:"#6A78A1",PRIMARY:h[500],PRIMARY_LIGHT:h[200],PRIMARY_DARK:h[800],SECONDARY:f.A400,SECONDARY_LIGHT:f[200],SECONDARY_DARK:f[900],TERTIARY:"#146EB3",TERTIARY_LIGHT:"#D0E2F0",BACKGROUND:"rgba(255,255,255,0)",BACKGROUND_DARK:"#ECEDF1",DROPDOWN_BACKGROUND:"#E0E1E6",SECONDARY_BACKGROUND:"rgba(241,241,241,1)",BORDER:"#9A9A9A",BORDER_LIGHT:"#D1D1D1",BORDER_DARK:"#646464",BORDER_GRAY:"#7E8494",BLACK:"#000000",WHITE:"#ffffff",TRANSPARENT:"transparent",FOCUS_CHECKED:"#BBDEFB",FOCUS_CHECKED_BORDER:"#1565C0",FOCUS_UNCHECKED:"#E0E0E0",FOCUS_UNCHECKED_BORDER:"#757575",BLUE_GREY100:"#F3F5F7",BLUE_GREY300:"#C0C3CF",BLUE_GREY600:"#7E8494",BLUE_GREY900:"#152452",FADED_PRIMARY:"#DCDAFB",KEYPAD_BUTTON:"rgb(188, 194, 229)",KEYPAD_BUTTON_OPERATOR:"rgb(255, 159, 192)",KEYPAD_EMPTY_PLACEHOLDER:"rgba(245, 0, 87, 0.4)",KEYPAD_BUTTON_HOVER:"rgb(214, 218, 239)",KEYPAD_BUTTON_OPERATOR_HOVER:"rgb(255, 197, 217)",BUTTON_BORDER:"rgba(0, 0, 0, 0.23)",BUTTON_HOVER_BG:"rgba(0, 0, 0, 0.08)"};Object.freeze(Hk);const Uk=(qk="pie",(...e)=>{const t=e.pop();return e.reduceRight((e,t)=>`var(--${qk}-${t}, ${e})`,t)});var qk;const Vk=()=>Uk("text",Hk.TEXT),Wk=()=>Uk("background",Hk.BACKGROUND),Kk=()=>Uk("tertiary",Hk.TERTIARY),Gk=()=>Uk("tertiary-light",Hk.TERTIARY_LIGHT),Jk=e,Yk=i,{styled:Zk}=r,Xk=Zk("div")({transformOrigin:"0% 0px 0px",width:"100%",display:"block",overflow:"hidden","&.incorrect":{color:"#946202"}}),Qk=Zk("div")({WebkitFontSmoothing:"antialiased",backgroundColor:`var(--feedback-bg-color, ${Uk("disabled",Hk.DISABLED)})`,borderRadius:"4px",lineHeight:"25px",margin:"0px",padding:"10px",verticalAlign:"middle",color:"var(--feedback-color, white)","&.correct":{backgroundColor:`var(--feedback-correct-bg-color, ${Uk("correct",Hk.CORRECT)})`},"&.incorrect":{backgroundColor:`var(--feedback-incorrect-bg-color, ${Uk("incorrect",Hk.INCORRECT)})`}}),eT=Zk("div")({"&.feedback-enter":{height:"1px"},"&.feedback-enter-active":{height:"45px",transition:"height 500ms"},"&.feedback-exit":{height:"45px"},"&.feedback-exit-active":{height:"1px",transition:"height 200ms"}});class tT extends Jk.Component{constructor(...e){super(...e),tT.prototype.__init.call(this)}static __initStatic(){this.propTypes={correctness:Yk.string,feedback:Yk.string}}__init(){this.nodeRef=Jk.createRef()}renderFeedback(){const{correctness:e,feedback:t}=this.props;return e&&t?Jk.createElement(_k,{key:"hasFeedback",nodeRef:this.nodeRef,timeout:{enter:500,exit:200},classNames:"feedback"},Jk.createElement(eT,{ref:this.nodeRef},Jk.createElement(Xk,null,Jk.createElement(Qk,{className:e,dangerouslySetInnerHTML:{__html:t}})))):null}render(){return Jk.createElement("div",null,Jk.createElement($k,null,this.renderFeedback()))}}tT.__initStatic();const nT=e,rT=i,{Popover:iT}=n,{styled:oT}=r,sT=s("pie-libs:render-ui:response-indicators"),aT=oT("div")(({hasFeedback:e})=>({cursor:e?"pointer":"default"})),lT=oT(iT)({cursor:"pointer"}),cT=oT("div")({padding:"0",borderRadius:"4px"}),uT=(e,t)=>{class n extends nT.Component{constructor(e){super(e),n.prototype.__init.call(this),n.prototype.__init2.call(this),this.state={}}__init(){this.handlePopoverOpen=e=>{sT("[handlePopoverOpen]",e.target),this.setState({anchorEl:e.target})}}__init2(){this.handlePopoverClose=()=>{this.setState({anchorEl:null})}}render(){const{feedback:n}=this.props,{anchorEl:r}=this.state;return nT.createElement(aT,{hasFeedback:!!n},nT.createElement("span",{ref:e=>this.icon=e,onClick:this.handlePopoverOpen},nT.createElement(e,null)),n&&nT.createElement(lT,{PaperComponent:cT,open:!!r,anchorEl:r,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},onClose:this.handlePopoverClose},nT.createElement(tT,{feedback:n,correctness:t})))}}return n.propTypes={feedback:rT.string},n};uT(NA,"correct"),uT(DA,"incorrect"),uT(tk,"partially-correct"),uT(YA,"nothing-submitted");const dT=e,{styled:pT}=r,hT=a,fT=i,{renderMath:mT}=c,gT=pT("span")(({theme:e})=>({color:e.palette.primary.light,borderBottom:`1px dotted ${e.palette.primary.light}`,cursor:"pointer"})),yT=pT(hT)(({theme:e})=>({paddingTop:e.spacing(2)}));class vT extends dT.Component{constructor(...e){super(...e),vT.prototype.__init.call(this),vT.prototype.__init2.call(this)}static __initStatic(){this.propTypes={className:fT.string,children:fT.object,labels:fT.shape({visible:fT.string,hidden:fT.string})}}static __initStatic2(){this.defaultProps={labels:{}}}__init(){this.state={expanded:!1}}__init2(){this.toggleExpanded=()=>{this.setState(e=>({expanded:!e.expanded}))}}componentDidMount(){mT(this.root)}componentDidUpdate(){mT(this.root)}render(){const{labels:e,children:t,className:n}=this.props,r=this.state.expanded?e.visible||"Hide":e.hidden||"Show";return dT.createElement("div",{className:n,ref:e=>this.root=e},dT.createElement("div",{onClick:this.toggleExpanded},dT.createElement(gT,null,r)),dT.createElement(yT,{in:this.state.expanded,timeout:{enter:225,exit:195},unmountOnExit:!0},t))}}vT.__initStatic(),vT.__initStatic2();const{Button:bT}=n,{styled:xT}=r;xT("div")({display:"flex",flexDirection:"column"}),xT("div")({display:"flex",alignItems:"center",justifyContent:"center"}),xT("div")(({theme:e})=>({width:"24px",height:"24px",color:"gray",marginRight:e.spacing(1),display:"flex",alignItems:"center"})),xT(bT)(({theme:e})=>({display:"flex",alignItems:"center",marginLeft:e.spacing(3),marginRight:e.spacing(3)}));const wT=e,{createTheme:ET}=r,{styled:MT}=r,{StyledEngineProvider:ST}=r,{ThemeProvider:CT}=r,NT=i;const AT=ET({typography:{fontFamily:"inherit"},palette:{action:{disabled:"rgba(0, 0, 0, 0.54);"}},components:{MuiTypography:{styleOverrides:{root:{fontFamily:"inherit"}}},MuiButton:{styleOverrides:{contained:{backgroundColor:"#e0e0e0",color:"#000000","&:hover":{backgroundColor:"#bdbdbd"}}}}}}),kT=MT("div")({"& table, th, td":{fontSize:"inherit"}});class TT extends wT.Component{static __initStatic(){this.propTypes={className:NT.string,children:NT.array,extraCSSRules:NT.shape({names:NT.arrayOf(NT.string),rules:NT.string}),fontSizeFactor:NT.number}}static __initStatic2(){this.defaultProps={extraCSSRules:{},fontSizeFactor:1}}constructor(e){super(e),this.classesSheet=document.createElement("style")}computeStyle(e){const t=e=>parseFloat(getComputedStyle(e).fontSize),n=t(document.documentElement),r=t(document.body),i=Math.max(n,r),o=null!=e&&"number"==typeof e?e:1;return 1!==o?{fontSize:i*o+"px"}:null}render(){const{children:e,className:t,fontSizeFactor:n,...r}=this.props,{extraCSSRules:i,...o}=r,s=this.computeStyle(n);return wT.createElement(ST,{injectFirst:!0},wT.createElement(CT,{theme:AT},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}([i,"optionalAccess",e=>e.rules])?wT.createElement("style",{dangerouslySetInnerHTML:{__html:`.extraCSSRules { ${i.rules} }`}}):null,wT.createElement(kT,{className:`${t} extraCSSRules`,...o,...s&&{style:s}},e)))}}TT.__initStatic(),TT.__initStatic2();const OT=e,{styled:_T}=r,RT=i,DT=_T(TT)({display:"flex",flexDirection:"column",position:"relative"});class IT extends OT.Component{static __initStatic(){this.propTypes={ariaLabel:RT.string,children:RT.oneOfType([RT.arrayOf(RT.node),RT.node]).isRequired,role:RT.string,extraCSSRules:RT.shape({names:RT.arrayOf(RT.string),rules:RT.string}),fontSizeFactor:RT.number}}render(){const{children:e,ariaLabel:t,role:n,extraCSSRules:r,fontSizeFactor:i,classes:o}=this.props,s=t?{"aria-label":t,role:n}:{};return OT.createElement(DT,{...s,extraCSSRules:r,fontSizeFactor:i,classes:o},e)}}IT.__initStatic();const LT=e,BT=i;class zT extends LT.Component{static __initStatic(){this.propTypes={tag:BT.string,className:BT.string,html:BT.string}}static __initStatic2(){this.defaultProps={tag:"div",html:""}}render(){const{tag:e,className:t,html:n}=this.props,r=e||"div";return LT.createElement(r,{ref:e=>this.node=e,className:t,dangerouslySetInnerHTML:{__html:n}})}}zT.__initStatic(),zT.__initStatic2();const{InputLabel:PT}=n,{FormControl:FT}=n,jT=i,$T=e,{styled:HT}=r,UT=HT(FT)(({theme:e})=>({margin:0,padding:0,flex:"1 0 auto",minWidth:e.spacing(4)})),qT=HT(PT)(()=>({fontSize:"inherit",whiteSpace:"nowrap",margin:0,padding:0,alignSelf:"flex-start",position:"absolute",top:0,left:0,transformOrigin:"top left",pointerEvents:"none","&.MuiInputLabel-shrink":{transform:"scale(0.75) translate(0, -0.75em)"},"&:not(.MuiInputLabel-shrink)":{transform:"translate(0, 0)"}})),VT=({label:e,className:t,children:n})=>$T.createElement(UT,{className:t},$T.createElement(qT,{shrink:!0},e),n);VT.propTypes={label:jT.oneOfType([jT.string,jT.object]).isRequired,className:jT.string,children:jT.oneOfType([jT.arrayOf(jT.node),jT.node]).isRequired};const WT=e,{Component:KT}=e,{styled:GT}=r,JT=i,{renderMath:YT}=c,ZT=GT("div")(({theme:e,tagName:t})=>({"&:not(.MathJax) > table":{borderCollapse:"collapse"},"&:not(.MathJax) > table:has(tbody tr > th:first-child):not(:has(tbody tr > td:first-child)) tbody td:nth-child(even)":{backgroundColor:"#f6f8fa",color:e.palette.common.black},"&:not(.MathJax) > table:has(tbody tr > td:first-child) tbody tr:nth-child(even) td":{backgroundColor:"#f6f8fa",color:e.palette.common.black},"&:not(.MathJax) table td, &:not(.MathJax) table th":{padding:".6em 1em",textAlign:"left"},"&:not(.MathJax) > table td > p.kds-indent":{textAlign:"initial"},"&.prompt":{verticalAlign:"middle",color:Vk()},"&.legend":{width:"100%",fontSize:"inherit !important"},"&.rationale":{paddingLeft:e.spacing(4),paddingBottom:e.spacing(1)},"&.prompt-label":{color:`${Vk()} !important`,display:"flex",flexDirection:"column",verticalAlign:"middle",cursor:"pointer","& > p":{margin:"0 0 0 0 !important"}}})),XT=/\\embed\{newLine\}\[\]/g;class QT extends KT{constructor(...e){super(...e),QT.prototype.__init.call(this)}static __initStatic(){this.propTypes={prompt:JT.string,tagName:JT.string,className:JT.string,onClick:JT.func,defaultClassName:JT.string,autoplayAudioEnabled:JT.bool,customAudioButton:{playImage:JT.string,pauseImage:JT.string}}}static __initStatic2(){this.defaultProps={onClick:()=>{}}}__init(){this.parsedText=e=>{const{customAudioButton:t}=this.props,n=document.createElement("div");n.innerHTML=e;const r=n.querySelector("audio");if(r){const e=document.createElement("source");if(e.setAttribute("type","audio/mp3"),e.setAttribute("src",r.getAttribute("src")),r.removeAttribute("src"),r.setAttribute("id","pie-prompt-audio-player"),r.appendChild(e),t){r.style.display="none";const e=document.createElement("div");e.id="play-audio-button",Object.assign(e.style,{cursor:"pointer",display:"block",width:"128px",height:"128px",backgroundImage:`url(${t.pauseImage})`,backgroundSize:"cover",borderRadius:"50%",border:"1px solid #326295"}),r.parentNode.insertBefore(e,r)}}return n.innerHTML}}addCustomAudioButtonControls(){const{autoplayAudioEnabled:e,customAudioButton:t}=this.props,n=document.getElementById("play-audio-button"),r=document.getElementById("pie-prompt-audio-player");if(e&&r&&r.play().then(()=>{n&&t&&r.addEventListener("ended",o)}).catch(e=>{console.error("Error playing audio",e)}),!n||!r||!t)return;const i=()=>{r.paused&&(n.style.backgroundImage.includes(t.pauseImage)||r.play())},o=()=>{n.style.backgroundImage=`url(${t.playImage})`},s=()=>{Object.assign(n.style,{backgroundImage:`url(${t.pauseImage})`,border:"1px solid #ccc"})},a=()=>{Object.assign(n.style,{backgroundImage:`url(${t.playImage})`,border:"1px solid #326295"})};n.addEventListener("click",i),r.addEventListener("play",s),r.addEventListener("pause",a),r.addEventListener("ended",o),this._handlePlayClick=i,this._handleAudioPlay=s,this._handleAudioPause=a,this._handleAudioEnded=o}removeCustomAudioButtonListeners(){const e=document.getElementById("play-audio-button"),t=document.querySelector("audio");e&&t&&(e.removeEventListener("click",this._handlePlayClick),t.removeEventListener("play",this._handleAudioPlay),t.removeEventListener("pause",this._handleAudioPause),t.removeEventListener("ended",this._handleAudioEnded))}componentDidMount(){this.alignImages(),this.addCustomAudioButtonControls(),this.setupMathRendering()}componentDidUpdate(e){this.alignImages(),e.prompt!==this.props.prompt&&this.renderMathContent()}componentWillUnmount(){this.removeCustomAudioButtonListeners()}setupMathRendering(){this.renderMathContent()}renderMathContent(){const e=document.getElementById("preview-prompt");e&&"function"==typeof YT&&YT(e)}alignImages(){document.querySelectorAll("#preview-prompt").forEach(e=>{const t=e.getElementsByTagName("img");if(t&&t.length)for(let e of t)if(e.attributes&&e.attributes.alignment&&e.attributes.alignment.value){const t=e.attributes.alignment.value,n="center"===t?"center":"right"===t?"flex-end":"flex-start",r=e.parentElement;if("DIV"===r.tagName&&"flex"===r.style.display&&"100%"===r.style.width)r.style.justifyContent=n;else{const t=document.createElement("div");t.style.display="flex",t.style.width="100%",t.style.justifyContent=n;const i=e.cloneNode(!0);t.appendChild(i),r.replaceChild(t,e)}}})}render(){const{prompt:e,tagName:t,className:n,onClick:r,defaultClassName:i}=this.props,o=`${n||""} ${i||""} ${"legend"===t?"legend":""}`.trim();return WT.createElement(ZT,{as:t||"div",id:"preview-prompt",onClick:r,className:o,tagName:t,dangerouslySetInnerHTML:{__html:this.parsedText(e||"").replace(XT,"\\newline ")}})}}QT.__initStatic(),QT.__initStatic2();const eO=i;eO.node,eO.bool;const tO=i;tO.node,tO.string,"undefined"!=typeof window&&new DOMParser,"undefined"!=typeof window&&new DOMParser;const nO=e,rO=i,{ChevronRight:iO}=o,{MoreVert:oO}=o,{styled:sO}=r,aO=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 nO.createElement(iO,{style:{transform:`rotate(${r}deg)`,...n}})};aO.propTypes={direction:rO.string,style:rO.object};const lO=({style:e})=>nO.createElement("span",{style:e},nO.createElement(oO,{style:{margin:"0 -16px"}}),nO.createElement(oO,null));lO.propTypes={style:rO.object},sO("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 cO=e,{useEffect:uO}=e,{useRef:dO}=e,{useState:pO}=e,hO=i,{styled:fO}=r,mO=l,{renderMath:gO}=c;function yO(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 vO=fO("span")(({theme:e})=>({border:`solid 0px ${e.palette.primary.main}`,"& mjx-frac":{fontSize:"120% !important"}}));function bO({n:e,children:t,isDragging:n,isOver:r,dragItem:i,value:o,selected:s}){const[a,l]=pO(null),c=dO(null),u=e=>{c.current&&(c.current.contains(e.target)?c.current.classList.add("selected"):c.current.classList.remove("selected"))};uO(()=>(document.addEventListener("click",u),()=>{document.removeEventListener("click",u)}),[]),uO(()=>{c.current&&"function"==typeof gO&&gO(c.current)},[yO([o,"optionalAccess",e=>e.value]),r,yO([i,"optionalAccess",e=>e.value,"optionalAccess",e=>e.value])]),uO(()=>{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 ${Uk("primary-dark",Hk.PRIMARY_DARK)}`:f?`1px solid ${Hk.BORDER_DARK}`:`1px solid ${Hk.BORDER_LIGHT}`;return cO.createElement("div",{ref:c,className:s?"selected":void 0,style:{display:"inline-flex",minWidth:"178px",minHeight:"36px",background:f?`${Hk.BORDER_LIGHT}`:`${Hk.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&&cO.createElement(lO,{style:{position:"absolute",top:"6px",left:"15px",color:"#9B9B9B"},contentEditable:!1}),cO.createElement("span",{dangerouslySetInnerHTML:{__html:p}}),t)}function xO({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}=JN({id:`drag-${i.index}`,disabled:t||!yO([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"===yO([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=VS("Droppable"),{active:s,dispatch:a,over:l,measureDroppableContainers:c}=lC(FN),u=hC({disabled:n}),d=hC(!1),p=hC(null),h=hC(null),{disabled:f,updateMeasurementsFor:m,timeout:g}={...YN,...i},y=jS(null!=m?m:r),v=CN({callback:dC(()=>{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=dC((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v]),[x,w]=HS(b),E=jS(t);return cC(()=>{v&&x.current&&(v.disconnect(),d.current=!1,v.observe(x.current))},[x,v]),cC(()=>(a({type:SC.RegisterDroppable,element:{id:r,key:o,disabled:n,node:x,rect:p,data:E}}),()=>a({type:SC.UnregisterDroppable,key:o,id:r})),[r]),cC(()=>{n!==u.current.disabled&&(a({type:SC.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:x,over:l,setNodeRef:w}}({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"===yO([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=cO.createElement(bO,{n:i,isDragging:h,isOver:m,dragItem:yO([g,"optionalAccess",e=>e.data,"optionalAccess",e=>e.current]),value:e,selected:c},r),v=e?cO.createElement("span",{ref:e=>{p(e),f(e)},...u,...d},y):cO.createElement("span",{ref:f},y);return cO.createElement(vO,{className:mO(m&&"over")},v)}bO.propTypes={n:hO.object,children:hO.node,isDragging:hO.bool,isOver:hO.bool,dragItem:hO.object,value:hO.object,selected:hO.bool},xO.propTypes={value:hO.object,disabled:hO.bool,instanceId:hO.string,children:hO.node,n:hO.object.isRequired,onChange:hO.func.isRequired,removeResponse:hO.func.isRequired,duplicates:hO.bool,selected:hO.bool};const wO=e,EO=i,MO=e=>{const{editor:t,node:n,getPos:r,options:i,selected:o}=e,{attrs:s}=n,{inTable:a}=s,l=r();return wO.createElement(Uh,{className:"drag-in-the-blank","data-selected":o,style:{display:"inline",whiteSpace:"normal"}},wO.createElement("span",{...s,style:{display:"inline-flex",minHeight:"50px",minWidth:"178px",position:"relative",margin:a?"10px":"0 10px",cursor:"pointer"}},wO.createElement(xO,{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,xr(t.attrs,["value","id"])),r.isDone=!0,e.view.dispatch(r)})(t,n,e)})))};MO.propTypes={attributes:EO.object,data:EO.object,n:EO.object,nodeProps:EO.object,opts:EO.object};const SO=e,{useEffect:CO}=e,{useRef:NO}=e,{useState:AO}=e,kO=i,TO=t,OO=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=NO(null),p=NO(null),[h,f]=AO(!1),[m,g]=AO({top:0,left:0}),y=i.respAreaToolbar([n,u],t,()=>{});return CO(()=>{const{selection:e}=t.state,r=e.from+n.nodeSize===e.to;o?r&&f(o):f(o)},[t,n,o]),CO(()=>{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]),SO.createElement(Uh,{className:"inline-dropdown","data-selected":o,style:{display:"inline-flex",height:"50px",cursor:"pointer"}},SO.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)},SO.createElement("div",{style:{flex:1,overflow:"hidden",padding:"0 25px 0 8px",whiteSpace:"nowrap",textOverflow:"ellipsis"}},SO.createElement("span",{style:{display:"inline-block",verticalAlign:"middle"},dangerouslySetInnerHTML:{__html:c}})),SO.createElement(aO,{direction:"down",style:{position:"absolute",top:"5px",right:"5px"}})),h&&TO.createPortal(SO.createElement("div",{ref:d,style:{zIndex:1}},SO.createElement(y,{editorCallback:e=>{p.current=e}})),document.body))};OO.propTypes={attributes:kO.object,selectedItem:kO.oneOfType([kO.string,kO.object])};const _O=e,RO=i,{styled:DO}=r,{mq:IO}=g,LO=DO("span")(()=>({display:"inline-flex",border:"1px solid #C0C3CF",margin:"1px 5px",cursor:"pointer",alignItems:"center",justifyContent:"center",minWidth:"50px",minHeight:"36px",height:"fit-content"})),BO=DO("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"})),zO=DO("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"}})),PO=e=>{const{node:t,options:n,selected:r}=e,{attrs:i}=t,{value:o,index:s}=i,a=`R ${parseInt(s)+1}`;return _O.createElement(Uh,{className:"math-templated","data-selected":r,style:{display:"inline-flex",minHeight:"36px",minWidth:"50px",cursor:"pointer"}},_O.createElement(LO,{...i},_O.createElement(BO,null,a),_O.createElement(zO,null,_O.createElement(IO.Static,{latex:o}))))};PO.propTypes={attributes:RO.object,value:RO.string,keyToDisplay:RO.string};const FO=e;function jO(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 $O={},HO=e=>String(e||"").replace(/-/g,"_"),UO=e=>e&&e.attrs&&null!=e.attrs.index?String(e.attrs.index):null,qO=(e,t)=>{const n=[];return e.descendants((e,r)=>{if(e.type&&e.type.name===t){const t=UO(e);null!=t&&n.push({index:t,pos:r,node:e})}return!0}),n},VO=Cd.create({name:"responseArea",addOptions:()=>({maxResponseAreas:null,error:null,options:null,respAreaToolbar:null,onHandleAreaChange:null}),addProseMirrorPlugins(){if(!this.options.type)return[];const e=HO(this.options.type),t=new gs(`response-area-watcher:${e}`);return[new hs({key:t,view:t=>(void 0===$O[e]&&($O[e]=0,t.state.doc.descendants(t=>{if(t.type&&t.type.name===e){const n=UO(t);if(null!=n){const t=parseInt(n,10);!Number.isNaN(t)&&t>$O[e]&&($O[e]=t)}}return!0})),{update:(t,n)=>{const r=t.state;if(n.doc.eq(r.doc))return;const i=qO(r.doc,e),o=qO(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=HO(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===$O[o]&&($O[o]=0);const a=$O[o]+1;$O[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(Qo.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 Zo.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,{...jO([o,"optionalAccess",e=>e.attrs]),updated:`${Date.now()}`}),e.setSelection(Qo.create(e.doc,s)),r&&(n.focus(),r(e)),!0}}}}),WO=Zp.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 Gh(e=>FO.createElement(SS,{...{...e,options:this.options}}))}}),KO=Zp.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 Gh(e=>FO.createElement(PO,{...{...e,options:this.options}}))}}),GO=Zp.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 Gh(e=>FO.createElement(MO,{...{...e,options:this.options}}))}}),JO=Zp.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 Gh(e=>FO.createElement(OO,{...{...e,options:this.options}}))}}),YO=e,{useEffect:ZO}=e,{useRef:XO}=e,{useState:QO}=e,e_=t,{MathPreview:t_}=y,{MathToolbar:n_}=y,{wrapMath:r_}=c;function i_(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 o_=new gs("ensureTextAfterMath"),s_=(e=[])=>e.map(e=>({name:e,latex:e,write:e,label:e})),a_=new hs({key:new gs("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(Qo.create(n.doc,o.pos))),!0}return r(n.tr.setSelection(Zo.create(n.doc,s-2))),!0}}return!1}}}),l_=Zp.create({name:"math",group:"inline",inline:!0,atom:!0,addAttributes:()=>({latex:{default:""},wrapper:{default:null},html:{default:null}}),addProseMirrorPlugins(){return[(e=this.name,new hs({key:o_,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}})),a_];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),i_([o,"optionalAccess",e=>e.type,"optionalAccess",e=>e.name])===this.name){const e=Qo.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},r_(e.latex,e.wrapper)],addNodeView(){return Gh(e=>YO.createElement(c_,{...{...e,options:this.options}}))}}),c_=e=>{const{node:t,updateAttributes:n,editor:r,selected:i,options:o}=e,[s,a]=QO(i),l=XO(null),[c,u]=QO({top:0,left:0}),{math:d={}}=o||{},{keypadMode:p,controlledKeypadMode:h=!0,customKeys:f=[],keyPadCharacterRef:m,setKeypadInteraction:g}=d,y=t.attrs.latex||"";ZO(()=>{i&&a(!0)},[i]),ZO(()=>{r._toolbarOpened=!!s},[s]),ZO(()=>{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=i_([e,"optionalAccess",e=>e.target]),n=(i_([document,"access",e=>e.querySelectorAll,"optionalCall",e=>e('[id^="equation-editor-select"][id*="listbox"], [aria-labelledby="equation-editor-label"][role="listbox"]')])||[]).length>0,r=!(!i_([t,"optionalAccess",e=>e.id])||!t.id.includes("equation-editor-select"))||!!i_([t,"optionalAccess",e=>e.closest,"optionalCall",e=>e('[id*="equation-editor-select"]')]),i=!!i_([t,"optionalAccess",e=>e.closest,"optionalCall",e=>e(".math-node")]);!l.current||l.current.contains(t)||i_([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 YO.createElement(Uh,{className:"math-node",style:{display:"inline-flex",cursor:"pointer",margin:"0 4px"},"data-selected":i},YO.createElement("div",{onClick:()=>a(!0),contentEditable:!1},YO.createElement(t_,{latex:y})),s&&e_.createPortal(YO.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)"}},YO.createElement(n_,{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=Zo.create(o,t.from+1);i.setSelection(s),r.view.dispatch(i),r.commands.focus()},keypadMode:p,controlledKeypadMode:h,additionalKeys:s_(f),keyPadCharacterRef:m,setKeypadInteraction:g})),i_([r,"optionalAccess",e=>e._tiptapContainerEl])||document.body))},u_=s("@pie-lib:editable-html:image:insert-image-handler");class d_{constructor(e,t,n,r=!1){this.editor=e,this.nodeInfo=t,this.node=t[0],this.nodePos=t[1],this.onFinish=n,this.isPasted=r,this.chosenFile=null}cancel(){u_("insert cancelled");try{this.deleteNode(),this.onFinish(!1)}catch(e){}finally{this.editor._insertingImage=!1}}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){u_("done: err:",e),e?(console.log(e),this.onFinish(!1)):(this.updateNode({loaded:!0,src:t,percent:100}),this.onFinish(!0)),this.editor._insertingImage=!1}fileChosen(e){if(!e)return;this.chosenFile=e,this.editor._insertingImage=!1,u_("[fileChosen] file: ",e);const t=new FileReader;t.onload=()=>{const e=t.result;this.updateNode({src:e})},t.readAsDataURL(e)}progress(e,t,n){u_("progress: ",e,t,n),this.updateNode({percent:e})}getChosenFile(){return this.chosenFile}}const p_=e,{DialogContent:h_}=n,{TextField:f_}=n,{DialogActions:m_}=n,{Button:g_}=n,{Dialog:y_}=n,{ArrowBackIos:v_}=o,b_=i;class x_ extends p_.Component{static __initStatic(){this.propTypes={onDone:b_.func.isRequired,alt:b_.string}}constructor(e){super(e),x_.prototype.__init.call(this),x_.prototype.__init2.call(this),x_.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 p_.createElement(y_,{open:!0,disablePortal:!0,onClose:this.closeDialog,id:"text-dialog",hideBackdrop:!0,disableScrollLock:!0,onEntered:this.handleOverflow},p_.createElement(h_,null,p_.createElement("div",{style:{display:"flex"}},p_.createElement(v_,{style:{paddingTop:"6px"}}),p_.createElement(f_,{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}}}))),p_.createElement(m_,null,p_.createElement(g_,{onClick:this.onDone},"Done")))}}x_.__initStatic();const w_=e,E_=s,{styled:M_}=r,S_=i,C_=M_("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}})),N_=E_("pie-elements:editable-html:raw-button");class A_ extends w_.Component{static __initStatic(){this.propTypes={onClick:S_.func.isRequired,children:S_.oneOfType([S_.arrayOf(S_.node),S_.node]).isRequired,active:S_.bool,disabled:S_.bool,extraStyles:S_.object}}constructor(e){super(e),A_.prototype.__init.call(this),A_.prototype.__init2.call(this)}__init(){this.onClick=e=>{N_("[onClick]"),e.preventDefault();const{onClick:t}=this.props;t(e)}}__init2(){this.onKeyDown=e=>{if("Enter"===e.key||" "===e.key){N_("[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 w_.createElement(C_,{style:r,active:e,disabled:n,onMouseDown:this.onClick,onKeyDown:this.onKeyDown,"aria-label":i,"aria-pressed":e,tabIndex:0},t)}}A_.__initStatic();class k_ extends w_.Component{static __initStatic2(){this.propTypes={onToggle:S_.func.isRequired,mark:S_.string,label:S_.string.isRequired,children:S_.oneOfType([S_.arrayOf(S_.node),S_.node]).isRequired,active:S_.bool}}constructor(e){super(e),k_.prototype.__init3.call(this),k_.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 w_.createElement(C_,{active:t,onMouseDown:this.onToggle,"aria-pressed":t,onKeyDown:this.onKeyDown,"aria-label":n,tabIndex:0},e)}}k_.__initStatic2();const T_=k_,O_=i,__=e,R_=s,D_=t,{styled:I_}=r,L_=R_("@pie-lib:editable-html:plugins:image:image-toolbar"),B_=I_("div")(({theme:e})=>({paddingLeft:e.spacing.unit,display:"flex",alignItems:"center"})),z_=I_("span",{shouldForwardProp:e=>!["disabled","hasAlignmentButtons"].includes(e)})(({disabled:e,hasAlignmentButtons:t})=>({...e&&{opacity:.5},...t&&{borderLeft:"1px solid grey",paddingLeft:8,marginLeft:4}})),P_=({alignment:e,active:t,onClick:n})=>__.createElement(T_,{active:t,onToggle:()=>n(e),label:e},e);P_.propTypes={alignment:O_.string.isRequired,active:O_.bool.isRequired,onClick:O_.func.isRequired};class F_ extends __.Component{constructor(...e){super(...e),F_.prototype.__init.call(this),F_.prototype.__init2.call(this),F_.prototype.__init3.call(this)}static __initStatic(){this.propTypes={onChange:O_.func.isRequired,alignment:O_.string,alt:O_.string,imageLoaded:O_.bool,disableImageAlignmentButtons:O_.bool}}__init(){this.onAltTextDone=e=>{L_("[onAltTextDone]: alt:",e),this.props.onChange({alt:e},!0)}}__init2(){this.onAlignmentClick=e=>{L_("[onAlignmentClick]: alignment:",e),this.props.onChange({alignment:e})}}__init3(){this.renderDialog=()=>{const{alt:e}=this.props,t=document.createElement("div"),n=__.createElement(x_,{alt:e,onDone:this.onAltTextDone});D_.render(n,t),document.body.appendChild(t)}}render(){const{alignment:e,imageLoaded:t,disableImageAlignmentButtons:n}=this.props;return __.createElement(B_,null,!n&&__.createElement(__.Fragment,null,__.createElement(P_,{alignment:"left",active:"left"===e,onClick:this.onAlignmentClick}),__.createElement(P_,{alignment:"center",active:"center"===e,onClick:this.onAlignmentClick}),__.createElement(P_,{alignment:"right",active:"right"===e,onClick:this.onAlignmentClick})),__.createElement(z_,{disabled:!t,hasAlignmentButtons:!n,onMouseDown:e=>t&&this.renderDialog(e)},"Alt text"))}}F_.__initStatic();const j_=e,{useCallback:$_}=e,{useEffect:H_}=e,{useMemo:U_}=e,{useRef:q_}=e,{useState:V_}=e,W_=i,K_=s,{LinearProgress:G_}=n,{styled:J_}=r,Y_=t;function Z_(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}K_("@pie-lib:editable-html:plugins:image:component");const X_=J_(G_,{shouldForwardProp:e=>"hideProgress"!==e})(({hideProgress:e})=>({position:"absolute",left:"0",width:"fit-content",top:"0%",transition:"opacity 200ms linear",...e&&{opacity:0}})),Q_=J_("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}})),eR=J_("div")(({theme:e})=>({position:"relative",width:"fit-content",display:"flex",alignItems:"center","&&:hover > .resize":{display:"block"}})),tR=J_("img",{shouldForwardProp:e=>"active"!==e})(({theme:e,active:t})=>({border:t?`solid 1px ${e.palette.primary.main}`:"solid 1px transparent"})),nR=J_("div")(({theme:e})=>({backgroundColor:e.palette.primary.main,cursor:"col-resize",height:"35px",width:"5px",borderRadius:8,marginLeft:"5px",marginRight:"10px",display:"none"})),rR=e=>e?`${e}px`:"calc(20px)";function iR(e){const{node:t,editor:n,attributes:r,onFocus:i,getPos:o,selected:s,options:a,maxImageWidth:l=700,maxImageHeight:c=900}=e;t.attrs;const u=o(),d=n.state.selection.from,p=n.state.selection.to,h=U_(()=>d+t.nodeSize===p,[d,p,t.nodeSize]),[f,m]=V_(!1),g=q_(t),y=q_(null),v=q_(null),b=q_(null),x=$_(e=>{const t=e/y.current.naturalWidth*4;return parseInt(25*t.toFixed(0),10)},[]),w=$_(()=>{const e=g.current.attrs.nodeKey;let t=null;return n.state.doc.descendants((n,r)=>null===t&&("imageUploadNode"===n.type.name&&n.attrs.nodeKey===e?(t=r,!1):void 0)),t},[n]),E=$_(e=>{const t=w();if(null===t)return;const r=n.state.doc.nodeAt(t);r&&n.view.dispatch(n.state.tr.setNodeMarkup(t,void 0,{...r.attrs,...e}))},[n,w]),M=$_(()=>{if(!t.attrs.width||!y.current)return;const e=x(t.attrs.width);t.attrs.resizePercent!==e&&E({resizePercent:e})},[t.attrs.width,t.attrs.resizePercent,x,E]);H_(()=>{g.current={...t,pos:u}},[t,u]),H_(()=>{if(s){if(h){!String((e=Z_([t,"access",e=>e.attrs,"optionalAccess",e=>e.src]),r=()=>"",null!=e?e:r())).trim()&&Z_([a,"access",e=>e.imageHandling,"optionalAccess",e=>e.insertImageRequested])&&a.imageHandling.insertImageRequested(n,[t,u],e=>new d_(n,[t,u],e)),m(s)}}else m(s);var e,r},[h,s]),H_(()=>{M();const e=v.current;return e&&e.addEventListener("mousedown",k,!1),()=>{e&&e.removeEventListener("mousedown",k,!1)}},[]),H_(()=>{M()});const S=$_(()=>{const e=y.current;var n,r;if(e&&(!e.style.width||"calc(20px)"===e.style.width)){const i=Math.min(e.naturalWidth,l),o=Math.min(e.naturalHeight,c);e.style.width=`${i}px`,e.style.height=`${o}px`;const s={width:i,height:o};n=s,r={width:t.attrs.width,height:t.attrs.height},Yn(n,r)||E(s)}},[t.attrs.width,t.attrs.height,l,c,E]),C=$_(e=>{const t=y.current;if(!t)return;const n=e.target.getBoundingClientRect(),r=((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:t.naturalWidth,height:t.naturalHeight},{width:e.clientX-n.left,height:e.clientY-n.top});r.width>50&&r.height>50&&r.width<=700&&r.height<=900&&(t.style.width=`${r.width}px`,t.style.height=`${r.height}px`,E({width:r.width,height:r.height}))},[n,E]),N=$_(e=>{E(e)},[n,E]),A=$_(()=>{window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",A)},[C]),k=$_(()=>{window.addEventListener("mousemove",C),window.addEventListener("mouseup",A)},[C,A]),T={width:rR(t.attrs.width),height:rR(t.attrs.height),objectFit:"contain"},O={left:"flex-start",center:"center",right:"flex-end"}[t.attrs.alignment]||"flex-start";return j_.createElement(Uh,null,j_.createElement(Q_,{onFocus:i,loading:!t.attrs.loaded,pendingDelete:"pending"===t.attrs.deleteStatus,style:{justifyContent:O}},j_.createElement(X_,{mode:"determinate",value:t.attrs.percent||0,hideProgress:t.attrs.loaded}),j_.createElement(eR,{onDragStart:e=>e.preventDefault()},j_.createElement(tR,{...r,active:s&&t.attrs.loaded,draggable:!1,ref:y,src:t.attrs.src,style:T,onLoad:S,alt:t.attrs.alt}),j_.createElement(nR,{ref:v,className:"resize"}))),f&&n._tiptapContainerEl&&Y_.createPortal(j_.createElement("div",{ref:b,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%"}},j_.createElement(yS,{showDone:!0,deletable:!0,toolbarOpts:a.toolbarOpts||{},onDelete:()=>{const e=w();null!==e&&(Z_([a,"access",e=>e.imageHandling,"optionalAccess",e=>e.onDelete,"optionalCall",e=>e(g.current)]),n.view.dispatch(n.state.tr.delete(e,e+n.state.doc.nodeAt(e).nodeSize)),m(!1),n.commands.focus())},onDone:()=>{m(!1),Z_([a,"access",e=>e.imageHandling,"optionalAccess",e=>e.onDone,"optionalCall",e=>e(n)]),n.commands.focus("end")}},j_.createElement(F_,{disableImageAlignmentButtons:Z_([a,"access",e=>e.imageHandling,"optionalAccess",e=>e.disableImageAlignmentButtons]),alt:t.attrs.alt,imageLoaded:t.attrs.loaded,alignment:t.attrs.alignment||"left",onChange:N}))),n._tiptapContainerEl))}iR.propTypes={node:W_.object.isRequired,editor:W_.object.isRequired,attributes:W_.object,onFocus:W_.func,maxImageWidth:W_.number,maxImageHeight:W_.number};const oR=e;const sR=Zp.create({name:"imageUploadNode",group:"block",atom:!0,selectable:!0,draggable:!0,addAttributes:()=>({nodeKey:{default:null},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:'img[data-type="image-upload-node"]'}],renderHTML:({HTMLAttributes:e})=>["img",Fu(e,{"data-type":"image-upload-node"})],addNodeView(){return Gh(e=>oR.createElement(iR,{...{...e,options:this.options}}))},addCommands(){return{setImageUploadNode:()=>({commands:e})=>e.insertContent({type:this.name,attrs:{nodeKey:`img-${Date.now()}-${Math.random().toString(36).slice(2)}`}})}},addProseMirrorPlugins(){const e=this.editor;return[new hs({props:{handlePaste(t,n){const r=Array.from(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,"access",e=>e.clipboardData,"optionalAccess",e=>e.items])||[]),i=r.find(e=>"file"===e.kind&&e.type.startsWith("image/"));if(!i)return!1;const o=i.getAsFile();if(!o)return!1;const s=new FileReader;return s.onload=()=>{const t=s.result;"string"==typeof t&&e.commands.insertContent({type:"imageUploadNode",attrs:{src:t,loaded:!0,nodeKey:`img-${Date.now()}-${Math.random().toString(36).slice(2)}`}})},s.readAsDataURL(o),!0}}})]}}),aR=e,lR=i,cR=s,{styled:uR}=r,{Button:dR}=n,{Dialog:pR}=n,{Tabs:hR}=n,{Tab:fR}=n,{DialogTitle:mR}=n,{DialogContent:gR}=n,{DialogContentText:yR}=n,{DialogActions:vR}=n,{TextField:bR}=n,{Typography:xR}=n,{IconButton:wR}=n,{Delete:ER}=o;function MR(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 SR=cR("@pie-lib:editable-html:plugins:media:dialog"),CR=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]},NR=e=>e&&/(http|https)?:\/\/(www\.)?(player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^/]*)\/videos\/|)(video\/)?(\d+)(?:|\/\?)/.test(e),AR={video:"Video",audio:"Audio"},kR="upload-file",TR="insert-url",OR=uR(pR)(({theme:e})=>({"& .MuiDialog-paper":{minWidth:"500px"}})),_R=uR(gR)(({theme:e})=>({padding:0})),RR=uR("div")(({theme:e})=>({display:"flex",flexDirection:"space-between"})),DR=uR("div")(({theme:e})=>({marginTop:e.spacing(1.5)})),IR=uR("input")(({theme:e})=>({})),LR=uR(xR)(({theme:e})=>({marginTop:e.spacing(1.5),color:e.palette.error.main})),BR=uR(wR)(({theme:e})=>({marginLeft:e.spacing(1.5)}));class zR extends aR.Component{static __initStatic(){this.propTypes={open:lR.bool,edit:lR.bool,disablePortal:lR.bool,handleClose:lR.func,uploadSoundSupport:lR.shape({add:lR.func,delete:lR.func}),type:lR.string,src:lR.string,url:lR.string,urlToUse:lR.string,starts:lR.number,ends:lR.number,height:lR.number,width:lR.number}}constructor(e){super(e),zR.prototype.__init.call(this),zR.prototype.__init2.call(this),zR.prototype.__init3.call(this),zR.prototype.__init4.call(this),zR.prototype.__init5.call(this),zR.prototype.__init6.call(this),zR.prototype.__init7.call(this),zR.prototype.__init8.call(this),zR.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=MR([s,"optionalAccess",e=>e.add])&&MR([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?kR:TR,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=CR(e),o=NR(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(""),SR(t)})}catch(t){e("")}})).then(t=>{this.handleStateChange({urlToUse:t,invalid:!t,url:e})}).catch(SR)}}__init4(){this.checkVideo=e=>{if(CR(e)){const t=/^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/,n=`https://youtube.com/embed/${e.match(t)[2]}`;SR("is youtube"),this.handleStateChange({urlToUse:n,url:e,invalid:!1})}if(NR(e)){const t=`https://player.vimeo.com/video/${e.replace(/.*vimeo.com\/(.*)/g,"$1")}`;SR("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`;SR("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===TR;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(SR("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=CR(u),y=f===TR,v=f===kR,b=y?a||null==u:!m.url||m.scheduled,x=MR([i,"optionalAccess",e=>e.add])&&MR([i,"optionalAccess",e=>e.delete])&&"video"!==n;return aR.createElement(OR,{disablePortal:t,open:e,onClose:()=>this.handleDone(!1),"aria-labelledby":"form-dialog-title"},aR.createElement(mR,{id:"form-dialog-title"},"Insert ",AR[n]),aR.createElement(gR,null,aR.createElement("div",null,aR.createElement(RR,null,aR.createElement(hR,{indicatorColor:"primary",value:f,onChange:(e,t)=>{this.setState({tabValue:t})}},x?aR.createElement(fR,{value:kR,label:"Upload file"}):null,aR.createElement(fR,{value:TR,label:"video"===n?"Insert YouTube, Vimeo, or Google Drive URL":"Insert SoundCloud URL"}))),y&&aR.createElement("div",null,aR.createElement(bR,{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&&aR.createElement(_R,null,aR.createElement(yR,null,"Video Properties"),aR.createElement(bR,{autoFocus:!0,margin:"dense",id:"width",label:"Width",type:"number",placeholder:"Width",value:c,onChange:this.changeHandler("width")}),aR.createElement(bR,{autoFocus:!0,margin:"dense",id:"height",label:"Height",type:"number",placeholder:"Height",value:s,onChange:this.changeHandler("height")})),p&&aR.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&&aR.createElement(aR.Fragment,null,aR.createElement(_R,null,aR.createElement(bR,{autoFocus:!0,margin:"dense",id:"starts",label:"Starts",type:"number",placeholder:"Starts",value:l,onChange:this.changeHandler("starts")}),g&&aR.createElement(bR,{autoFocus:!0,margin:"dense",id:"ends",label:"Ends",type:"number",placeholder:"Ends",value:o,onChange:this.changeHandler("ends")})))),v&&aR.createElement(DR,null,aR.createElement("div",null,m.url?aR.createElement(aR.Fragment,null,aR.createElement(RR,null,aR.createElement("audio",{controls:"controls",controlsList:"nodownload"},aR.createElement("source",{type:d,src:m.url})),aR.createElement(BR,{"aria-label":"delete",onClick:this.handleRemoveFile},aR.createElement(ER,null))),!m.scheduled&&m.loading?aR.createElement(xR,{variant:"subheading"},"Loading..."):null,m.scheduled?aR.createElement(xR,{variant:"subheading"},"Waiting for Upload to finish, then inserting item..."):null):m.loading?null:aR.createElement(IR,{accept:"audio/*",onChange:this.handleUploadFile,type:"file"}),!!m.error&&aR.createElement(LR,{variant:"caption"},m.error))))),aR.createElement(vR,null,aR.createElement(dR,{onClick:()=>this.handleDone(!1),color:"primary"},"Cancel"),aR.createElement(dR,{disabled:b,onClick:()=>this.handleDone(!0),color:"primary"},r?"Update":"Insert")))}}zR.__initStatic();const PR=e,FR=i,{styled:jR}=r,$R=jR("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)"})),HR=jR("span")(({theme:e})=>({cursor:"pointer",flex:3,border:`solid ${e.palette.common.black}`,textAlign:"right",borderWidth:"0 2px 0 0",marginRight:"5px",paddingRight:"5px"})),UR=jR("span")({cursor:"pointer"});class qR extends PR.Component{static __initStatic(){this.propTypes={onEdit:FR.func,hideEdit:FR.bool,onRemove:FR.func}}render(){const{hideEdit:e,onEdit:t,onRemove:n}=this.props;return PR.createElement($R,null,e?null:PR.createElement(HR,{onClick:t},"Edit Settings"),PR.createElement(UR,{onClick:n},"Remove"))}}qR.__initStatic();const VR=e,{useEffect:WR}=e,KR=t;function GR(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 JR=Zp.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:GR([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",Fu({"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 Gh(e=>VR.createElement(ZR,{...{...e,options:this.options}}))}}),YR=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=VR.createElement(zR,{...o,uploadSoundSupport:i.uploadSoundSupport,type:n,disablePortal:!0,open:!0,handleClose:(e,n)=>{r(e,n),t.remove(),document.body.style.overflow=s}});KR.render(a,t),document.body.appendChild(t)};function ZR({editor:e,node:t,updateAttributes:n,deleteNode:r,options:i}){const{type:o,src:s,width:a,height:l,tag:c}=t.attrs;return WR(()=>{s||YR({...t.attrs,options:i,edit:!0,callback:(t,i)=>{t?n(i):r(),e.chain().focus().run()}})},[]),VR.createElement(Uh,{"data-type":o,style:{width:a,height:l}},"audio"===c?VR.createElement("audio",{controls:!0,controlsList:"nodownload"},VR.createElement("source",{type:"audio/mp3",src:s})):VR.createElement("iframe",{src:s,allowFullScreen:!0,frameBorder:"0",width:a,height:l}),VR.createElement(qR,{onEdit:()=>{YR({...t.attrs,options:i,edit:!0,callback:(t,r)=>{t&&n(r),e.chain().focus().run()}})},onRemove:r}))}const XR=e,QR=t,{List:eD}=n,{ListItem:tD}=n;function nD(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 rD=({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=nD([i,"optionalAccess",e=>e.attrs,"access",e=>e.class]),p=e=>{let t=`<span class="${e}">${r}</span>`;if(i){let e="span";"inline"===nD([i,"optionalAccess",e=>e.object])&&(e="span"),"block"===nD([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=XR.createElement("div",{style:{background:"white",height:500,padding:20,overflow:"hidden",display:"flex",flexFlow:"column"}},XR.createElement("h2",null,"Please choose a css class"),d&&XR.createElement("div",null,"The current parent has this class ",d),XR.createElement(eD,{component:"nav",style:{overflow:"scroll"}},n.names.map((e,n)=>XR.createElement(tD,{key:`rule-${n}`,button:!0,onClick:()=>(e=>{t(e,!0),s.remove(),document.body.removeEventListener("click",c)})(e)},XR.createElement("div",{style:{marginRight:20}},e),XR.createElement("div",{dangerouslySetInnerHTML:{__html:p(e)}})))));QR.render(h,s,()=>{const t=nD([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)}})},iD=xd.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",Fu(e),0],addCommands(){return{setCSSClass:e=>({commands:t})=>t.setMark(this.name,{class:e}),unsetCSSClass:()=>({commands:e})=>e.unsetMark(this.name),openCSSClassDialog:()=>({editor:e})=>{rD({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()}})}}}}),oD=Wv.extend({content:"(div | paragraph | heading | bulletList | orderedList | blockquote | codeBlock | horizontalRule | image | imageUploadNode)+"}),sD=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},aD=e,{styled:lD}=r,cD=lD("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"})),uD=()=>aD.createElement(cD,null,"+ Response Area"),dD={characters:[["á","é","í","ó","ú"],["Á","É","Í","Ó","Ú"],["—","«","»","ñ","ü"],["-","¿","¡","Ñ","Ü"]]},pD={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:"—"}]]},hD=e,{useState:fD}=e,mD=a,{List:gD}=n,{ListItem:yD}=n;const vD=()=>hD.createElement("svg",{width:"20",height:"20",viewBox:"0 0 66 66",fill:"none",xmlns:"http://www.w3.org/2000/svg"},hD.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"})),bD=()=>hD.createElement("svg",{width:"20",height:"20",viewBox:"0 0 66 66",fill:"none",xmlns:"http://www.w3.org/2000/svg"},hD.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"})),xD=()=>hD.createElement("svg",{width:"20",height:"20",viewBox:"0 0 66 66",fill:"none",xmlns:"http://www.w3.org/2000/svg"},hD.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"})),wD=()=>hD.createElement("svg",{width:"20",height:"20",viewBox:"0 0 66 66",fill:"none",xmlns:"http://www.w3.org/2000/svg"},hD.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 ED=({editor:e,onChange:t})=>{const[n,r]=fD(!1);let i;switch(!0){case e.isActive({textAlign:"right"}):i=hD.createElement(bD,null);break;case e.isActive({textAlign:"center"}):i=hD.createElement(xD,null);break;case e.isActive({textAlign:"justify"}):i=hD.createElement(wD,null);break;default:i=hD.createElement(vD,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 hD.createElement("div",null,hD.createElement("div",{style:{display:"flex",alignItems:"center"},onClick:e=>{e.preventDefault(),e.stopPropagation(),r(!n)}},i,hD.createElement("span",{style:{marginLeft:"5px",fontSize:"8px"}},"▼")),hD.createElement(mD,{in:n,timeout:"auto",unmountOnExit:!0,style:{position:"absolute"}},hD.createElement(gD,{component:"div",disablePadding:!0,style:{background:"#fff",display:"flex",flexDirection:"row",padding:0}},hD.createElement(yD,{button:!0,type:"submit",value:"left","aria-label":"Align text left",onClick:o},hD.createElement(vD,null)),hD.createElement(yD,{button:!0,type:"submit",value:"center","aria-label":"Align text center",onClick:o},hD.createElement(xD,null)),hD.createElement(yD,{button:!0,type:"submit",value:"right","aria-label":"Align text right",onClick:o},hD.createElement(bD,null)),hD.createElement(yD,{button:!0,type:"submit",value:"justify","aria-label":"Justify text",onClick:o},hD.createElement(wD,null)))))};const MD=e,{styled:SD}=r,CD=SD("div")(({theme:e})=>({fontFamily:"Cerebri Sans, Arial, sans-serif",fontSize:e.typography.fontSize,fontWeight:"bold",lineHeight:"14px",position:"relative",whiteSpace:"nowrap"})),ND=()=>MD.createElement(CD,null,"CSS"),AD=e,{styled:kD}=r,TD=kD("path")({fill:"grey","&:hover":{fill:"black"}}),OD=e=>t=>AD.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",version:"1.1",width:"24",height:"24",viewBox:"0 0 24 24"},AD.createElement(e,{...t})),_D=OD(e=>AD.createElement(TD,{...e,d:"M22,10A2,2 0 0,1 20,12H4A2,2 0 0,1 2,10V3H4V5H8V3H10V5H14V3H16V5H20V3H22V10M4,10H8V7H4V10M10,10H14V7H10V10M20,10V7H16V10H20M11,14H13V17H16V19H13V22H11V19H8V17H11V14Z"})),RD=OD(e=>AD.createElement(TD,{...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"})),DD=OD(e=>AD.createElement(TD,{...e,d:"M11,2A2,2 0 0,1 13,4V20A2,2 0 0,1 11,22H2V2H11M4,10V14H11V10H4M4,16V20H11V16H4M4,4V8H11V4H4M15,11H18V8H20V11H23V13H20V16H18V13H15V11Z"})),ID=OD(e=>AD.createElement(TD,{...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"})),LD=OD(e=>AD.createElement(TD,{...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"})),BD=e,{styled:zD}=r,{Popper:PD}=n,{Typography:FD}=n,jD=zD(PD)({background:"#fff",padding:"10px",pointerEvents:"none",zIndex:99999}),$D=zD(FD)({fontSize:50,textAlign:"center"}),HD=({children:e,...t})=>BD.createElement(jD,{id:"mouse-over-popover",open:!0,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},disableRestoreFocus:!0,disableAutoFocus:!0,...t},BD.createElement($D,null,e)),UD=e,{useEffect:qD}=e,{useMemo:VD}=e,{useRef:WD}=e,{useState:KD}=e,GD=t,JD=i,{PureToolbar:YD}=y;const ZD=({letter:e})=>UD.createElement("div",{style:{fontSize:"24px",lineHeight:"24px"}},e);function XD({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=WD(null),[i,o]=KD({top:0,left:0}),[s,a]=KD(null),l=VD(()=>{if(!t)return dD;switch(!0){case"spanish"===t.language:return dD;case"special"===t.language:return pD;default:return t}},[t]),c=VD(()=>l.characters.reduce((e,t)=>(t.length>=e.columns&&(e.columns=t.length),e),{rows:l.characters.length,columns:0}),[l]),u=()=>a(null);qD(()=>()=>{u()},[]),qD(()=>{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 UD.createElement(UD.Fragment,null,GD.createPortal(UD.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}},UD.createElement("div",null,UD.createElement(YD,{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:kt(e,"name")||e,write:kt(e,"write")||e,label:kt(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&&GD.createPortal(UD.createElement(HD,{onClose:u,anchorEl:s.anchorEl},UD.createElement("div",null,s.el.label),UD.createElement("div",{style:{fontSize:20,lineHeight:"20px"}},s.el.description),UD.createElement("div",{style:{fontSize:20,lineHeight:"20px"}},s.el.unicode)),document.body))}ZD.propTypes={letter:JD.string},XD.propTypes={editor:JD.object,opts:JD.object,onClose:JD.func.isRequired};const QD=e,{useMemo:eI}=e,{useState:tI}=e,nI=l,{styled:rI}=r,{useTheme:iI}=r,{FormatBold:oI}=o,{FormatItalic:sI}=o,{FormatStrikethrough:aI}=o,{Code:lI}=o,{GridOn:cI}=o,{FormatListBulleted:uI}=o,{FormatListNumbered:dI}=o,{FormatUnderlined:pI}=o,{Functions:hI}=o,{Image:fI}=o,{Redo:mI}=o,{Undo:gI}=o,{FormatQuote:yI}=o,{Theaters:vI}=o,{VolumeUp:bI}=o,{BorderAll:xI}=o,{Delete:wI}=o;function EI(e,t){return null!=e?e:t()}function MI(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 SI=()=>QD.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"none"},QD.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"})),CI=()=>QD.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"none"},QD.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"})),NI=()=>QD.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"}},QD.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 AI({editor:e,classes:t,activePlugins:n,toolbarOpts:r,responseAreaProps:i,onChange:o,autoWidthToolbar:s}){const[a,l]=tI(!1),c=EI(r,()=>({})),u=Ph({editor:e,selector:e=>{const{selection:t}=MI([e,"access",e=>e.editor,"optionalAccess",e=>e.state])||{};let n;t instanceof Qo&&(n=t.node);return{currentNode:n,hideDefaultToolbar:MI([e,"access",e=>e.editor,"optionalAccess",e=>e.isActive,"call",e=>e("math")])||MI([e,"access",e=>e.editor,"optionalAccess",e=>e.isActive,"call",e=>e("explicit_constructed_response")])||MI([e,"access",e=>e.editor,"optionalAccess",e=>e.isActive,"call",e=>e("imageUploadNode")])||MI([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:MI([e,"access",e=>e.editor,"optionalAccess",e=>e.isFocused]),isBold:EI(e.editor.isActive("bold"),()=>!1),canBold:EI(e.editor.can().chain().toggleBold().run(),()=>!1),isTable:EI(e.editor.isActive("table"),()=>!1),tableHasBorder:EI("1"===MI([e,"access",e=>e.editor,"access",e=>e.getAttributes,"call",e=>e("table"),"optionalAccess",e=>e.border]),()=>!1),canTable:EI(e.editor.can().chain().insertTable().run(),()=>!1),isItalic:EI(e.editor.isActive("italic"),()=>!1),canItalic:EI(e.editor.can().chain().toggleItalic().run(),()=>!1),isStrike:EI(e.editor.isActive("strike"),()=>!1),canStrike:EI(e.editor.can().chain().toggleStrike().run(),()=>!1),isCode:EI(e.editor.isActive("code"),()=>!1),canCode:EI(e.editor.can().chain().toggleCode().run(),()=>!1),canClearMarks:EI(e.editor.can().chain().unsetAllMarks().run(),()=>!1),isUnderline:EI(e.editor.isActive("underline"),()=>!1),isSubScript:EI(e.editor.isActive("subscript"),()=>!1),isSuperScript:EI(e.editor.isActive("superscript"),()=>!1),isParagraph:EI(e.editor.isActive("paragraph"),()=>!1),isHeading1:EI(e.editor.isActive("heading",{level:1}),()=>!1),isHeading2:EI(e.editor.isActive("heading",{level:2}),()=>!1),isHeading3:EI(e.editor.isActive("heading",{level:3}),()=>!1),isHeading4:EI(e.editor.isActive("heading",{level:4}),()=>!1),isHeading5:EI(e.editor.isActive("heading",{level:5}),()=>!1),isHeading6:EI(e.editor.isActive("heading",{level:6}),()=>!1),isBulletList:EI(e.editor.isActive("bulletList"),()=>!1),isOrderedList:EI(e.editor.isActive("orderedList"),()=>!1),isCodeBlock:EI(e.editor.isActive("codeBlock"),()=>!1),isBlockquote:EI(e.editor.isActive("blockquote"),()=>!1),canUndo:EI(e.editor.can().chain().undo().run(),()=>!1),canRedo:EI(e.editor.can().chain().redo().run(),()=>!1)}}}),d=!!s,p=nI(t.toolbar,tS,{[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=eI(()=>[{icon:QD.createElement(cI,null),onClick:e=>e.chain().focus().insertTable({rows:2,cols:2,withHeaderRow:!1}).run(),hidden:e=>!MI([n,"optionalAccess",e=>e.includes,"call",e=>e("table")])||e.isTable,isActive:e=>e.isTable,isDisabled:e=>!e.canTable},{icon:QD.createElement(_D,null),onClick:e=>e.chain().focus().addRowAfter().run(),hidden:e=>!(e.isTable&&!e.hasTextSelectionInTable),isActive:e=>e.isTable,isDisabled:e=>!e.canTable},{icon:QD.createElement(RD,null),onClick:e=>e.chain().focus().deleteRow().run(),hidden:e=>!(e.isTable&&!e.hasTextSelectionInTable),isActive:e=>e.isTable,isDisabled:e=>!e.canTable},{icon:QD.createElement(DD,null),onClick:e=>e.chain().focus().addColumnAfter().run(),hidden:e=>!(e.isTable&&!e.hasTextSelectionInTable),isActive:e=>e.isTable,isDisabled:e=>!e.canTable},{icon:QD.createElement(ID,null),onClick:e=>e.chain().focus().deleteColumn().run(),hidden:e=>!(e.isTable&&!e.hasTextSelectionInTable),isActive:e=>e.isTable,isDisabled:e=>!e.canTable},{icon:QD.createElement(LD,null),onClick:e=>e.chain().focus().deleteTable().run(),hidden:e=>!(e.isTable&&!e.hasTextSelectionInTable),isActive:e=>e.isTable,isDisabled:e=>!e.canTable},{icon:QD.createElement(xI,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:QD.createElement(oI,null),onClick:e=>e.chain().focus().toggleBold().run(),hidden:()=>!MI([n,"optionalAccess",e=>e.includes,"call",e=>e("bold")]),isActive:e=>e.isBold,isDisabled:e=>!e.canBold},{icon:QD.createElement(sI,null),onClick:e=>e.chain().focus().toggleItalic().run(),hidden:()=>!MI([n,"optionalAccess",e=>e.includes,"call",e=>e("italic")]),isActive:e=>e.isItalic,isDisabled:e=>!e.canItalic},{icon:QD.createElement(aI,null),onClick:e=>e.chain().focus().toggleStrike().run(),hidden:()=>!MI([n,"optionalAccess",e=>e.includes,"call",e=>e("strikethrough")]),isActive:e=>e.isStrike,isDisabled:e=>!e.canStrike},{icon:QD.createElement(lI,null),onClick:e=>e.chain().focus().toggleCode().run(),hidden:()=>!MI([n,"optionalAccess",e=>e.includes,"call",e=>e("code")]),isActive:e=>e.isCode,isDisabled:e=>!e.canCode},{icon:QD.createElement(pI,null),onClick:e=>e.chain().focus().toggleUnderline().run(),hidden:()=>!MI([n,"optionalAccess",e=>e.includes,"call",e=>e("underline")]),isActive:e=>e.isUnderline},{icon:QD.createElement(CI,null),onClick:e=>e.chain().focus().toggleSubscript().run(),hidden:()=>!MI([n,"optionalAccess",e=>e.includes,"call",e=>e("subscript")]),isActive:e=>e.isSubScript},{icon:QD.createElement(SI,null),onClick:e=>e.chain().focus().toggleSuperscript().run(),hidden:()=>!MI([n,"optionalAccess",e=>e.includes,"call",e=>e("superscript")]),isActive:e=>e.isSuperScript},{icon:QD.createElement(fI,null),hidden:()=>!MI([n,"optionalAccess",e=>e.includes,"call",e=>e("image")]),onClick:e=>e.chain().focus().setImageUploadNode().run()},{icon:QD.createElement(vI,null),hidden:()=>!MI([n,"optionalAccess",e=>e.includes,"call",e=>e("video")]),onClick:e=>e.chain().focus().insertMedia({type:"video"}).run()},{icon:QD.createElement(bI,null),hidden:()=>!MI([n,"optionalAccess",e=>e.includes,"call",e=>e("audio")]),onClick:e=>e.chain().focus().insertMedia({type:"audio",tag:"audio"}).run()},{icon:QD.createElement(ND,null),hidden:()=>!MI([n,"optionalAccess",e=>e.includes,"call",e=>e("css")]),onClick:e=>e.commands.openCSSClassDialog()},{icon:QD.createElement(yI,null),hidden:()=>!MI([n,"optionalAccess",e=>e.includes,"call",e=>e("blockquote")]),onClick:e=>e.chain().focus().toggleBlockquote().run(),isActive:e=>e.isBlockquote},{icon:QD.createElement(NI,null),hidden:()=>!MI([n,"optionalAccess",e=>e.includes,"call",e=>e("h3")]),onClick:e=>e.chain().focus().toggleHeading({level:3}).run(),isActive:e=>e.isHeading3},{icon:QD.createElement(hI,null),hidden:()=>!MI([n,"optionalAccess",e=>e.includes,"call",e=>e("math")]),onClick:e=>e.chain().focus().insertMath("").run()},{icon:QD.createElement(ZD,{letter:"ñ"}),hidden:()=>!MI([n,"optionalAccess",e=>e.includes,"call",e=>e("languageCharacters")]),onClick:()=>l(dD)},{icon:QD.createElement(ZD,{letter:"€"}),hidden:()=>2!==MI([n,"optionalAccess",e=>e.filter,"call",e=>e(e=>"languageCharacters"===e),"access",e=>e.length]),onClick:()=>l(pD)},{icon:QD.createElement(ED,{editor:e}),hidden:()=>!MI([n,"optionalAccess",e=>e.includes,"call",e=>e("text-align")]),onClick:()=>{}},{icon:QD.createElement(uI,null),hidden:()=>!MI([n,"optionalAccess",e=>e.includes,"call",e=>e("bulleted-list")]),onClick:e=>e.chain().focus().toggleBulletList().run(),isActive:e=>e.isBulletList},{icon:QD.createElement(dI,null),hidden:()=>!MI([n,"optionalAccess",e=>e.includes,"call",e=>e("numbered-list")]),onClick:e=>e.chain().focus().toggleOrderedList().run(),isActive:e=>e.isOrderedList},{icon:QD.createElement(gI,null),hidden:()=>!MI([n,"optionalAccess",e=>e.includes,"call",e=>e("undo")]),onClick:e=>e.chain().focus().undo().run(),isDisabled:e=>!e.canUndo},{icon:QD.createElement(mI,null),hidden:()=>!MI([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"===MI([u,"access",e=>e.currentNode,"optionalAccess",e=>e.type,"optionalAccess",e=>e.name]);return QD.createElement("div",{className:p,style:{...h},onMouseDown:e=>{e.preventDefault()}},m&&QD.createElement("div",{className:t.defaultToolbar,tabIndex:"1"},QD.createElement("div",{className:t.buttonsContainer},QD.createElement("button",{type:"button",className:t.button,onClick:t=>{t.preventDefault(),e.chain().focus().deleteSelection().run(),MI([o,"optionalCall",t=>t(e.getHTML())])},"aria-label":"Delete response area"},QD.createElement(wI,null)))),!u.hideDefaultToolbar&&QD.createElement("div",{className:t.defaultToolbar,tabIndex:"1"},QD.createElement("div",{className:t.buttonsContainer},f.filter(e=>!MI([e,"access",e=>e.hidden,"optionalCall",e=>e(u)])).map((n,r)=>{const i=MI([n,"access",e=>e.isDisabled,"optionalCall",e=>e(u)]),o=MI([n,"access",e=>e.isActive,"optionalCall",e=>e(u)]);return QD.createElement("button",{key:r,disabled:i,onClick:t=>{t.preventDefault(),n.onClick(e)},className:nI(t.button,{[t.active]:o})},n.icon)})),MI([n,"optionalAccess",e=>e.includes,"call",e=>e("responseArea")])&&QD.createElement("button",{onClick:()=>{e.chain().focus().insertResponseArea(i.type).run()},className:t.button},QD.createElement(uD,null)),c.showDone&&QD.createElement(cS,{onClick:()=>{MI([o,"optionalCall",t=>t(e.getHTML())]),e.commands.blur()}})),a&&QD.createElement(XD,{editor:e,opts:{...a,renderPopOver:(e,t)=>console.log("Show popover",t),closePopOver:()=>console.log("Close popover")},onClose:()=>l(!1)}))}const kI=e=>{iI();return QD.createElement(TI,null,QD.createElement(AI,{...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"}}))},TI=rI("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"}})),OI=e,{useEffect:_I}=e,{useMemo:RI}=e,{useState:DI}=e,{useRef:II}=e,{styled:LI}=r,BI=LI("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:Vk(),backgroundColor:Wk()},'& 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`}})),zI=LI("div",{shouldForwardProp:e=>!["disableScrollbar","highlightShape"].includes(e)})(({theme:e,disableScrollbar:t,highlightShape:n})=>({position:"relative",padding:"0px",overflowY:"auto",color:Vk(),backgroundColor:n?e.palette.action.selected:Wk(),...t&&{"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none","-ms-overflow-style":"none"}})),PI=LI("div",{shouldForwardProp:e=>"noPadding"!==e})(({noPadding:e})=>({padding:e?0:"10px 8px"}));function FI(e){const[t,n]=DI(null),r=II(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(()=>{i&&r.current&&(i._tiptapContainerEl=r.current)},[i,r.current]),_I(()=>{i&&d&&Promise.resolve().then(()=>{i.commands.focus("end")})},[i,d]),_I(()=>{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 x=RI(()=>({width:sD(t||h),minWidth:sD(p),maxWidth:sD(f),height:sD(g),minHeight:sD(m),maxHeight:sD(y)}),[t,p,h,f,m,g,y]);return OI.createElement(BI,{noBorder:c&&c.noBorder,error:c&&c.error,className:e.className,style:{width:x.width,minWidth:x.minWidth,maxWidth:x.maxWidth},ref:r},OI.createElement(zI,{disableScrollbar:a,highlightShape:v},OI.createElement(PI,{noPadding:c&&c.noPadding},s)),i&&OI.createElement(kI,{editor:i,responseAreaProps:u,toolbarOpts:c,activePlugins:l,onChange:e.onChange,autoWidthToolbar:e.autoWidthToolbar}))}const jI=s("@pie-lib:editable-html:plugins"),$I={"text-align":"textAlign","bulleted-list":"ul_list","numbered-list":"ol_list"},HI=["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)),UI=(e,t,n)=>{jI("[buildPlugins] opts: ",n),e=e||HI;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(_e(e)&&(D(e)||"string"==typeof e||"function"==typeof e.splice||He(e)||Ze(e)||Pe(e)))return!e.length;var t=yn(e);if("[object Map]"==t||"[object Set]"==t)return!e.size;if(De(e))return!rt(e).length;for(var n in e)if(ur.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)])},qI=e,{useCallback:VI}=e,{useEffect:WI}=e,{useMemo:KI}=e,{useState:GI}=e,{styled:JI}=r;function YI(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 ZI={position:"bottom",alignment:"left",alwaysVisible:!1,showDone:!0,doneOn:"blur"},XI=["bold","italic","underline","strikethrough","code","bulleted-list","numbered-list","image","math","languageCharacters","text-align","table","video","audio","responseArea","superscript","subscript","css","h3","undo","redo"],QI={"--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)"},eL=e=>{const{showParagraphs:t,separateParagraphs:n}=e.pluginProps||{},[r,i]=GI([]),[o,s]=GI(!1),{toolbarOpts:a}=e,l=VI(e=>{i(t=>{const n=t.filter(t=>t.pos!==e);return 0===n.length&&s(!1),n})},[i]),c={...ZI,...a},u=KI(()=>{let{customPlugins:t,...n}=e.pluginProps||{};t=t||[];const r=YI([e.activePlugins||XI,"optionalAccess",e=>e.filter,"call",e=>e(e=>{const t=n[$I[e]||e]||{};return!t||!t.disabled})]);return UI(r,0,{math:{},textAlign:e.textAlign,html:{},extraCSSRules:e.extraCSSRules||{},image:{...e.imageSupport},toolbar:{},table:{},responseArea:{type:YI([e,"access",e=>e.responseAreaProps,"optionalAccess",e=>e.type])},languageCharacters:e.languageCharactersProps,keyPadCharacterRef:{},setKeypadInteraction:{},media:{}})},[e]),d=[dx.configure({types:["heading","paragraph","div","h1","h2","h3","h4","h5","h6","td","th"],alignments:["left","right","center","justify"]}),lx,Gb.configure({limit:e.charactersLimit||1e6}),tx.configure({trailingNode:{node:"paragraph",notAfter:["paragraph","div"]}}),oD,XM,QM,eS,mx.configure({placeholder:e.placeholder,showOnlyWhenEditable:!0,showOnlyCurrent:!1,includeChildren:!0}),jw,$M,ZM,YM,VO.configure(e.responseAreaProps),WO.configure(e.responseAreaProps),GO.configure(e.responseAreaProps),JO.configure(e.responseAreaProps),KO.configure(e.responseAreaProps),l_.configure({toolbarOpts:c,math:YI([e,"access",e=>e.pluginProps,"optionalAccess",e=>e.math])||{}}),ux,cx,fx,sR.configure({toolbarOpts:c,imageHandling:{disableImageAlignmentButtons:e.disableImageAlignmentButtons,onDone:t=>YI([e,"access",e=>e.onDone,"optionalCall",e=>e(t.getHTML())]),onDelete:e.imageSupport&&e.imageSupport.delete&&(t=>{const{src:n}=t.attrs;e.imageSupport.delete(n,e=>{l(t.pos)})}),insertImageRequested:e.imageSupport&&((t,n,r)=>{const[s,a]=n,c=n=>{let r;o&&n&&(r=e.onChange),l(a),YI([r,"optionalCall",e=>e(t.getHTML())])};t._insertingImage=!0,i(e=>[...e,s]),(()=>{const n=r(c),i=rr(()=>{const e=()=>window.removeEventListener("focus",i);t._insertingImage?(l(a),t._insertingImage=!1,e()):e()},500);window.addEventListener("focus",i),e.imageSupport.add(n)})()}),maxImageWidth:e.maxImageWidth,maxImageHeight:e.maxImageHeight},limit:3}),JR.configure({uploadSoundSupport:e.uploadSoundSupport}),iD.configure({extraCSSRules:e.extraCSSRules})],p=function(e={},t=[]){const n=yh(e);n.current=e;const[r]=vh(()=>new $h(n)),i=Nr.exports.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return mh(i),gh(r.onRender(t)),Ph({editor:i,selector:({transactionNumber:t})=>!1===e.shouldRerenderOnTransaction||void 0===e.shouldRerenderOnTransaction?null:e.immediatelyRender&&0===t?0:t+1}),i}({extensions:d,immediatelyRender:!1,editorProps:{handleKeyDown:(t,n)=>!!e.onKeyDown&&e.onKeyDown(n)},editable:!e.disabled,content:gx(e.markup),onUpdate:({editor:t,transaction:n})=>{n.isDone&&YI([e,"access",e=>e.onChange,"optionalCall",e=>e(t.getHTML())])},onBlur:rr(({editor:t})=>{t._insertingImage||t._toolbarOpened||t.isActive("inline_dropdown")||t.isActive("explicit_constructed_response")||(e.markup!==t.getHTML()&&YI([e,"access",e=>e.onChange,"optionalCall",e=>e(t.getHTML())]),"blur"===c.doneOn&&YI([e,"access",e=>e.onDone,"optionalCall",e=>e(t.getHTML())]))},200)},[e.charactersLimit]);WI(()=>{e.editorRef&&e.editorRef(p)},[e.editorRef,p]),WI(()=>{YI([p,"optionalAccess",e=>e.setEditable,"call",t=>t(!e.disabled)])},[e.disabled,p]),WI(()=>{if(!p)return;const t=gx(e.markup);t!==p.getHTML()&&p.commands.setContent(t,!1)},[e.markup,p]),WI(()=>{Object.entries(QI).forEach(([e,t])=>{document.documentElement.style.setProperty(e,t)})},[]);const h=Ph({editor:p,selector:e=>({isFocused:YI([e,"access",e=>e.editor,"optionalAccess",e=>e.isFocused])})}),f=KI(()=>{const{minWidth:t,width:n,maxWidth:r,minHeight:i,height:o,maxHeight:s}=e;return{width:sD(n),minWidth:sD(t),maxWidth:sD(r),height:sD(o),minHeight:sD(i),maxHeight:sD(s)}},[e]);return qI.createElement(FI,{...{...e,activePlugins:u,toolbarOpts:c},editorState:h,editor:p},p&&qI.createElement(tL,{style:{minHeight:f.minHeight,height:f.height,maxHeight:f.maxHeight},showParagraph:t&&!t.disabled,separateParagraph:n&&!n.disabled,editor:p}))},tL=JI(Lh,{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"}}}})),nL=(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=nL(e,t,r),e=e.nextSibling;return r},rL=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]},iL=e=>{const t=document.createElement("SPAN");return e.surroundContents(t),t},oL=e=>{if(e.startContainer===e.endContainer)return[iL(e)];const[t]=rL(e),n=document.createRange();n.selectNodeContents(e.startContainer),n.setStart(e.startContainer,e.startOffset);const r=iL(n),i=document.createRange();i.selectNode(e.endContainer),i.setEnd(e.endContainer,e.endOffset);const o=iL(i);return[r,...t.map(e=>{const t=document.createElement("SPAN");return e.parentNode.insertBefore(t,e),t.appendChild(e),t}),o]},sL=(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()},aL=()=>{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()},lL=e=>e.length>=20||-1!==e.search(/\n|\r|\r\n/),cL=e=>Array.from(document.querySelectorAll(`[data-id='${e}']`)),uL=e=>document.querySelector(`[data-ann-id='${e}']`),dL=e,pL=i,{Popover:hL}=n,{TextField:fL}=n,{styled:mL}=r,gL=mL(hL)(({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"}}}})),yL=mL("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"}})),vL=mL("div")(({theme:e})=>({display:"flex",flexWrap:"wrap",borderTop:`2px solid ${e.palette.grey[100]}`})),bL=mL("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 xL extends dL.Component{static __initStatic(){this.propTypes={anchorEl:pL.object,open:pL.bool,offset:pL.number,value:pL.string,type:pL.string,onClose:pL.func,onDelete:pL.func,onSave:pL.func,onTypeChange:pL.func}}constructor(e){super(e),xL.prototype.__init.call(this),xL.prototype.__init2.call(this),xL.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 dL.createElement(gL,{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"}},dL.createElement(yL,{annotationType:i},dL.createElement(fL,{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}}),dL.createElement(vL,null,dL.createElement(bL,{onClick:n},"Delete"),dL.createElement(bL,{variant:"typeChange",annotationType:i,onClick:this.handleTypeChange},"negative"===i?"Green":"Pink"),dL.createElement(bL,{onClick:this.handleSave},"Save"))))}}xL.__initStatic();const wL=e,EL=i,{styled:ML}=r,{Popover:SL}=n,CL=ML(SL)({"& .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"}}}),NL=ML("div")(({theme:e})=>({width:"300px",overflow:"hidden",borderRadius:"4px",backgroundColor:e.palette.common.white,border:`2px solid ${e.palette.grey[100]}`})),AL=ML("div")({display:"flex",flexWrap:"wrap"}),kL=ML("div")(({theme:e})=>({display:"flex",flexWrap:"wrap",borderTop:`2px solid ${e.palette.grey[100]}`})),TL=ML("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 OL extends wL.Component{static __initStatic(){this.propTypes={anchorEl:EL.object,open:EL.bool,annotations:EL.array,isNewAnnotation:EL.bool,onClose:EL.func,onDelete:EL.func,onEdit:EL.func,onWrite:EL.func,onAnnotate:EL.func}}render(){const{anchorEl:e,annotations:t,isNewAnnotation:n,onAnnotate:r,onClose:i,onEdit:o,onDelete:s,onWrite:a,open:l}=this.props;return wL.createElement(CL,{anchorEl:e,open:l,onClose:i,elevation:5,transitionDuration:{enter:225,exit:195},anchorOrigin:{vertical:"top",horizontal:"center"},transformOrigin:{vertical:"bottom",horizontal:"center"}},wL.createElement(NL,null,wL.createElement(AL,null,t.map((e,t)=>wL.createElement(TL,{key:`annotation-${t}`,variant:e.type,onClick:()=>r(e)},e.label))),wL.createElement(kL,null,wL.createElement(TL,{onClick:i},"Cancel"),wL.createElement(TL,{style:{pointerEvents:"none"}}),n?wL.createElement(wL.Fragment,null,wL.createElement(TL,{variant:"positive",onClick:()=>a("positive")},"Write"),wL.createElement(TL,{variant:"negative",onClick:()=>a("negative")},"Write")):wL.createElement(wL.Fragment,null,wL.createElement(TL,{onClick:s},"Delete"),wL.createElement(TL,{onClick:o},"Edit")))))}}OL.__initStatic();const _L=i,{DialogContentText:RL}=n,{DialogTitle:DL}=n,{styled:IL}=r;IL(DL)(()=>({fontSize:"max(1.25rem, 18px)"})),IL(RL)(()=>({fontSize:"max(1rem, 14px)"})),_L.oneOfType([_L.string,_L.object]),_L.string,_L.func,_L.func,_L.bool,_L.string,_L.string,_L.bool,_L.bool,_L.bool;const{FormControlLabel:LL}=n,{Radio:BL}=n,zL=e,PL=i,{styled:FL}=r,jL=FL(LL)(()=>({"& .MuiFormControlLabel-label":{left:"-5px",position:"relative"}})),$L=FL(BL)(()=>({color:`${Kk()} !important`})),HL=({label:e,value:t,checked:n,onChange:r})=>zL.createElement(jL,{value:t,control:zL.createElement($L,{checked:n,onChange:r}),label:e});HL.propTypes={label:PL.string,value:PL.string,checked:PL.bool,onChange:PL.func};const UL=i,qL=e,{styled:VL}=r,WL=VL("div")(()=>({display:"flex",alignItems:"center"})),KL=VL("div")(()=>({display:"flex",alignItems:"center"})),GL=VL(HL)(({theme:e})=>({"& .MuiFormControlLabel-label":{fontSize:e.typography.fontSize-2}})),JL=e=>{const{feedbackLabels:t,value:n,className:r,onChange:i,keys:o}=e;return qL.createElement(WL,{className:r},o.map(e=>qL.createElement(KL,{key:e},qL.createElement(GL,{value:e,checked:n===e,onChange:e=>i(e.currentTarget.value),label:t[e]}))))};JL.propTypes={className:UL.string,feedbackLabels:UL.object.isRequired,value:UL.string.isRequired,keys:UL.arrayOf(UL.string),onChange:UL.func};const YL=i,ZL=e,{styled:XL}=r;let QL,eB;"undefined"!=typeof window&&(QL=require("@pie-lib/editable-html-tip-tap").default,eB=XL(QL)(({theme:e})=>({fontFamily:e.typography.fontFamily})));const tB={default:"Simple Feedback",none:"No Feedback",custom:"Customized Feedback"},nB=XL("div")(({theme:e})=>({marginBottom:e.spacing(1)})),rB=XL(VT)(()=>({paddingBottom:0})),iB=XL("div")(({theme:e})=>({marginTop:"0px",background:e.palette.grey[300],padding:0,marginBottom:e.spacing(2),borderRadius:"4px"})),oB=XL("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"})),sB=XL(JL)(({theme:e})=>({paddingTop:e.spacing(1)})),aB={type:YL.oneOf(["default","custom","none"]),default:YL.string,custom:YL.string};class lB extends ZL.Component{constructor(...e){super(...e),lB.prototype.__init.call(this),lB.prototype.__init2.call(this)}static __initStatic(){this.propTypes={keys:YL.arrayOf(YL.string),label:YL.string.isRequired,feedback:YL.shape(aB).isRequired,onChange:YL.func.isRequired,toolbarOpts:YL.object,mathMlOptions:YL.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(tB);return ZL.createElement(nB,null,ZL.createElement(rB,{label:t,extraClasses:{label:{transform:"translateY(-20%)"}}},ZL.createElement(sB,{keys:o,label:t,value:n.type,onChange:this.changeType,feedbackLabels:tB})),"custom"===n.type&&ZL.createElement(iB,null,ZL.createElement(eB,{onChange:this.changeCustom,markup:n.custom||"",toolbarOpts:r,languageCharactersProps:[{language:"spanish"},{language:"special"}],mathMlOptions:i})),"default"===n.type&&ZL.createElement(oB,null," ",n.default))}}lB.__initStatic();const cB=i,uB=e,{styled:dB}=r,{Accordion:pB}=n,{AccordionSummary:hB}=n,{AccordionDetails:fB}=n,{Typography:mB}=n,{ExpandMore:gB}=o,yB=dB("div")(()=>({display:"flex",flex:1,flexDirection:"column"})),vB=dB(fB)(()=>({paddingTop:0,paddingBottom:0}));class bB extends uB.Component{constructor(...e){super(...e),bB.prototype.__init.call(this),bB.prototype.__init2.call(this),bB.prototype.__init3.call(this)}static __initStatic(){this.propTypes={allowPartial:cB.bool,className:cB.string,feedback:cB.shape({correct:cB.shape(aB),incorrect:cB.shape(aB),partial:cB.shape(aB)}),onChange:cB.func.isRequired,toolbarOpts:cB.object}}static __initStatic2(){var e;this.defaultProps={allowPartial:!0,feedback:mr({},{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 uB.createElement("div",{className:e},uB.createElement(pB,{slotProps:{transition:{timeout:{enter:225,exit:195}}}},uB.createElement(hB,{expandIcon:uB.createElement(gB,null)},uB.createElement(mB,null,"Feedback")),uB.createElement(vB,null,uB.createElement(yB,null,uB.createElement(lB,{label:"If correct, show",feedback:n.correct,onChange:this.onCorrectChange,toolbarOpts:r}),t&&uB.createElement(lB,{label:"If partially correct, show",feedback:n.partial,onChange:this.onPartialChange,toolbarOpts:r}),uB.createElement(lB,{label:"If incorrect, show",feedback:n.incorrect,onChange:this.onIncorrectChange,toolbarOpts:r})))))}}bB.__initStatic(),bB.__initStatic2();const{Checkbox:xB}=n,{Radio:wB}=n,{Switch:EB}=n,MB=i,SB=e,{styled:CB}=r,NB={className:MB.string,label:MB.string,checked:MB.bool,onChange:MB.func,disabled:MB.bool,error:MB.string};CB(EB)(()=>({justifyContent:"inherit",transform:"translate(-20%, 20%)"}));const AB=CB(xB)(({theme:e,error:t})=>({transform:"translate(-25%, 20%)",color:`${Kk()} !important`,...t&&{color:`${e.palette.error.main} !important`}})),kB=({className:e,label:t,checked:n,onChange:r,disabled:i,error:o})=>SB.createElement(VT,{className:e,label:t},SB.createElement(AB,{disabled:i,checked:n,onChange:r,"aria-label":t,error:o}));kB.propTypes={...NB};const TB=CB(wB)(({theme:e,error:t})=>({transform:"translate(-20%, 20%)",color:`${Kk()} !important`,...t&&{color:`${e.palette.error.main} !important`}})),OB=({className:e,label:t,checked:n,onChange:r,disabled:i,error:o})=>SB.createElement(VT,{className:e,label:t},SB.createElement(TB,{disabled:i,checked:n,onChange:r,"aria-label":t,error:o}));OB.propTypes={...NB};const{Input:_B}=n,{InputLabel:RB}=n,{Select:DB}=n,{MenuItem:IB}=n,{FormControl:LB}=n,BB=i,zB=e,{styled:PB}=r,FB=s("pie-elements:config-ui:langs"),jB=PB("div")(()=>({flexDirection:"column",alignItems:"start",display:"flex",position:"relative",paddingTop:"0px",paddingRight:"0px"})),$B=PB(LB)(()=>({position:"initial"})),HB=PB(RB)(({theme:e})=>({paddingBottom:e.spacing(1)}));class UB extends zB.Component{static __initStatic(){this.propTypes={onChange:BB.func,langs:BB.array,selected:BB.string,label:BB.string,uid:BB.string}}constructor(e){super(e),UB.prototype.__init.call(this),this.uid=e.uid||(1e4*Math.random()).toFixed()}__init(){this.choose=e=>{FB("[choose] event: ",e),this.props.onChange&&this.props.onChange(e.target.value)}}render(){let{langs:e,selected:t,label:n}=this.props;return FB("[render] selected:",t),zB.createElement(jB,null,zB.createElement($B,null,zB.createElement(HB,{htmlFor:this.uid},n),zB.createElement(DB,{value:t,onChange:this.choose,input:zB.createElement(_B,{id:this.uid})},e.map((e,t)=>zB.createElement(IB,{key:t,value:e},e)))))}}UB.__initStatic(),PB("div")(()=>({display:"grid",gridAutoFlow:"column",gridAutoColumns:"1fr",gridGap:"8px"})),BB.array,BB.string.isRequired,BB.string.isRequired,BB.func.isRequired,BB.func.isRequired,BB.string;const qB=e,{Tabs:VB}=n,{Tab:WB}=n,KB=i,{styled:GB}=r,JB=GB(WB)(()=>({}));class YB extends qB.Component{static __initStatic(){this.propTypes={className:KB.string,contentClassName:KB.string,contentStyle:KB.object,children:KB.oneOfType([KB.arrayOf(KB.node),KB.node]).isRequired}}constructor(e){super(e),YB.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 qB.createElement("div",{className:n},qB.createElement(VB,{indicatorColor:"primary",value:e,onChange:this.handleChange},qB.Children.map(t,(e,t)=>e&&e.props.title?qB.createElement(JB,{key:t,label:e.props.title}):null)),qB.createElement("div",{className:r,style:i},t[e]))}}YB.__initStatic();const{FormControlLabel:ZB}=n,{Checkbox:XB}=n,QB=i,ez=e,{styled:tz}=r,nz=tz(ZB)(({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:m[700],fontSize:e.typography.fontSize-3}}})),rz=tz(XB)(({theme:e,mini:t,error:n})=>({color:`${Kk()} !important`,...t&&{margin:0,padding:0,width:e.spacing(3),height:e.spacing(3)},...n&&{color:`${e.palette.error.main} !important`}})),iz=({mini:e,checked:t,onChange:n,value:r,label:i,error:o})=>ez.createElement(nz,{mini:e,control:ez.createElement(rz,{checked:t,onChange:n,value:r,mini:e,error:o}),label:i});iz.propTypes={mini:QB.bool,checked:QB.bool.isRequired,onChange:QB.func.isRequired,value:QB.string,label:QB.string.isRequired,error:QB.bool},iz.defaultProps={value:"",mini:!1,error:!1};const oz=i,{Typography:sz}=n,{styled:az}=r;az("div")(({theme:e})=>({marginTop:e.spacing(2),marginBottom:e.spacing(2)})),az(sz)(({theme:e})=>({marginBottom:e.spacing(1)})),oz.string,oz.string,oz.node,oz.object;const{Dialog:lz}=n,{DialogTitle:cz}=n,{DialogContentText:uz}=n,{DialogContent:dz}=n,{DialogActions:pz}=n,{Button:hz}=n,{IconButton:fz}=n,mz=i,{Help:gz}=o,yz=e,{styled:vz}=r,bz=vz(fz)(({theme:e})=>({"&:hover":{color:e.palette.grey[300]}})),xz=({onClick:e})=>yz.createElement(bz,{onClick:e,size:"large"},yz.createElement(gz,null));xz.propTypes={onClick:mz.func};const wz=({open:e,onClose:t,children:n,title:r})=>yz.createElement(lz,{open:e,onClose:t},yz.createElement(cz,null,r),yz.createElement(dz,null,yz.createElement(uz,null,n)),yz.createElement(pz,null,yz.createElement(hz,{onClick:t,color:"primary"},"OK")));wz.propTypes={open:mz.bool,onClose:mz.func,children:mz.oneOfType([mz.arrayOf(mz.node),mz.node]).isRequired,title:mz.string.isRequired};class Ez extends yz.Component{static __initStatic(){this.propTypes={children:mz.oneOfType([mz.arrayOf(mz.node),mz.node]).isRequired,title:mz.string}}constructor(e){super(e),this.state={open:!1}}render(){const{children:e,title:t}=this.props;return yz.createElement("div",null,yz.createElement(xz,{color:"accent",onClick:()=>this.setState({open:!0})}),yz.createElement(wz,{open:this.state.open,title:t,onClose:()=>this.setState({open:!1})},e))}}Ez.__initStatic();const Mz=e,Sz=i;class Cz extends Mz.Component{static __initStatic(){this.propTypes={value:Sz.oneOfType([Sz.string,Sz.number]),onChange:Sz.func.isRequired,label:Sz.string,type:Sz.string.isRequired,error:Sz.func,noModelUpdateOnError:Sz.bool}}static __initStatic2(){this.defaultProps={type:"text",error:(e,t)=>"number"===t?!e||isNaN(e):!e,noModelUpdateOnError:!1}}constructor(e){super(e),Cz.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?Mz.createElement(VT,{label:e},Mz.createElement(v,{type:t,...r,value:i,onChange:this.onChange,error:o})):Mz.createElement(v,{type:t,...r,value:i,onChange:this.onChange,error:o})}}Cz.__initStatic(),Cz.__initStatic2();const Nz=i,Az=e,{TextField:kz}=n,{InputAdornment:Tz}=n,{styled:Oz}=r,_z=s("@pie-lib:config-ui:number-text-field"),Rz=Oz(kz)(({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 Dz extends Az.Component{static __initStatic(){this.propTypes={disabled:Nz.bool,className:Nz.string,inputClassName:Nz.string,onChange:Nz.func.isRequired,value:Nz.number,min:Nz.number,max:Nz.number,label:Nz.string,suffix:Nz.string,showErrorWhenOutsideRange:Nz.bool,disableUnderline:Nz.bool,variant:Nz.string}}static __initStatic2(){this.defaultProps={showErrorWhenOutsideRange:!1}}constructor(e){super(e),Dz.prototype.__init.call(this),Dz.prototype.__init2.call(this),Dz.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 pr(e)?(pr(n)&&(e=Math.min(e,n)),pr(t)&&(e=Math.max(e,t)),e):((e,t)=>pr(e)||pr(t)?!pr(e)&&pr(t)?t:pr(e)?e:void 0:0)(t,n)}__init(){this.onBlur=e=>{const t=e.target.value,n=parseFloat(t);_z("rawNumber: ",n);const r=this.clamp(n);_z("number: ",r),r!==this.state.value&&(_z("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 Az.createElement(Rz,{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&&Az.createElement(Tz,{position:"end"},r),className:s,inputProps:{min:i,max:o}}},margin:"normal"})}}Dz.__initStatic(),Dz.__initStatic2();var Iz={epsilon:1e-12,matrix:"Matrix",number:"number",precision:64,predictable:!1,randomSeed:null};function Lz(e){return Lz="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},Lz(e)}function Bz(e){return"number"==typeof e}function zz(e){return e&&!0===e.constructor.prototype.isBigNumber||!1}function Pz(e){return e&&"object"===Lz(e)&&!0===Object.getPrototypeOf(e).isComplex||!1}function Fz(e){return e&&"object"===Lz(e)&&!0===Object.getPrototypeOf(e).isFraction||!1}function jz(e){return e&&!0===e.constructor.prototype.isUnit||!1}function $z(e){return"string"==typeof e}var Hz=Array.isArray;function Uz(e){return e&&!0===e.constructor.prototype.isMatrix||!1}function qz(e){return Array.isArray(e)||Uz(e)}function Vz(e){return e&&e.isDenseMatrix&&!0===e.constructor.prototype.isMatrix||!1}function Wz(e){return e&&e.isSparseMatrix&&!0===e.constructor.prototype.isMatrix||!1}function Kz(e){return e&&!0===e.constructor.prototype.isRange||!1}function Gz(e){return e&&!0===e.constructor.prototype.isIndex||!1}function Jz(e){return"boolean"==typeof e}function Yz(e){return e&&!0===e.constructor.prototype.isResultSet||!1}function Zz(e){return e&&!0===e.constructor.prototype.isHelp||!1}function Xz(e){return"function"==typeof e}function Qz(e){return e instanceof Date}function eP(e){return e instanceof RegExp}function tP(e){return!(!e||"object"!==Lz(e)||e.constructor!==Object||Pz(e)||Fz(e))}function nP(e){return null===e}function rP(e){return void 0===e}function iP(e){return e&&!0===e.isAccessorNode&&!0===e.constructor.prototype.isNode||!1}function oP(e){return e&&!0===e.isArrayNode&&!0===e.constructor.prototype.isNode||!1}function sP(e){return e&&!0===e.isAssignmentNode&&!0===e.constructor.prototype.isNode||!1}function aP(e){return e&&!0===e.isBlockNode&&!0===e.constructor.prototype.isNode||!1}function lP(e){return e&&!0===e.isConditionalNode&&!0===e.constructor.prototype.isNode||!1}function cP(e){return e&&!0===e.isConstantNode&&!0===e.constructor.prototype.isNode||!1}function uP(e){return e&&!0===e.isFunctionAssignmentNode&&!0===e.constructor.prototype.isNode||!1}function dP(e){return e&&!0===e.isFunctionNode&&!0===e.constructor.prototype.isNode||!1}function pP(e){return e&&!0===e.isIndexNode&&!0===e.constructor.prototype.isNode||!1}function hP(e){return e&&!0===e.isNode&&!0===e.constructor.prototype.isNode||!1}function fP(e){return e&&!0===e.isObjectNode&&!0===e.constructor.prototype.isNode||!1}function mP(e){return e&&!0===e.isOperatorNode&&!0===e.constructor.prototype.isNode||!1}function gP(e){return e&&!0===e.isParenthesisNode&&!0===e.constructor.prototype.isNode||!1}function yP(e){return e&&!0===e.isRangeNode&&!0===e.constructor.prototype.isNode||!1}function vP(e){return e&&!0===e.isSymbolNode&&!0===e.constructor.prototype.isNode||!1}function bP(e){return e&&!0===e.constructor.prototype.isChain||!1}function xP(e){var t=Lz(e);return"object"===t?null===e?"null":Array.isArray(e)?"Array":e instanceof Date?"Date":e instanceof RegExp?"RegExp":zz(e)?"BigNumber":Pz(e)?"Complex":Fz(e)?"Fraction":Uz(e)?"Matrix":jz(e)?"Unit":Gz(e)?"Index":Kz(e)?"Range":Yz(e)?"ResultSet":hP(e)?e.type:bP(e)?"Chain":Zz(e)?"Help":"Object":"function"===t?"Function":t}function wP(e){return wP="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},wP(e)}function EP(e){var t=wP(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 EP(e)});if(e instanceof Date)return new Date(e.valueOf());if(zz(e))return e;if(e instanceof RegExp)throw new TypeError("Cannot clone "+e);return function(e,t){var n={};for(var r in e)CP(e,r)&&(n[r]=t(e[r]));return n}(e,EP)}function MP(e,t){for(var n in t)CP(t,n)&&(e[n]=t[n]);return e}function SP(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(!SP(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)||!SP(e[n],t[n]))return!1;for(n in t)if(!(n in e)||!SP(e[n],t[n]))return!1;return!0}return e===t}function CP(e,t){return e&&Object.hasOwnProperty.call(e,t)}function NP(){return NP=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},NP.apply(this,arguments)}var AP=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(Iz)};NP(AP,Iz,{MATRIX_OPTIONS:["Matrix","Array"],NUMBER_OPTIONS:["number","BigNumber","Fraction"]});var kP={exports:{}};kP.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(M);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(j).filter($).filter(F),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(j).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 x(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 w(e,t){return t<e.params.length?e.params[t]:y(e.params)?V(e.params):null}function E(e,t,n){var r=w(e,t);return(r?n?r.types.filter(S):r.types:[]).map(M)}function M(e){return e.name}function S(e){return null===e.conversion||void 0===e.conversion}function C(e,t){var n=Y(Z(e,function(e){return E(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(w(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++)S(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++)S(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(S):s.types;if(s.restParam){var l=a.filter(S);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(E(e,r,!0),E(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 x(e.params)}),v=s?b(o[0].params[0]):t,w=a?b(o[1].params[0]):t,E=c?b(o[2].params[0]):t,M=u?b(o[3].params[0]):t,S=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,F=a?z[1]:n,j=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&&w(t)&&A(n)?F.apply(e,arguments):arguments.length===K&&E(t)&&k(n)?j.apply(e,arguments):arguments.length===G&&M(t)&&T(n)?$.apply(e,arguments):arguments.length===Y&&S(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 F(e){return-1===l.ignore.indexOf(e)}function j(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 TP=kP.exports;function OP(e){return"boolean"==typeof e||!!isFinite(e)&&e===Math.round(e)}var _P=Math.sign||function(e){return e>0?1:e<0?-1:0},RP=Math.log2||function(e){return Math.log(e)/Math.LN2},DP=Math.log10||function(e){return Math.log(e)/Math.LN10},IP=Math.log1p||function(e){return Math.log(e+1)},LP=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},BP=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function zP(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),Bz(t)?n=t:Bz(t.precision)&&(n=t.precision)),r){case"fixed":return FP(e,n);case"exponential":return jP(e,n);case"engineering":return function(e,t){if(isNaN(e)||!isFinite(e))return String(e);var n=PP(e),r=$P(n,t),i=r.exponent,o=r.coefficients,s=i%3==0?i:i<0?i-3-i%3:i-i%3;if(Bz(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=Bz(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=PP(e),s=t?$P(o,t):o;if(s.exponent<r||s.exponent>=i)return jP(e,t);var a=s.coefficients,l=s.exponent;a.length<t&&(a=a.concat(HP(t-a.length))),a=a.concat(HP(l-a.length+1+(a.length<t?t-a.length:0)));var c=l>0?l:0;return c<(a=HP(-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 PP(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 FP(e,t){if(isNaN(e)||!isFinite(e))return String(e);var n=PP(e),r="number"==typeof t?$P(n,n.exponent+1+t):n,i=r.coefficients,o=r.exponent+1,s=o+(t||0);return i.length<s&&(i=i.concat(HP(s-i.length))),o<0&&(i=HP(1-o).concat(i),o=1),o<i.length&&i.splice(o,0,0===o?"0.":"."),r.sign+i.join("")}function jP(e,t){if(isNaN(e)||!isFinite(e))return String(e);var n=PP(e),r=t?$P(n,t):n,i=r.coefficients,o=r.exponent;i.length<t&&(i=i.concat(HP(t-i.length)));var s=i.shift();return r.sign+s+(i.length>0?"."+i.join(""):"")+"e"+(o>=0?"+":"")+o}function $P(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 HP(e){for(var t=[],n=0;n<e;n++)t.push(0);return t}var UP=Number.EPSILON||2220446049250313e-31;function qP(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<UP||r<=Math.max(Math.abs(e),Math.abs(t))*n}return!1}var VP=Math.acosh||function(e){return Math.log(Math.sqrt(e*e-1)+e)},WP=Math.asinh||function(e){return Math.log(Math.sqrt(e*e+1)+e)},KP=Math.atanh||function(e){return Math.log((1+e)/(1-e))/2},GP=Math.cosh||function(e){return(Math.exp(e)+Math.exp(-e))/2},JP=Math.sinh||function(e){return(Math.exp(e)-Math.exp(-e))/2},YP=Math.tanh||function(e){var t=Math.exp(2*e);return(t-1)/(t+1)};function ZP(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 XP(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():XP(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 XP(e,t){return void 0!==t?e.toExponential(t-1):e.toExponential()}function QP(e){return QP="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},QP(e)}function eF(e,t){var n=e.length-t.length,r=e.length;return e.substring(n,r)===t}function tF(e,t){if("number"==typeof e)return zP(e,t);if(zz(e))return ZP(e,t);if(function(e){return e&&"object"===QP(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 nF(e,t);if($z(e))return'"'+e+'"';if("function"==typeof e)return e.syntax?String(e.syntax):"function";if(e&&"object"===QP(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+'": '+tF(e[n],t)});return"{"+n.join(", ")+"}"}return String(e)}function nF(e,t){if(Array.isArray(e)){for(var n="[",r=e.length,i=0;i<r;i++)0!==i&&(n+=", "),n+=nF(e[i],t);return n+="]"}return tF(e,t)}function rF(e,t){if(!$z(e))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+xP(e)+", index: 0)");if(!$z(t))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+xP(t)+", index: 1)");return e===t?0:e>t?1:-1}function iF(e,t,n){if(!(this instanceof iF))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 oF(e,t,n){if(!(this instanceof oF))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 sF(e){for(var t=[];Array.isArray(e);)t.push(e.length),e=e[0];return t}function aF(e,t,n){var r,i=e.length;if(i!==t[n])throw new iF(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 iF(t.length-1,t.length,"<");aF(e[r],t,o)}}else for(r=0;r<i;r++)if(Array.isArray(e[r]))throw new iF(t.length+1,t.length,">")}function lF(e,t){if(0===t.length){if(Array.isArray(e))throw new iF(e.length,0)}else aF(e,t,0)}function cF(e,t){if(!Bz(e)||!OP(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||"number"==typeof t&&e>=t)throw new oF(e,t)}function uF(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(!Bz(e)||!OP(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+tF(t)+")")}),dF(e,t,0,void 0!==n?n:0),e}function dF(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),dF(o,t,c,r);for(i=l;i<a;i++)o=[],e[i]=o,dF(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 pF(e,t){var n,r=yF(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 iF(0,i(sF(e)),"!=");for(var o=1,s=0;s<t.length;s++)o*=t[s];if(r.length!==o)throw new iF(i(t),i(sF(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 iF)throw new iF(i(t),i(sF(e)),"!=");throw n}return n}function hF(e,t){for(var n=t||sF(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=fF(e,r,0),n.length=r),e}function fF(e,t,n){var r,i;if(n<t){var o=n+1;for(r=0,i=e.length;r<i;r++)e[r]=fF(e[r],t,o)}else for(;Array.isArray(e);)e=e[0];return e}function mF(e,t,n,r){var i=r||sF(e);if(n)for(var o=0;o<n;o++)e=[e],i.unshift(1);for(e=gF(e,t,0);i.length<t;)i.push(1);return e}function gF(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]=gF(e[r],t,o)}else for(var s=n;s<t;s++)e=[e];return e}function yF(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 vF(e,t){if(1!==sF(e).length)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(e,function(e){return t.test(e)})}function bF(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 xF(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 wF(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?wF(o,t):t(o);if(void 0===n)n=a;else if(n!==a)return"mixed"}return n}function EF(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(MF));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 MF(e){return e&&"?"===e[0]?e.slice(1):e}iF.prototype=new RangeError,iF.prototype.constructor=RangeError,iF.prototype.name="DimensionError",iF.prototype.isDimensionError=!0,oF.prototype=new RangeError,oF.prototype.constructor=RangeError,oF.prototype.name="IndexError",oF.prototype.isIndexError=!0;var SF=function(){return SF=TP.create,TP},CF=EF("typed",["?BigNumber","?Complex","?DenseMatrix","?Fraction"],function(e){var t=e.BigNumber,n=e.Complex,r=e.DenseMatrix,i=e.Fraction,o=SF();return o.types=[{name:"number",test:Bz},{name:"Complex",test:Pz},{name:"BigNumber",test:zz},{name:"Fraction",test:Fz},{name:"Unit",test:jz},{name:"string",test:$z},{name:"Chain",test:bP},{name:"Array",test:Hz},{name:"Matrix",test:Uz},{name:"DenseMatrix",test:Vz},{name:"SparseMatrix",test:Wz},{name:"Range",test:Kz},{name:"Index",test:Gz},{name:"boolean",test:Jz},{name:"ResultSet",test:Yz},{name:"Help",test:Zz},{name:"function",test:Xz},{name:"Date",test:Qz},{name:"RegExp",test:eP},{name:"null",test:nP},{name:"undefined",test:rP},{name:"AccessorNode",test:iP},{name:"ArrayNode",test:oP},{name:"AssignmentNode",test:sP},{name:"BlockNode",test:aP},{name:"ConditionalNode",test:lP},{name:"ConstantNode",test:cP},{name:"FunctionNode",test:dP},{name:"FunctionAssignmentNode",test:uP},{name:"IndexNode",test:pP},{name:"Node",test:hP},{name:"ObjectNode",test:fP},{name:"OperatorNode",test:mP},{name:"ParenthesisNode",test:gP},{name:"RangeNode",test:yP},{name:"SymbolNode",test:vP},{name:"Object",test:tP}],o.conversions=[{from:"number",to:"BigNumber",convert:function(e){if(t||NF(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||AF(e),new n(e,0)}},{from:"number",to:"string",convert:function(e){return e+""}},{from:"BigNumber",to:"Complex",convert:function(e){return n||AF(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||AF(e),new n(e.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(e){i||kF(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||NF(e);try{return new t(e)}catch(t){throw new Error('Cannot convert "'+e+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(e){i||kF(e);try{return new i(e)}catch(t){throw new Error('Cannot convert "'+e+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(e){n||AF(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||NF(e),new t(+e)}},{from:"boolean",to:"Fraction",convert:function(e){return i||kF(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 NF(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function AF(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function kF(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}var TF,OF,_F=EF("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}),RF=9e15,DF=1e9,IF="0123456789abcdef",LF="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",BF="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",zF={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-RF,maxE:RF,crypto:!1},PF=!0,FF="[DecimalError] ",jF=FF+"Invalid argument: ",$F=FF+"Precision limit exceeded",HF=FF+"crypto unavailable",UF="[object Decimal]",qF=Math.floor,VF=Math.pow,WF=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,KF=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,GF=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,JF=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,YF=1e7,ZF=LF.length-1,XF=BF.length-1,QF={toStringTag:UF};function ej(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+=dj(n)),o+=r;(n=7-(r=(s=e[t])+"").length)&&(o+=dj(n))}else if(0===s)return"0";for(;s%10==0;)s/=10;return o+s}function tj(e,t,n){if(e!==~~e||e<t||e>n)throw Error(jF+e)}function nj(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=VF(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)==VF(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)==VF(10,t-3)-1,s}function rj(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]+=IF.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()}QF.absoluteValue=QF.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),oj(e)},QF.ceil=function(){return oj(new this.constructor(this),this.e+1,2)},QF.clampedTo=QF.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(jF+t);return n.cmp(e)<0?e:n.cmp(t)>0?t:new r(n)},QF.comparedTo=QF.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},QF.cosine=QF.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/wj(4,n=Math.ceil(r/3))).toString():(n=16,i="2.3283064365386962890625e-10");e.precision+=n,t=xj(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,Ej(r,n)),r.precision=e,r.rounding=t,oj(2==OF||3==OF?n.neg():n,e,t,!0)):new r(1):new r(NaN)},QF.cubeRoot=QF.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(PF=!1,(o=u.s*VF(u.s*u,1/3))&&Math.abs(o)!=1/0?r=new d(o.toString()):(n=ej(u.d),(o=((e=u.e)-n.length+1)%3)&&(n+=1==o||-2==o?"0":"00"),o=VF(n,1/3),e=qF((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=ij(c.plus(u).times(a),c.plus(l),s+2,1),ej(a.d).slice(0,s)===(n=ej(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))||(oj(r,e+1,1),t=!r.times(r).times(r).eq(u));break}if(!i&&(oj(a,e+1,0),a.times(a).times(a).eq(u))){r=a;break}s+=4,i=1}return PF=!0,oj(r,e,d.rounding,t)},QF.decimalPlaces=QF.dp=function(){var e,t=this.d,n=NaN;if(t){if(n=7*((e=t.length-1)-qF(this.e/7)),e=t[e])for(;e%10==0;e/=10)n--;n<0&&(n=0)}return n},QF.dividedBy=QF.div=function(e){return ij(this,new this.constructor(e))},QF.dividedToIntegerBy=QF.divToInt=function(e){var t=this.constructor;return oj(ij(this,new t(e),0,1,1),t.precision,t.rounding)},QF.equals=QF.eq=function(e){return 0===this.cmp(e)},QF.floor=function(){return oj(new this.constructor(this),this.e+1,3)},QF.greaterThan=QF.gt=function(e){return this.cmp(e)>0},QF.greaterThanOrEqualTo=QF.gte=function(e){var t=this.cmp(e);return 1==t||0===t},QF.hyperbolicCosine=QF.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/wj(4,e=Math.ceil(i/3))).toString():(e=16,t="2.3283064365386962890625e-10"),o=xj(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 oj(o,s.precision=n,s.rounding=r,!0)},QF.hyperbolicSine=QF.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=xj(o,2,i,i,!0);else{e=(e=1.4*Math.sqrt(r))>16?16:0|e,i=xj(o,2,i=i.times(1/wj(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,oj(i,t,n,!0)},QF.hyperbolicTangent=QF.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,ij(n.sinh(),n.cosh(),r.precision=e,r.rounding=t)):new r(n.s)},QF.inverseCosine=QF.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()?cj(t,r,i):new t(0):new t(NaN):e.isZero()?cj(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))},QF.inverseHyperbolicCosine=QF.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,PF=!1,n=n.times(n).minus(1).sqrt().plus(n),PF=!0,r.precision=e,r.rounding=t,n.ln()):new r(n)},QF.inverseHyperbolicSine=QF.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,PF=!1,n=n.times(n).plus(1).sqrt().plus(n),PF=!0,r.precision=e,r.rounding=t,n.ln())},QF.inverseHyperbolicTangent=QF.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?oj(new o(i),e,t,!0):(o.precision=n=r-i.e,i=ij(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)},QF.inverseSine=QF.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=cj(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)))},QF.inverseTangent=QF.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<=XF)return(s=cj(u,d+4,p).times(.25)).s=c.s,s}else{if(!c.s)return new u(NaN);if(d+4<=XF)return(s=cj(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(PF=!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)),PF=!0,oj(s,u.precision=d,u.rounding=p,!0)},QF.isFinite=function(){return!!this.d},QF.isInteger=QF.isInt=function(){return!!this.d&&qF(this.e/7)>this.d.length-2},QF.isNaN=function(){return!this.s},QF.isNegative=QF.isNeg=function(){return this.s<0},QF.isPositive=QF.isPos=function(){return this.s>0},QF.isZero=function(){return!!this.d&&0===this.d[0]},QF.lessThan=QF.lt=function(e){return this.cmp(e)<0},QF.lessThanOrEqualTo=QF.lte=function(e){return this.cmp(e)<1},QF.logarithm=QF.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(PF=!1,s=gj(c,a=d+5),r=t?lj(u,a+10):gj(e,a),nj((l=ij(s,r,a,1)).d,i=d,p))do{if(s=gj(c,a+=10),r=t?lj(u,a+10):gj(e,a),l=ij(s,r,a,1),!o){+ej(l.d).slice(i+1,i+15)+1==1e14&&(l=oj(l,d+1,0));break}}while(nj(l.d,i+=10,p));return PF=!0,oj(l,d,p)},QF.minus=QF.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 PF?oj(e,a,l):e}if(n=qF(e.e/7),u=qF(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]=YF-1;--c[i],c[r]+=YF}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=aj(c,n),PF?oj(e,a,l):e):new f(3===l?-0:0)},QF.modulo=QF.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]?oj(new r(n),r.precision,r.rounding):(PF=!1,9==r.modulo?(t=ij(n,e.abs(),0,3,1)).s*=e.s:t=ij(n,e,0,r.modulo,1),t=t.times(e),PF=!0,n.minus(t))},QF.naturalExponential=QF.exp=function(){return mj(this)},QF.naturalLogarithm=QF.ln=function(){return gj(this)},QF.negated=QF.neg=function(){var e=new this.constructor(this);return e.s=-e.s,oj(e)},QF.plus=QF.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)),PF?oj(e,a,l):e;if(o=qF(d.e/7),r=qF(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)/YF|0,c[i]%=YF;for(t&&(c.unshift(t),++r),s=c.length;0==c[--s];)c.pop();return e.d=c,e.e=aj(c,r),PF?oj(e,a,l):e},QF.precision=QF.sd=function(e){var t,n=this;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(jF+e);return n.d?(t=uj(n.d),e&&n.e+1>t&&(t=n.e+1)):t=NaN,t},QF.round=function(){var e=this,t=e.constructor;return oj(new t(e),e.e+1,t.rounding)},QF.sine=QF.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:xj(e,2,t,t);n=1.4*Math.sqrt(r),n=n>16?16:0|n,t=t.times(1/wj(5,n)),t=xj(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,Ej(r,n)),r.precision=e,r.rounding=t,oj(OF>2?n.neg():n,e,t,!0)):new r(NaN)},QF.squareRoot=QF.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(PF=!1,0==(c=Math.sqrt(+s))||c==1/0?(((t=ej(a)).length+l)%2==0&&(t+="0"),c=Math.sqrt(t),l=qF((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(ij(s,o,n+2,1)).times(.5),ej(o.d).slice(0,n)===(t=ej(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))||(oj(r,l+1,1),e=!r.times(r).eq(s));break}if(!i&&(oj(o,l+1,0),o.times(o).eq(s))){r=o;break}n+=4,i=1}return PF=!0,oj(r,l,u.rounding,e)},QF.tangent=QF.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=ij(n,new r(1).minus(n.times(n)).sqrt(),e+10,0),r.precision=e,r.rounding=t,oj(2==OF||4==OF?n.neg():n,e,t,!0)):new r(NaN)},QF.times=QF.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=qF(u.e/7)+qF(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%YF|0,t=a/YF|0;o[i]=(o[i]+t)%YF|0}for(;!o[--s];)o.pop();return t?++n:o.shift(),e.d=o,e.e=aj(o,n),PF?oj(e,d.precision,d.rounding):e},QF.toBinary=function(e,t){return Mj(this,2,e,t)},QF.toDecimalPlaces=QF.toDP=function(e,t){var n=this,r=n.constructor;return n=new r(n),void 0===e?n:(tj(e,0,DF),void 0===t?t=r.rounding:tj(t,0,8),oj(n,e+n.e+1,t))},QF.toExponential=function(e,t){var n,r=this,i=r.constructor;return void 0===e?n=sj(r,!0):(tj(e,0,DF),void 0===t?t=i.rounding:tj(t,0,8),n=sj(r=oj(new i(r),e+1,t),!0,e+1)),r.isNeg()&&!r.isZero()?"-"+n:n},QF.toFixed=function(e,t){var n,r,i=this,o=i.constructor;return void 0===e?n=sj(i):(tj(e,0,DF),void 0===t?t=o.rounding:tj(t,0,8),n=sj(r=oj(new o(i),e+i.e+1,t),!1,e+r.e+1)),i.isNeg()&&!i.isZero()?"-"+n:n},QF.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=uj(f)-h.e-1)%7,t.d[0]=VF(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(jF+a);e=a.gt(t)?o>0?t:c:a}for(PF=!1,a=new m(ej(f)),u=m.precision,m.precision=o=7*f.length*2;d=ij(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=ij(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=ij(c,r,o,1).minus(h).abs().cmp(ij(l,n,o,1).minus(h).abs())<1?[c,r]:[l,n],m.precision=u,PF=!0,p},QF.toHexadecimal=QF.toHex=function(e,t){return Mj(this,16,e,t)},QF.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:tj(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]?(PF=!1,n=ij(n,e,0,t,1).times(e),PF=!0,oj(n)):(e.s=n.s,n=e),n},QF.toNumber=function(){return+this},QF.toOctal=function(e,t){return Mj(this,8,e,t)},QF.toPower=QF.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(VF(+a,c));if((a=new l(a)).eq(1))return a;if(r=l.precision,o=l.rounding,e.eq(1))return oj(a,r,o);if((t=qF(e.e/7))>=e.d.length-1&&(n=c<0?-c:c)<=9007199254740991)return i=pj(l,a,n,r),e.s<0?new l(1).div(i):oj(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=VF(+a,c))&&isFinite(n)?new l(n+"").e:qF(c*(Math.log("0."+ej(a.d))/Math.LN10+a.e+1)))>l.maxE+1||t<l.minE-1?new l(t>0?s/0:0):(PF=!1,l.rounding=a.s=1,n=Math.min(12,(t+"").length),(i=mj(e.times(gj(a,r+n)),r)).d&&nj((i=oj(i,r+5,1)).d,r,o)&&(t=r+10,+ej((i=oj(mj(e.times(gj(a,t+n)),t),t+5,1)).d).slice(r+1,r+15)+1==1e14&&(i=oj(i,r+1,0))),i.s=s,PF=!0,l.rounding=o,oj(i,r,o))},QF.toPrecision=function(e,t){var n,r=this,i=r.constructor;return void 0===e?n=sj(r,r.e<=i.toExpNeg||r.e>=i.toExpPos):(tj(e,1,DF),void 0===t?t=i.rounding:tj(t,0,8),n=sj(r=oj(new i(r),e,t),e<=r.e||r.e<=i.toExpNeg,e)),r.isNeg()&&!r.isZero()?"-"+n:n},QF.toSignificantDigits=QF.toSD=function(e,t){var n=this.constructor;return void 0===e?(e=n.precision,t=n.rounding):(tj(e,1,DF),void 0===t?t=n.rounding:tj(t,0,8)),oj(new n(this),e,t)},QF.toString=function(){var e=this,t=e.constructor,n=sj(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+n:n},QF.truncated=QF.trunc=function(){return oj(new this.constructor(this),this.e+1,1)},QF.valueOf=QF.toJSON=function(){var e=this,t=e.constructor,n=sj(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+n:n};var ij=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,x,w,E,M,S,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=YF,h=7,u=qF(r.e/h)-qF(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?(E=o=T.precision,s=T.rounding):E=a?o+(r.e-i.e)+1:o,E<0)v.push(1),f=!0;else{if(E=E/h+2|0,d=0,1==A){for(p=0,R=R[0],E++;(d<C||p)&&E--;d++)M=p*l+(_[d]||0),v[d]=M/R|0,p=M%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),S=A,x=(b=_.slice(0,A)).length;x<A;)b[x++]=0;(k=R.slice()).unshift(0),N=R[0],R[1]>=l/2&&++N;do{p=0,(c=t(R,b,A,x))<0?(w=b[0],A!=x&&(w=w*l+(b[1]||0)),(p=w/N|0)>1?(p>=l&&(p=l-1),1==(c=t(m=e(R,p,l),b,g=m.length,x=b.length))&&(p--,n(m,A<g?k:R,g,l))):(0==p&&(c=p=1),m=R.slice()),(g=m.length)<x&&m.unshift(0),n(b,m,x,l),-1==c&&(c=t(R,b,A,x=b.length))<1&&(p++,n(b,A<x?k:R,x,l)),x=b.length):0===c&&(p++,b=[0]),v[d++]=p,c&&b[0]?b[x++]=_[S]||0:(b=[_[S]],x=1)}while((S++<C||void 0!==b[0])&&E--);f=void 0!==b[0]}v[0]||v.shift()}if(1==h)y.e=u,TF=f;else{for(d=1,p=v[0];p>=10;p/=10)d++;y.e=d+u*h-1,oj(y,a?o+y.e+1:o,s,f)}return y}}();function oj(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])/VF(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/VF(10,i-s-1)%10|0}if(r=r||t<0||void 0!==d[p+1]||(s<0?u:u%VF(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/VF(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]=VF(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=VF(10,7-o),d[p]=s>0?(u/VF(10,i-s)%VF(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]==YF&&(d[0]=1));break}if(d[p]+=a,d[p]!=YF)break;d[p--]=0,a=1}for(o=d.length;0===d[--o];)d.pop()}return PF&&(e.e>h.maxE?(e.d=null,e.e=NaN):e.e<h.minE&&(e.e=0,e.d=[0])),e}function sj(e,t,n){if(!e.isFinite())return yj(e);var r,i=e.e,o=ej(e.d),s=o.length;return t?(n&&(r=n-s)>0?o=o.charAt(0)+"."+o.slice(1)+dj(r):s>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(e.e<0?"e":"e+")+e.e):i<0?(o="0."+dj(-i-1)+o,n&&(r=n-s)>0&&(o+=dj(r))):i>=s?(o+=dj(i+1-s),n&&(r=n-i-1)>0&&(o=o+"."+dj(r))):((r=i+1)<s&&(o=o.slice(0,r)+"."+o.slice(r)),n&&(r=n-s)>0&&(i+1===s&&(o+="."),o+=dj(r))),o}function aj(e,t){var n=e[0];for(t*=7;n>=10;n/=10)t++;return t}function lj(e,t,n){if(t>ZF)throw PF=!0,n&&(e.precision=n),Error($F);return oj(new e(LF),t,1,!0)}function cj(e,t,n){if(t>XF)throw Error($F);return oj(new e(BF),t,n,!0)}function uj(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 dj(e){for(var t="";e--;)t+="0";return t}function pj(e,t,n,r){var i,o=new e(1),s=Math.ceil(r/7+4);for(PF=!1;;){if(n%2&&Sj((o=o.times(t)).d,s)&&(i=!0),0===(n=qF(n/2))){n=o.d.length-1,i&&0===o.d[n]&&++o.d[n];break}Sj((t=t.times(t)).d,s)}return PF=!0,o}function hj(e){return 1&e.d[e.d.length-1]}function fj(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 mj(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?(PF=!1,l=f):l=t,a=new p(.03125);e.e>-2;)e=e.times(a),d+=5;for(l+=r=Math.log(VF(2,d))/Math.LN10*2+5|0,n=o=s=new p(1),p.precision=l;;){if(o=oj(o.times(e),l,1),n=n.times(++u),ej((a=s.plus(ij(o,n,l,1))).d).slice(0,l)===ej(s.d).slice(0,l)){for(i=d;i--;)s=oj(s.times(s),l,1);if(null!=t)return p.precision=f,s;if(!(c<3&&nj(s.d,l-r,h,c)))return oj(s,p.precision=f,h,PF=!0);p.precision=l+=10,n=o=a=new p(1),u=0,c++}s=a}}function gj(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?(PF=!1,u=v):u=t,g.precision=u+=10,r=(n=ej(m)).charAt(0),!(Math.abs(o=f.e)<15e14))return c=lj(g,u+2,v).times(o+""),f=gj(new g(r+"."+n.slice(1)),u-10).plus(c),g.precision=v,null==t?oj(f,v,y,PF=!0):f;for(;r<7&&1!=r||1==r&&n.charAt(1)>3;)r=(n=ej((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=ij(f.minus(1),f.plus(1),u,1),p=oj(f.times(f),u,1),i=3;;){if(s=oj(s.times(p),u,1),ej((c=l.plus(ij(s,new g(i),u,1))).d).slice(0,u)===ej(l.d).slice(0,u)){if(l=l.times(2),0!==o&&(l=l.plus(lj(g,u+2,v).times(o+""))),l=ij(l,new g(h),u,1),null!=t)return g.precision=v,l;if(!nj(l.d,u-10,y,a))return oj(l,g.precision=v,y,PF=!0);g.precision=u+=10,c=s=f=ij(d.minus(1),d.plus(1),u,1),p=oj(f.times(f),u,1),i=a=1}l=c,i+=2}}function yj(e){return String(e.s*e.s/0)}function vj(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),PF&&(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 bj(e,t){var n,r,i,o,s,a,l,c,u;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),JF.test(t))return vj(e,t)}else if("Infinity"===t||"NaN"===t)return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(KF.test(t))n=16,t=t.toLowerCase();else if(WF.test(t))n=2;else{if(!GF.test(t))throw Error(jF+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=pj(r,new r(n),o,2*o)),o=u=(c=rj(t,n,YF)).length-1;0===c[o];--o)c.pop();return o<0?new r(0*e.s):(e.e=aj(c,u),e.d=c,PF=!1,s&&(e=ij(e,i,4*a)),l&&(e=e.times(Math.abs(l)<54?VF(2,l):d$.pow(2,l))),PF=!0,e)}function xj(e,t,n,r,i){var o,s,a,l,c=e.precision,u=Math.ceil(c/7);for(PF=!1,l=n.times(n),a=new e(r);;){if(s=ij(a.times(l),new e(t++*t++),c,1),a=i?r.plus(s):r.minus(s),r=ij(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 PF=!0,s.d.length=u+1,s}function wj(e,t){for(var n=e;--t;)n*=e;return n}function Ej(e,t){var n,r=t.s<0,i=cj(e,e.precision,1),o=i.times(.5);if((t=t.abs()).lte(o))return OF=r?4:1,t;if((n=t.divToInt(i)).isZero())OF=r?3:2;else{if((t=t.minus(n.times(i))).lte(o))return OF=hj(n)?r?2:3:r?4:1,t;OF=hj(n)?r?1:4:r?3:2}return t.minus(i).abs()}function Mj(e,t,n,r){var i,o,s,a,l,c,u,d,p,h=e.constructor,f=void 0!==n;if(f?(tj(n,1,DF),void 0===r?r=h.rounding:tj(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=sj(e)).indexOf("."))>=0&&(u=u.replace(".",""),(p=new h(1)).e=u.length-s,p.d=rj(sj(p),10,i),p.e=p.d.length),o=l=(d=rj(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=ij(e,p,n,r,0,i)).d,o=e.e,c=TF),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+=IF.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=rj(u,i,t)).length;!d[l-1];--l);for(s=1,u="1.";s<l;s++)u+=IF.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=yj(e);return e.s<0?"-"+u:u}function Sj(e,t){if(e.length>t)return e.length=t,!0}function Cj(e){return new this(e).abs()}function Nj(e){return new this(e).acos()}function Aj(e){return new this(e).acosh()}function kj(e,t){return new this(e).plus(t)}function Tj(e){return new this(e).asin()}function Oj(e){return new this(e).asinh()}function _j(e){return new this(e).atan()}function Rj(e){return new this(e).atanh()}function Dj(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?cj(this,r,i):new this(0)).s=e.s:!e.d||t.isZero()?(n=cj(this,o,1).times(.5)).s=e.s:t.s<0?(this.precision=o,this.rounding=1,n=this.atan(ij(e,t,o,1)),t=cj(this,o,1),this.precision=r,this.rounding=i,n=e.s<0?n.minus(t):n.plus(t)):n=this.atan(ij(e,t,o,1)):(n=cj(this,o,1).times(t.s>0?.25:.75)).s=e.s:n=new this(NaN),n}function Ij(e){return new this(e).cbrt()}function Lj(e){return oj(e=new this(e),e.e+1,2)}function Bj(e,t,n){return new this(e).clamp(t,n)}function zj(e){if(!e||"object"!=typeof e)throw Error(FF+"Object expected");var t,n,r,i=!0===e.defaults,o=["precision",1,DF,"rounding",0,8,"toExpNeg",-RF,0,"toExpPos",0,RF,"maxE",0,RF,"minE",-RF,0,"modulo",0,9];for(t=0;t<o.length;t+=3)if(n=o[t],i&&(this[n]=zF[n]),void 0!==(r=e[n])){if(!(qF(r)===r&&r>=o[t+1]&&r<=o[t+2]))throw Error(jF+n+": "+r);this[n]=r}if(n="crypto",i&&(this[n]=zF[n]),void 0!==(r=e[n])){if(!0!==r&&!1!==r&&0!==r&&1!==r)throw Error(jF+n+": "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(HF);this[n]=!0}else this[n]=!1}return this}function Pj(e){return new this(e).cos()}function Fj(e){return new this(e).cosh()}function jj(e,t){return new this(e).div(t)}function $j(e){return new this(e).exp()}function Hj(e){return oj(e=new this(e),e.e+1,3)}function Uj(){var e,t,n=new this(0);for(PF=!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 PF=!0,new this(1/0);n=t}return PF=!0,n.sqrt()}function qj(e){return e instanceof d$||e&&e.toStringTag===UF||!1}function Vj(e){return new this(e).ln()}function Wj(e,t){return new this(e).log(t)}function Kj(e){return new this(e).log(2)}function Gj(e){return new this(e).log(10)}function Jj(){return fj(this,arguments,-1)}function Yj(){return fj(this,arguments,1)}function Zj(e,t){return new this(e).mod(t)}function Xj(e,t){return new this(e).mul(t)}function Qj(e,t){return new this(e).pow(t)}function e$(e){var t,n,r,i,o=0,s=new this(1),a=[];if(void 0===e?e=this.precision:tj(e,1,DF),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(HF);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=VF(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 t$(e){return oj(e=new this(e),e.e+1,this.rounding)}function n$(e){return(e=new this(e)).d?e.d[0]?e.s:0*e.s:e.s||NaN}function r$(e){return new this(e).sin()}function i$(e){return new this(e).sinh()}function o$(e){return new this(e).sqrt()}function s$(e,t){return new this(e).sub(t)}function a$(){var e=0,t=arguments,n=new this(t[e]);for(PF=!1;n.s&&++e<t.length;)n=n.plus(t[e]);return PF=!0,oj(n,this.precision,this.rounding)}function l$(e){return new this(e).tan()}function c$(e){return new this(e).tanh()}function u$(e){return oj(e=new this(e),e.e+1,1)}QF[Symbol.for("nodejs.util.inspect.custom")]=QF.toString,QF[Symbol.toStringTag]="Decimal";var d$=QF.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,qj(e))return i.s=e.s,void(PF?!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(PF?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)):vj(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),JF.test(e)?vj(i,e):bj(i,e);if("bigint"===r)return e<0?(e=-e,i.s=-1):i.s=1,vj(i,e.toString());throw Error(jF+e)}if(o.prototype=QF,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=zj,o.clone=e,o.isDecimal=qj,o.abs=Cj,o.acos=Nj,o.acosh=Aj,o.add=kj,o.asin=Tj,o.asinh=Oj,o.atan=_j,o.atanh=Rj,o.atan2=Dj,o.cbrt=Ij,o.ceil=Lj,o.clamp=Bj,o.cos=Pj,o.cosh=Fj,o.div=jj,o.exp=$j,o.floor=Hj,o.hypot=Uj,o.ln=Vj,o.log=Wj,o.log10=Gj,o.log2=Kj,o.max=Jj,o.min=Yj,o.mod=Zj,o.mul=Xj,o.pow=Qj,o.random=e$,o.round=t$,o.sign=n$,o.sin=r$,o.sinh=i$,o.sqrt=o$,o.sub=s$,o.sum=a$,o.tan=l$,o.tanh=c$,o.trunc=u$,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}(zF);LF=new d$(LF),BF=new d$(BF);var p$=EF("BigNumber",["?on","config"],function(e){var t=e.on,n=e.config,r=d$.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 h$=Math.cosh||function(e){return Math.abs(e)<1e-9?1-e:.5*(Math.exp(e)+Math.exp(-e))},f$=Math.sinh||function(e){return Math.abs(e)<1e-9?e:.5*(Math.exp(e)-Math.exp(-e))},m$=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))},g$=function(){throw SyntaxError("Invalid Param")};function y$(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 v$={re:0,im:0},b$=function(e,t){const n=v$;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 x$.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 x$.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]):g$();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&&g$();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&&g$()," "===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))&&g$(),"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&&g$();break;case"number":n.im=0,n.re=e;break;default:g$()}return isNaN(n.re)||isNaN(n.im),n};function x$(e,t){if(!(this instanceof x$))return new x$(e,t);const n=b$(e,t);this.re=n.re,this.im=n.im}function w$(e){return w$="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},w$(e)}x$.prototype={re:0,im:0,sign:function(){const e=m$(this.re,this.im);return new x$(this.re/e,this.im/e)},add:function(e,t){const n=b$(e,t),r=this.isInfinite(),i=!(isFinite(n.re)&&isFinite(n.im));return r||i?r&&i?x$.NAN:x$.INFINITY:new x$(this.re+n.re,this.im+n.im)},sub:function(e,t){const n=b$(e,t),r=this.isInfinite(),i=!(isFinite(n.re)&&isFinite(n.im));return r||i?r&&i?x$.NAN:x$.INFINITY:new x$(this.re-n.re,this.im-n.im)},mul:function(e,t){const n=b$(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?x$.NAN:r||i?x$.INFINITY:0===n.im&&0===this.im?new x$(this.re*n.re,0):new x$(this.re*n.re-this.im*n.im,this.re*n.im+this.im*n.re)},div:function(e,t){const n=b$(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 x$.NAN;if(s||r)return x$.INFINITY;if(o||i)return x$.ZERO;if(0===n.im)return new x$(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 x$((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 x$((this.re+this.im*e)/t,(this.im-this.re*e)/t)}},pow:function(e,t){const n=b$(e,t),r=0===this.re&&0===this.im;if(0===n.re&&0===n.im)return x$.ONE;if(0===n.im){if(0===this.im&&this.re>0)return new x$(Math.pow(this.re,n.re),0);if(0===this.re)switch((n.re%4+4)%4){case 0:return new x$(Math.pow(this.im,n.re),0);case 1:return new x$(0,Math.pow(this.im,n.re));case 2:return new x$(-Math.pow(this.im,n.re),0);case 3:return new x$(0,-Math.pow(this.im,n.re))}}if(r&&n.re>0)return x$.ZERO;const i=Math.atan2(this.im,this.re),o=y$(this.re,this.im);let s=Math.exp(n.re*o-n.im*i),a=n.im*o+n.re*i;return new x$(s*Math.cos(a),s*Math.sin(a))},sqrt:function(){const e=this.re,t=this.im;if(0===t)return e>=0?new x$(Math.sqrt(e),0):new x$(0,Math.sqrt(-e));const n=m$(e,t);let r=Math.sqrt(.5*(n+Math.abs(e))),i=Math.abs(t)/(2*r);return e>=0?new x$(r,t<0?-i:i):new x$(i,t<0?-r:r)},exp:function(){const e=Math.exp(this.re);return 0===this.im?new x$(e,0):new x$(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){const e=this.re,t=this.im;return new x$(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 x$(Math.log(e),0):new x$(y$(e,t),Math.atan2(t,e))},abs:function(){return m$(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){const e=this.re,t=this.im;return new x$(Math.sin(e)*h$(t),Math.cos(e)*f$(t))},cos:function(){const e=this.re,t=this.im;return new x$(Math.cos(e)*h$(t),-Math.sin(e)*f$(t))},tan:function(){const e=2*this.re,t=2*this.im,n=Math.cos(e)+h$(t);return new x$(Math.sin(e)/n,f$(t)/n)},cot:function(){const e=2*this.re,t=2*this.im,n=Math.cos(e)-h$(t);return new x$(-Math.sin(e)/n,f$(t)/n)},sec:function(){const e=this.re,t=this.im,n=.5*h$(2*t)+.5*Math.cos(2*e);return new x$(Math.cos(e)*h$(t)/n,Math.sin(e)*f$(t)/n)},csc:function(){const e=this.re,t=this.im,n=.5*h$(2*t)-.5*Math.cos(2*e);return new x$(Math.sin(e)*h$(t)/n,-Math.cos(e)*f$(t)/n)},asin:function(){const e=this.re,t=this.im,n=new x$(t*t-e*e+1,-2*e*t).sqrt(),r=new x$(n.re-t,n.im+e).log();return new x$(r.im,-r.re)},acos:function(){const e=this.re,t=this.im,n=new x$(t*t-e*e+1,-2*e*t).sqrt(),r=new x$(n.re-t,n.im+e).log();return new x$(Math.PI/2-r.im,r.re)},atan:function(){const e=this.re,t=this.im;if(0===e){if(1===t)return new x$(0,1/0);if(-1===t)return new x$(0,-1/0)}const n=e*e+(1-t)*(1-t),r=new x$((1-t*t-e*e)/n,-2*e/n).log();return new x$(-.5*r.im,.5*r.re)},acot:function(){const e=this.re,t=this.im;if(0===t)return new x$(Math.atan2(1,e),0);const n=e*e+t*t;return 0!==n?new x$(e/n,-t/n).atan():new x$(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 x$(0,1/0);const n=e*e+t*t;return 0!==n?new x$(e/n,-t/n).acos():new x$(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 x$(Math.PI/2,1/0);const n=e*e+t*t;return 0!==n?new x$(e/n,-t/n).asin():new x$(0!==e?e/0:0,0!==t?-t/0:0).asin()},sinh:function(){const e=this.re,t=this.im;return new x$(f$(e)*Math.cos(t),h$(e)*Math.sin(t))},cosh:function(){const e=this.re,t=this.im;return new x$(h$(e)*Math.cos(t),f$(e)*Math.sin(t))},tanh:function(){const e=2*this.re,t=2*this.im,n=h$(e)+Math.cos(t);return new x$(f$(e)/n,Math.sin(t)/n)},coth:function(){const e=2*this.re,t=2*this.im,n=h$(e)-Math.cos(t);return new x$(f$(e)/n,-Math.sin(t)/n)},csch:function(){const e=this.re,t=this.im,n=Math.cos(2*t)-h$(2*e);return new x$(-2*f$(e)*Math.cos(t)/n,2*h$(e)*Math.sin(t)/n)},sech:function(){const e=this.re,t=this.im,n=Math.cos(2*t)+h$(2*e);return new x$(2*h$(e)*Math.cos(t)/n,-2*f$(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 x$((i*r-t*t)/o,(t*r+i*t)/o):new x$(-1!==e?e/0:0,0!==t?t/0:0),a=s.re;return s.re=y$(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 x$(0,Math.PI/2);const n=e*e+t*t;return 0!==n?new x$(e/n,-t/n).atanh():new x$(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 x$(0!==e?Math.log(e+Math.sqrt(e*e+1)):1/0,0);const n=e*e+t*t;return 0!==n?new x$(e/n,-t/n).asinh():new x$(0!==e?e/0:0,0!==t?-t/0:0).asinh()},asech:function(){const e=this.re,t=this.im;if(this.isZero())return x$.INFINITY;const n=e*e+t*t;return 0!==n?new x$(e/n,-t/n).acosh():new x$(0!==e?e/0:0,0!==t?-t/0:0).acosh()},inverse:function(){if(this.isZero())return x$.INFINITY;if(this.isInfinite())return x$.ZERO;const e=this.re,t=this.im,n=e*e+t*t;return new x$(e/n,-t/n)},conjugate:function(){return new x$(this.re,-this.im)},neg:function(){return new x$(-this.re,-this.im)},ceil:function(e){return e=Math.pow(10,e||0),new x$(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)},floor:function(e){return e=Math.pow(10,e||0),new x$(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)},round:function(e){return e=Math.pow(10,e||0),new x$(Math.round(this.re*e)/e,Math.round(this.im*e)/e)},equals:function(e,t){const n=b$(e,t);return Math.abs(n.re-this.re)<=x$.EPSILON&&Math.abs(n.im-this.im)<=x$.EPSILON},clone:function(){return new x$(this.re,this.im)},toString:function(){let e=this.re,t=this.im,n="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)<x$.EPSILON&&(e=0),Math.abs(t)<x$.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()}},x$.ZERO=new x$(0,0),x$.ONE=new x$(1,0),x$.I=new x$(0,1),x$.PI=new x$(Math.PI,0),x$.E=new x$(Math.E,0),x$.INFINITY=new x$(1/0,1/0),x$.NAN=new x$(NaN,NaN),x$.EPSILON=1e-15;var E$=EF("Complex",[],function(){return x$.prototype.type="Complex",x$.prototype.isComplex=!0,x$.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},x$.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},x$.prototype.format=function(e){var t=this.im,n=this.re,r=zP(this.re,e),i=zP(this.im,e),o=Bz(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"},x$.fromPolar=function(e){switch(arguments.length){case 1:var t=arguments[0];if("object"===w$(t))return x$(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(Bz(n)){if(jz(r)&&r.hasBase("ANGLE")&&(r=r.toNumber("rad")),Bz(r))return new x$({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")}},x$.prototype.valueOf=x$.prototype.toString,x$.fromJSON=function(e){return new x$(e)},x$.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},x$},{isClass:!0}),M$={s:1,n:0,d:1};function S$(e,t){if(isNaN(e=parseInt(e,10)))throw _$();return e*t}function C$(e,t){if(0===t)throw O$();var n=Object.create(T$.prototype);n.s=e<0?-1:1;var r=k$(e=e<0?-e:e,t);return n.n=e/r,n.d=t/r,n}function N$(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 A$=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 R$()}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 _$();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 _$();if("-"===p[d]?(o=-1,d++):"+"===p[d]&&d++,p.length===d+1?a=S$(p[d++],o):"."===p[d+1]||"."===p[d]?("."!==p[d]&&(s=S$(p[d++],o)),(++d+1===p.length||"("===p[d+1]&&")"===p[d+3]||"'"===p[d+1]&&"'"===p[d+3])&&(a=S$(p[d],o),c=Math.pow(10,p[d].length),d++),("("===p[d]&&")"===p[d+2]||"'"===p[d]&&"'"===p[d+2])&&(l=S$(p[d+1],o),u=Math.pow(10,p[d+1].length)-1,d+=3)):"/"===p[d+1]||":"===p[d+1]?(a=S$(p[d],o),c=S$(p[d+2],1),d+=3):"/"===p[d+3]&&" "===p[d+1]&&(s=S$(p[d],o),a=S$(p[d+2],o),c=S$(p[d+4],1),d+=5),p.length<=d){o=r=l+(i=c*u)*s+u*a;break}default:throw _$()}if(0===i)throw O$();M$.s=o<0?-1:1,M$.n=Math.abs(r),M$.d=Math.abs(i)};function k$(e,t){if(!e)return t;if(!t)return e;for(;;){if(!(e%=t))return t;if(!(t%=e))return e}}function T$(e,t){if(A$(e,t),!(this instanceof T$))return C$(M$.s*M$.n,M$.d);e=k$(M$.d,M$.n),this.s=M$.s,this.n=M$.n/e,this.d=M$.d/e}var O$=function(){return new Error("Division by Zero")},_$=function(){return new Error("Invalid argument")},R$=function(){return new Error("Parameters must be integer")};T$.prototype={s:1,n:0,d:1,abs:function(){return C$(this.n,this.d)},neg:function(){return C$(-this.s*this.n,this.d)},add:function(e,t){return A$(e,t),C$(this.s*this.n*M$.d+M$.s*this.d*M$.n,this.d*M$.d)},sub:function(e,t){return A$(e,t),C$(this.s*this.n*M$.d-M$.s*this.d*M$.n,this.d*M$.d)},mul:function(e,t){return A$(e,t),C$(this.s*M$.s*this.n*M$.n,this.d*M$.d)},div:function(e,t){return A$(e,t),C$(this.s*M$.s*this.n*M$.d,this.d*M$.n)},clone:function(){return C$(this.s*this.n,this.d)},mod:function(e,t){if(isNaN(this.n)||isNaN(this.d))return new T$(NaN);if(void 0===e)return C$(this.s*this.n%this.d,1);if(A$(e,t),0===M$.n&&0===this.d)throw O$();return C$(this.s*(M$.d*this.n)%(M$.n*this.d),M$.d*this.d)},gcd:function(e,t){return A$(e,t),C$(k$(M$.n,this.n)*k$(M$.d,this.d),M$.d*this.d)},lcm:function(e,t){return A$(e,t),0===M$.n&&0===this.n?C$(0,1):C$(M$.n*this.n,k$(M$.n,this.n)*k$(M$.d,this.d))},ceil:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new T$(NaN):C$(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 T$(NaN):C$(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 T$(NaN):C$(Math.round(e*this.s*this.n/this.d),e)},roundTo:function(e,t){return A$(e,t),C$(this.s*Math.round(this.n*M$.d/(this.d*M$.n))*M$.n,M$.d)},inverse:function(){return C$(this.s*this.d,this.n)},pow:function(e,t){if(A$(e,t),1===M$.d)return M$.s<0?C$(Math.pow(this.s*this.d,M$.n),Math.pow(this.n,M$.n)):C$(Math.pow(this.s*this.n,M$.n),Math.pow(this.d,M$.n));if(this.s<0)return null;var n=N$(this.n),r=N$(this.d),i=1,o=1;for(var s in n)if("1"!==s){if("0"===s){i=0;break}if(n[s]*=M$.n,n[s]%M$.d!==0)return null;n[s]/=M$.d,i*=Math.pow(s,n[s])}for(var s in r)if("1"!==s){if(r[s]*=M$.n,r[s]%M$.d!==0)return null;r[s]/=M$.d,o*=Math.pow(s,r[s])}return M$.s<0?C$(o,i):C$(i,o)},equals:function(e,t){return A$(e,t),this.s*this.n*M$.d===M$.s*M$.n*this.d},compare:function(e,t){A$(e,t);var n=this.s*this.n*M$.d-M$.s*M$.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=C$(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 A$(e,t),!(!(M$.n*this.d)||this.n*M$.d%(M$.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 D$=EF("Fraction",[],function(){return T$.prototype.type="Fraction",T$.prototype.isFraction=!0,T$.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},T$.fromJSON=function(e){return new T$(e)},T$},{isClass:!0}),I$=EF("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(zz(t))t=t.toNumber();else if("number"!=typeof t)throw new TypeError("Parameter start must be a number");if(o)if(zz(n))n=n.toNumber();else if("number"!=typeof n)throw new TypeError("Parameter end must be a number");if(s)if(zz(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 _P(n)===_P(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=zP(this.start,e);return 1!==this.step&&(t+=":"+zP(this.step,e)),t+=":"+zP(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}),L$=EF("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}),B$=EF("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&&!$z(t))throw new Error("Invalid datatype: "+t);if(Uz(e))"DenseMatrix"===e.type?(this._data=EP(e._data),this._size=EP(e._size),this._datatype=t||e._datatype):(this._data=e.toArray(),this._size=e.size(),this._datatype=t||e._datatype);else if(e&&Hz(e.data)&&Hz(e.size))this._data=e.data,this._size=e.size,lF(this._data,this._size),this._datatype=t||e.datatype;else if(Hz(e))this._data=a(e),this._size=sF(this._data),lF(this._data,this._size),this._datatype=t;else{if(e)throw new TypeError("Unsupported type of data ("+xP(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 cF(t,e.length),e[t]}).valueOf():s.map(function(o){return cF(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){cF(t),e[t]=n[r[0]]}):a.forEach(function(s,a){cF(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;Hz(r);)r=r[0];return r}return e._size=t.slice(0),e._data=uF(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];Hz(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 wF(this._data,xP)},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(!Gz(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 iF(o.length,e._size.length);for(var s=t.min(),a=t.max(),l=0,c=e._size.length;l<c;l++)cF(s[l],e._size[l]),cF(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();Uz(n)?(o=n.size(),n=n.valueOf()):o=sF(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 iF(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=mF(n,a.length,u,o)}if(!SP(a,o))throw new iF(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(!Hz(e))throw new TypeError("Array expected");if(e.length!==this._size.length)throw new iF(e.length,this._size.length);for(var t=0;t<e.length;t++)cF(e[t],this._size[t]);for(var n=this._data,r=0,i=e.length;r<i;r++){var o=e[r];cF(o,n.length),n=n[o]}return n},n.prototype.set=function(e,t,n){if(!Hz(e))throw new TypeError("Array expected");if(e.length<this._size.length)throw new iF(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++)cF(o=e[r],l.length),l=l[o];return cF(o=e[e.length-1],l.length),l[o]=t,this},n.prototype.resize=function(e,t,n){if(!qz(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=pF(n._data,e),n._size=e.slice(0),n},n.prototype.clone=function(){return new n({data:EP(this._data),size:EP(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 Hz(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?wF(r,xP):void 0)},n.prototype.forEach=function(e){var t=this;!function n(r,i){Hz(r)?r.forEach(function(e,t){n(e,i.concat(t))}):e(r,i,t)}(this._data,[])},n.prototype.toArray=function(){return EP(this._data)},n.prototype.valueOf=function(){return this._data},n.prototype.format=function(e){return tF(this._data,e)},n.prototype.toString=function(){return tF(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(zz(e)&&(e=e.toNumber()),!Bz(e)||!OP(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(!Hz(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(zz(e)&&(e=e.toNumber()),!Bz(e)||!OP(e)||e<1)throw new Error("Size values must be positive integers");return e}),r){if(zz(r)&&(r=r.toNumber()),!Bz(r)||!OP(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(Hz(t)){if(t.length!==u)throw new Error("Invalid value array length");o=function(e){return t[e]}}else if(Uz(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=zz(o(0))?o(0).mul(0):0);var p=[];if(e.length>0){p=uF(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(!(Bz(e)&&OP(e)&&Bz(t)&&OP(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 cF(e,this._size[0]),cF(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}),z$="clone",P$=EF(z$,["typed"],function(e){return(0,e.typed)(z$,{any:EP})});function F$(e){for(var t=0;t<e.length;t++)if(qz(e[t]))return!0;return!1}function j$(e,t){Uz(e)&&(e=e.valueOf());for(var n=0,r=e.length;n<r;n++){var i=e[n];Array.isArray(i)?j$(i,t):t(i)}}function $$(e,t,n){return e&&"function"==typeof e.map?e.map(function(e){return $$(e,t)}):t(e)}function H$(e,t,n){var r=Array.isArray(e)?sF(e):e.size();if(t<0||t>=r.length)throw new oF(t,r.length);return Uz(e)?e.create(U$(e.valueOf(),t,n)):U$(e,t,n)}function U$(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]=U$(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]=U$(e[r],t-1,n);return i}function q$(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 V$="isInteger",W$=EF(V$,["typed"],function(e){return(0,e.typed)(V$,{number:OP,BigNumber:function(e){return e.isInt()},Fraction:function(e){return 1===e.d&&isFinite(e.n)},"Array | Matrix":function(e){return $$(e,this)}})}),K$="number",G$="number, number";function J$(e){return Math.abs(e)}function Y$(e,t){return e+t}function Z$(e,t){return e*t}function X$(e){return-e}function Q$(e){return e}function eH(e){return LP(e)}function tH(e){return Math.ceil(e)}function nH(e){return e*e*e}function rH(e){return Math.exp(e)}function iH(e){return BP(e)}function oH(e,t){if(!OP(e)||!OP(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 sH(e,t){if(!OP(e)||!OP(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 aH(e){return Math.log(e)}function lH(e){return DP(e)}function cH(e){return RP(e)}function uH(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 dH(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 pH(e){return _P(e)}function hH(e){return e*e}function fH(e,t){var n,r,i,o=0,s=1,a=1,l=0;if(!OP(e)||!OP(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 mH(e,t){return e*e<1&&t===1/0||e*e>1&&t===-1/0?0:Math.pow(e,t)}function gH(e){return parseFloat(FP(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0))}J$.signature=K$,Y$.signature=G$,Z$.signature=G$,X$.signature=K$,Q$.signature=K$,eH.signature=K$,tH.signature=K$,nH.signature=K$,rH.signature=K$,iH.signature=K$,oH.signature=G$,sH.signature=G$,aH.signature=K$,lH.signature=K$,cH.signature=K$,uH.signature=G$,dH.signature=G$,pH.signature=K$,hH.signature=K$,fH.signature=G$,mH.signature=G$,gH.signature=G$;var yH="number, number";function vH(e,t){if(!OP(e)||!OP(t))throw new Error("Integers expected in function bitAnd");return e&t}function bH(e){if(!OP(e))throw new Error("Integer expected in function bitNot");return~e}function xH(e,t){if(!OP(e)||!OP(t))throw new Error("Integers expected in function bitOr");return e|t}function wH(e,t){if(!OP(e)||!OP(t))throw new Error("Integers expected in function bitXor");return e^t}function EH(e,t){if(!OP(e)||!OP(t))throw new Error("Integers expected in function leftShift");return e<<t}function MH(e,t){if(!OP(e)||!OP(t))throw new Error("Integers expected in function rightArithShift");return e>>t}function SH(e,t){if(!OP(e)||!OP(t))throw new Error("Integers expected in function rightLogShift");return e>>>t}function CH(e,t){if(t<e)return 1;if(t===e)return t;var n=t+e>>1;return CH(e,n)*CH(n+1,t)}function NH(e,t){if(!OP(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(!OP(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?CH(n+1,e)/CH(1,t):CH(t+1,e)/CH(1,n)}vH.signature=yH,bH.signature="number",xH.signature=yH,wH.signature=yH,EH.signature=yH,MH.signature=yH,SH.signature=yH,NH.signature="number, number";var AH=Math.PI,kH=2*Math.PI,TH=Math.E,OH="number, number";function _H(e){return!e}function RH(e,t){return!(!e&&!t)}function DH(e,t){return!!e!=!!t}function IH(e,t){return!(!e||!t)}function LH(e){var t;if(OP(e))return e<=0?isFinite(e)?1/0:NaN:e>171?1/0:CH(1,e-1);if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*LH(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=zH[0];for(var s=1;s<zH.length;++s)t+=zH[s]/(e+s);var a=e+BH+.5;return Math.sqrt(2*Math.PI)*Math.pow(a,e+.5)*Math.exp(-a)*t}_H.signature="number",RH.signature=OH,DH.signature=OH,IH.signature=OH,LH.signature="number";var BH=4.7421875,zH=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],PH="number";function FH(e){return VP(e)}function jH(e){return Math.atan(1/e)}function $H(e){return isFinite(e)?(Math.log((e+1)/e)+Math.log(e/(e-1)))/2:0}function HH(e){return Math.asin(1/e)}function UH(e){var t=1/e;return Math.log(t+Math.sqrt(t*t+1))}function qH(e){return Math.acos(1/e)}function VH(e){var t=1/e,n=Math.sqrt(t*t-1);return Math.log(n+t)}function WH(e){return WP(e)}function KH(e){return KP(e)}function GH(e){return 1/Math.tan(e)}function JH(e){var t=Math.exp(2*e);return(t+1)/(t-1)}function YH(e){return 1/Math.sin(e)}function ZH(e){return 0===e?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*_P(e)}function XH(e){return 1/Math.cos(e)}function QH(e){return 2/(Math.exp(e)+Math.exp(-e))}function eU(e){return JP(e)}FH.signature=PH,jH.signature=PH,$H.signature=PH,HH.signature=PH,UH.signature=PH,qH.signature=PH,VH.signature=PH,WH.signature=PH,KH.signature=PH,GH.signature=PH,JH.signature=PH,YH.signature=PH,ZH.signature=PH,XH.signature=PH,QH.signature=PH,eU.signature=PH;var tU="number";function nU(e){return e<0}function rU(e){return e>0}function iU(e){return 0===e}function oU(e){return Number.isNaN(e)}nU.signature=tU,rU.signature=tU,iU.signature=tU,oU.signature=tU;var sU="isNegative",aU=EF(sU,["typed"],function(e){return(0,e.typed)(sU,{number:nU,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 $$(e,this)}})}),lU="isNumeric",cU=EF(lU,["typed"],function(e){return(0,e.typed)(lU,{"number | BigNumber | Fraction | boolean":function(){return!0},"Complex | Unit | string | null | undefined | Node":function(){return!1},"Array | Matrix":function(e){return $$(e,this)}})}),uU="hasNumericValue",dU=EF(uU,["typed","isNumeric"],function(e){var t=e.typed,n=e.isNumeric;return t(uU,{string:function(e){return e.trim().length>0&&!isNaN(Number(e))},any:function(e){return n(e)}})}),pU="isPositive",hU=EF(pU,["typed"],function(e){return(0,e.typed)(pU,{number:rU,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 $$(e,this)}})}),fU="isZero",mU=EF(fU,["typed"],function(e){return(0,e.typed)(fU,{number:iU,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 $$(e,this)}})}),gU="isNaN",yU=EF(gU,["typed"],function(e){return(0,e.typed)(gU,{number:oU,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 $$(e,Number.isNaN)}})}),vU="typeOf",bU=EF(vU,["typed"],function(e){return(0,e.typed)(vU,{any:xP})});function xU(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 wU="equalScalar",EU=EF(wU,["typed","config"],function(e){var t=e.typed,n=e.config;return t(wU,{"boolean, boolean":function(e,t){return e===t},"number, number":function(e,t){return qP(e,t,n.epsilon)},"BigNumber, BigNumber":function(e,t){return e.eq(t)||xU(e,t,n.epsilon)},"Fraction, Fraction":function(e,t){return e.equals(t)},"Complex, Complex":function(e,t){return function(e,t,n){return qP(e.re,t.re,n)&&qP(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)}})});EF(wU,["typed","config"],function(e){var t=e.typed,n=e.config;return t(wU,{"number, number":function(e,t){return qP(e,t,n.epsilon)}})});var MU=EF("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&&!$z(t))throw new Error("Invalid datatype: "+t);if(Uz(e))!function(e,t,n){"SparseMatrix"===t.type?(e._values=t._values?EP(t._values):void 0,e._index=EP(t._index),e._ptr=EP(t._ptr),e._size=EP(t._size),e._datatype=n||t._datatype):o(e,t.valueOf(),n||t._datatype)}(this,e,t);else if(e&&Hz(e.index)&&Hz(e.ptr)&&Hz(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(Hz(e))o(this,e,t);else{if(e)throw new TypeError("Unsupported type of data ("+xP(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($z(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(Hz(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;$z(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?EP(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 wF(this._values,xP)},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(!Gz(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 iF(a.length,e._size.length);var l=t.min(),c=t.max();for(n=0,r=e._size.length;n<r;n++)cF(l[n],e._size[n]),cF(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();Uz(n)?(i=n.size(),n=n.toArray()):i=sF(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 iF(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=mF(n,o.length,l,i)}if(!SP(o,i))throw new iF(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(!Hz(e))throw new TypeError("Array expected");if(e.length!==this._size.length)throw new iF(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];cF(t,this._size[0]),cF(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(!Hz(e))throw new TypeError("Array expected");if(e.length!==this._size.length)throw new iF(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;$z(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]),cF(o,u),cF(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(!qz(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(!Bz(e)||!OP(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+tF(r)+")")}),l(n?this.clone():this,r[0],r[1],t)},i.prototype.reshape=function(e,t){if(!Hz(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(!Bz(t)||!OP(t)||t<0)throw new TypeError("Invalid size, must contain positive integers (size: "+tF(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?EP(this._values):void 0,index:EP(this._index),ptr:EP(this._ptr),size:EP(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;$z(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 x=e._index[b];x>=r&&x<=o&&m(e._values[b],x-r,g-s)}else{for(var w={},E=y;E<v;E++){w[e._index[E]]=e._values[E]}for(var M=r;M<=o;M++){m(M in w?w[M]:0,M-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 ["+tF(t,e)+" x "+tF(n,e)+"] density: "+tF(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 ("+tF(this._index[l],e)+", "+tF(o,e)+") ==> "+(this._values?tF(this._values[l],e):"X")}return i},i.prototype.toString=function(){return tF(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(zz(e)&&(e=e.toNumber()),!Bz(e)||!OP(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(!Hz(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(zz(e)&&(e=e.toNumber()),!Bz(e)||!OP(e)||e<1)throw new Error("Size values must be positive integers");return e}),o){if(zz(o)&&(o=o.toNumber()),!Bz(o)||!OP(o))throw new TypeError("The parameter k must be an integer number")}else o=0;var l=n,c=0;$z(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(Hz(r)){if(r.length!==m)throw new Error("Invalid value array length");u=function(e){return r[e]}}else if(Uz(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=[],x=0;x<f;x++){b.push(y.length);var w=x-d;if(w>=0&&w<m){var E=u(w);l(E,c)||(v.push(w+p),y.push(E))}}return b.push(y.length),new i({values:y,index:v,ptr:b,size:[h,f]})},i.prototype.swapRows=function(e,t){if(!(Bz(e)&&OP(e)&&Bz(t)&&OP(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 cF(e,this._size[0]),cF(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}),SU=EF("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 $$(e,this)}});return t.fromJSON=function(e){return parseFloat(e.value)},t}),CU="string",NU=EF(CU,["typed"],function(e){return(0,e.typed)(CU,{"":function(){return""},number:zP,null:function(e){return"null"},boolean:function(e){return e+""},string:function(e){return e},"Array | Matrix":function(e){return $$(e,this)},any:function(e){return String(e)}})}),AU="boolean",kU=EF(AU,["typed"],function(e){return(0,e.typed)(AU,{"":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 $$(e,this)}})}),TU=EF("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 $$(e,this)}})}),OU=EF("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 $$(e,this)}})}),_U=EF("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 $$(e,this)}})}),RU="matrix",DU=EF(RU,["typed","Matrix","DenseMatrix","SparseMatrix"],function(e){var t=e.typed;e.Matrix;var n=e.DenseMatrix,r=e.SparseMatrix;return t(RU,{"":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)+".")}}),IU="splitUnit",LU=EF(IU,["typed"],function(e){return(0,e.typed)(IU,{"Unit, Array":function(e,t){return e.splitUnit(t)}})}),BU="unaryMinus",zU=EF(BU,["typed"],function(e){return(0,e.typed)(BU,{number:X$,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 $$(e,this)}})}),PU="unaryPlus",FU=EF(PU,["typed","config","BigNumber"],function(e){var t=e.typed,n=e.config,r=e.BigNumber;return t(PU,{number:Q$,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 $$(e,this)},"boolean | string":function(e){return"BigNumber"===n.number?new r(+e):+e}})}),jU=EF("abs",["typed"],function(e){return(0,e.typed)("abs",{number:J$,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},Fraction:function(e){return e.abs()},"Array | Matrix":function(e){return $$(e,this)},Unit:function(e){return e.abs()}})}),$U="apply",HU=EF($U,["typed","isInteger"],function(e){var t=e.typed,n=e.isInteger;return t($U,{"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)?sF(e):e.size();if(t<0||t>=i.length)throw new oF(t,i.length);return Uz(e)?e.create(UU(e.valueOf(),t,r)):UU(e,t,r)}})});function UU(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]=UU(o[r],t-1,n);return i}return n(e)}for(i=[],r=0;r<e.length;r++)i[r]=UU(e[r],t-1,n);return i}var qU="addScalar",VU=EF(qU,["typed"],function(e){return(0,e.typed)(qU,{"number, number":Y$,"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}})}),WU="cbrt",KU=EF(WU,["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(WU,{number:eH,Complex:c,"Complex, boolean":c,BigNumber:function(e){return e.cbrt()},Unit:function(e){if(e.value&&Pz(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=zz(e.value)?new a(1).div(3):Fz(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 $$(e,this)}});function c(e,n){var r=e.arg()/3,i=e.abs(),a=new s(eH(i),0).mul(new s(0,r).exp());if(n){var l=[a,new s(eH(i),0).mul(new s(0,r+2*Math.PI/3).exp()),new s(eH(i),0).mul(new s(0,r-2*Math.PI/3).exp())];return"Array"===t.matrix?l:o(l)}return a}}),GU=EF("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=[],x=0;x<h;x++){b[x]=v.length;for(var w=l[x],E=l[x+1],M=w;M<E;M++){var S=a[M],C=o?g(r,s[M]):g(s[M],r);f(C,m)||(v.push(S),y.push(C))}}return b[h]=v.length,e.createSparseMatrix({values:y,index:v,ptr:b,size:[p,h],datatype:d})}}),JU=EF("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:EP(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 YU(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 ZU(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 ZU(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 ZU(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 XU=EF("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=GU({typed:t,equalScalar:o}),a=JU({typed:t});return t("ceil",{number:function(e){return qP(e,r(e),n.epsilon)?r(e):tH(e)},"number, number":function(e,t){if(qP(e,r(e,t),n.epsilon))return r(e,t);var i=YU("".concat(e,"e").split("e"),2),o=i[0],s=i[1],a=Math.ceil(Number("".concat(o,"e").concat(Number(s)+t))),l=YU("".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 xU(e,r(e),n.epsilon)?r(e):e.ceil()},"BigNumber, BigNumber":function(e,t){return xU(e,r(e,t),n.epsilon)?r(e,t):e.toDecimalPlaces(t.toNumber(),d$.ROUND_CEIL)},Fraction:function(e){return e.ceil()},"Fraction, number":function(e,t){return e.ceil(t)},"Array | Matrix":function(e){return $$(e,this)},"Array | Matrix, number":function(e,t){var n=this;return $$(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()}})}),QU="cube",eq=EF(QU,["typed"],function(e){return(0,e.typed)(QU,{number:nH,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 $$(e,this)},Unit:function(e){return e.pow(3)}})}),tq=EF("exp",["typed"],function(e){return(0,e.typed)("exp",{number:rH,Complex:function(e){return e.exp()},BigNumber:function(e){return e.exp()},"Array | Matrix":function(e){return $$(e,this)}})}),nq="expm1",rq=EF(nq,["typed","Complex"],function(e){var t=e.typed,n=e.Complex;return t(nq,{number:iH,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 $$(e,this)}})}),iq=EF("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=JU({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 $$(e,this)},"Array | Matrix, number | BigNumber":function(e,t){var n=this;return $$(e,function(e){return n(e,t)})},"number | Complex | BigNumber, Array":function(e,t){return s(r(t),e,this,!0).valueOf()}})});function oq(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 sq(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 sq(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 sq(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 aq=EF("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=GU({typed:t,equalScalar:o}),a=JU({typed:t});return t("floor",{number:function(e){return qP(e,r(e),n.epsilon)?r(e):Math.floor(e)},"number, number":function(e,t){if(qP(e,r(e,t),n.epsilon))return r(e,t);var i=oq("".concat(e,"e").split("e"),2),o=i[0],s=i[1],a=Math.floor(Number("".concat(o,"e").concat(Number(s)+t))),l=oq("".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 xU(e,r(e),n.epsilon)?r(e):e.floor()},"BigNumber, BigNumber":function(e,t){return xU(e,r(e,t),n.epsilon)?r(e,t):e.toDecimalPlaces(t.toNumber(),d$.ROUND_FLOOR)},Fraction:function(e){return e.floor()},"Fraction, number":function(e,t){return e.floor(t)},"Array | Matrix":function(e){return $$(e,this)},"Array | Matrix, number":function(e,t){var n=this;return $$(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()}})}),lq=EF("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 iF(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 x=[],w=[];for(f=0;f<g;f++){for(var E=f+1,M=u[f],S=u[f+1],C=M;C<S;C++)x[h=c[C]]=i?v(l[C],o[h][f]):v(o[h][f],l[C]),w[h]=E;for(h=0;h<m;h++)w[h]===E?b[h][f]=x[h]:b[h][f]=o[h][f]}return e.createDenseMatrix({data:b,size:[m,g],datatype:y})}}),cq=EF("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 iF(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,x=i;"string"==typeof c&&c===f&&(m=c,v=t.find(n,[m,m]),b=t.convert(0,m),x=t.find(i,[m,m]));var w,E,M,S,C,N=o&&u?[]:void 0,A=[],k=[],T=o&&u?[]:void 0,O=o&&u?[]:void 0,_=[],R=[];for(E=0;E<y;E++){k[E]=A.length;var D=E+1;for(S=a[E],C=a[E+1],M=S;M<C;M++)w=s[M],A.push(w),_[w]=D,T&&(T[w]=o[M]);for(S=p[E],C=p[E+1],M=S;M<C;M++)if(_[w=d[M]]===D){if(T){var I=x(T[w],u[M]);v(I,b)?_[w]=null:T[w]=I}}else A.push(w),R[w]=D,O&&(O[w]=u[M]);if(T&&O)for(M=k[E];M<A.length;)_[w=A[M]]===D?(N[M]=T[w],M++):R[w]===D?(N[M]=O[w],M++):A.splice(M,1)}return k[y]=A.length,e.createSparseMatrix({values:N,index:A,ptr:k,size:[g,y],datatype:m})}}),uq=EF("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,x=l[v],w=l[v+1],E=x;E<w;E++){var M=a[E];g[M]=s[E],y[M]=b}for(var S=0;S<p;S++)0===v&&(m[S]=[]),y[S]===b?m[S][v]=o?f(r,g[S]):f(g[S],r):m[S][v]=r}return new n({data:m,size:[p,h],datatype:d})}}),dq=EF("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 iF(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}}),pq=EF("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=lq({typed:t}),a=cq({typed:t,equalScalar:r}),l=uq({typed:t,DenseMatrix:o}),c=dq({typed:t}),u=JU({typed:t});return t("gcd",{"number, number":oH,"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}})}),hq=EF("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 iF(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 x=[],w=[],E=[],M=0;M<g;M++){E[M]=w.length;for(var S=d[M],C=d[M+1],N=S;N<C;N++){var A=u[N],k=o?b(c[N],s[A][M]):b(s[A][M],c[N]);y(k,v)||(w.push(A),x.push(k))}}return E[g]=w.length,r.createSparseMatrix({values:x,index:w,ptr:E,size:[m,g],datatype:f})}}),fq=EF("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 iF(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=[],x=y?[]:void 0,w=[],E=[],M=0;M<h;M++){b[M]=v.length;var S=M+1;if(q$(e,M,w,x,E,S,v,g),q$(r,M,w,x,E,S,v,g),x)for(var C=b[M];C<v.length;){var N=v[C];if(E[N]===S){var A=x[N];f(A,m)?v.splice(C,1):(y.push(A),C++)}else v.splice(C,1)}else for(var k=b[M];k<v.length;){E[v[k]]!==S?v.splice(k,1):k++}}return b[h]=v.length,e.createSparseMatrix({values:y,index:v,ptr:b,size:[p,h],datatype:d})}}),mq=EF("lcm",["typed","matrix","equalScalar"],function(e){var t=e.typed,n=e.matrix,r=e.equalScalar,i=hq({typed:t,equalScalar:r}),o=fq({typed:t,equalScalar:r}),s=GU({typed:t,equalScalar:r}),a=dq({typed:t}),l=JU({typed:t});return t("lcm",{"number, number":sH,"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}})}),gq="log10",yq=EF(gq,["typed","config","Complex"],function(e){var t=e.typed,n=e.config,r=e.Complex;return t(gq,{number:function(e){return e>=0||n.predictable?lH(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 $$(e,this)}})}),vq="log2",bq=EF(vq,["typed","config","Complex"],function(e){var t=e.typed,n=e.config,r=e.Complex;return t(vq,{number:function(e){return e>=0||n.predictable?cH(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 $$(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)}}),xq=EF("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 iF(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 x=[],w=[],E=0;E<m;E++){for(var M=E+1,S=u[E],C=u[E+1],N=S;N<C;N++){var A=c[N];x[A]=i?y(l[N],o[A][E]):y(o[A][E],l[N]),w[A]=M}for(var k=0;k<f;k++)w[k]===M?v[k][E]=x[k]:v[k][E]=i?y(g,o[k][E]):y(o[k][E],g)}return e.createDenseMatrix({data:v,size:[f,m],datatype:h})}}),wq=EF("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 iF(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,x=i;"string"==typeof c&&c===f&&(m=c,v=t.find(n,[m,m]),b=t.convert(0,m),x=t.find(i,[m,m]));var w,E,M,S,C=o&&u?[]:void 0,N=[],A=[],k=C?[]:void 0,T=C?[]:void 0,O=[],_=[];for(E=0;E<y;E++){A[E]=N.length;var R=E+1;for(M=a[E],S=a[E+1];M<S;M++)w=s[M],N.push(w),O[w]=R,k&&(k[w]=o[M]);for(M=p[E],S=p[E+1];M<S;M++)O[w=d[M]]!==R&&N.push(w),_[w]=R,T&&(T[w]=u[M]);if(C)for(M=A[E];M<N.length;){var D=O[w=N[M]],I=_[w];if(D===R||I===R){var L=x(D===R?k[w]:b,I===R?T[w]:b);v(L,b)?N.splice(M,1):(C.push(L),M++)}}}return A[y]=N.length,e.createSparseMatrix({values:C,index:N,ptr:A,size:[g,y],datatype:m})}}),Eq=EF("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,x=l[v],w=l[v+1],E=x;E<w;E++){var M=a[E];g[M]=s[E],y[M]=b}for(var S=0;S<p;S++)0===v&&(m[S]=[]),y[S]===b?m[S][v]=o?f(r,g[S]):f(g[S],r):m[S][v]=o?f(r,0):f(0,r)}return new n({data:m,size:[p,h],datatype:d})}}),Mq=EF("mod",["typed","matrix","equalScalar","DenseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.equalScalar,i=e.DenseMatrix,o=hq({typed:t,equalScalar:r}),s=xq({typed:t}),a=wq({typed:t,equalScalar:r}),l=GU({typed:t,equalScalar:r}),c=Eq({typed:t,DenseMatrix:i}),u=dq({typed:t}),d=JU({typed:t});return t("mod",{"number, number":uH,"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()}})}),Sq=EF("multiplyScalar",["typed"],function(e){return(0,e.typed)("multiplyScalar",{"number, number":Z$,"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)}})}),Cq="multiply",Nq=EF(Cq,["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=GU({typed:t,equalScalar:o}),l=JU({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,x=o,w=0;c&&p&&c===p&&"string"==typeof c&&(u=c,v=t.find(r,[u,u]),b=t.find(i,[u,u]),x=t.find(o,[u,u]),w=t.convert(0,u));var E=[],M=[];y[0]=0;for(var S=0;S<f;S++){var C=d[S];if(!x(C,w))for(var N=l[S],A=l[S+1],k=N;k<A;k++){var T=a[k];M[T]?E[T]=v(E[T],b(C,s[k])):(M[T]=!0,g.push(T),E[T]=b(C,s[k]))}}for(var O=g.length,_=0;_<O;_++){var R=g[_];m[_]=E[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 x=0;x<f;x++){for(var w=g(b[0],c[0][x]),E=1;E<h;E++)w=m(w,g(b[E],c[E][x]));y[v][x]=w}}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,x=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]),x=t.convert(0,f));for(var w=[],E=[],M=[],S=n.createSparseMatrix({values:w,index:E,ptr:M,size:[m,g],datatype:f}),C=0;C<g;C++){M[C]=E.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(_,x)||(E.push(T),w.push(_))}}return M[g]=E.length,S},"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 x=[],w=[],E=[],M=e.createSparseMatrix({values:x,index:w,ptr:E,size:[h,m],datatype:u}),S=[],C=[],N=0;N<m;N++){E[N]=w.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,w.push(D),S[D]=y(T,s[R])):S[D]=g(S[D],y(T,s[R]))}}for(var I=E[N],L=w.length,B=I;B<L;B++){var z=w[B];x[B]=S[z]}}return E[m]=w.length,M},"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,x,w,E,M,S,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(M=p[D],S=p[D+1],E=M;E<S;E++)if(N=d[E],g)for(x=l[N],w=l[N+1],b=x;b<w;b++)R[C=a[b]]!==I?(R[C]=I,k.push(C),_[C]=v(u[E],s[b])):_[C]=y(_[C],v(u[E],s[b]));else for(x=l[N],w=l[N+1],b=x;b<w;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(Cq,MP({"Array, Array":function(e,t){c(sF(e),sF(t));var r=this(n(e),n(t));return Uz(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))}),Aq="nthRoot",kq=EF(Aq,["typed","matrix","equalScalar","BigNumber"],function(e){var t=e.typed,n=e.matrix,r=e.equalScalar,i=e.BigNumber,o=lq({typed:t}),s=hq({typed:t,equalScalar:r}),a=fq({typed:t,equalScalar:r}),l=GU({typed:t,equalScalar:r}),c=dq({typed:t}),u=JU({typed:t}),d="Complex number not supported in function nthRoot. Use nthRoots instead.";return t(Aq,{number:function(e){return dH(e,2)},"number, number":dH,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))}});EF(Aq,["typed"],function(e){return(0,e.typed)(Aq,{number:dH,"number, number":dH})});var Tq="sign",Oq=EF(Tq,["typed","BigNumber","Fraction","complex"],function(e){var t=e.typed,n=e.BigNumber,r=e.complex,i=e.Fraction;return t(Tq,{number:pH,Complex:function(e){return 0===e.im?r(pH(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 $$(e,this)},Unit:function(e){return this(e.value)}})}),_q=EF("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 $$(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()}}),Rq="square",Dq=EF(Rq,["typed"],function(e){return(0,e.typed)(Rq,{number:hH,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 $$(e,this)},Unit:function(e){return e.pow(2)}})}),Iq="subtract",Lq=EF(Iq,["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=lq({typed:t}),l=xq({typed:t}),c=wq({typed:t,equalScalar:r}),u=uq({typed:t,DenseMatrix:s}),d=dq({typed:t}),p=JU({typed:t});return t(Iq,{"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 Bq(e,t),c(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return Bq(e,t),l(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return Bq(e,t),a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return Bq(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 Bq(e,t){var n=e.size(),r=t.size();if(n.length!==r.length)throw new iF(n.length,r.length)}var zq="xgcd",Pq=EF(zq,["typed","config","matrix","BigNumber"],function(e){var t=e.typed,n=e.config,r=e.matrix,i=e.BigNumber;return t(zq,{"number, number":function(e,t){var i=fH(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)}})}),Fq=EF("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 iF(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,x=i;"string"==typeof c&&c===f&&(m=c,v=t.find(n,[m,m]),b=t.convert(0,m),x=t.find(i,[m,m]));var w,E,M,S,C,N=o&&u?[]:void 0,A=[],k=[],T=N?[]:void 0,O=[];for(E=0;E<y;E++){k[E]=A.length;var _=E+1;if(T)for(S=p[E],C=p[E+1],M=S;M<C;M++)O[w=d[M]]=_,T[w]=u[M];for(S=a[E],C=a[E+1],M=S;M<C;M++)if(w=s[M],T){var R=O[w]===_?T[w]:b,D=x(o[M],R);v(D,b)||(A.push(w),N.push(D))}else A.push(w)}return k[y]=A.length,e.createSparseMatrix({values:N,index:A,ptr:k,size:[g,y],datatype:m})}}),jq="dotMultiply",$q=EF(jq,["typed","matrix","equalScalar","multiplyScalar"],function(e){var t=e.typed,n=e.matrix,r=e.equalScalar,i=e.multiplyScalar,o=hq({typed:t,equalScalar:r}),s=Fq({typed:t,equalScalar:r}),a=GU({typed:t,equalScalar:r}),l=dq({typed:t}),c=JU({typed:t});return t(jq,{"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 Hq(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 Vq(e,t,function(e,t){return e&t})}function Uq(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 qq(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()?Vq(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 Vq(e,t,n){var r,i,o,s,a,l=e.constructor,c=+(e.s<0),u=+(t.s<0);if(c){r=Wq(Uq(e));for(var d=0;d<r.length;++d)r[d]^=1}else r=Wq(e);if(u){i=Wq(Uq(t));for(var p=0;p<i.length;++p)i[p]^=1}else i=Wq(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 Wq(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 Kq(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)?Uq(t):t.eq(r)?Uq(e):e.isFinite()&&t.isFinite()?Vq(e,t,function(e,t){return e^t}):e.isFinite()||t.isFinite()?new n(e.isNegative()===t.isNegative()?1/0:-1/0):r}function Gq(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 Jq(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 Yq="bitAnd",Zq=EF(Yq,["typed","matrix","equalScalar"],function(e){var t=e.typed,n=e.matrix,r=e.equalScalar,i=hq({typed:t,equalScalar:r}),o=fq({typed:t,equalScalar:r}),s=GU({typed:t,equalScalar:r}),a=dq({typed:t}),l=JU({typed:t});return t(Yq,{"number, number":vH,"BigNumber, BigNumber":Hq,"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()}})}),Xq="bitNot",Qq=EF(Xq,["typed"],function(e){return(0,e.typed)(Xq,{number:bH,BigNumber:Uq,"Array | Matrix":function(e){return $$(e,this)}})}),eV="bitOr",tV=EF(eV,["typed","matrix","equalScalar","DenseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.equalScalar,i=e.DenseMatrix,o=lq({typed:t}),s=cq({typed:t,equalScalar:r}),a=uq({typed:t,DenseMatrix:i}),l=dq({typed:t}),c=JU({typed:t});return t(eV,{"number, number":xH,"BigNumber, BigNumber":qq,"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()}})}),nV=EF("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 iF(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=[],x=[],w=[];for(p=0;p<f;p++){var E=p+1;for(r(e,p,x,v,E),r(i,p,w,b,E),d=0;d<h;d++){var M=x[d]===E?v[d]:m,S=w[d]===E?b[d]:m;y[d][p]=g(M,S)}}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]}}}),rV="bitXor",iV=EF(rV,["typed","matrix","DenseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.DenseMatrix,i=xq({typed:t}),o=nV({typed:t,DenseMatrix:r}),s=Eq({typed:t,DenseMatrix:r}),a=dq({typed:t}),l=JU({typed:t});return t(rV,{"number, number":wH,"BigNumber, BigNumber":Kq,"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()}})}),oV=EF("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 $$(e,this)}})}),sV="conj",aV=EF(sV,["typed"],function(e){return(0,e.typed)(sV,{number:function(e){return e},BigNumber:function(e){return e},Complex:function(e){return e.conjugate()},"Array | Matrix":function(e){return $$(e,this)}})}),lV=EF("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 $$(e,this)}})}),cV=EF("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 $$(e,this)}})}),uV=EF("not",["typed"],function(e){return(0,e.typed)("not",{number:_H,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 $$(e,this)}})}),dV=EF("or",["typed","matrix","equalScalar","DenseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.equalScalar,i=e.DenseMatrix,o=xq({typed:t}),s=wq({typed:t,equalScalar:r}),a=Eq({typed:t,DenseMatrix:i}),l=dq({typed:t}),c=JU({typed:t});return t("or",{"number, number":RH,"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()}})}),pV=EF("xor",["typed","matrix","DenseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.DenseMatrix,i=xq({typed:t}),o=nV({typed:t,DenseMatrix:r}),s=Eq({typed:t,DenseMatrix:r}),a=dq({typed:t}),l=JU({typed:t});return t("xor",{"number, number":DH,"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()}})}),hV="concat",fV=EF(hV,["typed","matrix","isInteger"],function(e){var t=e.typed,n=e.matrix,r=e.isInteger;return t(hV,{"...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(Uz(c)&&(a=!0),Bz(c)||zz(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 oF(s,i+1)}else{var u=EP(c).valueOf(),d=sF(u);if(l[t]=u,i=s,s=d.length-1,t>0&&s!==i)throw new iF(i+1,s+1)}}if(0===l.length)throw new SyntaxError("At least one matrix expected");for(var p=l.shift();l.length;)p=mV(p,l.shift(),s,0);return a?n(p):p},"...string":function(e){return e.join("")}})});function mV(e,t,n,r){if(r<n){if(e.length!==t.length)throw new iF(e.length,t.length);for(var i=[],o=0;o<e.length;o++)i[o]=mV(e[o],t[o],n,r+1);return i}return e.concat(t)}var gV="column",yV=EF(gV,["typed","Index","matrix","range"],function(e){var t=e.typed,n=e.Index,r=e.matrix,i=e.range;return t(gV,{"Matrix, number":o,"Array, number":function(e,t){return o(r(EP(e)),t).valueOf()}});function o(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");cF(t,e.size()[1]);var r=i(0,e.size()[0]),o=new n(r,t);return e.subset(o)}}),vV="cross",bV=EF(vV,["typed","matrix","subtract","multiply"],function(e){var t=e.typed,n=e.matrix,r=e.subtract,i=e.multiply;return t(vV,{"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(sF(e).length,sF(t).length);e=hF(e),t=hF(t);var o=sF(e),s=sF(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}}),xV="diag",wV=EF(xV,["typed","matrix","DenseMatrix","SparseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.DenseMatrix,i=e.SparseMatrix;return t(xV,{Array:function(e){return o(e,0,sF(e),null)},"Array, number":function(e,t){return o(e,t,sF(e),null)},"Array, BigNumber":function(e,t){return o(e,t.toNumber(),sF(e),null)},"Array, string":function(e,t){return o(e,0,sF(e),t)},"Array, number, string":function(e,t,n){return o(e,t,sF(e),n)},"Array, BigNumber, string":function(e,t,n){return o(e,t.toNumber(),sF(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(!OP(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(Uz(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 EV(e){return EV="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},EV(e)}function MV(e,t){return function n(){"object"!==EV(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 SV(e){return Object.keys(e.signatures||{}).reduce(function(e,t){var n=(t.match(/,/g)||[]).length+1;return Math.max(e,n)},-1)}var CV=EF("filter",["typed"],function(e){return(0,e.typed)("filter",{"Array, function":NV,"Matrix, function":function(e,t){return e.create(NV(e.toArray(),t))},"Array, RegExp":vF,"Matrix, RegExp":function(e,t){return e.create(vF(e.toArray(),t))}})});function NV(e,t){var n=SV(t);return function(e,t){if(1!==sF(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 AV="flatten",kV=EF(AV,["typed","matrix"],function(e){var t=e.typed,n=e.matrix;return t(AV,{Array:function(e){return yF(EP(e))},Matrix:function(e){var t=yF(EP(e.toArray()));return n(t)}})}),TV="forEach",OV=EF(TV,["typed"],function(e){return(0,e.typed)(TV,{"Array, function":_V,"Matrix, function":function(e,t){return e.forEach(t)}})});function _V(e,t){var n=SV(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 RV="getMatrixDataType",DV=EF(RV,["typed"],function(e){return(0,e.typed)(RV,{Array:function(e){return wF(e,xP)},Matrix:function(e){return e.getDataType()}})}),IV="identity",LV=EF(IV,["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(IV,{"":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=zz(e)||zz(t)?i:null;if(zz(e)&&(e=e.toNumber()),zz(t)&&(t=t.toNumber()),!OP(e)||e<1)throw new Error("Parameters in function identity must be positive integers");if(!OP(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=uF([],c,l),d=e<t?e:t,p=0;p<d;p++)u[p][p]=a;return u}}),BV="kron",zV=EF(BV,["typed","matrix","multiplyScalar"],function(e){var t=e.typed,n=e.matrix,r=e.multiplyScalar;return t(BV,{"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===sF(e).length&&(e=[e]),1===sF(t).length&&(t=[t]),sF(e).length>2||sF(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}}),PV=EF("map",["typed"],function(e){return(0,e.typed)("map",{"Array, function":FV,"Matrix, function":function(e,t){return e.map(t)}})});function FV(e,t){var n=SV(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 jV="diff",$V=EF(jV,["typed","matrix","subtract","number"],function(e){var t=e.typed,n=e.matrix,r=e.subtract,i=e.number;return t(jV,{"Array | Matrix":function(e){return Uz(e)?n(s(e.toArray())):s(e)},"Array | Matrix, number":function(e,t){if(!OP(t))throw new RangeError("Dimension must be a whole number");return Uz(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(Uz(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){Uz(e)&&(e=e.toArray()),Uz(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")}}),HV=EF("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){zz(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||!OP(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?uF(a,e,o):a}});function UV(){throw new Error('No "bignumber" implementation available')}function qV(){throw new Error('No "fraction" implementation available')}function VV(){throw new Error('No "matrix" implementation available')}var WV="range",KV=EF(WV,["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(WV,{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):VV():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&&UV(),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}}),GV="reshape",JV=EF(GV,["typed","isInteger","matrix"],function(e){var t=e.typed,n=e.isInteger,r=e.matrix;return t(GV,{"Matrix, Array":function(e,t){return e.reshape?e.reshape(t):r(pF(e.valueOf(),t))},"Array, Array":function(e,t){return t.forEach(function(e){if(!n(e))throw new TypeError("Invalid size for dimension: "+e)}),pF(e,t)}})});function YV(e,t,n,r){if(!(this instanceof YV))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}YV.prototype=new Error,YV.prototype.constructor=Error,YV.prototype.name="ArgumentsError",YV.prototype.isArgumentsError=!0;var ZV=EF("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 YV("resize",arguments.length,2,3);if(Uz(r)&&(r=r.valueOf()),zz(r[0])&&(r=r.map(function(e){return zz(e)?e.toNumber():e})),Uz(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 iF(t.length,1);var r=t[0];if("number"!=typeof r||!OP(r))throw new TypeError("Invalid size, must contain positive integers (size: "+tF(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 EP(e)}Array.isArray(e)||(e=[e]);var s=uF(e=EP(e),r,i);return o?n(s):s}}),XV="rotate",QV=EF(XV,["typed","multiply","rotationMatrix"],function(e){var t=e.typed,n=e.multiply,r=e.rotationMatrix;return t(XV,{"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)?sF(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))}}),eW="rotationMatrix",tW=EF(eW,["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(eW,{"":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=zz(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=zz(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)),x=p(e);return g([[i(v,m([h,h,b])),i(m([h,f,b]),m([u,y,x])),i(m([h,y,b]),m([f,x]))],[i(m([h,f,b]),m([y,x])),i(v,m([f,f,b])),i(m([f,y,b]),m([u,h,x]))],[i(m([h,y,b]),m([u,f,x])),i(m([f,y,b]),m([h,x])),i(v,m([y,y,b]))]],n)}}),nW=EF("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(EP(e)),t).valueOf()}});function o(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");cF(t,e.size()[0]);var r=i(0,e.size()[1]),o=new n(t,r);return e.subset(o)}}),rW="size",iW=EF(rW,["typed","config","?matrix"],function(e){var t=e.typed,n=e.config,r=e.matrix;return t(rW,{Matrix:function(e){return e.create(e.size())},Array:sF,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([]):VV()}})}),oW="squeeze",sW=EF(oW,["typed","matrix"],function(e){var t=e.typed,n=e.matrix;return t(oW,{Array:function(e){return hF(EP(e))},Matrix:function(e){var t=hF(e.toArray());return Array.isArray(t)?n(t):t},any:function(e){return EP(e)}})});function aW(e){return aW="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},aW(e)}function lW(e,t){if(uW(e)&&cW(e,t))return e[t];if("function"==typeof e[t]&&function(e,t){if(null==e||"function"!=typeof e[t])return!1;if(CP(e,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(e))return!1;if(CP(pW,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 cW(e,t){return!(!e||"object"!==aW(e))&&(!!CP(dW,t)||!(t in Object.prototype)&&!(t in Function.prototype))}function uW(e){return"object"===aW(e)&&e&&e.constructor===Object}var dW={length:!0,name:!0},pW={toString:!0,valueOf:!0,toLocaleString:!0},hW="subset",fW=EF(hW,["typed","matrix"],function(e){var t=e.typed,n=e.matrix;return t(hW,{"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":yW,"string, Index":mW,"Array, Index, any":function(e,t,r){return n(EP(e)).subset(t,r,void 0).valueOf()},"Array, Index, any, any":function(e,t,r,i){return n(EP(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":gW,"string, Index, string, string":gW,"Object, Index, any":vW})});function mW(e,t){if(!Gz(t))throw new TypeError("Index expected");if(1!==t.size().length)throw new iF(t.size().length,1);var n=e.length;cF(t.min()[0],n),cF(t.max()[0],n);var r=t.dimension(0),i="";return r.forEach(function(t){i+=e.charAt(t)}),i}function gW(e,t,n,r){if(!t||!0!==t.isIndex)throw new TypeError("Index expected");if(1!==t.size().length)throw new iF(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 iF(i.size()[0],n.length);var o=e.length;cF(t.min()[0]),cF(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 yW(e,t){if(1!==t.size().length)throw new iF(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 lW(e,n)}function vW(e,t,n){if(1!==t.size().length)throw new iF(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=EP(e);return function(e,t,n){if(uW(e)&&cW(e,t))return e[t]=n,n;throw new Error('No access to property "'+t+'"')}(i,r,n),i}var bW=EF("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: "+tF(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]=EP(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]=EP(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: "+tF(this._size)+")")}return t},any:function(e){return EP(e)}})}),xW="ctranspose",wW=EF(xW,["typed","transpose","conj"],function(e){var t=e.typed,n=e.transpose,r=e.conj;return t(xW,{any:function(e){return r(n(e))}})}),EW="zeros",MW=EF(EW,["typed","config","matrix","BigNumber"],function(e){var t=e.typed,n=e.config,r=e.matrix,i=e.BigNumber;return t(EW,{"":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){zz(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||!OP(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?uF(a,e,o):a}}),SW=EF("erf",["typed"],function(e){return(0,e.typed)("name",{number:function(e){var t=Math.abs(e);return t>=TW?_P(e):t<=CW?_P(e)*function(e){var t,n=e*e,r=AW[0][4]*n,i=n;for(t=0;t<3;t+=1)r=(r+AW[0][t])*n,i=(i+kW[0][t])*n;return e*(r+AW[0][3])/(i+kW[0][3])}(t):t<=4?_P(e)*(1-function(e){var t,n=AW[1][8]*e,r=e;for(t=0;t<7;t+=1)n=(n+AW[1][t])*e,r=(r+kW[1][t])*e;var i=(n+AW[1][7])/(r+kW[1][7]),o=parseInt(16*e)/16,s=(e-o)*(e+o);return Math.exp(-o*o)*Math.exp(-s)*i}(t)):_P(e)*(1-function(e){var t,n=1/(e*e),r=AW[2][5]*n,i=n;for(t=0;t<4;t+=1)r=(r+AW[2][t])*n,i=(i+kW[2][t])*n;var o=n*(r+AW[2][4])/(i+kW[2][4]);o=(NW-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 $$(e,this)}})}),CW=.46875,NW=.5641895835477563,AW=[[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]],kW=[[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]],TW=Math.pow(2,53),OW="mode",_W=EF(OW,["typed","isNaN","isNumeric"],function(e){var t=e.typed,n=e.isNaN,r=e.isNumeric;return t(OW,{"Array | Matrix":i,"...":function(e){return i(e)}});function i(e){if(0===(e=yF(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 RW(e,t,n){var r;return-1!==String(e).indexOf("Unexpected type")?(r=arguments.length>2?" (type: "+xP(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: "+xP(n)+", value: "+JSON.stringify(n)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+r)):e}var DW="prod",IW=EF(DW,["typed","config","multiplyScalar","numeric"],function(e){var t=e.typed,n=e.config,r=e.multiplyScalar,i=e.numeric;return t(DW,{"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(j$(e,function(e){try{t=void 0===t?e:r(t,e)}catch(t){throw RW(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}}),LW="format",BW=EF(LW,["typed"],function(e){return(0,e.typed)(LW,{any:tF,"any, Object | function | number":tF})});function zW(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(!OP(n))throw new Error("Value must be an integer");return n<0&&(n+=Math.pow(2,32)),"".concat(t).concat(n.toString(e))}}var PW=["typed"];function FW(e,t){return EF(e,PW,function(n){return(0,n.typed)(e,{number:zW(t)})})}var jW=FW("bin",2),$W=FW("oct",8),HW=FW("hex",16),UW="print",qW=EF(UW,["typed"],function(e){return(0,e.typed)(UW,{"string, Object | Array":VW,"string, Object | Array, number | Object":VW})});function VW(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?$z(o)?o:tF(o,n):e})}var WW=EF("to",["typed","matrix"],function(e){var t=e.typed,n=e.matrix,r=dq({typed:t}),i=JU({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()}})}),KW="isPrime",GW=EF(KW,["typed"],function(e){return(0,e.typed)(KW,{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 $$(e,this)}})}),JW=EF("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)}:UV,Fraction:r?function(e){return r(e)}:qV};return function(e,t){var n=xP(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)}}),YW="divideScalar",ZW=EF(YW,["typed","numeric"],function(e){var t=e.typed,n=e.numeric;return t(YW,{"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,xP(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,xP(e));return r.value=this(e,null===t.value?t._normalize(i):t.value),r},"Unit, Unit":function(e,t){return e.divide(t)}})}),XW=EF("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&&!OP(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:OP(t)||e>=0||n.predictable?mH(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(!OP(t)||t<0)throw new TypeError("For A^b, b must be a positive integer (value is "+t+")");var n=sF(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 QW(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 eK(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?QW(Object(n),!0).forEach(function(t){tK(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):QW(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function tK(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var nK="Number of decimals in function round must be an integer",rK="round",iK=EF(rK,["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=GU({typed:t,equalScalar:r}),l=Eq({typed:t,DenseMatrix:s}),c=JU({typed:t});return t(rK,eK(eK({},oK),{},{Complex:function(e){return e.round()},"Complex, number":function(e,t){if(t%1)throw new TypeError(nK);return e.round(t)},"Complex, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(nK);var n=t.toNumber();return e.round(n)},"number, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(nK);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(nK);return e.toDecimalPlaces(t.toNumber())},Fraction:function(e){return e.round()},"Fraction, number":function(e,t){if(t%1)throw new TypeError(nK);return e.round(t)},"Array | Matrix":function(e){return $$(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()}}))}),oK={number:gH,"number, number":function(e,t){if(!OP(t))throw new TypeError(nK);if(t<0||t>15)throw new Error("Number of decimals in function round must be in te range of 0-15");return gH(e,t)}};EF(rK,["typed"],function(e){return(0,e.typed)(rK,oK)});var sK=EF("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?aH(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 $$(e,this)},"any, any":function(e,t){return r(this(e),this(t))}})}),aK="log1p",lK=EF(aK,["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(aK,{number:function(e){return e>=-1||n.predictable?IP(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 $$(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))}}),cK="nthRoots",uK=EF(cK,["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(cK,{Complex:function(e){return i(e,2)},"Complex, number":i})}),dK="dotPow",pK=EF(dK,["typed","equalScalar","matrix","pow","DenseMatrix"],function(e){var t=e.typed,n=e.equalScalar,r=e.matrix,i=e.pow,o=e.DenseMatrix,s=xq({typed:t}),a=nV({typed:t,DenseMatrix:o}),l=GU({typed:t,equalScalar:n}),c=Eq({typed:t,DenseMatrix:o}),u=dq({typed:t}),d=JU({typed:t});return t(dK,{"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()}})}),hK="dotDivide",fK=EF(hK,["typed","matrix","equalScalar","divideScalar","DenseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.equalScalar,i=e.divideScalar,o=e.DenseMatrix,s=hq({typed:t,equalScalar:r}),a=xq({typed:t}),l=nV({typed:t,DenseMatrix:o}),c=GU({typed:t,equalScalar:r}),u=Eq({typed:t,DenseMatrix:o}),d=dq({typed:t}),p=JU({typed:t});return t(hK,{"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 mK(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: "+tF(i)+")");var o=i[0];if(o!==i[1])throw new RangeError("Matrix must be square (size: "+tF(i)+")");var s=[];if(Uz(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(Vz(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(Wz(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(Hz(n)){var y=sF(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 gK="lsolve",yK=EF(gK,["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=mK({DenseMatrix:a});return t(gK,{"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=[],x=h[m],w=h[m+1],E=x;E<w;E++){var M=p[E];M===m?y=d[E]:M>m&&(v.push(d[E]),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),C=0,N=b.length;C<N;C++){var A=b[C];n[A]=[o(n[A][0]||0,i(S,v[C]))]}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=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]})}}),vK="usolve",bK=EF(vK,["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=mK({DenseMatrix:a});return t(vK,{"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=[],x=h[m],w=h[m+1]-1;w>=x;w--){var E=p[w];E===m?y=d[w]:E<m&&(v.push(d[w]),b.push(E))}if(s(y,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var M=r(g,y),S=0,C=b.length;S<C;S++){var N=b[S];n[N]=[o(n[N][0],i(M,v[S]))]}f[m]=[M]}}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 xK(e){return function(e){if(Array.isArray(e))return wK(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 wK(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 wK(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 wK(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 EK="lsolveAll",MK=EF(EK,["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=mK({DenseMatrix:a});return t(EK,{"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=[],x=h[f],w=h[f+1],E=0,M=x;M<w;M++){var S=p[M];S===f?E=d[M]:S>f&&(v.push(d[M]),b.push(S))}if(s(E,0))if(s(y[f],0)){if(0===g){var C=xK(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],E);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=xK(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 SK(e){return function(e){if(Array.isArray(e))return CK(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 CK(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 CK(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 CK(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 NK="usolveAll",AK=EF(NK,["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=mK({DenseMatrix:a});return t(NK,{"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=[],x=h[f],w=0,E=h[f+1]-1;E>=x;E--){var M=p[E];M===f?w=d[E]:M<f&&(v.push(d[E]),b.push(M))}if(s(w,0))if(s(y[f],0)){if(0===g){var S=SK(y);S[f]=1;for(var C=0,N=b.length;C<N;C++){var A=b[C];S[A]=o(S[A],v[C])}n.push(S)}}else{if(0===g)return[];n.splice(g,1),g-=1,m-=1}else{y[f]=r(y[f],w);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=SK(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]})})}}),kK=EF("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 iF(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,x=i;"string"==typeof c&&c===f&&(m=c,v=t.find(n,[m,m]),b=t.convert(0,m),x=t.find(i,[m,m]));for(var w,E,M,S,C=[],N=[],A=[],k=[],T=[],O=0;O<y;O++){A[O]=N.length;var _=O+1;for(E=a[O],M=a[O+1],w=E;w<M;w++)T[S=s[w]]=_,k[S]=o[w],N.push(S);for(E=p[O],M=p[O+1],w=E;w<M;w++)T[S=d[w]]===_&&(k[S]=x(k[S],u[w]));for(w=A[O];w<N.length;){var R=k[S=N[w]];v(R,b)?N.splice(w,1):(C.push(R),w++)}}return A[y]=N.length,e.createSparseMatrix({values:C,index:N,ptr:A,size:[g,y],datatype:m})}}),TK="leftShift",OK=EF(TK,["typed","matrix","equalScalar","zeros","DenseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.equalScalar,i=e.zeros,o=e.DenseMatrix,s=lq({typed:t}),a=hq({typed:t,equalScalar:r}),l=kK({typed:t,equalScalar:r}),c=uq({typed:t,DenseMatrix:o}),u=GU({typed:t,equalScalar:r}),d=dq({typed:t}),p=JU({typed:t});return t(TK,{"number, number":EH,"BigNumber, BigNumber":Gq,"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()}})}),_K="rightArithShift",RK=EF(_K,["typed","matrix","equalScalar","zeros","DenseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.equalScalar,i=e.zeros,o=e.DenseMatrix,s=lq({typed:t}),a=hq({typed:t,equalScalar:r}),l=kK({typed:t,equalScalar:r}),c=uq({typed:t,DenseMatrix:o}),u=GU({typed:t,equalScalar:r}),d=dq({typed:t}),p=JU({typed:t});return t(_K,{"number, number":MH,"BigNumber, BigNumber":Jq,"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()}})}),DK="rightLogShift",IK=EF(DK,["typed","matrix","equalScalar","zeros","DenseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.equalScalar,i=e.zeros,o=e.DenseMatrix,s=lq({typed:t}),a=hq({typed:t,equalScalar:r}),l=kK({typed:t,equalScalar:r}),c=uq({typed:t,DenseMatrix:o}),u=GU({typed:t,equalScalar:r}),d=dq({typed:t}),p=JU({typed:t});return t(DK,{"number, number":SH,"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()}})}),LK=EF("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=hq({typed:t,equalScalar:r}),a=fq({typed:t,equalScalar:r}),l=GU({typed:t,equalScalar:r}),c=dq({typed:t}),u=JU({typed:t});return t("and",{"number, number":IH,"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()}})}),BK="compare",zK=EF(BK,["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=xq({typed:t}),c=wq({typed:t,equalScalar:r}),u=Eq({typed:t,DenseMatrix:a}),d=dq({typed:t}),p=JU({typed:t});return t(BK,{"boolean, boolean":function(e,t){return e===t?0:e>t?1:-1},"number, number":function(e,t){return qP(e,t,n.epsilon)?0:e>t?1:-1},"BigNumber, BigNumber":function(e,t){return xU(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()}})});EF(BK,["typed","config"],function(e){var t=e.typed,n=e.config;return t(BK,{"number, number":function(e,t){return qP(e,t,n.epsilon)?0:e>t?1:-1}})});var PK=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},FK="compareNatural",jK=EF(FK,["typed","compare"],function(e){var t=e.typed,n=e.compare,r=n.signatures["boolean,boolean"];return t(FK,{"any, any":function(e,t){var s,a=xP(e),l=xP(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:PK(a,l);if("Array"===a||"Matrix"===a||"Array"===l||"Matrix"===l)return 0!==(s=i(this,e,t))?s:PK(a,l);if(a!==l)return PK(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 PK(e,t);if("Object"===a)return function(e,t,n){var r=Object.keys(t),i=Object.keys(n);r.sort(PK),i.sort(PK);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 Wz(t)&&Wz(n)?o(e,t.toJSON().values,n.toJSON().values):Wz(t)?i(e,t.toArray(),n):Wz(n)?i(e,t,n.toArray()):Vz(t)?i(e,t.toJSON().data,n):Vz(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 $K="compareText",HK=EF($K,["typed","matrix"],function(e){var t=e.typed,n=e.matrix,r=dq({typed:t}),i=JU({typed:t});return t($K,{"any, any":rF,"DenseMatrix, DenseMatrix":function(e,t){return r(e,t,rF)},"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,rF,!1)},"any, DenseMatrix":function(e,t){return i(t,e,rF,!0)},"Array, any":function(e,t){return i(n(e),t,rF,!1).valueOf()},"any, Array":function(e,t){return i(n(t),e,rF,!0).valueOf()}})});EF($K,["typed"],function(e){return(0,e.typed)($K,{"any, any":rF})});var UK="equal",qK=EF(UK,["typed","matrix","equalScalar","DenseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.equalScalar,i=e.DenseMatrix,o=xq({typed:t}),s=nV({typed:t,DenseMatrix:i}),a=Eq({typed:t,DenseMatrix:i}),l=dq({typed:t}),c=JU({typed:t});return t(UK,{"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()}})});EF(UK,["typed","equalScalar"],function(e){var t=e.typed,n=e.equalScalar;return t(UK,{"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 VK="equalText",WK=EF(VK,["typed","compareText","isZero"],function(e){var t=e.typed,n=e.compareText,r=e.isZero;return t(VK,{"any, any":function(e,t){return r(n(e,t))}})}),KK="smaller",GK=EF(KK,["typed","config","matrix","DenseMatrix"],function(e){var t=e.typed,n=e.config,r=e.matrix,i=e.DenseMatrix,o=xq({typed:t}),s=nV({typed:t,DenseMatrix:i}),a=Eq({typed:t,DenseMatrix:i}),l=dq({typed:t}),c=JU({typed:t});return t(KK,{"boolean, boolean":function(e,t){return e<t},"number, number":function(e,t){return e<t&&!qP(e,t,n.epsilon)},"BigNumber, BigNumber":function(e,t){return e.lt(t)&&!xU(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()}})});EF(KK,["typed","config"],function(e){var t=e.typed,n=e.config;return t(KK,{"number, number":function(e,t){return e<t&&!qP(e,t,n.epsilon)}})});var JK="smallerEq",YK=EF(JK,["typed","config","matrix","DenseMatrix"],function(e){var t=e.typed,n=e.config,r=e.matrix,i=e.DenseMatrix,o=xq({typed:t}),s=nV({typed:t,DenseMatrix:i}),a=Eq({typed:t,DenseMatrix:i}),l=dq({typed:t}),c=JU({typed:t});return t(JK,{"boolean, boolean":function(e,t){return e<=t},"number, number":function(e,t){return e<=t||qP(e,t,n.epsilon)},"BigNumber, BigNumber":function(e,t){return e.lte(t)||xU(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()}})});EF(JK,["typed","config"],function(e){var t=e.typed,n=e.config;return t(JK,{"number, number":function(e,t){return e<=t||qP(e,t,n.epsilon)}})});var ZK="larger",XK=EF(ZK,["typed","config","matrix","DenseMatrix"],function(e){var t=e.typed,n=e.config,r=e.matrix,i=e.DenseMatrix,o=xq({typed:t}),s=nV({typed:t,DenseMatrix:i}),a=Eq({typed:t,DenseMatrix:i}),l=dq({typed:t}),c=JU({typed:t});return t(ZK,{"boolean, boolean":function(e,t){return e>t},"number, number":function(e,t){return e>t&&!qP(e,t,n.epsilon)},"BigNumber, BigNumber":function(e,t){return e.gt(t)&&!xU(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()}})});EF(ZK,["typed","config"],function(e){var t=e.typed,n=e.config;return t(ZK,{"number, number":function(e,t){return e>t&&!qP(e,t,n.epsilon)}})});var QK="largerEq",eG=EF(QK,["typed","config","matrix","DenseMatrix"],function(e){var t=e.typed,n=e.config,r=e.matrix,i=e.DenseMatrix,o=xq({typed:t}),s=nV({typed:t,DenseMatrix:i}),a=Eq({typed:t,DenseMatrix:i}),l=dq({typed:t}),c=JU({typed:t});return t(QK,{"boolean, boolean":function(e,t){return e>=t},"number, number":function(e,t){return e>=t||qP(e,t,n.epsilon)},"BigNumber, BigNumber":function(e,t){return e.gte(t)||xU(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()}})});EF(QK,["typed","config"],function(e){var t=e.typed,n=e.config;return t(QK,{"number, number":function(e,t){return e>=t||qP(e,t,n.epsilon)}})});var tG="deepEqual",nG=EF(tG,["typed","equal"],function(e){var t=e.typed,n=e.equal;return t(tG,{"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)}}),rG="unequal",iG=EF(rG,["typed","config","equalScalar","matrix","DenseMatrix"],function(e){var t=e.typed;e.config;var n=e.equalScalar,r=e.matrix,i=e.DenseMatrix,o=xq({typed:t}),s=nV({typed:t,DenseMatrix:i}),a=Eq({typed:t,DenseMatrix:i}),l=dq({typed:t}),c=JU({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)}});EF(rG,["typed","equalScalar"],function(e){var t=e.typed,n=e.equalScalar;return t(rG,{"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 oG="partitionSelect",sG=EF(oG,["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(oG,{"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(!OP(t)||t<0)throw new Error("k must be a non-negative integer");if(Uz(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]}}),aG="sort",lG=EF(aG,["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(aG,{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!==sF(e).length)throw new Error("One dimensional array expected")}function c(e){if(1!==e.size().length)throw new Error("One dimensional matrix expected")}}),cG=EF("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 H$(e,t.valueOf(),o)},"...":function(e){if(F$(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 RW(e,"max",t)}}function s(e){var t;if(j$(e,function(e){try{isNaN(e)&&"number"==typeof e?t=NaN:(void 0===t||i(e,t))&&(t=e)}catch(t){throw RW(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}}),uG=EF("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 H$(e,t.valueOf(),o)},"...":function(e){if(F$(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 RW(e,"min",t)}}function s(e){var t;if(j$(e,function(e){try{isNaN(e)&&"number"==typeof e?t=NaN:(void 0===t||i(e,t))&&(t=e)}catch(t){throw RW(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}}),dG=EF("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&&!$z(t))throw new Error("Invalid datatype: "+t);if(Uz(e)||Hz(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&&Hz(e.data)&&Hz(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 ("+xP(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 Uz(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:EP(this._data),size:EP(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}),pG=EF("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(Kz(o))this._dimensions.push(o),this._isScalar=!1;else if(Array.isArray(o)||Uz(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]||!OP(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=EP(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}),hG=EF("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}),fG=EF("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}),mG=MV(function(e){return new e(1).exp()},bG),gG=MV(function(e){return new e(1).plus(new e(5).sqrt()).div(2)},bG),yG=MV(function(e){return e.acos(-1)},bG),vG=MV(function(e){return yG(e).times(2)},bG);function bG(e){return e[0].precision}function xG(e){return xG="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},xG(e)}function wG(){return wG=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},wG.apply(this,arguments)}function EG(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 MG(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?EG(Object(n),!0).forEach(function(t){SG(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):EG(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function SG(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var CG=EF("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,x=e.Fraction,w=y;function E(e,t){if(!(this instanceof E))throw new Error("Constructor must be called with the new operator");if(null!=e&&!m(e)&&!Pz(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=E.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 M(){for(;" "===r||"\t"===r;)C()}function S(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(),!S(r))return N(t),null}else{for(;S(r);)e+=r,C();"."===r&&(e+=r,C())}for(;S(r);)e+=r,C();if("E"===r||"e"===r){var i="",o=n;if(i+=r,C(),"+"!==r&&"-"!==r||(i+=r,C()),!S(r))return N(o),e;for(e+=i;S(r);)e+=r,C()}return e}function k(){for(var e="";S(r)||E.isValidAlpha(r);)e+=r,C();var t=e.charAt(0);return E.isValidAlpha(t)?e:null}function T(e){return r===e?(C(),e):null}function O(e){if(CP(z,e)){var t=z[e];return{unit:t,prefix:t.prefixes[""]}}for(var n in z)if(CP(z,n)&&eF(e,n)){var r=z[n],i=e.length-n.length,o=e.substring(0,i),s=CP(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}E.prototype.type="Unit",E.prototype.isUnit=!0,E.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 E;s.units=[];var a=1,l=!1;C(),M();var c=A(),u=null;if(c){if("BigNumber"===o.number)u=new b(c);else if("Fraction"===o.number)try{u=new x(c)}catch(e){u=parseFloat(c)}else u=parseFloat(c);M(),T("*")?(a=1,l=!0):T("/")&&(a=-1,l=!0)}for(var d=[],p=1;;){for(M();"("===r;)d.push(a),p*=a,a=1,C(),M();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(M(),T("^")){M();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(M();")"===r;){if(0===d.length)throw new SyntaxError('Unmatched ")" in "'+t+'" at index '+n.toString());p/=d.pop(),C(),M()}if(l=!1,T("*")?(a=1,l=!0):T("/")?(a=-1,l=!0):a=1,m.unit.base){var w=m.unit.base.key;j.auto[w]={unit:m.unit,prefix:m.prefix}}}if(M(),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},E.prototype.clone=function(){var e=new E;e.fixPrefix=this.fixPrefix,e.skipAutomaticSimplification=this.skipAutomaticSimplification,e.value=EP(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])CP(this.units[t],n)&&(e.units[t][n]=this.units[t][n]);return e},E.prototype._isDerived=function(){return 0!==this.units.length&&(this.units.length>1||Math.abs(this.units[0].power-1)>1e-15)},E.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=E._getNumberConverter(xP(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=E._getNumberConverter(xP(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))},E.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=E._getNumberConverter(xP(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=E._getNumberConverter(xP(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)},E.isValuelessUnit=function(e){return null!==O(e)},E.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},E.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},E.prototype.equals=function(e){return this.equalBase(e)&&f(this.value,e.value)},E.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=MG({},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)},E.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=MG(MG({},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)},E.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)},E.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},E.prototype.to=function(e){var t,n=null===this.value?this._normalize(1):this.value;if("string"==typeof e){if(t=E.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=EP(n),t.fixPrefix=!0,t.skipAutomaticSimplification=!0,t}if(jz(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=EP(n),t.fixPrefix=!0,t.skipAutomaticSimplification=!0,t}throw new Error("String or Unit expected as parameter")},E.prototype.toNumber=function(e){return w(this.toNumeric(e))},E.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)},E.prototype.toString=function(){return this.format()},E.prototype.toJSON=function(){return{mathjs:"Unit",value:this._denormalize(this.value),unit:this.formatUnits(),fixPrefix:this.fixPrefix}},E.fromJSON=function(e){var t=new E(e.value,e.unit);return t.fixPrefix=e.fixPrefix||!1,t},E.prototype.valueOf=E.prototype.toString,E.prototype.simplify=function(){var e,t,n=this.clone(),r=[];for(var i in $)if(CP($,i)&&n.hasBase(I[i])){e=i;break}if("NONE"===e)n.units=[];else if(e&&CP($,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&&(CP($,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},E.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(!CP(j.si,r))throw new Error("Cannot express custom unit "+r+" in SI units");t.push({unit:j.si[r].unit,prefix:j.si[r].prefix,power:e.dimensions[n]||0})}}return e.units=t,e.fixPrefix=!0,e.skipAutomaticSimplification=!0,e},E.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},E.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&&Pz(t.value)&&(n=Math.abs(t.value.re)<1e-14),t.units)CP(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&&Pz(t.value)&&(o="("+o+")"),s.length>0&&o.length>0&&(o+=" "),o+=s},E.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(CP(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},E.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 E(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=wG({},R.SHORT,R.LONG),R.BINARY_SHORT=wG({},R.BINARY_SHORT_SI,R.BINARY_SHORT_IEC),R.BINARY_LONG=wG({},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)CP(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 F(e){if("BigNumber"===e.number){var t=yG(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}F(o),i&&i("config",function(e,t){e.number!==t.number&&F(e)});var j={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[""]}}};j.cgs=JSON.parse(JSON.stringify(j.si)),j.cgs.LENGTH={unit:z.m,prefix:R.SHORT.c},j.cgs.MASS={unit:z.g,prefix:R.SHORT[""]},j.cgs.FORCE={unit:z.dyn,prefix:R.SHORT[""]},j.cgs.ENERGY={unit:z.erg,prefix:R.NONE[""]},j.us=JSON.parse(JSON.stringify(j.si)),j.us.LENGTH={unit:z.ft,prefix:R.NONE[""]},j.us.MASS={unit:z.lbm,prefix:R.NONE[""]},j.us.TEMPERATURE={unit:z.degF,prefix:R.NONE[""]},j.us.FORCE={unit:z.lbf,prefix:R.NONE[""]},j.us.ENERGY={unit:z.BTU,prefix:R.BTU[""]},j.us.POWER={unit:z.hp,prefix:R.NONE[""]},j.us.PRESSURE={unit:z.psi,prefix:R.NONE[""]},j.auto=JSON.parse(JSON.stringify(j.si));var $=j.auto;for(var H in E.setUnitSystem=function(e){if(!CP(j,e))throw new Error("Unit system "+e+" does not exist. Choices are: "+Object.keys(j).join(", "));$=j[e]},E.getUnitSystem=function(){for(var e in j)if(CP(j,e)&&j[e]===$)return e},E.typeConverters={BigNumber:function(e){return new b(e+"")},Fraction:function(e){return new x(e)},Complex:function(e){return e},number:function(e){return e}},E._getNumberConverter=function(e){if(!E.typeConverters[e])throw new TypeError('Unsupported type "'+e+'"');return E.typeConverters[e]},z)if(CP(z,H)){var U=z[H];U.dimensions=U.base.dimensions}for(var q in P)if(CP(P,q)){var V=z[P[q]],W={};for(var K in V)CP(V,K)&&(W[K]=V[K]);W.name=q,z[q]=W}return E.isValidAlpha=function(e){return/^[a-zA-Z]$/.test(e)},E.createUnit=function(e,t){if("object"!==xG(e))throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(t&&t.override)for(var n in e)if(CP(e,n)&&E.deleteUnit(n),e[n].aliases)for(var r=0;r<e[n].aliases.length;r++)E.deleteUnit(e[n].aliases[r]);var i;for(var o in e)CP(e,o)&&(i=E.createUnitSingle(o,e[o]));return i},E.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(CP(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&&!E.isValidAlpha(r))throw new Error('Invalid unit name (must begin with alpha character): "'+e+'"');if(t>0&&!E.isValidAlpha(r)&&!S(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"!==xG(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(CP(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=E.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(CP(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)CP(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[""]}}E.UNITS[e]=d;for(var x=0;x<l.length;x++){var w=l[x],M={};for(var C in d)CP(d,C)&&(M[C]=d[C]);M.name=w,E.UNITS[w]=M}return new E(null,e)},E.deleteUnit=function(e){delete E.UNITS[e]},E.PREFIXES=R,E.BASE_DIMENSIONS=D,E.BASE_UNITS=I,E.UNIT_SYSTEMS=j,E.UNITS=z,E},{isClass:!0}),NG="unit",AG=EF(NG,["typed","Unit"],function(e){var t=e.typed,n=e.Unit;return t(NG,{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 $$(e,this)}})}),kG="sparse",TG=EF(kG,["typed","SparseMatrix"],function(e){var t=e.typed,n=e.SparseMatrix;return t(kG,{"":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)}})}),OG="createUnit",_G=EF(OG,["typed","Unit"],function(e){var t=e.typed,n=e.Unit;return t(OG,{"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,{})}})}),RG="acos",DG=EF(RG,["typed","config","Complex"],function(e){var t=e.typed,n=e.config,r=e.Complex;return t(RG,{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 $$(e,this)}})}),IG="acosh",LG=EF(IG,["typed","config","Complex"],function(e){var t=e.typed,n=e.config,r=e.Complex;return t(IG,{number:function(e){return e>=1||n.predictable?FH(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 $$(e,this)}})}),BG="acot",zG=EF(BG,["typed","BigNumber"],function(e){var t=e.typed,n=e.BigNumber;return t(BG,{number:jH,Complex:function(e){return e.acot()},BigNumber:function(e){return new n(1).div(e).atan()},"Array | Matrix":function(e){return $$(e,this)}})}),PG="acoth",FG=EF(PG,["typed","config","Complex","BigNumber"],function(e){var t=e.typed,n=e.config,r=e.Complex,i=e.BigNumber;return t(PG,{number:function(e){return e>=1||e<=-1||n.predictable?$H(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 $$(e,this)}})}),jG="acsc",$G=EF(jG,["typed","config","Complex","BigNumber"],function(e){var t=e.typed,n=e.config,r=e.Complex,i=e.BigNumber;return t(jG,{number:function(e){return e<=-1||e>=1||n.predictable?HH(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 $$(e,this)}})}),HG="acsch",UG=EF(HG,["typed","BigNumber"],function(e){var t=e.typed,n=e.BigNumber;return t(HG,{number:UH,Complex:function(e){return e.acsch()},BigNumber:function(e){return new n(1).div(e).asinh()},"Array | Matrix":function(e){return $$(e,this)}})}),qG="asec",VG=EF(qG,["typed","config","Complex","BigNumber"],function(e){var t=e.typed,n=e.config,r=e.Complex,i=e.BigNumber;return t(qG,{number:function(e){return e<=-1||e>=1||n.predictable?qH(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 $$(e,this)}})}),WG="asech",KG=EF(WG,["typed","config","Complex","BigNumber"],function(e){var t=e.typed,n=e.config,r=e.Complex,i=e.BigNumber;return t(WG,{number:function(e){if(e<=1&&e>=-1||n.predictable){var t=1/e;if(t>0||n.predictable)return VH(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 $$(e,this)}})}),GG="asin",JG=EF(GG,["typed","config","Complex"],function(e){var t=e.typed,n=e.config,r=e.Complex;return t(GG,{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 $$(e,this)}})}),YG=EF("asinh",["typed"],function(e){return(0,e.typed)("asinh",{number:WH,Complex:function(e){return e.asinh()},BigNumber:function(e){return e.asinh()},"Array | Matrix":function(e){return $$(e,this)}})}),ZG=EF("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 $$(e,this)}})}),XG="atan2",QG=EF(XG,["typed","matrix","equalScalar","BigNumber","DenseMatrix"],function(e){var t=e.typed,n=e.matrix,r=e.equalScalar,i=e.BigNumber,o=e.DenseMatrix,s=hq({typed:t,equalScalar:r}),a=xq({typed:t}),l=Fq({typed:t,equalScalar:r}),c=GU({typed:t,equalScalar:r}),u=Eq({typed:t,DenseMatrix:o}),d=dq({typed:t}),p=JU({typed:t});return t(XG,{"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()}})}),eJ="atanh",tJ=EF(eJ,["typed","config","Complex"],function(e){var t=e.typed,n=e.config,r=e.Complex;return t(eJ,{number:function(e){return e<=1&&e>=-1||n.predictable?KH(e):new r(e,0).atanh()},Complex:function(e){return e.atanh()},BigNumber:function(e){return e.atanh()},"Array | Matrix":function(e){return $$(e,this)}})}),nJ=EF("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 $$(e,this)}})}),rJ="cosh",iJ=EF(rJ,["typed"],function(e){return(0,e.typed)(rJ,{number:GP,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 $$(e,this)}})}),oJ=EF("cot",["typed","BigNumber"],function(e){var t=e.typed,n=e.BigNumber;return t("cot",{number:GH,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 $$(e,this)}})}),sJ="coth",aJ=EF(sJ,["typed","BigNumber"],function(e){var t=e.typed,n=e.BigNumber;return t(sJ,{number:JH,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 $$(e,this)}})}),lJ=EF("csc",["typed","BigNumber"],function(e){var t=e.typed,n=e.BigNumber;return t("csc",{number:YH,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 $$(e,this)}})}),cJ="csch",uJ=EF(cJ,["typed","BigNumber"],function(e){var t=e.typed,n=e.BigNumber;return t(cJ,{number:ZH,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 $$(e,this)}})}),dJ=EF("sec",["typed","BigNumber"],function(e){var t=e.typed,n=e.BigNumber;return t("sec",{number:XH,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 $$(e,this)}})}),pJ="sech",hJ=EF(pJ,["typed","BigNumber"],function(e){var t=e.typed,n=e.BigNumber;return t(pJ,{number:QH,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 $$(e,this)}})}),fJ=EF("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 $$(e,this)}})}),mJ="sinh",gJ=EF(mJ,["typed"],function(e){return(0,e.typed)(mJ,{number:eU,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 $$(e,this)}})}),yJ=EF("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 $$(e,this)}})}),vJ=EF("tanh",["typed"],function(e){return(0,e.typed)("tanh",{number:YP,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 $$(e,this)}})}),bJ="setCartesian",xJ=EF(bJ,["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(bJ,{"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=yF(Array.isArray(e)?e:e.toArray()).sort(i),c=yF(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)}})}),wJ="setDifference",EJ=EF(wJ,["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(wJ,{"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 yF(e.toArray());var l,c=bF(yF(Array.isArray(e)?e:e.toArray()).sort(i)),u=bF(yF(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)?xF(a):new s(xF(a))}})}),MJ="setDistinct",SJ=EF(MJ,["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(MJ,{"Array | Matrix":function(e){var t;if(0===r(n(e),new o(0)))t=[];else{var a=yF(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)}})}),CJ="setIntersect",NJ=EF(CJ,["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(CJ,{"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=bF(yF(Array.isArray(e)?e:e.toArray()).sort(i)),c=bF(yF(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)?xF(a):new s(xF(a))}})}),AJ="setIsSubset",kJ=EF(AJ,["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(AJ,{"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=bF(yF(Array.isArray(e)?e:e.toArray()).sort(i)),l=bF(yF(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}})}),TJ="setMultiplicity",OJ=EF(TJ,["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(TJ,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(e,t){if(0===r(n(t),new o(0)))return 0;for(var s=yF(Array.isArray(t)?t:t.toArray()),a=0,l=0;l<s.length;l++)0===i(s[l],e)&&a++;return a}})}),_J="setPowerset",RJ=EF(_J,["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(_J,{"Array | Matrix":function(e){if(0===r(n(e),new o(0)))return[];for(var t=yF(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}}),DJ="setSize",IJ=EF(DJ,["typed","compareNatural"],function(e){var t=e.typed,n=e.compareNatural;return t(DJ,{"Array | Matrix":function(e){return Array.isArray(e)?yF(e).length:yF(e.toArray()).length},"Array | Matrix, boolean":function(e,t){if(!1===t||0===e.length)return Array.isArray(e)?yF(e).length:yF(e.toArray()).length;for(var r=yF(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}})}),LJ="setSymDifference",BJ=EF(LJ,["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(LJ,{"Array | Matrix, Array | Matrix":function(e,t){if(0===i(n(e),new s(0)))return yF(t);if(0===i(n(t),new s(0)))return yF(e);var a=yF(e),l=yF(t);return r(o(a,l),o(l,a))}})}),zJ="setUnion",PJ=EF(zJ,["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(zJ,{"Array | Matrix, Array | Matrix":function(e,t){if(0===i(n(e),new a(0)))return yF(t);if(0===i(n(t),new a(0)))return yF(e);var l=yF(e),c=yF(t);return r(s(l,c),o(l,c))}})}),FJ=EF("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=lq({typed:t}),a=cq({typed:t,equalScalar:i}),l=uq({typed:t,DenseMatrix:o}),c=dq({typed:t}),u=JU({typed:t});return t("add",MP({"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))}),jJ="hypot",$J=EF(jJ,["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(jJ,{"... 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,yF(e))},Matrix:function(e){return this.apply(this,yF(e.toArray()))}})}),HJ="norm",UJ=EF(HJ,["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(HJ,{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")}}}),qJ=EF("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=Uz(e)?e._data:e,u=Uz(e)?e._datatype:void 0,d=Uz(o)?o._data:o,p=Uz(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 x=g(i(c[0]),d[0][0]),w=1;w<l;w++)x=m(x,g(i(c[w]),d[w][0]));return x}if(h&&!f){for(var E=g(i(c[0][0]),d[0]),M=1;M<l;M++)E=m(E,g(i(c[M][0]),d[M]));return E}if(h&&f){for(var S=g(i(c[0][0]),d[0][0]),C=1;C<l;C++)S=m(S,g(i(c[C][0]),d[C][0]));return S}},"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 Uz(e)?e.size():o(e)}}),VJ=EF("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: "+tF(o)+")")},DenseMatrix:i,any:EP});function i(e){var t=e._size,n=e._data;switch(t.length){case 1:if(1===t[0])return EP(n[0]);throw new RangeError("Matrix must be square (size: "+tF(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: "+tF(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+tF(t)+")")}}}),WJ="index",KJ=EF(WJ,["typed","Index"],function(e){var t=e.typed,n=e.Index;return t(WJ,{"...number | string | BigNumber | Range | Array | Matrix":function(e){var t=e.map(function(e){return zz(e)?e.toNumber():Array.isArray(e)||Uz(e)?e.map(function(e){return zz(e)?e.toNumber():e}):e}),r=new n;return n.apply(r,t),r}})}),GJ=EF("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=EP(e._data),g=[],y=[p,f],v=[],b=[f,h],x=[];for(t=0;t<p;t++)x[t]=t;for(n=0;n<h;n++){if(n>0)for(t=0;t<p;t++){var w=Math.min(t,n),E=0;for(u=0;u<w;u++)E=i(E,s(m[t][u],m[u][n]));m[t][n]=a(m[t][n],E)}var M=n,S=0,C=0;for(t=n;t<p;t++){var N=m[t][n],A=r(N);l(A,S)&&(M=t,S=A,C=N)}if(n!==M&&(x[n]=[x[M],x[M]=x[n]][0],d._swapRows(n,M,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=x.length;t<f;t++)_[x[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=[],x=[],w=[a,f],E=[],M=[],S=[],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&&(x.push(v.length),v.push(1),b.push(n)),S.push(E.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,x,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,w[1],v,b,x),p._swapRows(n,R,C[1],E,M,S),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?(E.push(t),M.push(e)):(t=o(t,D),c(t,0)||(v.push(t),b.push(e)))})};for(n=0;n<d;n++)k();return S.push(E.length),x.push(v.length),{L:new p({values:v,index:b,ptr:x,size:w}),U:new p({values:E,index:M,ptr:S,size:C}),p:N,toString:function(){return"L: "+this.L.toString()+"\nU: "+this.U.toString()+"\nP: "+this.p}}}});function JJ(){return JJ=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},JJ.apply(this,arguments)}var YJ=EF("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 JJ(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,x=e.clone(),w=x._data,E=r([g],"");for(m=0;m<Math.min(y,g);++m){var M=w[m][m],S=u(s(M,0)?1:a(M)),C=c(S),N=0;for(t=m;t<g;t++)N=d(N,h(w[t][m],c(w[t][m])));var A=h(S,l(N));if(!o(A)){var k=f(M,A);for(E[m]=1,t=m+1;t<g;t++)E[t]=p(w[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(E[t]),w[t][n]));for(O=h(O,T),t=m;t<g;t++)w[t][n]=h(f(w[t][n],h(E[t],O)),C)}for(t=0;t<g;t++){for(O=0,n=m;n<g;n++)O=d(O,h(b[t][n],E[n]));for(O=h(O,T),n=m;n<g;++n)b[t][n]=p(f(b[t][n],h(O,c(E[n]))),C)}}}return{Q:v,R:x,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 ZJ(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 XJ(e){return-e-2}var QJ=EF("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,x,w,E,M,S,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),F=6*(c+1),j=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,j,I,F,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]=XJ(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,F,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,x=D[0+m]-V):(b=O[v=T[G++]],x=D[0+v]),y=1;y<=x;y++)(w=D[I+(h=T[b++])])<=0||(K+=w,D[I+h]=-w,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]=XJ(m),D[F+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,F,c),E=J;E<Y;E++)if(!((M=D[z+(h=T[E])])<=0)){var Z=H-(w=-D[I+h]);for(G=O[h],S=O[h]+M-1;G<=S;G++)D[F+(v=T[G])]>=H?D[F+v]-=w:0!==D[F+v]&&(D[F+v]=D[P+v]+Z)}for(E=J;E<Y;E++){for(C=(S=O[h=T[E]])+D[z+h]-1,N=S,A=0,k=0,G=S;G<=C;G++)if(0!==D[F+(v=T[G])]){var X=D[F+v]-H;X>0?(k+=X,T[N++]=v,A+=v):(O[v]=XJ(m),D[F+v]=0)}D[z+h]=N-S+1;var Q=N,ee=S+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]=XJ(m),K-=w=-D[I+h],W+=w,U+=w,D[I+h]=0,D[z+h]=-1):(D[P+h]=Math.min(D[P+h],k),T[N]=T[Q],T[Q]=T[S],T[S]=m,D[0+h]=N-S+1,A=(A<0?-A:A)%c,D[L+h]=D[j+A],D[j+A]=h,$[h]=A)}for(D[P+m]=K,H=i(H+(u=Math.max(u,K)),u,D,F,c),E=J;E<Y;E++)if(!(D[I+(h=T[E])]>=0))for(h=D[j+(A=$[h])],D[j+A]=-1;-1!==h&&-1!==D[L+h];h=D[L+h],H++){for(x=D[0+h],M=D[z+h],G=O[h]+1;G<=O[h]+x-1;G++)D[F+T[G]]=H;var ne=h;for(f=D[L+h];-1!==f;){var re=D[0+f]===x&&D[z+f]===M;for(G=O[f]+1;re&&G<=O[f]+x-1;G++)D[F+T[G]]!==H&&(re=0);re?(O[f]=XJ(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,E=J;E<Y;E++)(w=-D[I+(h=T[E])])<=0||(D[I+h]=w,k=D[P+h]+K-w,-1!==D[B+(k=Math.min(k,c-U-w))]&&($[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[F+m]=0),0!==V&&(_=G)}for(h=0;h<c;h++)O[h]=XJ(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=ZJ(h,m,D,B,L,R,F));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 eY(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 tY=EF("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,x=4*f,w=5*f+1;for(a=0;a<m;a++)g[a]=-1;var E=[],M=t(e),S=M._index,C=M._ptr;for(a=0;a<f;a++)for(E[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[S[c]]);g[w+o]=g[x+a],g[x+a]=o}}for(o=0;o<f;o++)g[0+o]=o;for(a=0;a<f;a++){for(-1!==n[s=r[a]]&&E[n[s]]--,l=i?g[x+a]:s;-1!==l;l=i?g[w+l]:-1)for(c=C[l];c<C[l+1];c++){var N=eY(o=S[c],s,g,b,y,v,0);N.jleaf>=1&&E[s]++,2===N.jleaf&&E[N.q]--}-1!==n[s]&&(g[0+s]=n[s])}for(s=0;s<f;s++)-1!==n[s]&&(E[n[s]]+=E[s]);return E}}),nY=EF("csSqr",["add","multiply","transpose"],function(e){var t=e.add,n=e.multiply,r=e.transpose,i=QJ({add:t,multiply:n,transpose:r}),o=tY({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 x=t?t[o[b]]:o[b];p[f]=x,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=ZJ(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 x=p[l];-1!==x&&(0===m[b+x]&&(m[v+x]=m[v+l]),m[g+m[v+l]]=m[y+x],m[y+x]=m[g+a],m[b+x]+=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 rY(e,t){return e[t]<0}function iY(e,t){e[t]=XJ(e[t])}function oY(e){return e<0?XJ(e):e}function sY(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;rY(c,e)||(iY(c,e),r[u+d]=p<0?0:oY(c[p]));var h=1;for(s=r[u+d],a=p<0?0:oY(c[p+1]);s<a;s++)if(!rY(c,o=l[s])){r[u+d]=s,r[++d]=o,h=0;break}h&&(d--,r[--n]=e)}return n}var aY=EF("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,x=i._ptr,w=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];rY(l,f)||(h=sY(f,e,h,r,i))}for(o=h;o<p;o++)iY(l,r[o]);return h}(e,i,o,s,l);for(u=w;u<y;u++)a[s[u]]=0;for(d=x[o],p=x[o+1],u=d;u<p;u++)a[b[u]]=v[u];for(var E=w;E<y;E++){var M=s[E],S=l?l[M]:M;if(!(S<0))for(d=g[S],p=g[S+1],a[M]=t(a[M],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[M]))}}return w}}),lY=EF("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=aY({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]}),x=[],w=[],E=[],M=new a({values:x,index:w,ptr:E,size:[d,d]}),S=[],C=[],N=[];for(f=0;f<d;f++)C[f]=0,S[f]=-1,v[f+1]=0;p=0,h=0;for(var A=0;A<d;A++){v[A]=p,E[A]=h;var k=u?u[A]:A,T=l(b,e,k,N,C,S,1),O=-1,_=-1;for(m=T;m<d;m++)if(S[f=N[m]]<0){var R=t(C[f]);o(R,_)&&(_=R,O=f)}else w[h]=S[f],x[h++]=C[f];if(-1===O||_<=0)return null;S[k]<0&&s(t(C[k]),r(_,c))&&(O=k);var D=C[O];for(w[h]=A,x[h++]=D,S[O]=A,y[p]=O,g[p++]=1,m=T;m<d;m++)S[f=N[m]]<0&&(y[p]=f,g[p++]=n(C[f],D)),C[f]=0}for(v[d]=p,E[d]=h,m=0;m<p;m++)y[m]=S[y[m]];return g.splice(p,g.length-p),y.splice(p,y.length-p),x.splice(h,x.length-h),w.splice(h,w.length-h),{L:b,U:M,pinv:S}}}),cY=EF("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=nY({add:r,multiply:i,transpose:o}),p=lY({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(!OP(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 uY(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 dY="lusolve",pY=EF(dY,["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=mK({DenseMatrix:e.DenseMatrix});return t(dY,{"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(Uz(e))return e;if(Hz(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=uY(n,i._data));var c=s(e,i),u=o(t,c);return r&&(u._data=uY(r,u._data)),u}}),hY=EF("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 EP(e)},"Array | Matrix":function(e){var t;switch((t=Uz(e)?e.size():Array.isArray(e)?(e=n(e)).size():[]).length){case 0:return EP(e);case 1:if(1===t[0])return EP(e.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+tF(t)+")");case 2:var a=t[0];if(a===t[1])return function(e,t){if(1===t)return EP(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: "+tF(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+tF(t)+")")}}})}),fY=EF("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=Uz(e)?e.size():sF(e);switch(t.length){case 1:if(1===t[0])return Uz(e)?n([r(1,e.valueOf()[0])]):[r(1,e[0])];throw new RangeError("Matrix must be square (size: "+tF(t)+")");case 2:var i=t[0],o=t[1];if(i===o)return Uz(e)?n(u(e.valueOf(),i,o),e.storage()):u(e,i,o);throw new RangeError("Matrix must be square (size: "+tF(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+tF(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]),x=v;for(u=v+1;u<t;)c(g[u][v])>b&&(b=c(g[u][v]),x=u),u++;if(0===b)throw Error("Cannot calculate inverse, determinant is zero");(u=x)!==v&&(f=g[v],g[v]=g[u],g[u]=f,f=y[v],y[v]=y[u],y[u]=f);var w=g[v],E=y[v];for(u=0;u<t;u++){var M=g[u],S=y[u];if(u!==v){if(0!==M[v]){for(p=r(s(M[v]),w[v]),d=v;d<n;d++)M[d]=i(M[d],o(p,w[d]));for(d=0;d<n;d++)S[d]=i(S[d],o(p,E[d]))}}else{for(p=w[v],d=v;d<n;d++)M[d]=r(M[d],p);for(d=0;d<n;d++)S[d]=r(S[d],p)}}}return y}}),mY=EF("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: "+tF(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: "+tF(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=E(e,n=b(e[c][c],e[u][u],e[c][u]),c,u),o=w(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(EP(d),EP(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=S(e);Math.abs(a[1])>=Math.abs(i);){var l=a[0][0],c=a[0][1];e=M(e,n=v(e[l][l],e[c][c],e[l][c]),l,c),o=x(o,n,l,c),a=S(e)}for(var u=A(r,0),d=0;d<r;d++)u[d]=e[d][d];return N(EP(u),EP(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 x(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 w(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 E(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]),x=i(o(d(p,e[n][n]),b),d(g,e[r][r])),w=m(d(g,e[n][n]),b,d(p,e[r][r])),E=0;E<s;E++)y[E]=o(d(a,e[n][E]),d(l,e[r][E])),v[E]=i(d(l,e[n][E]),d(a,e[r][E]));e[n][n]=x,e[r][r]=w,e[n][r]=h(0),e[r][n]=h(0);for(var M=0;M<s;M++)M!==n&&M!==r&&(e[n][M]=y[M],e[M][n]=y[M],e[r][M]=v[M],e[M][r]=v[M]);return e}function M(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 S(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[EP(r),EP(i)]}function A(e,t){for(var n=new Array(e),r=0;r<e;r++)n[r]=t;return n}}),gY="expm",yY=EF(gY,["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(gY,{Matrix:function(e){var t=e.size();if(2!==t.length||t[0]!==t[1])throw new RangeError("Matrix must be square (size: "+tF(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 x=s(o(m),f),w=0;w<p;w++)x=s(x,x);return Wz(e)?e.createSparseMatrix(x):x}});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)}}),vY="sqrtm",bY=EF(vY,["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(vY,{"Array | Matrix":function(e){var t=Uz(e)?e.size():sF(e);switch(t.length){case 1:if(1===t[0])return o(e);throw new RangeError("Matrix must be square (size: "+tF(t)+")");case 2:if(t[0]===t[1])return p(e);throw new RangeError("Matrix must be square (size: "+tF(t)+")");default:throw new RangeError("Matrix must be at most two dimensional (size: "+tF(t)+")")}}})}),xY=EF("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=GU({typed:t,equalScalar:i}),l=JU({typed:t});return t("divide",MP({"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))}),wY="distance",EY=EF(wY,["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(wY,{"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||zz(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)}}),MY=EF("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),x=c(u(u(u(h,f),g),v),u(u(u(o(o(m,y),b),f),g),v)),w=o(e,l(x,u(r,e))),E=o(t,l(x,u(i,t))),M=o(n,l(x,u(s,n)));return[w,E,M]}(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]),x=l(g[0],f[1]),w=l(g[1],f[0]),E=c(o(u(u(v,b),x),w),y);return i(a(m,E),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),x=g(e,a,r,e,t,d,i,t,n,h,s,n),w=g(f,a,f,a,m,d,m,d,y,h,y,h),E=g(r,e,r,e,i,t,i,t,s,n,s,n),M=c(u(l(v,b),l(x,w)),u(l(E,w),l(b,b))),S=c(o(v,l(M,b)),w),C=o(e,l(M,u(r,e))),N=o(t,l(M,u(i,t))),A=o(n,l(M,u(s,n))),k=o(a,l(S,u(f,a))),T=o(d,l(S,u(m,d))),O=o(h,l(S,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||zz(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)}}),SY=EF("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 H$(e,t,r)}catch(e){throw RW(e,"sum")}},"...":function(e){if(F$(e))throw new TypeError("Scalar values expected in function sum");return o(e)}});function o(e){var t;return j$(e,function(e){try{t=void 0===t?e:r(t,e)}catch(t){throw RW(t,"sum",e)}}),void 0===t&&(t=i(0,n.number)),"string"==typeof t&&(t=i(t,n.number)),t}}),CY="mean",NY=EF(CY,["typed","add","divide"],function(e){var t=e.typed,n=e.add,r=e.divide;return t(CY,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(e,t){try{var i=H$(e,t,n),o=Array.isArray(e)?sF(e):e.size();return r(i,o[t])}catch(e){throw RW(e,"mean")}},"...":function(e){if(F$(e))throw new TypeError("Scalar values expected in function mean");return i(e)}});function i(e){var t,i=0;if(j$(e,function(e){try{t=void 0===t?e:n(t,e),i++}catch(t){throw RW(t,"mean",e)}}),0===i)throw new Error("Cannot calculate the mean of an empty array");return r(t,i)}}),AY="median",kY=EF(AY,["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=yF(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 RW(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(AY,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("median(A, dim) is not yet supported")},"...":function(e){if(F$(e))throw new TypeError("Scalar values expected in function median");return s(e)}})}),TY=EF("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=yF(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")):RW(e,"mad")}}}),OY="unbiased",_Y="variance",RY=EF(_Y,["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(_Y,{"Array | Matrix":function(e){return l(e,OY)},"Array | Matrix, string":l,"Array | Matrix, number | BigNumber":function(e,t){return c(e,t,OY)},"Array | Matrix, number | BigNumber, string":c,"...":function(e){return l(e,OY)}});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(j$(e,function(e){try{s=void 0===s?e:n(s,e),l++}catch(t){throw RW(t,"variance",e)}}),0===l)throw new Error("Cannot calculate variance of an empty array");var c=o(s,l);if(s=void 0,j$(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=zz(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 RW(e,"variance")}}}),DY=EF("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=yF(e),c=l.length;if(0===c)throw new Error("Cannot calculate quantile of an empty sequence");if(Bz(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,x,w=y.floor(),E=y.minus(w),M=w.toNumber();if(s)b=l[M],x=l[M+1];else{x=i(l,M+1),b=l[M];for(var S=0;S<M;++S)o(l[S],b)>0&&(b=l[S])}a(b),a(x);var C=new E.constructor(1);return n(r(b,C.minus(E)),r(x,E))}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(qz(e)){if("boolean"==typeof(n=n||!1)){if(i=e.valueOf(),Bz(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(!OP(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(zz(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(Bz(f)){if(f<0||f>1)throw new Error("Probability must be between 0 and 1, inclusive")}else{if(!zz(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")}}),IY=EF("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}}}),LY="combinations",BY=EF(LY,["typed"],function(e){return(0,e.typed)(LY,{"number, number":NH,"BigNumber, BigNumber":function(e,t){var n,r,i=e.constructor,o=e.minus(t),s=new i(1);if(!zY(e)||!zY(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 zY(e){return e.isInteger()&&e.gte(0)}var PY="combinationsWithRep",FY=EF(PY,["typed"],function(e){return(0,e.typed)(PY,{"number, number":function(e,t){if(!OP(e)||e<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(!OP(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?CH(e,e+t-1)/CH(1,t):CH(t+1,e+t-1)/CH(1,e-1)},"BigNumber, BigNumber":function(e,t){var n,r,i=new(0,e.constructor)(1),o=e.minus(i);if(!jY(e)||!jY(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 jY(e){return e.isInteger()&&e.gte(0)}var $Y="gamma",HY=EF($Y,["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($Y,{number:LH,Complex:function(e){if(0===e.im)return this(e.re);e=new s(e.re-1,e.im);for(var t=new s(zH[0],0),n=1;n<zH.length;++n){var o=e.re+n,a=o*o+e.im*e.im;0!==a?(t.re+=zH[n]*o/a,t.im+=-zH[n]*e.im/a):t.re=zH[n]<0?-1/0:1/0}var l=new s(e.re+BH+.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 $$(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))}}),UY="factorial",qY=EF(UY,["typed","gamma"],function(e){var t=e.typed,n=e.gamma;return t(UY,{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 $$(e,this)}})}),VY="kldivergence",WY=EF(VY,["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(VY,{"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}}),KY="multinomial",GY=EF(KY,["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(KY,{"Array | Matrix":function(e){var t=0,l=1;return j$(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)}})}),JY="permutations",YY=EF(JY,["typed","factorial"],function(e){var t=e.typed,n=e.factorial;return t(JY,{"number | BigNumber":n,"number, number":function(e,t){if(!OP(e)||e<0)throw new TypeError("Positive integer value expected in function permutations");if(!OP(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 CH(e-t+1,e)},"BigNumber, BigNumber":function(e,t){var n,r;if(!ZY(e)||!ZY(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 ZY(e){return e.isInteger()&&e.gte(0)}var XY={exports:{}};!function(e){var t=256,n=[],r=void 0===Cr?window:Cr,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)}(XY);var QY=XY.exports,eZ=QY();function tZ(e){var t,n;return t=null===(n=e)?eZ:QY(String(n)),function(){return t()}}var nZ=EF("pickRandom",["typed","config","?on"],function(e){var t=e.typed,n=e.config,r=e.on,i=tZ(n.randomSeed);return r&&r("config",function(e,t){e.randomSeed!==t.randomSeed&&(i=tZ(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=yF(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(!Bz(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 rZ(e,t){var n=[];if((e=e.slice(0)).length>1)for(var r=0,i=e.shift();r<i;r++)n.push(rZ(e,t));else for(var o=0,s=e.shift();o<s;o++)n.push(t());return n}var iZ="random",oZ=EF(iZ,["typed","config","?on"],function(e){var t=e.typed,n=e.config,r=e.on,i=tZ(n.randomSeed);return r&&r("config",function(e,t){e.randomSeed!==t.randomSeed&&(i=tZ(e.randomSeed))}),t(iZ,{"":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=rZ(e.valueOf(),function(){return s(t,n)});return Uz(e)?e.create(r):r}function s(e,t){return e+i()*(t-e)}});EF(iZ,["typed","config","?on"],function(e){var t=e.typed,n=e.config,r=e.on;e.matrix;var i=tZ(n.randomSeed);return r&&r("config",function(e,t){e.randomSeed!==t.randomSeed&&(i=tZ(e.randomSeed))}),t(iZ,{"":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 sZ="randomInt",aZ=EF(sZ,["typed","config","?on"],function(e){var t=e.typed,n=e.config,r=e.on,i=tZ(n.randomSeed);return r&&r("config",function(e,t){e.randomSeed!==t.randomSeed&&(i=tZ(e.randomSeed))}),t(sZ,{"":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=rZ(e.valueOf(),function(){return s(t,n)});return Uz(e)?e.create(r):r}function s(e,t){return Math.floor(e+i()*(t-e))}}),lZ="stirlingS2",cZ=EF(lZ,["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(lZ,{"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)}})}),uZ="bellNumbers",dZ=EF(uZ,["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(uZ,{"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}})}),pZ="catalan",hZ=EF(pZ,["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(pZ,{"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))}})}),fZ="composition",mZ=EF(fZ,["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(fZ,{"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))}})}),gZ=EF("replacer",[],function(){return function(e,t){return"number"!=typeof t||isFinite(t)&&!isNaN(t)?t:{mathjs:"number",value:String(t)}}}),yZ=EF("true",[],function(){return!0}),vZ=EF("false",[],function(){return!1}),bZ=EF("null",[],function(){return null}),xZ=IZ("Infinity",["config","?BigNumber"],function(e){var t=e.config,n=e.BigNumber;return"BigNumber"===t.number?new n(1/0):1/0}),wZ=IZ("NaN",["config","?BigNumber"],function(e){var t=e.config,n=e.BigNumber;return"BigNumber"===t.number?new n(NaN):NaN}),EZ=IZ("pi",["config","?BigNumber"],function(e){var t=e.config,n=e.BigNumber;return"BigNumber"===t.number?yG(n):AH}),MZ=IZ("tau",["config","?BigNumber"],function(e){var t=e.config,n=e.BigNumber;return"BigNumber"===t.number?vG(n):kH}),SZ=IZ("e",["config","?BigNumber"],function(e){var t=e.config,n=e.BigNumber;return"BigNumber"===t.number?mG(n):TH}),CZ=IZ("phi",["config","?BigNumber"],function(e){var t=e.config,n=e.BigNumber;return"BigNumber"===t.number?gG(n):1.618033988749895}),NZ=IZ("LN2",["config","?BigNumber"],function(e){var t=e.config,n=e.BigNumber;return"BigNumber"===t.number?new n(2).ln():Math.LN2}),AZ=IZ("LN10",["config","?BigNumber"],function(e){var t=e.config,n=e.BigNumber;return"BigNumber"===t.number?new n(10).ln():Math.LN10}),kZ=IZ("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}),TZ=IZ("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}),OZ=IZ("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}),_Z=IZ("SQRT2",["config","?BigNumber"],function(e){var t=e.config,n=e.BigNumber;return"BigNumber"===t.number?new n(2).sqrt():Math.SQRT2}),RZ=IZ("i",["Complex"],function(e){return e.Complex.I});EF("PI",["pi"],function(e){return e.pi}),EF("E",["e"],function(e){return e.e});var DZ=EF("version",[],function(){return"7.6.0"});function IZ(e,t,n){return EF(e,t,n,{recreateOnConfigChange:!0})}var LZ=_X("speedOfLight","299792458","m s^-1"),BZ=_X("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),zZ=_X("planckConstant","6.62607015e-34","J s"),PZ=_X("reducedPlanckConstant","1.0545718176461565e-34","J s"),FZ=_X("magneticConstant","1.25663706212e-6","N A^-2"),jZ=_X("electricConstant","8.8541878128e-12","F m^-1"),$Z=_X("vacuumImpedance","376.730313667","ohm"),HZ=_X("coulomb","8.987551792261171e9","N m^2 C^-2"),UZ=_X("elementaryCharge","1.602176634e-19","C"),qZ=_X("bohrMagneton","9.2740100783e-24","J T^-1"),VZ=_X("conductanceQuantum","7.748091729863649e-5","S"),WZ=_X("inverseConductanceQuantum","12906.403729652257","ohm"),KZ=_X("magneticFluxQuantum","2.0678338484619295e-15","Wb"),GZ=_X("nuclearMagneton","5.0507837461e-27","J T^-1"),JZ=_X("klitzing","25812.807459304513","ohm");_X("josephson","4.835978484169836e14 Hz V","Hz V^-1");var YZ=_X("bohrRadius","5.29177210903e-11","m"),ZZ=_X("classicalElectronRadius","2.8179403262e-15","m"),XZ=_X("electronMass","9.1093837015e-31","kg"),QZ=_X("fermiCoupling","1.1663787e-5","GeV^-2"),eX=RX("fineStructure",.0072973525693),tX=_X("hartreeEnergy","4.3597447222071e-18","J"),nX=_X("protonMass","1.67262192369e-27","kg"),rX=_X("deuteronMass","3.3435830926e-27","kg"),iX=_X("neutronMass","1.6749271613e-27","kg"),oX=_X("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),sX=_X("rydberg","10973731.568160","m^-1"),aX=_X("thomsonCrossSection","6.6524587321e-29","m^2"),lX=RX("weakMixingAngle",.2229),cX=RX("efimovFactor",22.7),uX=_X("atomicMass","1.66053906660e-27","kg"),dX=_X("avogadro","6.02214076e23","mol^-1"),pX=_X("boltzmann","1.380649e-23","J K^-1"),hX=_X("faraday","96485.33212331001","C mol^-1"),fX=_X("firstRadiation","3.7417718521927573e-16","W m^2"),mX=_X("loschmidt","2.686780111798444e25","m^-3"),gX=_X("gasConstant","8.31446261815324","J K^-1 mol^-1"),yX=_X("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),vX=_X("molarVolume","0.022413969545014137","m^3 mol^-1"),bX=RX("sackurTetrode",-1.16487052358),xX=_X("secondRadiation","0.014387768775039337","m K"),wX=_X("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),EX=_X("wienDisplacement","2.897771955e-3","m K"),MX=_X("molarMass","0.99999999965e-3","kg mol^-1"),SX=_X("molarMassC12","11.9999999958e-3","kg mol^-1"),CX=_X("gravity","9.80665","m s^-2"),NX=_X("planckLength","1.616255e-35","m"),AX=_X("planckMass","2.176435e-8","kg"),kX=_X("planckTime","5.391245e-44","s"),TX=_X("planckCharge","1.87554603778e-18","C"),OX=_X("planckTemperature","1.416785e+32","K");function _X(e,t,n){return EF(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 RX(e,t){return EF(e,["config","BigNumber"],function(e){var n=e.config,r=e.BigNumber;return"BigNumber"===n.number?new r(t):t})}_F({});var DX=E$({});I$({}),vZ({}),bZ({}),yZ({});var IX=p$({config:AP}),LX=L$({});gZ({}),RZ({Complex:DX}),AZ({BigNumber:IX,config:AP}),TZ({BigNumber:IX,config:AP}),wZ({BigNumber:IX,config:AP}),EZ({BigNumber:IX,config:AP}),OZ({BigNumber:IX,config:AP}),MZ({BigNumber:IX,config:AP}),cX({BigNumber:IX,config:AP}),eX({BigNumber:IX,config:AP}),bX({BigNumber:IX,config:AP}),lX({BigNumber:IX,config:AP});var BX=D$({});SZ({BigNumber:IX,config:AP}),xZ({BigNumber:IX,config:AP}),kZ({BigNumber:IX,config:AP}),DZ({});var zX=B$({Matrix:LX});CZ({BigNumber:IX,config:AP});var PX=CF({BigNumber:IX,Complex:DX,DenseMatrix:zX,Fraction:BX}),FX=W$({typed:PX}),jX=cU({typed:PX}),$X=hU({typed:PX}),HX=yU({typed:PX}),UX=EU({config:AP,typed:PX}),qX=SU({typed:PX});kU({typed:PX});var VX=OU({Complex:DX,typed:PX});LU({typed:PX}),FU({BigNumber:IX,config:AP,typed:PX});var WX=HU({isInteger:FX,typed:PX});eq({typed:PX}),rq({Complex:DX,typed:PX}),yq({Complex:DX,config:AP,typed:PX});var KX=Sq({typed:PX}),GX=Oq({BigNumber:IX,Fraction:BX,complex:VX,typed:PX});Dq({typed:PX}),Qq({typed:PX}),oV({typed:PX}),lV({typed:PX});var JX=uV({typed:PX});CV({typed:PX}),OV({typed:PX});var YX=PV({typed:PX});SW({typed:PX});var ZX=BW({typed:PX});$W({typed:PX}),qW({typed:PX}),GW({typed:PX}),DG({Complex:DX,config:AP,typed:PX}),zG({BigNumber:IX,typed:PX}),$G({BigNumber:IX,Complex:DX,config:AP,typed:PX}),VG({BigNumber:IX,Complex:DX,config:AP,typed:PX}),JG({Complex:DX,config:AP,typed:PX});var XX=ZG({typed:PX});tJ({Complex:DX,config:AP,typed:PX}),iJ({typed:PX}),aJ({BigNumber:IX,typed:PX}),uJ({BigNumber:IX,typed:PX}),hJ({BigNumber:IX,typed:PX}),gJ({typed:PX}),vJ({typed:PX});var QX=BY({typed:PX});nZ({config:AP,typed:PX}),aZ({config:AP,typed:PX}),NZ({BigNumber:IX,config:AP}),P$({typed:PX}),dU({isNumeric:jX,typed:PX}),bU({typed:PX}),NU({typed:PX});var eQ=_U({Fraction:BX,typed:PX}),tQ=zU({typed:PX}),nQ=VU({typed:PX});tq({typed:PX}),bq({Complex:DX,config:AP,typed:PX});var rQ=_q({Complex:DX,config:AP,typed:PX}),iQ=aV({typed:PX});DV({typed:PX}),_W({isNaN:HX,isNumeric:jX,typed:PX}),jW({typed:PX}),LG({Complex:DX,config:AP,typed:PX}),UG({BigNumber:IX,typed:PX}),YG({typed:PX});var oQ=nJ({typed:PX});lJ({BigNumber:IX,typed:PX});var sQ=fJ({typed:PX});FY({typed:PX}),oZ({config:AP,typed:PX}),_Z({BigNumber:IX,config:AP});var aQ=aU({typed:PX}),lQ=MU({Matrix:LX,equalScalar:UX,typed:PX}),cQ=DU({DenseMatrix:zX,Matrix:LX,SparseMatrix:lQ,typed:PX});KU({BigNumber:IX,Complex:DX,Fraction:BX,config:AP,isNegative:aQ,matrix:cQ,typed:PX,unaryMinus:tQ}),pq({BigNumber:IX,DenseMatrix:zX,equalScalar:UX,matrix:cQ,typed:PX}),Mq({DenseMatrix:zX,equalScalar:UX,matrix:cQ,typed:PX}),kq({BigNumber:IX,equalScalar:UX,matrix:cQ,typed:PX}),Pq({BigNumber:IX,config:AP,matrix:cQ,typed:PX}),Zq({equalScalar:UX,matrix:cQ,typed:PX}),iV({DenseMatrix:zX,matrix:cQ,typed:PX}),dV({DenseMatrix:zX,equalScalar:UX,matrix:cQ,typed:PX});var uQ=fV({isInteger:FX,matrix:cQ,typed:PX});wV({DenseMatrix:zX,SparseMatrix:lQ,matrix:cQ,typed:PX});var dQ=LV({BigNumber:IX,DenseMatrix:zX,SparseMatrix:lQ,config:AP,matrix:cQ,typed:PX});HV({BigNumber:IX,config:AP,matrix:cQ,typed:PX}),JV({isInteger:FX,matrix:cQ,typed:PX});var pQ=iW({matrix:cQ,config:AP,typed:PX}),hQ=fW({matrix:cQ,typed:PX}),fQ=MW({BigNumber:IX,config:AP,matrix:cQ,typed:PX});HW({typed:PX});var mQ=iK({BigNumber:IX,DenseMatrix:zX,equalScalar:UX,matrix:cQ,typed:PX,zeros:fQ});OK({DenseMatrix:zX,equalScalar:UX,matrix:cQ,typed:PX,zeros:fQ}),IK({DenseMatrix:zX,equalScalar:UX,matrix:cQ,typed:PX,zeros:fQ});var gQ=zK({BigNumber:IX,DenseMatrix:zX,Fraction:BX,config:AP,equalScalar:UX,matrix:cQ,typed:PX}),yQ=HK({matrix:cQ,typed:PX}),vQ=GK({DenseMatrix:zX,config:AP,matrix:cQ,typed:PX}),bQ=XK({DenseMatrix:zX,config:AP,matrix:cQ,typed:PX});iG({DenseMatrix:zX,config:AP,equalScalar:UX,matrix:cQ,typed:PX});var xQ=dG({DenseMatrix:zX,smaller:vQ}),wQ=hG({larger:bQ,smaller:vQ});TG({SparseMatrix:lQ,typed:PX}),FG({BigNumber:IX,Complex:DX,config:AP,typed:PX}),QG({BigNumber:IX,DenseMatrix:zX,equalScalar:UX,matrix:cQ,typed:PX}),dJ({BigNumber:IX,typed:PX});var EQ=FJ({DenseMatrix:zX,SparseMatrix:lQ,addScalar:nQ,equalScalar:UX,matrix:cQ,typed:PX}),MQ=qJ({addScalar:nQ,conj:iQ,multiplyScalar:KX,size:pQ,typed:PX});mZ({addScalar:nQ,combinations:QX,isInteger:FX,isNegative:aQ,isPositive:$X,larger:bQ,typed:PX});var SQ=mU({typed:PX}),CQ=jU({typed:PX}),NQ=aq({config:AP,equalScalar:UX,matrix:cQ,round:mQ,typed:PX}),AQ=Nq({addScalar:nQ,dot:MQ,equalScalar:UX,matrix:cQ,multiplyScalar:KX,typed:PX});$q({equalScalar:UX,matrix:cQ,multiplyScalar:KX,typed:PX}),cV({typed:PX}),kV({matrix:cQ,typed:PX}),ZV({config:AP,matrix:cQ}),sW({matrix:cQ,typed:PX}),WW({matrix:cQ,typed:PX});var kQ=XW({Complex:DX,config:AP,fraction:eQ,identity:dQ,matrix:cQ,multiply:AQ,number:qX,typed:PX});pK({DenseMatrix:zX,equalScalar:UX,matrix:cQ,pow:kQ,typed:PX}),RK({DenseMatrix:zX,equalScalar:UX,matrix:cQ,typed:PX,zeros:fQ});var TQ=jK({compare:gQ,typed:PX});WK({compareText:yQ,isZero:SQ,typed:PX});var OQ=eG({DenseMatrix:zX,config:AP,matrix:cQ,typed:PX}),_Q=sG({compare:gQ,isNaN:HX,isNumeric:jX,typed:PX}),RQ=pG({ImmutableDenseMatrix:xQ});KG({BigNumber:IX,Complex:DX,config:AP,typed:PX}),yJ({typed:PX});var DQ=EJ({DenseMatrix:zX,Index:RQ,compareNatural:TQ,size:pQ,subset:hQ,typed:PX}),IQ=NJ({DenseMatrix:zX,Index:RQ,compareNatural:TQ,size:pQ,subset:hQ,typed:PX});OJ({Index:RQ,compareNatural:TQ,size:pQ,subset:hQ,typed:PX}),IJ({compareNatural:TQ,typed:PX}),VJ({add:EQ,matrix:cQ,typed:PX}),DY({add:EQ,compare:gQ,multiply:AQ,partitionSelect:_Q,typed:PX});var LQ=HY({BigNumber:IX,Complex:DX,config:AP,multiplyScalar:KX,pow:kQ,typed:PX}),BQ=TU({BigNumber:IX,typed:PX});mq({equalScalar:UX,matrix:cQ,typed:PX}),tV({DenseMatrix:zX,equalScalar:UX,matrix:cQ,typed:PX}),zV({matrix:cQ,multiplyScalar:KX,typed:PX});var zQ=bW({matrix:cQ,typed:PX}),PQ=JW({bignumber:BQ,fraction:eQ,number:qX});LK({equalScalar:UX,matrix:cQ,not:JX,typed:PX,zeros:fQ});var FQ=YK({DenseMatrix:zX,config:AP,matrix:cQ,typed:PX});lG({compare:gQ,compareNatural:TQ,matrix:cQ,typed:PX}),uG({config:AP,numeric:PQ,smaller:vQ,typed:PX}),oJ({BigNumber:IX,typed:PX}),SJ({DenseMatrix:zX,Index:RQ,compareNatural:TQ,size:pQ,subset:hQ,typed:PX}),RJ({Index:RQ,compareNatural:TQ,size:pQ,subset:hQ,typed:PX}),KJ({Index:RQ,typed:PX});var jQ=SY({add:EQ,config:AP,numeric:PQ,typed:PX}),$Q=qY({gamma:LQ,typed:PX});YY({factorial:$Q,typed:PX});var HQ=XU({config:AP,equalScalar:UX,matrix:cQ,round:mQ,typed:PX}),UQ=Lq({DenseMatrix:zX,addScalar:nQ,equalScalar:UX,matrix:cQ,typed:PX,unaryMinus:tQ});bV({matrix:cQ,multiply:AQ,subtract:UQ,typed:PX});var qQ=KV({bignumber:BQ,matrix:cQ,config:AP,larger:bQ,largerEq:OQ,smaller:vQ,smallerEq:FQ,typed:PX});nW({Index:RQ,matrix:cQ,range:qQ,typed:PX}),IW({config:AP,multiplyScalar:KX,numeric:PQ,typed:PX});var VQ=qK({DenseMatrix:zX,equalScalar:UX,matrix:cQ,typed:PX}),WQ=cG({config:AP,larger:bQ,numeric:PQ,typed:PX});xJ({DenseMatrix:zX,Index:RQ,compareNatural:TQ,size:pQ,subset:hQ,typed:PX});var KQ=BJ({Index:RQ,concat:uQ,setDifference:DQ,size:pQ,subset:hQ,typed:PX}),GQ=iq({Complex:DX,ceil:HQ,floor:NQ,matrix:cQ,typed:PX});yV({Index:RQ,matrix:cQ,range:qQ,typed:PX});var JQ=wW({conj:iQ,transpose:zQ,typed:PX});nG({equal:VQ,typed:PX}),kJ({Index:RQ,compareNatural:TQ,size:pQ,subset:hQ,typed:PX}),pV({DenseMatrix:zX,matrix:cQ,typed:PX});var YQ=ZW({numeric:PQ,typed:PX});uK({Complex:DX,config:AP,divideScalar:YQ,typed:PX});var ZQ=yK({DenseMatrix:zX,divideScalar:YQ,equalScalar:UX,matrix:cQ,multiplyScalar:KX,subtract:UQ,typed:PX});MK({DenseMatrix:zX,divideScalar:YQ,equalScalar:UX,matrix:cQ,multiplyScalar:KX,subtract:UQ,typed:PX});var XQ=fG({FibonacciHeap:wQ,addScalar:nQ,equalScalar:UX});PJ({Index:RQ,concat:uQ,setIntersect:IQ,setSymDifference:KQ,size:pQ,subset:hQ,typed:PX});var QQ=GJ({DenseMatrix:zX,Spa:XQ,SparseMatrix:lQ,abs:CQ,addScalar:nQ,divideScalar:YQ,equalScalar:UX,larger:bQ,matrix:cQ,multiplyScalar:KX,subtract:UQ,typed:PX,unaryMinus:tQ}),e0=cY({SparseMatrix:lQ,abs:CQ,add:EQ,divideScalar:YQ,larger:bQ,largerEq:OQ,multiply:AQ,subtract:UQ,transpose:zQ,typed:PX}),t0=hY({lup:QQ,matrix:cQ,multiply:AQ,subtract:UQ,typed:PX,unaryMinus:tQ});EY({abs:CQ,addScalar:nQ,divideScalar:YQ,multiplyScalar:KX,sqrt:rQ,subtract:UQ,typed:PX,unaryMinus:tQ});var n0=cZ({addScalar:nQ,combinations:QX,divideScalar:YQ,factorial:$Q,isInteger:FX,isNegative:aQ,larger:bQ,multiplyScalar:KX,pow:kQ,subtract:UQ,typed:PX});hZ({addScalar:nQ,combinations:QX,divideScalar:YQ,isInteger:FX,isNegative:aQ,multiplyScalar:KX,typed:PX}),$V({matrix:cQ,number:qX,subtract:UQ,typed:PX});var r0=sK({Complex:DX,config:AP,divideScalar:YQ,typed:PX}),i0=fK({DenseMatrix:zX,divideScalar:YQ,equalScalar:UX,matrix:cQ,typed:PX});AK({DenseMatrix:zX,divideScalar:YQ,equalScalar:UX,matrix:cQ,multiplyScalar:KX,subtract:UQ,typed:PX}),$J({abs:CQ,addScalar:nQ,divideScalar:YQ,isPositive:$X,multiplyScalar:KX,smaller:vQ,sqrt:rQ,typed:PX}),YJ({addScalar:nQ,complex:VX,conj:iQ,divideScalar:YQ,equal:VQ,identity:dQ,isZero:SQ,matrix:cQ,multiplyScalar:KX,sign:GX,sqrt:rQ,subtract:UQ,typed:PX,unaryMinus:tQ,zeros:fQ});var o0=fY({abs:CQ,addScalar:nQ,det:t0,divideScalar:YQ,identity:dQ,matrix:cQ,multiply:AQ,typed:PX,unaryMinus:tQ});yY({abs:CQ,add:EQ,identity:dQ,inv:o0,multiply:AQ,typed:PX});var s0=xY({divideScalar:YQ,equalScalar:UX,inv:o0,matrix:cQ,multiply:AQ,typed:PX});NY({add:EQ,divide:s0,typed:PX});var a0=RY({add:EQ,apply:WX,divide:s0,isNaN:HX,multiply:AQ,subtract:UQ,typed:PX});WY({divide:s0,dotDivide:i0,isNumeric:jX,log:r0,matrix:cQ,multiply:AQ,sum:jQ,typed:PX}),dZ({addScalar:nQ,isInteger:FX,isNegative:aQ,stirlingS2:n0,typed:PX}),lK({Complex:DX,config:AP,divideScalar:YQ,log:r0,typed:PX});var l0=CG({BigNumber:IX,Complex:DX,Fraction:BX,abs:CQ,addScalar:nQ,config:AP,divideScalar:YQ,equal:VQ,fix:GQ,format:ZX,isNumeric:jX,multiplyScalar:KX,number:qX,pow:kQ,round:mQ,subtract:UQ});_G({Unit:l0,typed:PX});var c0=mY({abs:CQ,add:EQ,addScalar:nQ,atan:XX,bignumber:BQ,config:AP,cos:oQ,equal:VQ,inv:o0,matrix:cQ,multiply:AQ,multiplyScalar:KX,sin:sQ,subtract:UQ,typed:PX});MY({abs:CQ,add:EQ,addScalar:nQ,config:AP,divideScalar:YQ,equalScalar:UX,matrix:cQ,multiply:AQ,multiplyScalar:KX,smaller:vQ,subtract:UQ,typed:PX}),IY({sqrt:rQ,typed:PX,variance:a0}),uX({BigNumber:IX,Unit:l0,config:AP}),qZ({BigNumber:IX,Unit:l0,config:AP}),pX({BigNumber:IX,Unit:l0,config:AP}),VZ({BigNumber:IX,Unit:l0,config:AP}),rX({BigNumber:IX,Unit:l0,config:AP}),XZ({BigNumber:IX,Unit:l0,config:AP}),hX({BigNumber:IX,Unit:l0,config:AP}),fX({BigNumber:IX,Unit:l0,config:AP}),BZ({BigNumber:IX,Unit:l0,config:AP}),tX({BigNumber:IX,Unit:l0,config:AP}),JZ({BigNumber:IX,Unit:l0,config:AP}),FZ({BigNumber:IX,Unit:l0,config:AP}),MX({BigNumber:IX,Unit:l0,config:AP}),yX({BigNumber:IX,Unit:l0,config:AP}),iX({BigNumber:IX,Unit:l0,config:AP}),TX({BigNumber:IX,Unit:l0,config:AP}),NX({BigNumber:IX,Unit:l0,config:AP}),OX({BigNumber:IX,Unit:l0,config:AP}),nX({BigNumber:IX,Unit:l0,config:AP}),PZ({BigNumber:IX,Unit:l0,config:AP}),xX({BigNumber:IX,Unit:l0,config:AP}),wX({BigNumber:IX,Unit:l0,config:AP}),$Z({BigNumber:IX,Unit:l0,config:AP});var u0=bK({DenseMatrix:zX,divideScalar:YQ,equalScalar:UX,matrix:cQ,multiplyScalar:KX,subtract:UQ,typed:PX}),d0=UJ({abs:CQ,add:EQ,conj:iQ,ctranspose:JQ,eigs:c0,equalScalar:UX,larger:bQ,matrix:cQ,multiply:AQ,pow:kQ,smaller:vQ,sqrt:rQ,typed:PX});pY({DenseMatrix:zX,lsolve:ZQ,lup:QQ,matrix:cQ,slu:e0,typed:PX,usolve:u0}),bY({abs:CQ,add:EQ,identity:dQ,inv:o0,max:WQ,multiply:AQ,size:pQ,sqrt:rQ,subtract:UQ,typed:PX}),GY({add:EQ,divide:s0,factorial:$Q,isInteger:FX,isPositive:$X,multiply:AQ,typed:PX}),dX({BigNumber:IX,Unit:l0,config:AP}),ZZ({BigNumber:IX,Unit:l0,config:AP}),jZ({BigNumber:IX,Unit:l0,config:AP}),QZ({BigNumber:IX,Unit:l0,config:AP}),CX({BigNumber:IX,Unit:l0,config:AP}),mX({BigNumber:IX,Unit:l0,config:AP}),SX({BigNumber:IX,Unit:l0,config:AP}),GZ({BigNumber:IX,Unit:l0,config:AP}),AX({BigNumber:IX,Unit:l0,config:AP}),oX({BigNumber:IX,Unit:l0,config:AP}),LZ({BigNumber:IX,Unit:l0,config:AP}),EX({BigNumber:IX,Unit:l0,config:AP});var p0=tW({BigNumber:IX,DenseMatrix:zX,SparseMatrix:lQ,addScalar:nQ,config:AP,cos:oQ,matrix:cQ,multiplyScalar:KX,norm:d0,sin:sQ,typed:PX,unaryMinus:tQ}),h0=kY({add:EQ,compare:gQ,divide:s0,partitionSelect:_Q,typed:PX});YZ({BigNumber:IX,Unit:l0,config:AP}),UZ({BigNumber:IX,Unit:l0,config:AP}),WZ({BigNumber:IX,Unit:l0,config:AP}),vX({BigNumber:IX,Unit:l0,config:AP}),kX({BigNumber:IX,Unit:l0,config:AP}),aX({BigNumber:IX,Unit:l0,config:AP}),QV({multiply:AQ,rotationMatrix:p0,typed:PX}),TY({abs:CQ,map:YX,median:h0,subtract:UQ,typed:PX}),HZ({BigNumber:IX,Unit:l0,config:AP}),KZ({BigNumber:IX,Unit:l0,config:AP}),sX({BigNumber:IX,Unit:l0,config:AP}),AG({Unit:l0,typed:PX}),gX({BigNumber:IX,Unit:l0,config:AP}),zZ({BigNumber:IX,Unit:l0,config:AP});const f0=i,m0=e,{TextField:g0}=n,{IconButton:y0}=n,{InputAdornment:v0}=n,{styled:b0}=r,{Remove:x0}=o,{Add:w0}=o,E0=b0(g0)(()=>({"& 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}})),M0=b0(y0)(()=>({padding:"2px"}));class S0 extends m0.Component{static __initStatic(){this.propTypes={className:f0.string,customValues:f0.array,disabled:f0.bool,error:f0.bool,inputClassName:f0.string,helperText:f0.string,onChange:f0.func.isRequired,onlyIntegersAllowed:f0.bool,value:f0.any,min:f0.number,max:f0.number,step:f0.number,label:f0.string,disableUnderline:f0.bool,textAlign:f0.string,variant:f0.string,type:f0.string}}static __initStatic2(){this.defaultProps={step:1,customValues:[],textAlign:"center",variant:"standard",onlyIntegersAllowed:!1}}constructor(e){super(e),S0.prototype.__init.call(this),S0.prototype.__init2.call(this),S0.prototype.__init3.call(this),S0.prototype.__init4.call(this),S0.prototype.__init5.call(this),S0.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:pr(e)?(pr(n)&&(e=Math.min(e,n)),pr(t)&&(e=Math.max(e,t)),e):((e,t)=>pr(e)||pr(t)?!pr(e)&&pr(t)?t:pr(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(qX(eQ(n))-qX(eQ(t)))<Math.abs(qX(eQ(e.value))-qX(eQ(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]):pr(i)&&pr(o)&&(m=h===i,g=h===o),m0.createElement(E0,{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:m0.createElement(v0,{position:"start"},m0.createElement(M0,{disabled:n||m,onClick:e=>this.changeValue(e,-1,!0),size:"large"},m0.createElement(x0,{fontSize:"small"}))),endAdornment:m0.createElement(v0,{position:"end"},m0.createElement(M0,{disabled:n||g,onClick:e=>this.changeValue(e,1,!0),size:"large"},m0.createElement(w0,{fontSize:"small"})))},inputProps:{style:{textAlign:d},min:i,max:o}})}}S0.__initStatic(),S0.__initStatic2();const C0=i,N0=e,{styled:A0}=r,k0=A0("div")(({theme:e,direction:t})=>({display:"flex",flexWrap:"wrap",paddingLeft:0,marginTop:e.spacing(1),..."vertical"===t&&{flexDirection:"column"}}));class T0 extends N0.Component{constructor(...e){super(...e),T0.prototype.__init.call(this)}static __initStatic(){this.propTypes={header:C0.string.isRequired,className:C0.string,customLabel:C0.func,opts:C0.array.isRequired,value:C0.string,onChange:C0.func.isRequired,direction:C0.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||HL;return N0.createElement(VT,{label:e,className:t},N0.createElement(k0,{direction:o},s.map((e,t)=>N0.createElement(a,{value:e.value,key:t,checked:e.value===i,onChange:this.handleChange,label:e.label}))))}}T0.__initStatic();const O0=C0.shape({label:C0.string,value:C0.string});class _0 extends N0.Component{static __initStatic2(){this.propTypes={header:C0.string.isRequired,value:C0.string.isRequired,onChange:C0.func.isRequired,one:C0.oneOfType([O0,C0.string]),two:C0.oneOfType([O0,C0.string]),className:C0.string,customLabel:C0.func}}render(){const{one:e,two:t,header:n,className:r,customLabel:i,value:o,onChange:s}=this.props,a=[e,t];return N0.createElement(T0,{customLabel:i,header:n,className:r,opts:a,value:o,onChange:s})}}_0.__initStatic2();const R0=e,D0=i,{styled:I0}=r,L0=s("pie-elements:config-ui:mui-box"),B0=I0("div")(({theme:e,focused:t})=>{const n="light"===e.palette.mode?"rgba(0, 0, 0, 0.42)":"rgba(255, 255, 255, 0.7)";return L0(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]}}}),z0=({children:e,focused:t})=>R0.createElement(B0,{focused:t},e);z0.propTypes={children:D0.oneOfType([D0.arrayOf(D0.node),D0.node]).isRequired,focused:D0.bool.isRequired};const P0=e,F0=i,{styled:j0}=r,{Chip:$0}=n,H0=j0($0)(()=>({padding:"0px",margin:"1px"})),U0=({label:e,onDelete:t})=>P0.createElement(H0,{label:e,onDelete:t});U0.propTypes={label:F0.string.isRequired,onDelete:F0.func.isRequired};const q0=j0("div")(({theme:e})=>({border:`0px solid ${e.palette.background.paper}`,display:"flex",flexWrap:"wrap"})),V0=j0("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 W0 extends P0.Component{static __initStatic(){this.propTypes={tags:F0.arrayOf(F0.string).isRequired,onChange:F0.func.isRequired}}constructor(e){super(e),W0.prototype.__init.call(this),W0.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=Sr(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 P0.createElement(z0,{focused:this.state.focused},P0.createElement(q0,null,(e||[]).map((e,t)=>P0.createElement(U0,{key:t,label:e,onDelete:()=>this.deleteTag(e)})),P0.createElement(V0,{ref:e=>this.input=e,onKeyDown:this.onKeyDown,onChange:this.onChange,value:this.state.value,onFocus:this.onFocus,onBlur:this.onBlur,type:"text"})))}}W0.__initStatic();const{Menu:K0}=n,{MenuItem:G0}=n,{IconButton:J0}=n,{Feedback:Y0}=o,Z0=i,X0=e;class Q0 extends X0.Component{static __initStatic(){this.propTypes={opts:Z0.object,onClick:Z0.func.isRequired,iconButtonElement:Z0.any}}constructor(e){super(e),Q0.prototype.__init.call(this),Q0.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 X0.createElement("div",null,X0.createElement("div",{onClick:this.handleClick},this.props.iconButtonElement),X0.createElement(K0,{id:"simple-menu",anchorEl:this.state.anchorEl,open:this.state.open,onClose:this.handleRequestClose,transitionDuration:{enter:225,exit:195}},n.map((t,n)=>X0.createElement(G0,{key:n,onClick:r(t)},e[t]))))}}Q0.__initStatic();class e1 extends X0.Component{static __initStatic2(){this.propTypes={value:Z0.object,onChange:Z0.func.isRequired,classes:Z0.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=X0.createElement(J0,{className:n.icon,"aria-label":o,size:"large"},X0.createElement(Y0,{color:i}));return X0.createElement(Q0,{iconButtonElement:s,onClick:e=>t(e),opts:{none:"No Feedback",default:"Default",custom:"Custom"}})}}e1.__initStatic2(),e1.__initStatic3();const t1=e,n1=i,{styled:r1}=r,{TextField:i1}=n,{IconButton:o1}=n,{Delete:s1}=o,{SubdirectoryArrowRight:a1}=o;let l1;"undefined"!=typeof window&&(l1=require("@pie-lib/editable-html-tip-tap").default);const c1=r1("div")(({theme:e})=>({marginTop:e.spacing(2)})),u1=({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={}})=>t1.createElement(VT,{label:e,className:r},t1.createElement(c1,null,t1.createElement(l1,{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}))),d1=r1("div")(()=>({position:"relative"})),p1=r1(a1)(({theme:e})=>({fill:e.palette.grey[400],left:-56,position:"absolute",top:40})),h1=r1(i1)(({theme:e})=>({width:"100%",marginTop:e.spacing(2)})),f1=r1(u1)(({theme:e})=>({width:"100%",marginTop:e.spacing(2)})),m1=({value:e,onChange:t,type:n,correct:r,defaults:i,toolbarOpts:o,mathMlOptions:s={}})=>n&&"none"!==n?"default"===n?t1.createElement(d1,null,t1.createElement(p1,null),t1.createElement(h1,{label:"Feedback Text",value:r?i.correct:i.incorrect,variant:"standard"})):t1.createElement(d1,null,t1.createElement(p1,null),t1.createElement(f1,{label:"Feedback Text",value:e,onChange:t,toolbarOpts:o,mathMlOptions:s})):null,g1=r1("span")(({theme:e})=>({paddingRight:e.spacing(1),paddingTop:e.spacing(3)})),y1=r1("div")(()=>({display:"flex",alignItems:"center"})),v1=r1("div")(({theme:e})=>({flex:"0 1 auto",paddingTop:e.spacing(.5),paddingBottom:0,marginRight:0,marginLeft:e.spacing(1)})),b1=r1("div")(({theme:e})=>({flex:"0 1 auto",paddingTop:e.spacing(2),paddingLeft:0,marginLeft:0,marginRight:e.spacing(1)})),x1=r1("div")(()=>({margin:0,width:"inherit"})),w1=r1("div")(()=>({margin:0,width:"inherit"})),E1=r1("div")(({theme:e})=>({flex:"0 1 auto",paddingTop:e.spacing(2),paddingLeft:0,marginLeft:0})),M1=r1("div")(({theme:e})=>({display:"flex",flex:1,flexDirection:"column",marginRight:e.spacing(1)})),S1=r1("div")(({theme:e})=>({fontSize:e.typography.fontSize-2,color:e.palette.error.main}));class C1 extends t1.Component{constructor(...e){super(...e),C1.prototype.__init.call(this),C1.prototype.__init2.call(this),C1.prototype.__init3.call(this),C1.prototype.__init4.call(this),C1.prototype.__init5.call(this)}static __initStatic(){this.propTypes={noLabels:n1.bool,useLetterOrdering:n1.bool,className:n1.string,error:n1.string,mode:n1.oneOf(["checkbox","radio"]),defaultFeedback:n1.object.isRequired,disabled:n1.bool,nonEmpty:n1.bool,data:n1.shape({label:n1.string.isRequired,value:n1.string.isRequired,correct:n1.bool,feedback:n1.shape({type:n1.string,value:n1.string})}),onDelete:n1.func,onChange:n1.func,index:n1.number,imageSupport:n1.shape({add:n1.func.isRequired,delete:n1.func.isRequired}),disableImageAlignmentButtons:n1.bool,allowFeedBack:n1.bool,allowDelete:n1.bool,noCorrectAnswerError:n1.string,spellCheck:n1.bool,pluginOpts:n1.object,toolbarOpts:n1.object,uploadSoundSupport:n1.object,maxImageWidth:n1.number,maxImageHeight:n1.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:x,maxImageHeight:w,mathMlOptions:E={}}=this.props,M="checkbox"===t?kB:OB;return t1.createElement(y1,null,i>0&&t1.createElement(g1,{type:"title"},a?String.fromCharCode(96+i).toUpperCase():i),t1.createElement(v1,null,t1.createElement(M,{onChange:this.onCheckedChange,label:s?"":"Correct",checked:!!e.correct,error:v})),t1.createElement(M1,null,t1.createElement(u1,{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:E,maxImageWidth:x,maxImageHeight:w}),y&&t1.createElement(S1,null,y),h&&t1.createElement(m1,{...e.feedback,correct:e.correct,defaults:r,onChange:this.onFeedbackValueChange,toolbarOpts:g})),h&&t1.createElement(b1,null,t1.createElement(VT,{label:s?"":"Feedback"},t1.createElement(x1,null,t1.createElement(e1,{onChange:this.onFeedbackTypeChange,value:e.feedback})))),f&&t1.createElement(E1,null,t1.createElement(VT,{label:s?"":"Delete"},t1.createElement(w1,null,t1.createElement(o1,{"aria-label":"delete",onClick:n,size:"large"},t1.createElement(s1,null))))))}}C1.__initStatic(),C1.__initStatic2();var N1=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}()}(),A1="undefined"!=typeof window&&"undefined"!=typeof document&&window.document===document,k1="undefined"!=typeof global&&global.Math===Math?global:"undefined"!=typeof self&&self.Math===Math?self:"undefined"!=typeof window&&window.Math===Math?window:Function("return this")(),T1="function"==typeof requestAnimationFrame?requestAnimationFrame.bind(k1):function(e){return setTimeout(function(){return e(Date.now())},1e3/60)};var O1=["top","right","bottom","left","width","height","size","weight"],_1="undefined"!=typeof MutationObserver,R1=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(){T1(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(){A1&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),_1?(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(){A1&&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=O1.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}(),D1=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},I1=function(e){return e&&e.ownerDocument&&e.ownerDocument.defaultView||k1},L1=$1(0,0,0,0);function B1(e){return parseFloat(e)||0}function z1(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return t.reduce(function(t,n){return t+B1(e["border-"+n+"-width"])},0)}function P1(e){var t=e.clientWidth,n=e.clientHeight;if(!t&&!n)return L1;var r=I1(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]=B1(o)}return t}(r),o=i.left+i.right,s=i.top+i.bottom,a=B1(r.width),l=B1(r.height);if("border-box"===r.boxSizing&&(Math.round(a+o)!==t&&(a-=z1(r,"left","right")+o),Math.round(l+s)!==n&&(l-=z1(r,"top","bottom")+s)),!function(e){return e===I1(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 $1(i.left,i.top,a,l)}var F1="undefined"!=typeof SVGGraphicsElement?function(e){return e instanceof I1(e).SVGGraphicsElement}:function(e){return e instanceof I1(e).SVGElement&&"function"==typeof e.getBBox};function j1(e){return A1?F1(e)?function(e){var t=e.getBBox();return $1(0,0,t.width,t.height)}(e):P1(e):L1}function $1(e,t,n,r){return{x:e,y:t,width:n,height:r}}var H1=function(){function e(e){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=$1(0,0,0,0),this.target=e}return e.prototype.isActive=function(){var e=j1(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}(),U1=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),D1(l,{x:r,y:i,width:o,height:s,top:i,right:r+o,bottom:s+i,left:r}),l);D1(this,{target:e,contentRect:c})},q1=function(){function e(e,t,n){if(this.activeObservations_=[],this.observations_=new N1,"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 I1(e).Element))throw new TypeError('parameter 1 is not of type "Element".');var t=this.observations_;t.has(e)||(t.set(e,new H1(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 I1(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 U1(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}(),V1="undefined"!=typeof WeakMap?new WeakMap:new N1,W1=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=R1.getInstance(),r=new q1(t,n,this);V1.set(this,r)};["observe","unobserve","disconnect"].forEach(function(e){W1.prototype[e]=function(){var t;return(t=V1.get(this))[e].apply(t,arguments)}});var K1=void 0!==k1.ResizeObserver?k1.ResizeObserver:W1;const{Component:G1}=e,{createElement:J1}=e,Y1=i;var Z1=["client","offset","scroll","bounds","margin"];function X1(e){var t=[];return Z1.forEach(function(n){e[n]&&t.push(n)}),t}function Q1(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 e2(e){return function(t){var n,r;return r=n=function(n){function r(){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=Q1(t._node,e||X1(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}pk(r,n);var i=r.prototype;return i.componentDidMount=function(){this._resizeObserver=null!==this._window&&this._window.ResizeObserver?new this._window.ResizeObserver(this.measure):new K1(this.measure),null!==this._node&&(this._resizeObserver.observe(this._node),"function"==typeof this.props.onResize&&this.props.onResize(Q1(this._node,e||X1(this.props))))},i.componentWillUnmount=function(){null!==this._window&&this._window.cancelAnimationFrame(this._animationFrameID),null!==this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null)},i.render=function(){var e=this.props;e.innerRef,e.onResize;var n=uk(e,["innerRef","onResize"]);return J1(t,ck({},n,{measureRef:this._handleRef,measure:this.measure,contentRect:this.state.contentRect}))},r}(G1),n.propTypes={client:Y1.bool,offset:Y1.bool,scroll:Y1.bool,bounds:Y1.bool,margin:Y1.bool,innerRef:Y1.oneOfType([Y1.object,Y1.func]),onResize:Y1.func},r}}var t2=e2()(function(e){var t=e.measure,n=e.measureRef,r=e.contentRect;return(0,e.children)({measure:t,measureRef:n,contentRect:r})});t2.displayName="Measure",t2.propTypes.children=Y1.func;const n2=e,r2=i,{styled:i2}=r;function o2(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 s2=i2("div")(()=>({display:"flex",flexDirection:"column",position:"relative"})),a2=i2("div")(()=>({display:"flex",justifyContent:"space-between"})),l2=i2("div")(({theme:e})=>({padding:`${e.spacing(2)} 0`})),c2=i2("div")(()=>({flex:"1"})),u2=i2("div")(({theme:e})=>({marginLeft:e.spacing(2)}));class d2 extends n2.Component{constructor(...e){super(...e),d2.prototype.__init.call(this)}static __initStatic(){this.propTypes={mode:r2.oneOf(["tabbed","inline"]),secondary:r2.oneOfType([r2.arrayOf(r2.node),r2.node]),children:r2.oneOfType([r2.arrayOf(r2.node),r2.node]),dimensions:r2.object}}__init(){this.getConfiguration=()=>{const{secondary:e}=this.props;return o2([e,"optionalAccess",e=>e.props,"optionalAccess",e=>e.configuration])||o2([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])=>!!o2([e,"optionalAccess",e=>e.settings]));if(!c)try{c=o2([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 n2.createElement(s2,{style:{minHeight:i,minWidth:o,maxHeight:s,maxWidth:a}},"inline"===e&&n2.createElement(a2,null,n2.createElement(c2,{className:"design-container"},n),c&&n2.createElement(u2,{className:"settings-container"},t)),"tabbed"===e&&c&&n2.createElement(YB,{onChange:this.onTabsChange,contentClassName:"content-container",indicatorColor:"primary"},n2.createElement(l2,{title:"Design",className:"design-container"},n),n2.createElement(l2,{title:"Settings",className:"settings-container"},t)),"tabbed"===e&&!c&&n2.createElement(l2,{className:"design-container"},n))}}d2.__initStatic();const p2=e,h2=i,{styled:f2}=r,m2=f2("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 g2 extends p2.Component{static __initStatic(){this.propTypes={className:h2.string,children:h2.oneOfType([h2.arrayOf(h2.node),h2.node]).isRequired}}static __initStatic2(){this.defaultProps={}}render(){const{className:e,children:t}=this.props;return p2.createElement(m2,{className:e},t)}}g2.__initStatic(),g2.__initStatic2();const y2=e,{createTheme:v2}=r,{StyledEngineProvider:b2}=r,{ThemeProvider:x2}=r,w2=i;const E2=v2({typography:{fontFamily:"inherit"},components:{MuiButton:{styleOverrides:{contained:{backgroundColor:"#e0e0e0",color:"#000000","&:hover":{backgroundColor:"#bdbdbd"}}}}}});class M2 extends y2.Component{static __initStatic(){this.propTypes={children:w2.oneOfType([w2.string,w2.arrayOf(w2.element),w2.element]),className:w2.string,dimensions:w2.object,settings:w2.element,sidePanelMinWidth:w2.number,hideSettings:w2.bool,extraCSSRules:w2.shape({names:w2.arrayOf(w2.string),rules:w2.string})}}static __initStatic2(){this.defaultProps={sidePanelMinWidth:1135,hideSettings:!1,dimensions:{}}}constructor(...e){super(...e),M2.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 y2.createElement(b2,{injectFirst:!0},y2.createElement(x2,{theme:E2},y2.createElement(t2,{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?y2.createElement(g2,{className:"settings-box"},n):n,l=r?null:a;return y2.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])?y2.createElement("style",{dangerouslySetInnerHTML:{__html:`.extraCSSRules { ${o.rules} }`}}):null,y2.createElement(d2,{mode:s,secondary:l,dimensions:i},t))})))}}M2.__initStatic(),M2.__initStatic2(),e2("bounds")(M2);const S2=e,C2=i,{InputLabel:N2}=n,{Switch:A2}=n,{styled:k2}=r,T2=k2("div")(()=>({display:"flex",width:"100%",justifyContent:"space-between"})),O2=k2(N2)(({theme:e})=>({color:"rgba(0, 0, 0, 0.89)",fontSize:e.typography.fontSize,paddingTop:e.spacing(2)})),_2=k2(A2)(({checked:e})=>({"&.Mui-checked .MuiSwitch-thumb":{color:`${Kk()} !important`},"&.Mui-checked .MuiSwitch-track":{backgroundColor:`${Gk()} !important`},"& .MuiSwitch-track":{backgroundColor:e?`${Gk()} !important`:void 0}})),R2=({checked:e,disabled:t,label:n,toggle:r})=>S2.createElement(T2,null,S2.createElement(O2,null,n),S2.createElement(_2,{checked:e,disabled:t,onChange:e=>r(e.target.checked)}));R2.propTypes={checked:C2.bool,disabled:C2.bool,label:C2.string.isRequired,toggle:C2.func.isRequired};const D2=i,{styled:I2}=r;I2("div")(({theme:e})=>({display:"flex",paddingTop:e.spacing(1)})),D2.shape({width:D2.number.isRequired,height:D2.number.isRequired}).isRequired,D2.string.isRequired,D2.func;const{FormControlLabel:L2}=n,{Radio:B2}=n,z2=e,P2=i,{styled:F2}=r,j2=F2(L2)(({theme:e})=>({"& .MuiFormControlLabel-label":{color:"rgba(0, 0, 0, 0.89)",fontSize:e.typography.fontSize-2,left:"-5px",position:"relative"}})),$2=F2(B2)(()=>({color:`${Kk()} !important`})),H2=({label:e,value:t,checked:n,onChange:r})=>z2.createElement(j2,{value:t,control:z2.createElement($2,{checked:n,onChange:r}),label:e});H2.propTypes={label:P2.string,value:P2.string,checked:P2.bool,onChange:P2.func};const U2=e,q2=i,{styled:V2}=r,{Select:W2}=n,{Input:K2}=n,{MenuItem:G2}=n,{Typography:J2}=n,Y2=s("pie-lib:config-ui:settings:panel"),Z2={label:q2.string,value:q2.string},X2={label:q2.string,value:q2.string,onChange:q2.func},Q2=({label:e,value:t,onChange:n})=>U2.createElement(iz,{checked:t,label:e,onChange:e=>{n(e.target.checked)}});Q2.propTypes={label:q2.string,value:q2.bool,onChange:q2.func};const e5=V2(T0)(({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)}})),t5=({label:e,value:t,onChange:n,choices:r})=>U2.createElement(e5,{direction:"horizontal",customLabel:H2,value:t,header:e,opts:r,onChange:n});t5.propTypes={...X2,choices:q2.arrayOf(q2.shape(Z2))};const n5=t5,r5=V2("p")(({theme:e})=>({margin:0,fontSize:e.typography.fontSize})),i5=V2(W2)(({theme:e})=>({marginTop:e.spacing(.5),border:"2px solid lightgrey",padding:`0 ${e.spacing(1)}`,borderRadius:"4px"})),o5=({label:e,value:t,onChange:n,choices:r=[]})=>{const i=e=>"string"==typeof e?e:e.value;return U2.createElement("div",null,e&&U2.createElement(r5,null,e),U2.createElement(i5,{value:t||r&&r[0],onChange:({target:e})=>n(e.value),input:U2.createElement(K2,{id:`dropdown-${e}`}),disableUnderline:!0,MenuProps:{transitionDuration:{enter:225,exit:195}}},r.map((e,t)=>U2.createElement(G2,{key:t,value:i(e)},(e=>"string"==typeof e?e:e.label)(e)))))};o5.propTypes={...X2,choices:q2.arrayOf(q2.string)};const s5=V2(J2)(({theme:e})=>({marginRight:e.spacing(3),marginTop:e.spacing(1)})),a5=({label:e})=>U2.createElement(s5,null,e),l5=V2(Dz)(({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"}})),c5=({label:e,value:t,onChange:n=()=>{},suffix:r,min:i,max:o})=>U2.createElement(l5,{variant:"standard",label:e||"Label",value:t,max:o,min:i,onChange:(e,t)=>n(t),suffix:r,showErrorWhenOutsideRange:!0,disableUnderline:!0});c5.propTypes={...X2,suffix:q2.string,min:q2.number,max:q2.number,value:q2.number},a5.propTypes={...X2};const u5=({disabled:e,label:t,value:n,onChange:r})=>U2.createElement(R2,{label:t,checked:!!n,disabled:!!e,toggle:r});u5.propTypes={...X2,value:q2.bool};const d5={toggle:u5,radio:n5,dropdown:o5,numberField:c5,checkbox:Q2,textField:a5},p5=V2("div")(({theme:e})=>({margin:`0 0 ${e.spacing(2)} 0`})),h5=V2("div")(({theme:e})=>({color:"#495B8F",fontSize:e.typography.fontSize+2,fontWeight:600,marginBottom:e.spacing(1)})),f5=V2("p")(({theme:e})=>({fontSize:e.typography.fontSize,marginBottom:0})),m5=e=>{const{model:t,label:n,group:r,configuration:i,onChange:o}=e,s=(e,n,r)=>{const{isConfigProperty:s,...a}=kt(e,r||n),l=kt(s?i:t,n),c={...a,key:n,value:l},u=d5[c.type];return U2.createElement(u,{key:n,...c,onChange:e=>o(n,e,s)})};return U2.createElement(p5,null,U2.createElement(h5,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?U2.createElement("div",{key:`numberField-${i}`},U2.createElement(f5,null,i),Object.keys(o).map(n=>s(e,`${t}.${n}`,`${t}.fields.${n}`))):"checkboxes"===r?U2.createElement("div",{key:`checkbox-${i}`},U2.createElement("p",null,i),Object.keys(a).map(n=>s(e,`${t}.${n}`,`${t}.choices.${n}`))):s(e,t)})(r,e)))};m5.propTypes={model:q2.object,label:q2.string,group:q2.object,configuration:q2.object,onChange:q2.func};class g5 extends U2.Component{constructor(...e){super(...e),g5.prototype.__init.call(this)}static __initStatic(){this.propTypes={model:q2.object,configuration:q2.object,groups:q2.object,onChangeModel:q2.func,onChangeConfiguration:q2.func,modal:q2.object}}static __initStatic2(){this.defaultProps={onChangeModel:()=>{},onChangeConfiguration:()=>{}}}__init(){this.change=(e,t,n=!1)=>{Y2("[changeModel]",e,t);const{onChangeModel:r,onChangeConfiguration:i}=this.props,o={...this.props.model},s={...this.props.configuration};n?(wr(s,e,t),i(s,e)):(wr(o,e,t),r(o,e))}}render(){const{groups:e,model:t,configuration:n,modal:r}=this.props;Y2("render:",t);const i=Object.keys(e||{}).map(r=>Object.entries(e[r]).some(([,e])=>!!e)?U2.createElement(m5,{label:r,key:r,model:t,configuration:n,group:e[r],onChange:this.change}):null);return U2.createElement("div",null,i,r)}}g5.__initStatic(),g5.__initStatic2();const y5=e,{styled:v5}=r,b5=i,x5=v5("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"}}),w5=v5("div")({width:"230px"}),E5=v5("div")({position:"relative",overflowX:"hidden",display:"flex"}),M5=v5(VT)(({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 S5 extends y5.Component{static __initStatic(){this.propTypes={text:b5.string,comment:b5.string,annotations:b5.array,predefinedAnnotations:b5.array,onChange:b5.func.isRequired,onCommentChange:b5.func.isRequired,width:b5.number,height:b5.number,maxHeight:b5.string,disabled:b5.bool,disabledMath:b5.bool,customKeys:b5.array,keypadMode:b5.string}}constructor(e){super(e),S5.prototype.__init.call(this),S5.prototype.__init2.call(this),S5.prototype.__init3.call(this),S5.prototype.__init4.call(this),S5.prototype.__init5.call(this),S5.prototype.__init6.call(this),S5.prototype.__init7.call(this),S5.prototype.__init8.call(this),S5.prototype.__init9.call(this),S5.prototype.__init10.call(this),S5.prototype.__init11.call(this),S5.prototype.__init12.call(this),S5.prototype.__init13.call(this),S5.prototype.__init14.call(this),S5.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=nL(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=oL(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=cL(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=cL(o),a=uL(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=cL(r),o=uL(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=cL(r),o=uL(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")&&sL(t,this.textRef),n&&(n.style.zIndex=""),this.setState({anchorEl:null,openedMenu:!1,openedEditor:!1,selectedElems:[],labelElem:null,selectionDetails:null,annotationIndex:null,annotation:null}),aL()}}__init6(){this.handleSelection=e=>{const t=window.getSelection();if(e.detail>2)aL();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]=rL(n),[,i]=rL(e),o=r.length;return{quote:i,start:o,end:o+i.length}})(e,this.textRef),n=oL(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;(lL(o.label)?this.labelsRef:n[0]).removeChild(r),sL(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,lL(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=uL(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;lL(o)&&lL(e)||!lL(o)&&!lL(e)?(i.innerHTML=o,n&&(i.classList.remove(n),i.classList.add(s),r.forEach(e=>{e.classList.remove(n),e.classList.add(s)}))):lL(o)&&!lL(e)?(r[0].removeChild(i),this.createDOMAnnotation(r,t)):!lL(o)&&lL(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 y5.createElement("div",null,y5.createElement(E5,null,y5.createElement(x5,{style:{width:s-34,minHeight:o,maxHeight:a},ref:e=>this.textRef=e,onMouseDown:n?()=>{}:aL,onMouseUp:n?()=>{}:this.handleSelection,dangerouslySetInnerHTML:{__html:u}}),y5.createElement(w5,{ref:e=>this.labelsRef=e})),y5.createElement(M5,{label:"Comment"},y5.createElement(eL,{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}}})),y5.createElement(OL,{anchorEl:d,open:h&&!n,annotations:c,isNewAnnotation:!!m,onClose:this.handleClose,onDelete:this.deleteAnnotation,onEdit:this.editAnnotation,onWrite:this.addAnnotation,onAnnotate:this.handleMenuClick}),y5.createElement(xL,{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}))}}S5.__initStatic();const C5=e,N5=i,A5=s,{Typography:k5}=n,{styled:T5}=r,O5=A5("@pie-ui:extended-text-entry"),_5=T5(TT)({backgroundColor:Wk(),color:Vk()}),R5=T5(k5)(({theme:e})=>({width:"100%",color:Vk(),marginBottom:e.spacing(2),fontSize:"inherit"})),D5=T5("div")(({theme:e})=>({marginBottom:e.spacing(2)})),I5=T5(eL)(({theme:e})=>({marginBottom:e.spacing(2),borderRadius:"4px"})),L5=T5("h2")({position:"absolute",left:"-10000px",top:"auto",width:"1px",height:"1px",overflow:"hidden"});class B5 extends C5.Component{constructor(...e){super(...e),B5.prototype.__init.call(this),B5.prototype.__init2.call(this)}static __initStatic(){this.propTypes={onValueChange:N5.func.isRequired,onAnnotationsChange:N5.func.isRequired,onCommentChange:N5.func.isRequired,model:N5.object,session:N5.shape({value:N5.string,annotations:N5.array,comment:N5.string}).isRequired}}__init(){this.changeSessionValue=rr(this.props.onValueChange,1500)}__init2(){this.changeSessionComment=rr(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:x,comment:w,value:E}=t,{width:M,height:S}=s||{},C="40vh",N={position:"top"===h?"top":"bottom"};O5("[render] disabled? ",a);const A=C5.createElement(QT,{defaultClassName:"teacher-instructions",prompt:b}),k=[];return g&&k.push({language:"spanish"}),y&&k.push({language:"special"}),C5.createElement(_5,{extraCSSRules:u,ref:e=>{this.containerRef=e}},C5.createElement(L5,null,"Constructed Response Question"),b&&C5.createElement(D5,null,r?A:C5.createElement(vT,{labels:{hidden:"Show Teacher Instructions",visible:"Hide Teacher Instructions"}},A)),m&&C5.createElement(R5,{component:"span"},C5.createElement(QT,{defaultClassName:"prompt",prompt:e.prompt})),i?C5.createElement(S5,{text:E||"",annotations:x||[],comment:w||"",predefinedAnnotations:f||[],onChange:n,onCommentChange:this.changeSessionComment,width:M,height:S,maxHeight:C,disabled:l,disabledMath:!p,customKeys:o,keypadMode:c}):C5.createElement(I5,{className:"response-area-editor",onChange:this.changeSessionValue,markup:E||"",maxWidth:M&&M.toString(),minWidth:"100px",minHeight:S&&S.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&&C5.createElement(tT,{correctness:"correct",feedback:d}))}}B5.__initStatic();var z5,P5=t;z5=P5.createRoot,P5.hydrateRoot;var F5={};Object.defineProperty(F5,"__esModule",{value:!0});class j5 extends CustomEvent{constructor(e,t,n){super(j5.TYPE,{bubbles:!0,composed:!0,detail:{complete:t,component:e,hasModel:n}}),this.component=e,this.complete=t}}j5.TYPE="model-set";var $5=F5.ModelSetEvent=j5;class H5 extends CustomEvent{constructor(e,t){super(H5.TYPE,{bubbles:!0,composed:!0,detail:{complete:t,component:e}}),this.component=e,this.complete=t}}H5.TYPE="session-changed";var U5=F5.SessionChangedEvent=H5;const q5=e,V5=s,{renderMath:W5}=c,K5=V5("@pie-elements:extended-text-entry"),G5=void 0!==typeof window?new DOMParser:{parseFromString:e=>e};function J5(e){if("string"==typeof e)try{const t=G5.parseFromString(e,"text/html");return t.body.textContent}catch(t){return K5("tried to parse as dom and failed",e),e}}function Y5(e){const t=J5(e);return void 0!==t&&t.length>0}class Z5 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 $5(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 U5(this.tagName.toLowerCase(),Y5(e))),this.render()}annotationsChange(e){this._session.annotations=e,this.dispatchEvent(new U5(this.tagName.toLowerCase(),!0)),this.render()}commentChange(e){this._session.comment=e,this.dispatchEvent(new U5(this.tagName.toLowerCase(),Y5(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=q5.createElement(B5,{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=z5(this)),this._root.render(e),queueMicrotask(()=>{W5(this)})}}disconnectedCallback(){this._root&&this._root.unmount()}}export{Z5 as default,Y5 as isComplete,J5 as textContent};
1
+ import{_dll_react as e,_dll_prop_types as t,_dll_mui__material as n,_dll_mui__material_styles as o,_dll_debug as i,_dll_pie_lib__render_ui as s,_dll_react_dom_client as a}from"../../../@pie-lib/shared-module@^5.0.0/module/index.js";import{_dll_pie_lib__math_rendering as r}from"../../../@pie-lib/math-rendering-module@^5.0.0/module/index.js";import{_dll_pie_lib__editable_html_tip_tap as l}from"../../../@pie-lib/editable-html-module@^7.0.0/module/index.js";import{_dll_pie_lib__config_ui as d}from"../../../@pie-lib/config-module@^4.0.0/module/index.js";var c="object"==typeof global&&global&&global.Object===Object&&global,p="object"==typeof self&&self&&self.Object===Object&&self,h=c||p||Function("return this")(),u=h.Symbol,m=Object.prototype,g=m.hasOwnProperty,f=m.toString,b=u?u.toStringTag:void 0;var y=Object.prototype.toString;var v=u?u.toStringTag:void 0;function C(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":v&&v in Object(e)?function(e){var t=g.call(e,b),n=e[b];try{e[b]=void 0;var o=!0}catch(e){}var i=f.call(e);return o&&(t?e[b]=n:delete e[b]),i}(e):function(e){return y.call(e)}(e)}var x=/\s/;var _=/^\s+/;function E(e){return e?e.slice(0,function(e){for(var t=e.length;t--&&x.test(e.charAt(t)););return t}(e)+1).replace(_,""):e}function w(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}var S=/^[-+]0x[0-9a-f]+$/i,A=/^0b[01]+$/i,k=/^0o[0-7]+$/i,T=parseInt;function R(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return null!=e&&"object"==typeof e}(e)&&"[object Symbol]"==C(e)}(e))return NaN;if(w(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=w(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=E(e);var n=A.test(e);return n||k.test(e)?T(e.slice(2),n?2:8):S.test(e)?NaN:+e}var M=function(){return h.Date.now()},L=Math.max,P=Math.min;function N(e,t,n){var o,i,s,a,r,l,d=0,c=!1,p=!1,h=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function u(t){var n=o,s=i;return o=i=void 0,d=t,a=e.apply(s,n)}function m(e){var n=e-l;return void 0===l||n>=t||n<0||p&&e-d>=s}function g(){var e=M();if(m(e))return f(e);r=setTimeout(g,function(e){var n=t-(e-l);return p?P(n,s-(e-d)):n}(e))}function f(e){return r=void 0,h&&o?u(e):(o=i=void 0,a)}function b(){var e=M(),n=m(e);if(o=arguments,i=this,l=e,n){if(void 0===r)return function(e){return d=e,r=setTimeout(g,t),c?u(e):a}(l);if(p)return clearTimeout(r),r=setTimeout(g,t),u(l)}return void 0===r&&(r=setTimeout(g,t)),a}return t=R(t)||0,w(n)&&(c=!!n.leading,s=(p="maxWait"in n)?L(R(n.maxWait)||0,t):s,h="trailing"in n?!!n.trailing:h),b.cancel=function(){void 0!==r&&clearTimeout(r),d=0,o=l=i=r=void 0},b.flush=function(){return void 0===r?a:f(M())},b}const I=(e,t,n)=>{const o=n||[],i=o.reduce((e,t)=>e+t.textContent.length,0);let s=!0;if(i>t)return!1;for(e&&(3===e.nodeType&&e.parentNode&&!e.parentNode.hasAttribute("data-ann-id")&&o.push(e),e=e.firstChild);e&&s;)s=I(e,t,o),e=e.nextSibling;return o},D=e=>{const{commonAncestorContainer:t,startContainer:n,endContainer:o,startOffset:i,endOffset:s}=e,a=[];let r=!1,l=!1,d="";const c=e=>{const{nodeValue:t,childNodes:p}=e;e===n&&e===o?(t&&(d+=t.substring(i,s)),r=l=!0):e===n?(t&&(d+=t.substring(i)),r=!0):e===o?(t&&(d+=t.substring(0,s)),l=!0):e&&3===e.nodeType&&e.parentNode&&!e.parentNode.hasAttribute("data-ann-id")&&t&&r&&!l&&(d+=t,a.push(e)),p.forEach(e=>{l||c(e)})};return c(t),[a,d]},j=e=>{const t=document.createElement("SPAN");return e.surroundContents(t),t},O=e=>{if(e.startContainer===e.endContainer)return[j(e)];const[t]=D(e),n=document.createRange();n.selectNodeContents(e.startContainer),n.setStart(e.startContainer,e.startOffset);const o=j(n),i=document.createRange();i.selectNode(e.endContainer),i.setEnd(e.endContainer,e.endOffset);const s=j(i);return[o,...t.map(e=>{const t=document.createElement("SPAN");return e.parentNode.insertBefore(t,e),t.appendChild(e),t}),s]},W=(e,t)=>{(e||[]).forEach(e=>{const t=e.parentNode,n=e.childNodes,o=n.length;if(o>0)for(let i=0;i<o;i++)t.insertBefore(n[0],e);else t.insertBefore(document.createTextNode(e.textContent),e);t.removeChild(e)}),t.normalize()},$=()=>{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()},H=e=>e.length>=20||-1!==e.search(/\n|\r|\r\n/),z=e=>Array.from(document.querySelectorAll(`[data-id='${e}']`)),q=e=>document.querySelector(`[data-ann-id='${e}']`),B=e,F=t,{Popover:K}=n,{TextField:U}=n,{styled:V}=o,Y=V(K)(({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"}}}})),G=V("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"}})),X=V("div")(({theme:e})=>({display:"flex",flexWrap:"wrap",borderTop:`2px solid ${e.palette.grey[100]}`})),Q=V("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 J extends B.Component{static __initStatic(){this.propTypes={anchorEl:F.object,open:F.bool,offset:F.number,value:F.string,type:F.string,onClose:F.func,onDelete:F.func,onSave:F.func,onTypeChange:F.func}}constructor(e){super(e),J.prototype.__init.call(this),J.prototype.__init2.call(this),J.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:o}=this.props,{value:i}=this.state;""===i&&o(),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:o,type:i}=this.props,{value:s}=this.state;return B.createElement(Y,{anchorEl:e,elevation:2,open:o,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"}},B.createElement(G,{annotationType:i},B.createElement(U,{id:"annotation-editor",style:{padding:"2px 5px",width:"95%"},autoFocus:!0,multiline:!0,rows:1,maxRows:4,value:s,onChange:this.onValueChange,InputProps:{disableUnderline:!0}}),B.createElement(X,null,B.createElement(Q,{onClick:n},"Delete"),B.createElement(Q,{variant:"typeChange",annotationType:i,onClick:this.handleTypeChange},"negative"===i?"Green":"Pink"),B.createElement(Q,{onClick:this.handleSave},"Save"))))}}J.__initStatic();const Z=e,ee=t,{styled:te}=o,{Popover:ne}=n,oe=te(ne)({"& .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"}}}),ie=te("div")(({theme:e})=>({width:"300px",overflow:"hidden",borderRadius:"4px",backgroundColor:e.palette.common.white,border:`2px solid ${e.palette.grey[100]}`})),se=te("div")({display:"flex",flexWrap:"wrap"}),ae=te("div")(({theme:e})=>({display:"flex",flexWrap:"wrap",borderTop:`2px solid ${e.palette.grey[100]}`})),re=te("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 le extends Z.Component{static __initStatic(){this.propTypes={anchorEl:ee.object,open:ee.bool,annotations:ee.array,isNewAnnotation:ee.bool,onClose:ee.func,onDelete:ee.func,onEdit:ee.func,onWrite:ee.func,onAnnotate:ee.func}}render(){const{anchorEl:e,annotations:t,isNewAnnotation:n,onAnnotate:o,onClose:i,onEdit:s,onDelete:a,onWrite:r,open:l}=this.props;return Z.createElement(oe,{anchorEl:e,open:l,onClose:i,elevation:5,transitionDuration:{enter:225,exit:195},anchorOrigin:{vertical:"top",horizontal:"center"},transformOrigin:{vertical:"bottom",horizontal:"center"}},Z.createElement(ie,null,Z.createElement(se,null,t.map((e,t)=>Z.createElement(re,{key:`annotation-${t}`,variant:e.type,onClick:()=>o(e)},e.label))),Z.createElement(ae,null,Z.createElement(re,{onClick:i},"Cancel"),Z.createElement(re,{style:{pointerEvents:"none"}}),n?Z.createElement(Z.Fragment,null,Z.createElement(re,{variant:"positive",onClick:()=>r("positive")},"Write"),Z.createElement(re,{variant:"negative",onClick:()=>r("negative")},"Write")):Z.createElement(Z.Fragment,null,Z.createElement(re,{onClick:a},"Delete"),Z.createElement(re,{onClick:s},"Edit")))))}}le.__initStatic();const de=e,{styled:ce}=o,pe=t,he=l,{InputContainer:ue}=d,me=ce("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"}}),ge=ce("div")({width:"230px"}),fe=ce("div")({position:"relative",overflowX:"hidden",display:"flex"}),be=ce(ue)(({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 ye extends de.Component{static __initStatic(){this.propTypes={text:pe.string,comment:pe.string,annotations:pe.array,predefinedAnnotations:pe.array,onChange:pe.func.isRequired,onCommentChange:pe.func.isRequired,width:pe.number,height:pe.number,maxHeight:pe.string,disabled:pe.bool,disabledMath:pe.bool,customKeys:pe.array,keypadMode:pe.string}}constructor(e){super(e),ye.prototype.__init.call(this),ye.prototype.__init2.call(this),ye.prototype.__init3.call(this),ye.prototype.__init4.call(this),ye.prototype.__init5.call(this),ye.prototype.__init6.call(this),ye.prototype.__init7.call(this),ye.prototype.__init8.call(this),ye.prototype.__init9.call(this),ye.prototype.__init10.call(this),ye.prototype.__init11.call(this),ye.prototype.__init12.call(this),ye.prototype.__init13.call(this),ye.prototype.__init14.call(this),ye.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 o=I(n,t),i=[];let s=0;return o.forEach(n=>{const o=s+n.textContent.length;[e,t].forEach(e=>{s<=e&&e<o&&i.push({node:n,offset:e-s})}),s=o}),i})(e.start,e.end,this.textRef);if(t&&n){const o=document.createRange();o.setStart(t.node,t.offset),o.setEnd(n.node,n.offset);const i=O(o);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=z(t.dataset.annId),o=(n[0].offsetTop?n[0].offsetTop:n[0].offsetParent.offsetTop)-this.textRef.scrollTop-6;t.style.top=`${o}px`,t.style.left=`${e}px`})}}}__init2(){this.handleClick=e=>{const{annotations:t}=this.props,{selectionDetails:n}=this.state;if(n)return;const{id:o,annId:i}=e.target.dataset,s=o||i,a=z(s),r=q(s),l=t.findIndex(e=>e.id===s),d=r.hasAttribute("data-freeform");d&&(r.style.zIndex="10"),this.setState({anchorEl:a[0],openedMenu:!!o||!!i&&!d,openedEditor:!!i&&d,selectedElems:a,labelElem:r,annotationIndex:l,annotation:t[l],selectionDetails:null})}}__init3(){this.handleHover=e=>{const{id:t,annId:n}=e.target.dataset,o=t||n,i=z(o),s=q(o),a=s.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)")}),a?(s.style.zIndex="20",s.classList.contains("positive")?(s.style.backgroundColor="rgb(128, 255, 128)",s.style.setProperty("--before-border-color","rgb(153, 255, 153)")):s.classList.contains("negative")&&(s.style.backgroundColor="rgb(255, 179, 230)",s.style.setProperty("--before-border-color","rgb(255, 179, 230)"))):(s.style.zIndex="20",s.classList.contains("positive")?s.style.color="rgb(0, 77, 0)":s.classList.contains("negative")&&(s.style.color="rgb(153, 0, 102)"))}}__init4(){this.handleCancelHover=e=>{const{id:t,annId:n}=e.target.dataset,o=t||n,i=z(o),s=q(o),a=s.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)")}),a?(s.style.zIndex="",s.classList.contains("positive")?(s.style.backgroundColor="rgb(153, 255, 153)",s.style.removeProperty("--before-border-color")):s.classList.contains("negative")&&(s.style.backgroundColor="rgb(255, 204, 238)",s.style.removeProperty("--before-border-color"))):(s.style.zIndex="",s.classList.contains("positive")?s.style.color="rgb(0, 128, 0)":s.classList.contains("negative")&&(s.style.color="rgb(204, 0, 136)"))}}__init5(){this.handleClose=e=>{const{selectedElems:t,labelElem:n}=this.state;t.length&&!t[0].hasAttribute("data-id")&&W(t,this.textRef),n&&(n.style.zIndex=""),this.setState({anchorEl:null,openedMenu:!1,openedEditor:!1,selectedElems:[],labelElem:null,selectionDetails:null,annotationIndex:null,annotation:null}),$()}}__init6(){this.handleSelection=e=>{const t=window.getSelection();if(e.detail>2)$();else if(t&&t.rangeCount>0){const e=t.getRangeAt(0),n=e.toString(),o=this.textRef.contains(e.commonAncestorContainer);if(!t.isCollapsed&&""!==n&&o){const t=((e,t)=>{const n=document.createRange();n.setStart(t,0),n.setEnd(e.startContainer,e.startOffset);const[,o]=D(n),[,i]=D(e),s=o.length;return{quote:i,start:s,end:s+i.length}})(e,this.textRef),n=O(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:o,annotationIndex:i,annotation:s}=this.state;(H(s.label)?this.labelsRef:n[0]).removeChild(o),W(n,this.textRef),e.splice(i,1),t(e),this.handleClose()}}__init8(){this.createDOMAnnotation=(e,t)=>{const{disabled:n}=this.props,{id:o,label:i,type:s}=t;(e||[]).forEach(e=>{e.dataset.id=o,e.className=`annotation ${s}`,e.style.position="relative",e.style.cursor="pointer","positive"===s?e.style.backgroundColor="rgb(51, 255, 51, 0.5)":"negative"===s&&(e.style.backgroundColor="rgba(255, 102, 204, 0.4)"),e.onclick=!n&&this.handleClick,e.onmouseover=this.handleHover,e.onmouseout=this.handleCancelHover});const a=e&&e[0]||{},r=document.createElement("SPAN");if(r.dataset.annId=o,r.innerHTML=i,r.onclick=!n&&this.handleClick,r.onmouseover=this.handleHover,r.onmouseout=this.handleCancelHover,H(i)){const e=(a.offsetTop?a.offsetTop:a.offsetParent.offsetTop)-this.textRef.scrollTop,t=this.textRef.offsetLeft+this.textRef.offsetWidth+8;r.dataset.freeform=!0,r.className=`sideAnnotation ${s}`,r.style.position="absolute",r.style.padding="4px",r.style.borderRadius="4px",r.style.marginLeft="8px",r.style.width="180px",r.style.whiteSpace="pre-wrap",r.style.wordBreak="break-word",r.style.border="2px solid #ffffff",r.style.fontSize="14px",r.style.fontStyle="normal",r.style.fontWeight="normal",r.style.top=`${e}px`,r.style.left=`${t}px`,"negative"===s?r.style.backgroundColor="rgb(255, 204, 238)":"positive"===s&&(r.style.backgroundColor="rgb(153, 255, 153)"),r.style.setProperty("--before-border-width","7px"),r.style.setProperty("--before-top","5px"),r.style.setProperty("--before-right","100%"),"negative"===s?r.style.setProperty("--before-border-color","rgb(255, 204, 238)"):"positive"===s&&r.style.setProperty("--before-border-color","rgb(153, 255, 153)"),this.labelsRef.appendChild(r)}else r.className=`annotationLabel ${s}`,r.style.backgroundColor="rgb(242, 242, 242)",r.style.padding="2px",r.style.position="absolute",r.style.userSelect="none",r.style.whiteSpace="nowrap",r.style.top="-10px",r.style.left="-2px",r.style.fontSize="12px",r.style.fontStyle="normal",r.style.fontWeight="normal",r.style.lineHeight="6px",r.style.webkitUserSelect="none",r.style.mozUserSelect="none",r.style.msUserSelect="none","positive"===s?r.style.color="rgb(0, 128, 0)":"negative"===s&&(r.style.color="rgb(204, 0, 136)"),a.appendChild(r)}}__init9(){this.createNewAnnotation=(e,t)=>{const{selectedElems:n,selectionDetails:o}=this.state,i={id:[o.start,o.end,(new Date).getTime()].join("-"),label:e,type:t,...o};return this.createDOMAnnotation(n,i),i}}__init10(){this.handleMenuClick=e=>{const{annotations:t,onChange:n}=this.props,{annotation:o,annotationIndex:i}=this.state,{type:s,text:a}=e;if(o){const e={...o,label:a,type:s},{type:n,label:r}=o;this.updateLabel(r,e,s!==n&&n),t.splice(i,1,e)}else{const e=this.createNewAnnotation(a,s);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,o=this.createNewAnnotation("",e),i=q(o.id);t.push(o),this.setState({openedMenu:!1,openedEditor:!0,annotationIndex:t.length-1,annotation:o,labelElem:i}),n(t)}}__init13(){this.updateLabel=(e,t,n)=>{const{selectedElems:o,labelElem:i}=this.state,{label:s,type:a}=t;H(s)&&H(e)||!H(s)&&!H(e)?(i.innerHTML=s,n&&(i.classList.remove(n),i.classList.add(a),o.forEach(e=>{e.classList.remove(n),e.classList.add(a)}))):H(s)&&!H(e)?(o[0].removeChild(i),this.createDOMAnnotation(o,t)):!H(s)&&H(e)&&(this.labelsRef.removeChild(i),this.createDOMAnnotation(o,t))}}__init14(){this.changeAnnotationType=e=>{const{annotations:t,onChange:n}=this.props,{annotationIndex:o,selectedElems:i}=this.state,{type:s,label:a}=t[o],r="positive"===s?"negative":"positive",l={...t[o],type:r,label:e};i.forEach(e=>{e.classList.remove(s),e.classList.add(r)}),this.updateLabel(a,l,s),t.splice(o,1,l),n(t),this.handleClose()}}__init15(){this.updateAnnotation=(e,t)=>{const{annotations:n,onChange:o}=this.props,{annotationIndex:i}=this.state,s={...n[i],label:t};this.updateLabel(e,s),n.splice(i,1,s),o(n)}}componentWillUnmount(){this.textRef.removeEventListener("scroll",this.adjustAnnotationsPosition)}render(){const{comment:e,customKeys:t,disabled:n,disabledMath:o,keypadMode:i,height:s,width:a,maxHeight:r,onCommentChange:l,predefinedAnnotations:d,text:c}=this.props,{anchorEl:p,annotation:h,openedMenu:u,openedEditor:m,selectionDetails:g}=this.state,f=p&&(p.offsetTop?p.offsetTop:p.offsetParent.offsetTop),b=this.textRef&&f?f-this.textRef.scrollTop-8:0;return de.createElement("div",null,de.createElement(fe,null,de.createElement(me,{style:{width:a-34,minHeight:s,maxHeight:r},ref:e=>this.textRef=e,onMouseDown:n?()=>{}:$,onMouseUp:n?()=>{}:this.handleSelection,dangerouslySetInnerHTML:{__html:c}}),de.createElement(ge,{ref:e=>this.labelsRef=e})),de.createElement(be,{label:"Comment"},de.createElement(he,{className:"prompt",markup:e||"",onChange:l,width:a&&(a+104).toString(),disabled:n,pluginProps:{math:{disabled:o,customKeys:t,keypadMode:i,controlledKeypadMode:!1},video:{disabled:!0},audio:{disabled:!0},textAlign:{disabled:!0},h3:{disabled:!0}}})),de.createElement(le,{anchorEl:p,open:u&&!n,annotations:d,isNewAnnotation:!!g,onClose:this.handleClose,onDelete:this.deleteAnnotation,onEdit:this.editAnnotation,onWrite:this.addAnnotation,onAnnotate:this.handleMenuClick}),de.createElement(J,{anchorEl:this.textRef,open:m&&!n,offset:b,value:h&&h.label||"",type:h&&h.type,onClose:this.handleClose,onDelete:this.deleteAnnotation,onSave:this.updateAnnotation,onTypeChange:this.changeAnnotationType}))}}ye.__initStatic();const ve=e,Ce=t,xe=i,{Typography:_e}=n,{styled:Ee}=o,{color:we}=s,{Feedback:Se}=s,{Collapsible:Ae}=s,{PreviewPrompt:ke}=s,{UiLayout:Te}=s,Re=l,Me=xe("@pie-ui:extended-text-entry"),Le=Ee(Te)({backgroundColor:we.background(),color:we.text()}),Pe=Ee(_e)(({theme:e})=>({width:"100%",color:we.text(),marginBottom:e.spacing(2),fontSize:"inherit"})),Ne=Ee("div")(({theme:e})=>({marginBottom:e.spacing(2)})),Ie=Ee(Re)(({theme:e})=>({marginBottom:e.spacing(2),borderRadius:"4px"})),De=Ee("h2")({position:"absolute",left:"-10000px",top:"auto",width:"1px",height:"1px",overflow:"hidden"});class je extends ve.Component{constructor(...e){super(...e),je.prototype.__init.call(this),je.prototype.__init2.call(this)}static __initStatic(){this.propTypes={onValueChange:Ce.func.isRequired,onAnnotationsChange:Ce.func.isRequired,onCommentChange:Ce.func.isRequired,model:Ce.object,session:Ce.shape({value:Ce.string,annotations:Ce.array,comment:Ce.string}).isRequired}}__init(){this.changeSessionValue=N(this.props.onValueChange,1500)}__init2(){this.changeSessionComment=N(this.props.onCommentChange,1500)}render(){const{model:e,session:t,onAnnotationsChange:n}=this.props,{animationsDisabled:o,annotatorMode:i,customKeys:s,dimensions:a,disabled:r,disabledAnnotator:l,equationEditor:d,extraCSSRules:c,feedback:p,mathInput:h,playersToolbarPosition:u,predefinedAnnotations:m,prompt:g,spanishInput:f,specialInput:b,spellCheckEnabled:y,teacherInstructions:v}=e,{annotations:C,comment:x,value:_}=t,{width:E,height:w}=a||{},S="40vh",A={position:"top"===u?"top":"bottom"};Me("[render] disabled? ",r);const k=ve.createElement(ke,{defaultClassName:"teacher-instructions",prompt:v}),T=[];return f&&T.push({language:"spanish"}),b&&T.push({language:"special"}),ve.createElement(Le,{extraCSSRules:c,ref:e=>{this.containerRef=e}},ve.createElement(De,null,"Constructed Response Question"),v&&ve.createElement(Ne,null,o?k:ve.createElement(Ae,{labels:{hidden:"Show Teacher Instructions",visible:"Hide Teacher Instructions"}},k)),g&&ve.createElement(Pe,{component:"span"},ve.createElement(ke,{defaultClassName:"prompt",prompt:e.prompt})),i?ve.createElement(ye,{text:_||"",annotations:C||[],comment:x||"",predefinedAnnotations:m||[],onChange:n,onCommentChange:this.changeSessionComment,width:E,height:w,maxHeight:S,disabled:l,disabledMath:!h,customKeys:s,keypadMode:d}):ve.createElement(Ie,{className:"response-area-editor",onChange:this.changeSessionValue,markup:_||"",maxWidth:E&&E.toString(),minWidth:"100px",minHeight:w&&w.toString(),maxHeight:S,disabled:r,highlightShape:!0,toolbarOpts:A,spellCheck:y,charactersLimit:5e4,autoWidthToolbar:!0,pluginProps:{math:{disabled:!h,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:T}),p&&ve.createElement(Se,{correctness:"correct",feedback:p}))}}je.__initStatic();var Oe={};Object.defineProperty(Oe,"__esModule",{value:!0});class We extends CustomEvent{constructor(e,t,n){super(We.TYPE,{bubbles:!0,composed:!0,detail:{complete:t,component:e,hasModel:n}}),this.component=e,this.complete=t}}We.TYPE="model-set";var $e=Oe.ModelSetEvent=We;class He extends CustomEvent{constructor(e,t){super(He.TYPE,{bubbles:!0,composed:!0,detail:{complete:t,component:e}}),this.component=e,this.complete=t}}He.TYPE="session-changed";var ze=Oe.SessionChangedEvent=He;const qe=e,{createRoot:Be}=a,Fe=i,{renderMath:Ke}=r,Ue=Fe("@pie-elements:extended-text-entry"),Ve=void 0!==typeof window?new DOMParser:{parseFromString:e=>e};function Ye(e){if("string"==typeof e)try{const t=Ve.parseFromString(e,"text/html");return t.body.textContent}catch(t){return Ue("tried to parse as dom and failed",e),e}}function Ge(e){const t=Ye(e);return void 0!==t&&t.length>0}class Xe 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 $e(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 ze(this.tagName.toLowerCase(),Ge(e))),this.render()}annotationsChange(e){this._session.annotations=e,this.dispatchEvent(new ze(this.tagName.toLowerCase(),!0)),this.render()}commentChange(e){this._session.comment=e,this.dispatchEvent(new ze(this.tagName.toLowerCase(),Ge(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=qe.createElement(je,{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=Be(this)),this._root.render(e),queueMicrotask(()=>{Ke(this)})}}disconnectedCallback(){this._root&&this._root.unmount()}}export{Xe as default,Ge as isComplete,Ye as textContent};