!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("quill")):"function"==typeof define&&define.amd?define(["quill"],t):"object"==typeof exports?exports.QuillTableBetter=t(require("quill")):e.QuillTableBetter=t(e.Quill)}(self,(function(e){return function(){var t={386:function(e){var t=-1,r=1,n=0;function i(e,g,b,m,v){if(e===g)return e?[[n,e]]:[];if(null!=b){var w=function(e,t,r){var n="number"==typeof r?{index:r,length:0}:r.oldRange,i="number"==typeof r?null:r.newRange,l=e.length,o=t.length;if(0===n.length&&(null===i||0===i.length)){var s=n.index,a=e.slice(0,s),c=e.slice(s),d=i?i.index:null,u=s+o-l;if((null===d||d===u)&&!(u<0||u>o)){var h=t.slice(0,u);if((g=t.slice(u))===c){var p=Math.min(s,u);if((m=a.slice(0,p))===(w=h.slice(0,p)))return y(m,a.slice(p),h.slice(p),c)}}if(null===d||d===s){var f=s,g=(h=t.slice(0,f),t.slice(f));if(h===a){var b=Math.min(l-f,o-f);if((v=c.slice(c.length-b))===(C=g.slice(g.length-b)))return y(a,c.slice(0,c.length-b),g.slice(0,g.length-b),v)}}}if(n.length>0&&i&&0===i.length){var m=e.slice(0,n.index),v=e.slice(n.index+n.length);if(!(o<(p=m.length)+(b=v.length))){var w=t.slice(0,p),C=t.slice(o-b);if(m===w&&v===C)return y(m,e.slice(p,l-b),t.slice(p,o-b),v)}}return null}(e,g,b);if(w)return w}var C=o(e,g),x=e.substring(0,C);C=a(e=e.substring(C),g=g.substring(C));var k=e.substring(e.length-C),T=function(e,s){var c;if(!e)return[[r,s]];if(!s)return[[t,e]];var d=e.length>s.length?e:s,u=e.length>s.length?s:e,h=d.indexOf(u);if(-1!==h)return c=[[r,d.substring(0,h)],[n,u],[r,d.substring(h+u.length)]],e.length>s.length&&(c[0][0]=c[2][0]=t),c;if(1===u.length)return[[t,e],[r,s]];var p=function(e,t){var r=e.length>t.length?e:t,n=e.length>t.length?t:e;if(r.length<4||2*n.length=e.length?[n,i,l,s,u]:null}var l,s,c,d,u,h=i(r,n,Math.ceil(r.length/4)),p=i(r,n,Math.ceil(r.length/2));return h||p?(l=p?h&&h[4].length>p[4].length?h:p:h,e.length>t.length?(s=l[0],c=l[1],d=l[2],u=l[3]):(d=l[0],u=l[1],s=l[2],c=l[3]),[s,c,d,u,l[4]]):null}(e,s);if(p){var f=p[0],g=p[1],b=p[2],m=p[3],v=p[4],y=i(f,b),w=i(g,m);return y.concat([[n,v]],w)}return function(e,n){for(var i=e.length,o=n.length,s=Math.ceil((i+o)/2),a=s,c=2*s,d=new Array(c),u=new Array(c),h=0;hi)b+=2;else if(x>o)g+=2;else if(f&&(_=a+p-w)>=0&&_=(T=i-u[_]))return l(e,n,A,x)}for(var k=-y+m;k<=y-v;k+=2){for(var T,_=a+k,N=(T=k===-y||k!==y&&u[_-1]i)v+=2;else if(N>o)m+=2;else if(!f){var A;if((C=a+p-k)>=0&&C=(T=i-T))return l(e,n,A,x)}}}return[[t,e],[r,n]]}(e,s)}(e=e.substring(0,e.length-C),g=g.substring(0,g.length-C));return x&&T.unshift([n,x]),k&&T.push([n,k]),f(T,v),m&&function(e){for(var i=!1,l=[],o=0,g=null,b=0,m=0,v=0,y=0,w=0;b0?l[o-1]:-1,m=0,v=0,y=0,w=0,g=null,i=!0)),b++;for(i&&f(e),function(e){function t(e,t){if(!e||!t)return 6;var r=e.charAt(e.length-1),n=t.charAt(0),i=r.match(c),l=n.match(c),o=i&&r.match(d),s=l&&n.match(d),a=o&&r.match(u),f=s&&n.match(u),g=a&&e.match(h),b=f&&t.match(p);return g||b?5:a||f?4:i&&!o&&s?3:o||s?2:i||l?1:0}for(var r=1;r=v&&(v=y,g=i,b=l,m=o)}e[r-1][1]!=g&&(g?e[r-1][1]=g:(e.splice(r-1,1),r--),e[r][1]=b,m?e[r+1][1]=m:(e.splice(r+1,1),r--))}r++}}(e),b=1;b=T?(k>=C.length/2||k>=x.length/2)&&(e.splice(b,0,[n,x.substring(0,k)]),e[b-1][1]=C.substring(0,C.length-k),e[b+1][1]=x.substring(k),b++):(T>=C.length/2||T>=x.length/2)&&(e.splice(b,0,[n,C.substring(0,T)]),e[b-1][0]=r,e[b-1][1]=x.substring(0,x.length-T),e[b+1][0]=t,e[b+1][1]=C.substring(T),b++),b++}b++}}(T),T}function l(e,t,r,n){var l=e.substring(0,r),o=t.substring(0,n),s=e.substring(r),a=t.substring(n),c=i(l,o),d=i(s,a);return c.concat(d)}function o(e,t){if(!e||!t||e.charAt(0)!==t.charAt(0))return 0;for(var r=0,n=Math.min(e.length,t.length),i=n,l=0;rn?e=e.substring(r-n):r=0&&v(e[p][1])){var g=e[p][1].slice(-1);if(e[p][1]=e[p][1].slice(0,-1),u=g+u,h=g+h,!e[p][1]){e.splice(p,1),s--;var b=p-1;e[b]&&e[b][0]===r&&(d++,h=e[b][1]+h,b--),e[b]&&e[b][0]===t&&(c++,u=e[b][1]+u,b--),p=b}}m(e[s][1])&&(g=e[s][1].charAt(0),e[s][1]=e[s][1].slice(1),u+=g,h+=g)}if(s0||h.length>0){u.length>0&&h.length>0&&(0!==(l=o(h,u))&&(p>=0?e[p][1]+=h.substring(0,l):(e.splice(0,0,[n,h.substring(0,l)]),s++),h=h.substring(l),u=u.substring(l)),0!==(l=a(h,u))&&(e[s][1]=h.substring(h.length-l)+e[s][1],h=h.substring(0,h.length-l),u=u.substring(0,u.length-l)));var y=d+c;0===u.length&&0===h.length?(e.splice(s-y,y),s-=y):0===u.length?(e.splice(s-y,y,[r,h]),s=s-y+1):0===h.length?(e.splice(s-y,y,[t,u]),s=s-y+1):(e.splice(s-y,y,[t,u],[r,h]),s=s-y+2)}0!==s&&e[s-1][0]===n?(e[s-1][1]+=e[s][1],e.splice(s,1)):s++,d=0,c=0,u="",h=""}""===e[e.length-1][1]&&e.pop();var w=!1;for(s=1;s=55296&&e<=56319}function b(e){return e>=56320&&e<=57343}function m(e){return b(e.charCodeAt(0))}function v(e){return g(e.charCodeAt(e.length-1))}function y(e,i,l,o){return v(e)||m(o)?null:function(e){for(var t=[],r=0;r0&&t.push(e[r]);return t}([[n,e],[t,i],[r,l],[n,o]])}function w(e,t,r,n){return i(e,t,r,n,!0)}w.INSERT=r,w.DELETE=t,w.EQUAL=n,e.exports=w},861:function(e,t,r){e=r.nmd(e);var n="__lodash_hash_undefined__",i=9007199254740991,l="[object Arguments]",o="[object Boolean]",s="[object Date]",a="[object Function]",c="[object GeneratorFunction]",d="[object Map]",u="[object Number]",h="[object Object]",p="[object Promise]",f="[object RegExp]",g="[object Set]",b="[object String]",m="[object Symbol]",v="[object WeakMap]",y="[object ArrayBuffer]",w="[object DataView]",C="[object Float32Array]",x="[object Float64Array]",k="[object Int8Array]",T="[object Int16Array]",_="[object Int32Array]",N="[object Uint8Array]",A="[object Uint8ClampedArray]",L="[object Uint16Array]",S="[object Uint32Array]",j=/\w*$/,q=/^\[object .+?Constructor\]$/,E=/^(?:0|[1-9]\d*)$/,M={};M[l]=M["[object Array]"]=M[y]=M[w]=M[o]=M[s]=M[C]=M[x]=M[k]=M[T]=M[_]=M[d]=M[u]=M[h]=M[f]=M[g]=M[b]=M[m]=M[N]=M[A]=M[L]=M[S]=!0,M["[object Error]"]=M[a]=M[v]=!1;var B="object"==typeof r.g&&r.g&&r.g.Object===Object&&r.g,R="object"==typeof self&&self&&self.Object===Object&&self,O=B||R||Function("return this")(),P=t&&!t.nodeType&&t,I=P&&e&&!e.nodeType&&e,z=I&&I.exports===P;function D(e,t){return e.set(t[0],t[1]),e}function H(e,t){return e.add(t),e}function F(e,t,r,n){var i=-1,l=e?e.length:0;for(n&&l&&(r=e[++i]);++i-1},Ae.prototype.set=function(e,t){var r=this.__data__,n=qe(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Le.prototype.clear=function(){this.__data__={hash:new Ne,map:new(fe||Ae),string:new Ne}},Le.prototype.delete=function(e){return Re(this,e).delete(e)},Le.prototype.get=function(e){return Re(this,e).get(e)},Le.prototype.has=function(e){return Re(this,e).has(e)},Le.prototype.set=function(e,t){return Re(this,e).set(e,t),this},Se.prototype.clear=function(){this.__data__=new Ae},Se.prototype.delete=function(e){return this.__data__.delete(e)},Se.prototype.get=function(e){return this.__data__.get(e)},Se.prototype.has=function(e){return this.__data__.has(e)},Se.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Ae){var n=r.__data__;if(!fe||n.length<199)return n.push([e,t]),this;r=this.__data__=new Le(n)}return r.set(e,t),this};var Pe=de?U(de,Object):function(){return[]},Ie=function(e){return te.call(e)};function ze(e,t){return!!(t=null==t?i:t)&&("number"==typeof e||E.test(e))&&e>-1&&e%1==0&&e-1&&e%1==0&&e<=i}(e.length)&&!Ge(e)}var Ue=ue||function(){return!1};function Ge(e){var t=$e(e)?te.call(e):"";return t==a||t==c}function $e(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Ke(e){return We(e)?function(e,t){var r=Ve(e)||function(e){return function(e){return function(e){return!!e&&"object"==typeof e}(e)&&We(e)}(e)&&ee.call(e,"callee")&&(!ae.call(e,"callee")||te.call(e)==l)}(e)?function(e,t){for(var r=-1,n=Array(e);++rc))return!1;var u=s.get(e);if(u&&s.get(t))return u==t;var h=-1,p=!0,f=r&l?new Ne:void 0;for(s.set(e,t),s.set(t,e);++h-1},Te.prototype.set=function(e,t){var r=this.__data__,n=Le(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this},_e.prototype.clear=function(){this.size=0,this.__data__={hash:new ke,map:new(ue||Te),string:new ke}},_e.prototype.delete=function(e){var t=Be(this,e).delete(e);return this.size-=t?1:0,t},_e.prototype.get=function(e){return Be(this,e).get(e)},_e.prototype.has=function(e){return Be(this,e).has(e)},_e.prototype.set=function(e,t){var r=Be(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this},Ne.prototype.add=Ne.prototype.push=function(e){return this.__data__.set(e,n),this},Ne.prototype.has=function(e){return this.__data__.has(e)},Ae.prototype.clear=function(){this.__data__=new Te,this.size=0},Ae.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},Ae.prototype.get=function(e){return this.__data__.get(e)},Ae.prototype.has=function(e){return this.__data__.has(e)},Ae.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Te){var n=r.__data__;if(!ue||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new _e(n)}return r.set(e,t),this.size=r.size,this};var Oe=se?function(e){return null==e?[]:(e=Object(e),function(t,r){for(var n=-1,i=null==t?0:t.length,l=0,o=[];++n-1&&e%1==0&&e-1&&e%1==0&&e<=o}function Ge(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function $e(e){return null!=e&&"object"==typeof e}var Ke=z?function(e){return function(t){return e(t)}}(z):function(e){return $e(e)&&Ue(e.length)&&!!j[Se(e)]};function Ze(e){return null!=(t=e)&&Ue(t.length)&&!We(t)?function(e,t){var r=Fe(e),n=!r&&He(e),i=!r&&!n&&Ve(e),l=!r&&!n&&!i&&Ke(e),o=r||n||i||l,s=o?function(e,t){for(var r=-1,n=Array(e);++r-1},ee.prototype.set=function(e,t){var r=this.__data__,n=le(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this},te.prototype.clear=function(){this.size=0,this.__data__={hash:new Q,map:new(Y||ee),string:new Q}},te.prototype.delete=function(e){var t=ue(this,e).delete(e);return this.size-=t?1:0,t},te.prototype.get=function(e){return ue(this,e).get(e)},te.prototype.has=function(e){return ue(this,e).has(e)},te.prototype.set=function(e,t){var r=ue(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this},re.prototype.clear=function(){this.__data__=new ee,this.size=0},re.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},re.prototype.get=function(e){return this.__data__.get(e)},re.prototype.has=function(e){return this.__data__.has(e)},re.prototype.set=function(e,t){var r=this.__data__;if(r instanceof ee){var n=r.__data__;if(!Y||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new te(n)}return r.set(e,t),this.size=r.size,this};function se(e){return null==e?void 0===e?h:c:U&&U in Object(e)?function(e){var t=M.call(e,U),r=e[U];try{e[U]=void 0;var n=!0}catch(e){}var i=R.call(e);return n&&(t?e[U]=r:delete e[U]),i}(e):function(e){return R.call(e)}(e)}function ae(e){return _e(e)&&se(e)==l}function ce(e,t,r,n,i){e!==t&&function(e,t,r){for(var n=-1,i=Object(e),l=r(e),o=l.length;o--;){var s=l[++n];if(!1===t(i[s],s,i))break}}(t,(function(l,o){if(i||(i=new re),Te(l))!function(e,t,r,n,i,l,o){var s=ge(e,r),a=ge(t,r),c=o.get(a);if(c)ne(e,r,c);else{var u,h,p,f,g,b=l?l(s,a,r+"",e,t,o):void 0,m=void 0===b;if(m){var v=ye(a),y=!v&&Ce(a),w=!v&&!y&&Ne(a);b=a,v||y||w?ye(s)?b=s:_e(g=s)&&we(g)?b=function(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r-1&&e%1==0&&e0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(de);function me(e,t){return e===t||e!=e&&t!=t}var ve=ae(function(){return arguments}())?ae:function(e){return _e(e)&&M.call(e,"callee")&&!V.call(e,"callee")},ye=Array.isArray;function we(e){return null!=e&&ke(e.length)&&!xe(e)}var Ce=$||function(){return!1};function xe(e){if(!Te(e))return!1;var t=se(e);return t==s||t==a||t==o||t==u}function ke(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=i}function Te(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function _e(e){return null!=e&&"object"==typeof e}var Ne=A?function(e){return function(t){return e(t)}}(A):function(e){return _e(e)&&ke(e.length)&&!!g[se(e)]};function Ae(e){return we(e)?function(e,t){var r=ye(e),n=!r&&ve(e),i=!r&&!n&&Ce(e),l=!r&&!n&&!i&&Ne(e),o=r||n||i||l,s=o?function(e,t){for(var r=-1,n=Array(e);++r1?t[n-1]:void 0,l=n>2?t[2]:void 0;for(i=Le.length>3&&"function"==typeof i?(n--,i):void 0,l&&function(e,t,r){if(!Te(r))return!1;var n=typeof t;return!!("number"==n?we(r)&&pe(t,r.length):"string"==n&&t in r)&&me(r[t],e)}(t[0],t[1],l)&&(i=n<3?void 0:i,n=1),e=Object(e);++r(null!=i[t]&&(e[t]=i[t]),e)),{}));for(const r in e)void 0!==e[r]&&void 0===t[r]&&(i[r]=e[r]);return Object.keys(i).length>0?i:void 0},e.diff=function(e={},t={}){"object"!=typeof e&&(e={}),"object"!=typeof t&&(t={});const r=Object.keys(e).concat(Object.keys(t)).reduce(((r,n)=>(i(e[n],t[n])||(r[n]=void 0===t[n]?null:t[n]),r)),{});return Object.keys(r).length>0?r:void 0},e.invert=function(e={},t={}){e=e||{};const r=Object.keys(t).reduce(((r,n)=>(t[n]!==e[n]&&void 0!==e[n]&&(r[n]=t[n]),r)),{});return Object.keys(e).reduce(((r,n)=>(e[n]!==t[n]&&void 0===t[n]&&(r[n]=null),r)),r)},e.transform=function(e,t,r=!1){if("object"!=typeof e)return t;if("object"!=typeof t)return;if(!r)return t;const n=Object.keys(t).reduce(((r,n)=>(void 0===e[n]&&(r[n]=t[n]),r)),{});return Object.keys(n).length>0?n:void 0}}(l||(l={})),t.default=l},32:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AttributeMap=t.OpIterator=t.Op=void 0;const n=r(386),i=r(861),l=r(842),o=r(382);t.AttributeMap=o.default;const s=r(427);t.Op=s.default;const a=r(505);t.OpIterator=a.default;const c=String.fromCharCode(0),d=(e,t)=>{if("object"!=typeof e||null===e)throw new Error("cannot retain a "+typeof e);if("object"!=typeof t||null===t)throw new Error("cannot retain a "+typeof t);const r=Object.keys(e)[0];if(!r||r!==Object.keys(t)[0])throw new Error(`embed types not matched: ${r} != ${Object.keys(t)[0]}`);return[r,e[r],t[r]]};class u{constructor(e){Array.isArray(e)?this.ops=e:null!=e&&Array.isArray(e.ops)?this.ops=e.ops:this.ops=[]}static registerEmbed(e,t){this.handlers[e]=t}static unregisterEmbed(e){delete this.handlers[e]}static getHandler(e){const t=this.handlers[e];if(!t)throw new Error(`no handlers for embed type "${e}"`);return t}insert(e,t){const r={};return"string"==typeof e&&0===e.length?this:(r.insert=e,null!=t&&"object"==typeof t&&Object.keys(t).length>0&&(r.attributes=t),this.push(r))}delete(e){return e<=0?this:this.push({delete:e})}retain(e,t){if("number"==typeof e&&e<=0)return this;const r={retain:e};return null!=t&&"object"==typeof t&&Object.keys(t).length>0&&(r.attributes=t),this.push(r)}push(e){let t=this.ops.length,r=this.ops[t-1];if(e=i(e),"object"==typeof r){if("number"==typeof e.delete&&"number"==typeof r.delete)return this.ops[t-1]={delete:r.delete+e.delete},this;if("number"==typeof r.delete&&null!=e.insert&&(t-=1,r=this.ops[t-1],"object"!=typeof r))return this.ops.unshift(e),this;if(l(e.attributes,r.attributes)){if("string"==typeof e.insert&&"string"==typeof r.insert)return this.ops[t-1]={insert:r.insert+e.insert},"object"==typeof e.attributes&&(this.ops[t-1].attributes=e.attributes),this;if("number"==typeof e.retain&&"number"==typeof r.retain)return this.ops[t-1]={retain:r.retain+e.retain},"object"==typeof e.attributes&&(this.ops[t-1].attributes=e.attributes),this}}return t===this.ops.length?this.ops.push(e):this.ops.splice(t,0,e),this}chop(){const e=this.ops[this.ops.length-1];return e&&"number"==typeof e.retain&&!e.attributes&&this.ops.pop(),this}filter(e){return this.ops.filter(e)}forEach(e){this.ops.forEach(e)}map(e){return this.ops.map(e)}partition(e){const t=[],r=[];return this.forEach((n=>{(e(n)?t:r).push(n)})),[t,r]}reduce(e,t){return this.ops.reduce(e,t)}changeLength(){return this.reduce(((e,t)=>t.insert?e+s.default.length(t):t.delete?e-t.delete:e),0)}length(){return this.reduce(((e,t)=>e+s.default.length(t)),0)}slice(e=0,t=1/0){const r=[],n=new a.default(this.ops);let i=0;for(;i0&&r.next(i.retain-e)}const s=new u(n);for(;t.hasNext()||r.hasNext();)if("insert"===r.peekType())s.push(r.next());else if("delete"===t.peekType())s.push(t.next());else{const e=Math.min(t.peekLength(),r.peekLength()),n=t.next(e),i=r.next(e);if(i.retain){const a={};if("number"==typeof n.retain)a.retain="number"==typeof i.retain?e:i.retain;else if("number"==typeof i.retain)null==n.retain?a.insert=n.insert:a.retain=n.retain;else{const e=null==n.retain?"insert":"retain",[t,r,l]=d(n[e],i.retain),o=u.getHandler(t);a[e]={[t]:o.compose(r,l,"retain"===e)}}const c=o.default.compose(n.attributes,i.attributes,"number"==typeof n.retain);if(c&&(a.attributes=c),s.push(a),!r.hasNext()&&l(s.ops[s.ops.length-1],a)){const e=new u(t.rest());return s.concat(e).chop()}}else"number"==typeof i.delete&&("number"==typeof n.retain||"object"==typeof n.retain&&null!==n.retain)&&s.push(i)}return s.chop()}concat(e){const t=new u(this.ops.slice());return e.ops.length>0&&(t.push(e.ops[0]),t.ops=t.ops.concat(e.ops.slice(1))),t}diff(e,t){if(this.ops===e.ops)return new u;const r=[this,e].map((t=>t.map((r=>{if(null!=r.insert)return"string"==typeof r.insert?r.insert:c;throw new Error("diff() called "+(t===e?"on":"with")+" non-document")})).join(""))),i=new u,s=n(r[0],r[1],t,!0),d=new a.default(this.ops),h=new a.default(e.ops);return s.forEach((e=>{let t=e[1].length;for(;t>0;){let r=0;switch(e[0]){case n.INSERT:r=Math.min(h.peekLength(),t),i.push(h.next(r));break;case n.DELETE:r=Math.min(t,d.peekLength()),d.next(r),i.delete(r);break;case n.EQUAL:r=Math.min(d.peekLength(),h.peekLength(),t);const e=d.next(r),s=h.next(r);l(e.insert,s.insert)?i.retain(r,o.default.diff(e.attributes,s.attributes)):i.push(s).delete(r)}t-=r}})),i.chop()}eachLine(e,t="\n"){const r=new a.default(this.ops);let n=new u,i=0;for(;r.hasNext();){if("insert"!==r.peekType())return;const l=r.peek(),o=s.default.length(l)-r.peekLength(),a="string"==typeof l.insert?l.insert.indexOf(t,o)-o:-1;if(a<0)n.push(r.next());else if(a>0)n.push(r.next(a));else{if(!1===e(n,r.next(1).attributes||{},i))return;i+=1,n=new u}}n.length()>0&&e(n,{},i)}invert(e){const t=new u;return this.reduce(((r,n)=>{if(n.insert)t.delete(s.default.length(n));else{if("number"==typeof n.retain&&null==n.attributes)return t.retain(n.retain),r+n.retain;if(n.delete||"number"==typeof n.retain){const i=n.delete||n.retain;return e.slice(r,r+i).forEach((e=>{n.delete?t.push(e):n.retain&&n.attributes&&t.retain(s.default.length(e),o.default.invert(n.attributes,e.attributes))})),r+i}if("object"==typeof n.retain&&null!==n.retain){const i=e.slice(r,r+1),l=new a.default(i.ops).next(),[s,c,h]=d(n.retain,l.insert),p=u.getHandler(s);return t.retain({[s]:p.invert(c,h)},o.default.invert(n.attributes,l.attributes)),r+1}}return r}),0),t.chop()}transform(e,t=!1){if(t=!!t,"number"==typeof e)return this.transformPosition(e,t);const r=e,n=new a.default(this.ops),i=new a.default(r.ops),l=new u;for(;n.hasNext()||i.hasNext();)if("insert"!==n.peekType()||!t&&"insert"===i.peekType())if("insert"===i.peekType())l.push(i.next());else{const e=Math.min(n.peekLength(),i.peekLength()),r=n.next(e),s=i.next(e);if(r.delete)continue;if(s.delete)l.push(s);else{const n=r.retain,i=s.retain;let a="object"==typeof i&&null!==i?i:e;if("object"==typeof n&&null!==n&&"object"==typeof i&&null!==i){const e=Object.keys(n)[0];if(e===Object.keys(i)[0]){const r=u.getHandler(e);r&&(a={[e]:r.transform(n[e],i[e],t)})}}l.retain(a,o.default.transform(r.attributes,s.attributes,t))}}else l.retain(s.default.length(n.next()));return l.chop()}transformPosition(e,t=!1){t=!!t;const r=new a.default(this.ops);let n=0;for(;r.hasNext()&&n<=e;){const i=r.peekLength(),l=r.peekType();r.next(),"delete"!==l?("insert"===l&&(n=i-r?(e=i-r,this.index+=1,this.offset=0):this.offset+=e,"number"==typeof t.delete)return{delete:e};{const n={};return t.attributes&&(n.attributes=t.attributes),"number"==typeof t.retain?n.retain=e:"object"==typeof t.retain&&null!==t.retain?n.retain=t.retain:"string"==typeof t.insert?n.insert=t.insert.substr(r,e):n.insert=t.insert,n}}return{retain:1/0}}peek(){return this.ops[this.index]}peekLength(){return this.ops[this.index]?n.default.length(this.ops[this.index])-this.offset:1/0}peekType(){const e=this.ops[this.index];return e?"number"==typeof e.delete?"delete":"number"==typeof e.retain||"object"==typeof e.retain&&null!==e.retain?"retain":"insert":"retain"}rest(){if(this.hasNext()){if(0===this.offset)return this.ops.slice(this.index);{const e=this.offset,t=this.index,r=this.next(),n=this.ops.slice(this.index);return this.offset=e,this.index=t,[r].concat(n)}}return[]}}},912:function(t){"use strict";t.exports=e}},r={};function n(e){var i=r[e];if(void 0!==i)return i.exports;var l=r[e]={id:e,loaded:!1,exports:{}};return t[e](l,l.exports,n),l.loaded=!0,l.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.nmd=function(e){return e.paths=[],e.children||(e.children=[]),e};var i={};return function(){"use strict";n.d(i,{default:function(){return mn}});var e=n(912),t=n.n(e),r=n(32),l=n.n(r),o='',s='',a='';const c=["data-row","width","height","colspan","rowspan","style"],d={"border-style":"none","border-color":"","border-width":"","background-color":"",width:"",height:"",padding:"","text-align":"left","vertical-align":"middle"},u=["border-style","border-color","border-width","background-color","width","height","padding","text-align","vertical-align"],h=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","currentcolor","currentcolor","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"],p=["border-style","border-color","border-width","background-color","width","height","align"];const f=t().import("formats/list"),g=t().import("blots/container"),b=["colspan","rowspan"];class m extends g{static create(e){const t=super.create();for(const t of b)"1"==e[t]&&delete e[t];const r=Object.keys(e);for(const n of r)"data-row"===n?t.setAttribute(n,e[n]):"cellId"===n?t.setAttribute("data-cell",e[n]):t.setAttribute(`data-${n}`,e[n]);return t}format(e,t){return this.wrap(e,t)}static formats(e){const t=c.reduce(((t,r)=>{const n=r.includes("data")?r:`data-${r}`;return e.hasAttribute(n)&&(t[r]=e.getAttribute(n)),t}),{});t.cellId=e.getAttribute("data-cell");for(const e of b)t[e]||(t[e]="1");return t}formats(){const e=this.statics.formats(this.domNode,this.scroll);return{[this.statics.blotName]:e}}}m.blotName="table-list-container",m.className="table-list-container",m.tagName="OL";class v extends f{format(e,t,r){const n=this.formats()[this.statics.blotName];if("list"===e){const[e,i]=this.getCellFormats(this.parent);if(!t||t===n)return this.setReplace(r,e),this.replaceWith($.blotName,i);if(t!==n)return this.replaceWith(this.statics.blotName,t)}else if(e===m.blotName){"string"==typeof t&&(t={cellId:t});const[r,n,i]=this.getCorrectCellFormats(t);this.wrap(i,r),this.wrap(e,Object.assign(Object.assign({},r),{cellId:n}))}else{if("header"===e){const[e,n]=this.getCellFormats(this.parent);return this.setReplace(r,e),this.replaceWith("table-header",{cellId:n,value:t})}if(!t||e!==Z.blotName&&e!==Y.blotName)if(e!==this.statics.blotName||t)super.format(e,t);else{const[,e]=this.getCellFormats(this.parent);this.replaceWith($.blotName,e)}else{const r=this.getListContainer(this.parent);if(!r)return;const n=r.formats()[r.statics.blotName];this.wrap(e,t),this.wrap(m.blotName,Object.assign(Object.assign({},n),t))}}}getCellFormats(e){return N(B(e))}getCorrectCellFormats(e){const t=B(this.parent);if(t){const r=t.statics.blotName,[n,i]=N(t),l=Object.assign(Object.assign({},n),e),o=l.cellId||i;return delete l.cellId,[l,o,r]}{const t=e.cellId,r=Object.assign({},e);return delete r.cellId,[r,t,Z.blotName]}}getListContainer(e){for(;e;){if(e.statics.blotName===m.blotName)return e;e=e.parent}return null}static register(){t().register(m)}setReplace(e,t){e?this.parent.replaceWith(Z.blotName,t):this.wrap(Z.blotName,t)}}v.blotName="table-list",v.className="table-list",t().register({"formats/table-list":v},!0),m.allowedChildren=[v],v.requiredContainer=m;const y=t().import("formats/header");class w extends y{static create(e){const{cellId:t,value:r}=e,n=super.create(r);return n.setAttribute("data-cell",t),n}format(e,t,r){if("header"===e){const e=this.statics.formats(this.domNode).value,r=this.domNode.getAttribute("data-cell");e!=t&&t?super.format("table-header",{cellId:r,value:t}):this.replaceWith($.blotName,r)}else{if("list"===e){const[e,n,i]=this.getCellFormats(this.parent);return r?this.wrap(m.blotName,Object.assign(Object.assign({},e),{cellId:n})):this.wrap(i,e),this.replaceWith("table-list",t)}if(t&&(e===Z.blotName||e===Y.blotName))return this.wrap(e,t);if(e!==this.statics.blotName||t)super.format(e,t);else{const e=this.domNode.getAttribute("data-cell");this.replaceWith($.blotName,e)}}}static formats(e){return{cellId:e.getAttribute("data-cell"),value:this.tagName.indexOf(e.tagName)+1}}formats(){const e=this.attributes.values(),t=this.statics.formats(this.domNode,this.scroll);return null!=t&&(e[this.statics.blotName]=t),e}getCellFormats(e){const t=B(e);return[...N(t),t.statics.blotName]}}w.blotName="table-header",w.className="ql-table-header",t().register({"formats/table-header":w},!0);var C=w;function x(e){if("string"!=typeof e||!e||e.endsWith("%"))return e;const t=e.replace(/\d+\.?\d*/,""),r=e.slice(0,-t.length);return`${Math.round(parseFloat(r))}${t}`}function k(e){const t=document.createElement("div");return t.innerText=e,t.classList.add("ql-table-tooltip","ql-hidden"),t}function T(e){return e.replace(/mso.*?;/g,"")}function _(e){const[t]=e.descendant($),[r]=e.descendant(m),[n]=e.descendant(C);return t||r||n}function N(e){const t=Z.formats(e.domNode),r=_(e);if(r)return[t,A(r.formats()[r.statics.blotName])];{const e=t["data-row"].split("-")[1];return[t,`cell-${e}`]}}function A(e){return e instanceof Object?e.cellId:e}function L(e,t){return e.closest(t)}function S(e,t){return{left:Math.min(e.left,t.left),right:Math.max(e.right,t.right),top:Math.min(e.top,t.top),bottom:Math.max(e.bottom,t.bottom)}}function j(e,r,n){const i=t().find(r).descendants(re);let l=0;return i.reduce(((t,r)=>{const{left:i,width:o}=M(r.domNode,n);return l=l||i,l+2>=e.left&&l-2+o<=e.right&&t.push(r.domNode),l+=o,t}),[])}function q(e,r,n,i){return t().find(r).descendants(Z).reduce(((t,r)=>{const{left:l,top:o,width:s,height:a}=M(r.domNode,n);switch(i){case"column":(l+2>=e.left&&l-2+s<=e.right||l+2l+2&&e.left=e.left&&l-2+s<=e.right&&o+2>=e.top&&o-2+a<=e.bottom&&t.push(r.domNode)}return t}),[])}function E(e){return e.replace(/data-(?!list)[a-z]+="[^"]*"/g,"").replace(/class="[^"]*"/g,(e=>e.replace(/ql-cell-[^"]*/g,"").replace(/ql-table-[^"]*/,"").replace(/table-list(?:[^"]*)?/g,""))).replace(/class="\s*"/g,"")}function M(e,t){const r=e.getBoundingClientRect(),n=t.getBoundingClientRect(),i=r.left-n.left-t.scrollLeft,l=r.top-n.top-t.scrollTop,o=r.width,s=r.height;return{left:i,top:l,width:o,height:s,right:i+o,bottom:l+s}}function B(e){for(;e;){if(e.statics.blotName===Z.blotName||e.statics.blotName===Y.blotName)return e;e=e.parent}return null}function R(){const e=document.querySelector(".ql-editor"),{clientWidth:t}=e,r=getComputedStyle(e);return t-~~r.getPropertyValue("padding-left")-~~r.getPropertyValue("padding-right")}function O(e,t){return t?`${(e/R()*100).toFixed(2)}%`:`${e}px`}function P(e,t){const r=getComputedStyle(e),n=e.style;return t.reduce(((e,t)=>{return e[t]=(i=n.getPropertyValue(t)||r.getPropertyValue(t)).startsWith("rgba(")?function(e){e=e.replace(/^[^\d]+/,"").replace(/[^\d]+$/,"");const t=Math.round(+e[0]),r=Math.round(+e[1]),n=Math.round(+e[2]),i=Math.round(255*+e[3]).toString(16).toUpperCase().padStart(2,"0");return"#"+((1<<24)+(t<<16)+(r<<8)+n).toString(16).slice(1)+i}(i):i.startsWith("rgb(")?`#${(i=i.replace(/^[^\d]+/,"").replace(/[^\d]+$/,"")).split(",").map((e=>`00${parseInt(e,10).toString(16)}`.slice(-2))).join("")}`:i,e;var i}),{})}function I(e){return!e||(!!/^#([A-Fa-f0-9]{3,6})$/.test(e)||!!/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/.test(e)||function(e){for(const t of h)if(t===e)return!0;return!1}(e))}function z(e){if(!e)return!0;const t=e.replace(/\d+\.?\d*/,"");return!t||"px"===t||"em"===t||"%"===t||!/[a-z]/.test(t)&&!isNaN(parseFloat(t))}function D(e,t){for(const r in t)e.setAttribute(r,t[r])}function H(e,t){const r=e.style;if(r)for(const e in t)r.setProperty(e,t[e]);else e.setAttribute("style",t.toString())}function F(e,r,n){const i=t().find(e);if(!i)return;const l=i.isPercent();if(l&&!n)return;const o=i.colgroup(),s=i.temporary();if(o)if(l){let e=0;const t=o.domNode.querySelectorAll("col");for(const r of t){const t=r.style.getPropertyValue("width");e+=t?parseFloat(t):0}H(s.domNode,{width:`${e}%`})}else{let e=0;const t=o.domNode.querySelectorAll("col");for(const r of t)e+=~~r.getAttribute("width");H(s.domNode,{width:O(e,l)})}else H(s.domNode,{width:O(r.width+n,l)})}const V=t().import("blots/block"),W=t().import("blots/container"),U=["border","cellspacing","style","data-class"],G=["width"];class $ extends V{static create(e){const t=super.create();return e?t.setAttribute("data-cell",e):t.setAttribute("data-cell",le()),t}format(e,t){const r=this.formats()[this.statics.blotName];if(e===Z.blotName&&t)return this.wrap(J.blotName),this.wrap(e,t);if(e===Y.blotName&&t)return this.wrap(X.blotName),this.wrap(e,t);if(e===ie.blotName)this.wrap(e,t);else{if("header"===e)return this.replaceWith("table-header",{cellId:r,value:t});if("table-header"===e&&t)return this.wrapTableCell(this.parent),this.replaceWith(e,t);if("list"===e||"table-list"===e&&t){const e=this.getCellFormats(this.parent);return this.wrap(m.blotName,Object.assign(Object.assign({},e),{cellId:r})),this.replaceWith("table-list",t)}super.format(e,t)}}formats(){const e=this.attributes.values(),t=this.domNode.getAttribute("data-cell");return null!=t&&(e[this.statics.blotName]=t),e}getCellFormats(e){const t=B(e);if(!t)return{};const[r]=N(t);return r}wrapTableCell(e){const t=B(e);if(!t)return;const[r]=N(t);this.wrap(t.statics.blotName,r)}}$.blotName="table-cell-block",$.className="ql-table-block",$.tagName="P";class K extends ${}K.blotName="table-th-block",K.className="table-th-block",K.tagName="P";class Z extends W{checkMerge(){if(super.checkMerge()&&null!=this.next.children.head&&this.next.children.head.formats){const e=this.children.head.formats()[this.children.head.statics.blotName],t=this.children.tail.formats()[this.children.tail.statics.blotName],r=this.next.children.head.formats()[this.next.children.head.statics.blotName],n=this.next.children.tail.formats()[this.next.children.tail.statics.blotName],i=A(e),l=A(t),o=A(r),s=A(n);return i===l&&i===o&&i===s}return!1}static create(e){const t=super.create(),r=Object.keys(e);for(const n of r)e[n]&&t.setAttribute(n,e[n]);return t}static formats(e){const t=this.getEmptyRowspan(e),r=c.reduce(((r,n)=>(e.hasAttribute(n)&&(r[n]="rowspan"===n&&t?""+(~~e.getAttribute(n)-t):T(e.getAttribute(n))),r)),{});return this.hasColgroup(e)&&(delete r.width,r.style&&(r.style=r.style.replace(/width.*?;/g,""))),r}formats(){const e=this.statics.formats(this.domNode,this.scroll);return{[this.statics.blotName]:e}}static getEmptyRowspan(e){let t=e.parentElement.nextElementSibling,r=0;for(;t&&"TR"===t.tagName&&!t.innerHTML.replace(/\s/g,"");)r++,t=t.nextElementSibling;return r}static hasColgroup(e){for(;e&&"TBODY"!==e.tagName;)e=e.parentElement;for(;e;){if("COLGROUP"===e.tagName)return!0;e=e.previousElementSibling}return!1}html(){return this.domNode.outerHTML.replace(/<(ol)[^>]*>]* data-list="bullet">(?:.*?)<\/li><\/(ol)>/gi,((e,t,r)=>e.replace(t,"ul").replace(r,"ul")))}row(){return this.parent}rowOffset(){return this.row()?this.row().rowOffset():-1}setChildrenId(e){this.children.forEach((t=>{t.domNode.setAttribute("data-cell",e)}))}table(){let e=this.parent;for(;null!=e&&"table-container"!==e.statics.blotName;)e=e.parent;return e}optimize(e){super.optimize(e),this.children.forEach((e=>{if(null!=e.next&&A(e.formats()[e.statics.blotName])!==A(e.next.formats()[e.next.statics.blotName])){const t=this.splitAfter(e);t&&t.optimize(),this.prev&&this.prev.optimize()}}))}}Z.blotName="table-cell",Z.tagName="TD";class Y extends Z{}Y.blotName="table-th",Y.tagName="TH";class J extends W{checkMerge(){if(super.checkMerge()&&null!=this.next.children.head&&this.next.children.head.formats){const e=this.children.head.formats()[this.children.head.statics.blotName],t=this.children.tail.formats()[this.children.tail.statics.blotName],r=this.next.children.head.formats()[this.next.children.head.statics.blotName],n=this.next.children.tail.formats()[this.next.children.tail.statics.blotName];return e["data-row"]===t["data-row"]&&e["data-row"]===r["data-row"]&&e["data-row"]===n["data-row"]}return!1}rowOffset(){return this.parent?this.parent.children.indexOf(this):-1}}J.blotName="table-row",J.tagName="TR";class X extends J{}X.blotName="table-th-row",X.tagName="TR";class Q extends W{}Q.blotName="table-body",Q.tagName="TBODY";class ee extends Q{}ee.blotName="table-thead",ee.tagName="THEAD";class te extends V{static create(e){const t=super.create(),r=Object.keys(e),n=ie.defaultClassName;for(const i of r)"data-class"!==i||~e[i].indexOf(n)?t.setAttribute(i,e[i]):t.setAttribute(i,`${n} ${e[i]}`);return t}static formats(e){return U.reduce(((t,r)=>(e.hasAttribute(r)&&(t[r]=e.getAttribute(r)),t)),{})}formats(){const e=this.statics.formats(this.domNode,this.scroll);return{[this.statics.blotName]:e}}optimize(...e){if(this.statics.requiredContainer&&this.parent instanceof this.statics.requiredContainer){const e=this.formats()[this.statics.blotName];for(const t of U)e[t]?"data-class"===t?this.parent.domNode.setAttribute("class",e[t]):this.parent.domNode.setAttribute(t,e[t]):this.parent.domNode.removeAttribute(t)}super.optimize(...e)}}te.blotName="table-temporary",te.className="ql-table-temporary",te.tagName="temporary";class re extends V{static create(e){const t=super.create(),r=Object.keys(e);for(const n of r)t.setAttribute(n,e[n]);return t}static formats(e){return G.reduce(((t,r)=>(e.hasAttribute(r)&&(t[r]=e.getAttribute(r)),t)),{})}formats(){const e=this.statics.formats(this.domNode,this.scroll);return{[this.statics.blotName]:e}}html(){return this.domNode.outerHTML}}re.blotName="table-col",re.tagName="COL";class ne extends W{}ne.blotName="table-colgroup",ne.tagName="COLGROUP";class ie extends W{colgroup(){const[e]=this.descendant(ne);return e||this.findChild("table-colgroup")}deleteColumn(e,r,n,i=[]){const l=this.tbody(),o=this.descendants(Z);if(null!=l&&null!=l.children.head)if(r.length===o.length)n();else{for(const[r,n]of e)this.setCellColspan(t().find(r),n);for(const e of[...r,...i])1===e.parentElement.children.length&&this.setCellRowspan(e.parentElement.previousElementSibling),e.remove()}}deleteRow(e,t){const r=this.tbody();if(null!=r&&null!=r.children.head)if(e.length===r.children.length)t();else{const t=new WeakMap,n=[],i=[],l=this.getMaxColumns(r.children.head.children);for(const r of e){const n=this.getCorrectRow(r,l);n&&n.children.forEach((r=>{var n;const l=~~r.domNode.getAttribute("rowspan")||1;if(l>1){const o=r.statics.blotName,[s]=N(r);if(e.includes(r.parent)){const e=null===(n=r.parent)||void 0===n?void 0:n.next;if(t.has(r)){const{rowspan:n}=t.get(r);t.set(r,{next:e,rowspan:n-1})}else t.set(r,{next:e,rowspan:l-1}),i.push(r)}else r.replaceWith(o,Object.assign(Object.assign({},s),{rowspan:l-1}))}}))}for(const e of i){const[r]=N(e),{right:i,width:l}=e.domNode.getBoundingClientRect(),{next:o,rowspan:s}=t.get(e);this.setColumnCells(o,n,{position:i,width:l},r,s,e)}for(const[e,t,r,i]of n){const n=this.scroll.create(Z.blotName,t);i.moveChildren(n);const l=le();n.setChildrenId(l),e.insertBefore(n,r),i.remove()}for(const t of e)t.remove()}}deleteTable(){this.remove()}findChild(e){let t=this.children.head;for(;t;){if(t.statics.blotName===e)return t;t=t.next}return null}getCopyTable(e=this.domNode.outerHTML){return e.replace(/]*>(.*?)<\/temporary>/gi,"").replace(/]*>(.*?)<\/td>/gi,(e=>E(e)))}getCorrectRow(e,t){let r=!1;for(;e&&!r;){if(t===this.getMaxColumns(e.children))return r=!0,e;e=e.prev}return e}getInsertRow(e,t,r,n){const i=this.tbody(),l=this.thead();if(!(null!=i&&null!=i.children.head||null!=l&&null!=l.children.head))return;const o=oe(),s=n?X.blotName:J.blotName,a=this.scroll.create(s),c=this.getMaxColumns((i||l).children.head.children);return this.getMaxColumns(e.children)===c?(e.children.forEach((e=>{const t={height:"24","data-row":o},r=~~e.domNode.getAttribute("colspan")||1;this.insertTableCell(r,t,a,n)})),a):(this.getCorrectRow(e.prev,c).children.forEach((e=>{const i={height:"24","data-row":o},l=~~e.domNode.getAttribute("colspan")||1,s=~~e.domNode.getAttribute("rowspan")||1;if(s>1)if(r>0&&!t)this.insertTableCell(l,i,a,n);else{const[t]=N(e);e.replaceWith(e.statics.blotName,Object.assign(Object.assign({},t),{rowspan:s+1}))}else this.insertTableCell(l,i,a,n)})),a)}getMaxColumns(e){return e.reduce(((e,t)=>e+(~~t.domNode.getAttribute("colspan")||1)),0)}insertColumn(e,t,r,n){const i=this.colgroup(),l=this.tbody(),o=this.thead();if(!(null!=l&&null!=l.children.head||null!=o&&null!=o.children.head))return;const s=[],a=[],c=this.descendants(J);for(const i of c)if(t&&n>0){const e=i.children.tail.domNode.getAttribute("data-row");s.push([i,e,null,null])}else this.setColumnCells(i,s,{position:e,width:r});if(i)if(t)a.push([i,null]);else{let t=0,r=0,n=i.children.head;for(;n;){const{left:l,width:o}=n.domNode.getBoundingClientRect();if(t=t||l,r=t+o,Math.abs(t-e)<=2){a.push([i,n]);break}if(Math.abs(r-e)<=2&&!n.next){a.push([i,null]);break}t+=o,n=n.next}}for(const[e,t,r]of s)e?this.insertColumnCell(e,t,r):this.setCellColspan(r,1);for(const[e,t]of a)this.insertCol(e,t)}insertCol(e,t){const r=this.scroll.create(re.blotName,{width:"72"});e.insertBefore(r,t)}insertColumnCell(e,t,r){if(!e){const t=this.tbody();e=this.scroll.create(J.blotName),t.insertBefore(e,null)}const n=this.colgroup()?{"data-row":t}:{"data-row":t,width:"72"},i=e.statics.blotName===J.blotName,l=i?Z.blotName:Y.blotName,o=i?$.blotName:K.blotName,s=this.scroll.create(l,n),a=this.scroll.create(o,le());return s.appendChild(a),e.insertBefore(s,r),a.optimize(),s}insertRow(e,t,r){const n=this.tbody(),i=this.thead();if(!(null!=n&&null!=n.children.head||null!=i&&null!=i.children.head))return;const l=r?i:n,o=r?i.children.at(e):n.children.at(e),s=o||n.children.at(e-1),a=this.getInsertRow(s,o,t,r);l.insertBefore(a,o)}insertTableCell(e,t,r,n){e>1?Object.assign(t,{colspan:e}):delete t.colspan;const i=n?Y.blotName:Z.blotName,l=n?K.blotName:$.blotName,o=this.scroll.create(i,t),s=this.scroll.create(l,le());o.appendChild(s),r.appendChild(o),s.optimize()}isPercent(){const e=this.domNode.getAttribute("width")||this.domNode.style.getPropertyValue("width");return!!e&&e.endsWith("%")}optimize(e){super.optimize(e);const t=this.descendants(te);if(this.setClassName(t),t.length>1){t.shift();for(const e of t)e.remove()}}setCellColspan(e,t){const r=e.statics.blotName,n=e.formats()[r],i=(~~n.colspan||1)+t;i>1?Object.assign(n,{colspan:i}):delete n.colspan,e.replaceWith(r,n)}setCellRowspan(e){for(;e;){const r=e.querySelectorAll("td[rowspan]");if(r.length){for(const e of r){const r=t().find(e),n=r.statics.blotName,i=r.formats()[n],l=(~~i.rowspan||1)-1,o=_(r);l>1?Object.assign(i,{rowspan:l}):delete i.rowspan,o.format(n,i)}break}e=e.previousElementSibling}}setClassName(e){const t=this.statics.defaultClassName,r=e[0],n=this.domNode.getAttribute("class"),i=(e,r)=>{const n=e.domNode.getAttribute("data-class");n!==r&&null!=r&&e.domNode.setAttribute("data-class",(e=>{const r=(e||"").split(/\s+/);return r.find((e=>e===t))||r.unshift(t),r.join(" ").trim()})(r)),r||n||e.domNode.setAttribute("data-class",t)};if(r)i(r,n);else{const e=this.prev;if(!e)return;const[t]=e.descendant(Z),[r]=e.descendant(te);!t&&r&&i(r,n)}}setColumnCells(e,t,r,n,i,l){if(!e)return;const{position:o,width:s}=r;let a=e.children.head;for(;a;){const{left:r,right:c}=a.domNode.getBoundingClientRect(),d=a.domNode.getAttribute("data-row");"object"==typeof n&&Object.assign(n,{rowspan:i,"data-row":d});const u=n||d;if(Math.abs(r-o)<=2){t.push([e,u,a,l]);break}if(Math.abs(c-o)<=2&&!a.next){t.push([e,u,null,l]);break}if(Math.abs(r-o-s)<=2){t.push([e,u,a,l]);break}if(o>r&&ode(e,r,t[r])),e):e.reduce(((e,n)=>n.attributes&&n.attributes[t]?e.push(n):e.insert(n.insert,ae()({},{[t]:r},n.attributes))),new(l()))}function ue(e,t){const r=e.querySelectorAll("th"),n=(null==r?void 0:r.length)?"table-th":"table-cell",i="TABLE"===e.parentNode.tagName?e.parentNode:e.parentNode.parentNode,o=Array.from(i.querySelectorAll("tr")).indexOf(e)+1;return e.innerHTML.replace(/\s/g,"")?de(t,n,o):new(l())}function he(e,t){var r;const n=e.tagName,i="TD"===n,l=i?"table-cell":"table-th",o=i?"table-cell-block":"table-th-block",s="TABLE"===e.parentNode.parentNode.tagName?e.parentNode.parentNode:e.parentNode.parentNode.parentNode,a=Array.from(s.querySelectorAll("tr")),c=Array.from(e.parentNode.querySelectorAll(n)),d=e.getAttribute("data-row")||a.indexOf(e.parentNode)+1,u=(null===(r=null==e?void 0:e.firstElementChild)||void 0===r?void 0:r.getAttribute("data-cell"))||c.indexOf(e)+1;return t.length()||t.insert("\n",{[l]:{"data-row":d}}),t.ops.forEach((e=>{e.attributes&&e.attributes[l]&&(e.attributes[l]=Object.assign(Object.assign({},e.attributes[l]),{"data-row":d}))})),de(function(e,t){return"TH"===e.tagName&&t.ops.forEach((e=>{"string"!=typeof e.insert||e.insert.endsWith("\n")||(e.insert+="\n")})),t}(e,t),o,u)}function pe(e,t){let r=~~e.getAttribute("span")||1;const n=e.getAttribute("width"),i=new(l());for(;r>1;)i.insert("\n",{"table-col":{width:n}}),r--;return i.concat(t)}function fe(e,t){const r=ce.reduce(((t,r)=>(e.hasAttribute(r)&&("class"===r?t["data-class"]=e.getAttribute(r):t[r]=T(e.getAttribute(r))),t)),{});return(new(l())).insert("\n",{"table-temporary":r}).concat(t)}var ge={col:"Column",insColL:"Insert column left",insColR:"Insert column right",delCol:"Delete column",selCol:"Select column",row:"Row",headerRow:"Header row",insRowAbv:"Insert row above",insRowBlw:"Insert row below",delRow:"Delete row",selRow:"Select row",mCells:"Merge cells",sCell:"Split cell",tblProps:"Table properties",cellProps:"Cell properties",insParaOTbl:"Insert paragraph outside the table",insB4:"Insert before",insAft:"Insert after",copyTable:"Copy table",delTable:"Delete table",border:"Border",color:"Color",width:"Width",background:"Background",dims:"Dimensions",height:"Height",padding:"Padding",tblCellTxtAlm:"Table cell text alignment",alCellTxtL:"Align cell text to the left",alCellTxtC:"Align cell text to the center",alCellTxtR:"Align cell text to the right",jusfCellTxt:"Justify cell text",alCellTxtT:"Align cell text to the top",alCellTxtM:"Align cell text to the middle",alCellTxtB:"Align cell text to the bottom",dimsAlm:"Dimensions and alignment",alTblL:"Align table to the left",tblC:"Center table",alTblR:"Align table to the right",save:"Save",cancel:"Cancel",colorMsg:'The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".',dimsMsg:'The value is invalid. Try "10px" or "2em" or "2%" or simply "2".',colorPicker:"Color picker",removeColor:"Remove color",black:"Black",dimGrey:"Dim grey",grey:"Grey",lightGrey:"Light grey",white:"White",red:"Red",orange:"Orange",yellow:"Yellow",lightGreen:"Light green",green:"Green",aquamarine:"Aquamarine",turquoise:"Turquoise",lightBlue:"Light blue",blue:"Blue",purple:"Purple"},be={col:"列",insColL:"向左插入列",insColR:"向右插入列",delCol:"删除列",selCol:"选择列",row:"行",headerRow:"标题行",insRowAbv:"在上面插入行",insRowBlw:"在下面插入行",delRow:"删除行",selRow:"选择行",mCells:"合并单元格",sCell:"拆分单元格",tblProps:"表格属性",cellProps:"单元格属性",insParaOTbl:"在表格外插入段落",insB4:"在表格前面插入",insAft:"在表格后面插入",copyTable:"复制表格",delTable:"删除表格",border:"边框",color:"颜色",width:"宽度",background:"背景",dims:"尺寸",height:"高度",padding:"内边距",tblCellTxtAlm:"单元格文本对齐方式",alCellTxtL:"左对齐",alCellTxtC:"水平居中对齐",alCellTxtR:"右对齐",jusfCellTxt:"两边对齐",alCellTxtT:"顶端对齐",alCellTxtM:"垂直居中对齐",alCellTxtB:"底部对齐",dimsAlm:"尺寸和对齐方式",alTblL:"表格左对齐",tblC:"表格居中",alTblR:"表格右对齐",save:"保存",cancel:"取消",colorMsg:'无效颜色,请使用 "#FF0000" 或者 "rgb(255,0,0)" 或者 "red"',dimsMsg:'无效值,请使用 "10px" 或者 "2em" 或者 "2%" 或者 "2"',colorPicker:"颜色选择器",removeColor:"删除颜色",black:"黑色",dimGrey:"暗灰色",grey:"灰色",lightGrey:"浅灰色",white:"白色",red:"红色",orange:"橙色",yellow:"黄色",lightGreen:"浅绿色",green:"绿色",aquamarine:"海蓝色",turquoise:"青绿色",lightBlue:"浅蓝色",blue:"蓝色",purple:"紫色"},me={col:"Colonne",insColL:"Insérer colonne à gauche",insColR:"Insérer colonne à droite",delCol:"Supprimer la colonne",selCol:"Sélectionner la colonne",row:"Ligne",headerRow:"Ligne d'en-tête",insRowAbv:"Insérer ligne au-dessus",insRowBlw:"Insérer ligne en dessous",delRow:"Supprimer la ligne",selRow:"Sélectionner la ligne",mCells:"Fusionner les cellules",sCell:"Diviser la cellule",tblProps:"Propriétés du tableau",cellProps:"Propriétés de la cellule",insParaOTbl:"Insérer paragraphe en dehors du tableau",insB4:"Insérer avant",insAft:"Insérer après",copyTable:"Copier le tableau",delTable:"Supprimer le tableau",border:"Bordure",color:"Couleur",width:"Largeur",background:"Arrière-plan",dims:"Dimensions",height:"Hauteur",padding:"Marge intérieure",tblCellTxtAlm:"Alignement du texte de la cellule du tableau",alCellTxtL:"Aligner le texte de la cellule à gauche",alCellTxtC:"Aligner le texte de la cellule au centre",alCellTxtR:"Aligner le texte de la cellule à droite",jusfCellTxt:"Justifier le texte de la cellule",alCellTxtT:"Aligner le texte de la cellule en haut",alCellTxtM:"Aligner le texte de la cellule au milieu",alCellTxtB:"Aligner le texte de la cellule en bas",dimsAlm:"Dimensions et alignement",alTblL:"Aligner le tableau à gauche",tblC:"Centrer le tableau",alTblR:"Aligner le tableau à droite",save:"Enregistrer",cancel:"Annuler",colorMsg:'La couleur est invalide. Essayez "#FF0000" ou "rgb(255,0,0)" ou "rouge".',dimsMsg:'La valeur est invalide. Essayez "10px" ou "2em" ou "2%" ou simplement "2".',colorPicker:"Sélecteur de couleur",removeColor:"Supprimer la couleur",black:"Noir",dimGrey:"Gris foncé",grey:"Gris",lightGrey:"Gris clair",white:"Blanc",red:"Rouge",orange:"Orange",yellow:"Jaune",lightGreen:"Vert clair",green:"Vert",aquamarine:"Aigue-marine",turquoise:"Turquoise",lightBlue:"Bleu clair",blue:"Bleu",purple:"Violet"},ve={col:"Kolumna",insColL:"Wstaw kolumnę z lewej",insColR:"Wstaw kolumnę z prawej",delCol:"Usuń kolumnę",selCol:"Wybierz kolumnę",row:"Wiersz",headerRow:"Wiersz nagłówka",insRowAbv:"Wstaw wiersz powyżej",insRowBlw:"Wstaw wiersz poniżej",delRow:"Usuń wiersz",selRow:"Wybierz wiersz",mCells:"Scal komórki",sCell:"Podziel komórkę",tblProps:"Właściwości tabeli",cellProps:"Właściwości komórki",insParaOTbl:"Wstaw akapit poza tabelą",insB4:"Wstaw przed",insAft:"Wstaw po",copyTable:"Kopiuj tabelę",delTable:"Usuń tabelę",border:"Obramowanie",color:"Kolor",width:"Szerokość",background:"Tło",dims:"Wymiary",height:"Wysokość",padding:"Margines wewnętrzny",tblCellTxtAlm:"Wyrównanie tekstu w komórce tabeli",alCellTxtL:"Wyrównaj tekst w komórce do lewej",alCellTxtC:"Wyrównaj tekst w komórce do środka",alCellTxtR:"Wyrównaj tekst w komórce do prawej",jusfCellTxt:"Wyjustuj tekst w komórce",alCellTxtT:"Wyrównaj tekst w komórce do góry",alCellTxtM:"Wyrównaj tekst w komórce do środka",alCellTxtB:"Wyrównaj tekst w komórce do dołu",dimsAlm:"Wymiary i wyrównanie",alTblL:"Wyrównaj tabelę do lewej",tblC:"Wyśrodkuj tabelę",alTblR:"Wyrównaj tabelę do prawej",save:"Zapisz",cancel:"Anuluj",colorMsg:'Kolor jest nieprawidłowy. Spróbuj "#FF0000" lub "rgb(255,0,0)" lub "red".',dimsMsg:'Wartość jest nieprawidłowa. Spróbuj "10px" lub "2em" lub "2%" lub po prostu "2".',colorPicker:"Wybór koloru",removeColor:"Usuń kolor",black:"Czarny",dimGrey:"Przyciemniony szary",grey:"Szary",lightGrey:"Jasnoszary",white:"Biały",red:"Czerwony",orange:"Pomarańczowy",yellow:"Żółty",lightGreen:"Jasnozielony",green:"Zielony",aquamarine:"Akwamaryna",turquoise:"Turkusowy",lightBlue:"Jasnoniebieski",blue:"Niebieski",purple:"Fioletowy"},ye={col:"Spalte",insColL:"Spalte links einfügen",insColR:"Spalte rechts einfügen",delCol:"Spalte löschen",selCol:"Spalte auswählen",row:"Zeile",headerRow:"Kopfzeile",insRowAbv:"Zeile oberhalb einfügen",insRowBlw:"Zeile unterhalb einfügen",delRow:"Zeile löschen",selRow:"Zeile auswählen",mCells:"Zellen verbinden",sCell:"Zelle teilen",tblProps:"Tabelleneingenschaften",cellProps:"Zelleneigenschaften",insParaOTbl:"Absatz außerhalb der Tabelle einfügen",insB4:"Davor einfügen",insAft:"Danach einfügen",copyTable:"Tabelle kopieren",delTable:"Tabelle löschen",border:"Rahmen",color:"Farbe",width:"Breite",background:"Schattierung",dims:"Maße",height:"Höhe",padding:"Abstand",tblCellTxtAlm:"Ausrichtung",alCellTxtL:"Zellentext links ausrichten",alCellTxtC:"Zellentext mittig ausrichten",alCellTxtR:"Zellentext rechts ausrichten",jusfCellTxt:"Zellentext Blocksatz",alCellTxtT:"Zellentext oben ausrichten",alCellTxtM:"Zellentext mittig ausrichten",alCellTxtB:"Zellentext unten ausrichten",dimsAlm:"Maße und Ausrichtung",alTblL:"Tabelle links ausrichten",tblC:"Tabelle mittig ausrichten",alTblR:"Tabelle rechts ausrichten",save:"Speichern",cancel:"Abbrechen",colorMsg:'Die Farbe ist ungültig. Probiere "#FF0000", "rgb(255,0,0)" oder "red".',dimsMsg:'Der Wert ist ungültig. Probiere "10px", "2em" oder "2%" oder einfach "2".',colorPicker:"Farbwähler",removeColor:"Farbe entfernen",black:"Schwarz",dimGrey:"Dunkelgrau",grey:"Grau",lightGrey:"Hellgrau",white:"Weiß",red:"Rot",orange:"Orange",yellow:"Gelb",lightGreen:"Hellgrün",green:"Grün",aquamarine:"Aquamarin",turquoise:"Türkis",lightBlue:"Hellblau",blue:"Blau",purple:"Lila"},we={col:"Столбец",insColL:"Вставить столбец слева",insColR:"Вставить столбец справа",delCol:"Удалить столбец",selCol:"Выбрать столбец",row:"Строка",headerRow:"Строка заголовка",insRowAbv:"Вставить строку сверху",insRowBlw:"Вставить строку снизу",delRow:"Удалить строку",selRow:"Выбрать строку",mCells:"Объединить ячейки",sCell:"Разбить ячейку",tblProps:"Свойства таблицы",cellProps:"Свойства ячейки",insParaOTbl:"Вставить абзац за пределами таблицы",insB4:"Вставить абзац перед",insAft:"Вставить абзац после",copyTable:"Копировать таблицу",delTable:"Удалить таблицу",border:"Обводка",color:"Цвет",width:"Ширина",background:"Фон",dims:"Размеры",height:"Высота",padding:"Отступ",tblCellTxtAlm:"Выравнивание текста в ячейке таблицы",alCellTxtL:"Выровнять текст в ячейке по левому краю",alCellTxtC:"Выровнять текст в ячейке по центру",alCellTxtR:"Выровнять текст в ячейке по правому краю",jusfCellTxt:"Выровнять текст в ячейке по ширине",alCellTxtT:"Выровнять текст в ячейке по верху",alCellTxtM:"Выровнять текст в ячейке по середине",alCellTxtB:"Выровнять текст в ячейке по низу",dimsAlm:"Размеры и выравнивание",alTblL:"Выровнять таблицу по левому краю",tblC:"Центрировать таблицу",alTblR:"Выровнять таблицу по правому краю",save:"Сохранить",cancel:"Отменить",colorMsg:'Неверный цвет. Попробуйте "#FF0000", "rgb(255,0,0)" или "red".',dimsMsg:'Недопустимое значение. Попробуйте "10px", "2em" или "2%" или просто "2".',colorPicker:"Выбор цвета",removeColor:"Удалить цвет",black:"Черный",dimGrey:"Темно-серый",grey:"Серый",lightGrey:"Светло-серый",white:"Белый",red:"Красный",orange:"Оранжевый",yellow:"Желтый",lightGreen:"Светло-зеленый",green:"Зеленый",aquamarine:"Аквамарин",turquoise:"Бирюзовый",lightBlue:"Светло-голубой",blue:"Синий",purple:"Фиолетовый"},Ce={col:"Sütun",insColL:"Sola sütun ekle",insColR:"Sağa sütun ekle",delCol:"Sütunu sil",selCol:"Sütunu seç",row:"Satır",headerRow:"Başlık satırı",insRowAbv:"Üstüne satır ekle",insRowBlw:"Altına satır ekle",delRow:"Satırı sil",selRow:"Satır seç",mCells:"Hücreleri birleştir",sCell:"Hücreyi böl",tblProps:"Tablo özellikleri",cellProps:"Hücre özellikleri",insParaOTbl:"Tablo dışında paragraf ekle",insB4:"Öncesine ekle",insAft:"Sonrasına ekle",copyTable:"Tabloyu kopyala",delTable:"Tabloyu sil",border:"Kenarlık",color:"Renk",width:"Genişlik",background:"Arka plan",dims:"Boyutlar",height:"Yükseklik",padding:"Dolgu",tblCellTxtAlm:"Tablo hücresi metin hizalaması",alCellTxtL:"Hücre metnini sola hizala",alCellTxtC:"Hücre metnini ortaya hizala",alCellTxtR:"Hücre metnini sağa hizala",jusfCellTxt:"Hücre metnini yasla",alCellTxtT:"Hücre metnini üste hizala",alCellTxtM:"Hücre metnini ortaya hizala",alCellTxtB:"Hücre metnini alta hizala",dimsAlm:"Boyutlar ve hizalama",alTblL:"Tabloyu sola hizala",tblC:"Tabloyu ortala",alTblR:"Tabloyu sağa hizala",save:"Kaydet",cancel:"İptal",colorMsg:'Renk geçersiz. "#FF0000", "rgb(255,0,0)" veya "red" deneyin.',dimsMsg:'Değer geçersiz. "10px", "2em" veya "2%" veya sadece "2" deneyin.',colorPicker:"Renk seçici",removeColor:"Rengi kaldır",black:"Siyah",dimGrey:"Koyu gri",grey:"Gri",lightGrey:"Açık gri",white:"Beyaz",red:"Kırmızı",orange:"Turuncu",yellow:"Sarı",lightGreen:"Açık yeşil",green:"Yeşil",aquamarine:"Akuamarin",turquoise:"Turkuaz",lightBlue:"Açık mavi",blue:"Mavi",purple:"Mor"},xe={col:"Coluna",insColL:"Inserir coluna à esquerda",insColR:"Inserir coluna à direita",delCol:"Eliminar coluna",selCol:"Selecionar coluna",row:"Linha",headerRow:"Linha de cabeçalho",insRowAbv:"Inserir linha acima",insRowBlw:"Inserir linha abaixo",delRow:"Eliminar linha",selRow:"Selecionar linha",mCells:"Unir células",sCell:"Dividir célula",tblProps:"Propriedades da tabela",cellProps:"Propriedades da célula",insParaOTbl:"Inserir parágrafo fora da tabela",insB4:"Inserir antes",insAft:"Inserir depois",copyTable:"Copiar tabela",delTable:"Eliminar tabela",border:"Borda",color:"Cor",width:"Largura",background:"Cor de Fundo",dims:"Dimensões",height:"Altura",padding:"Margem interna",tblCellTxtAlm:"Alinhamento do texto",alCellTxtL:"Alinhar texto da célula à esquerda",alCellTxtC:"Alinhar texto da célula ao centro",alCellTxtR:"Alinhar texto da célula à direita",jusfCellTxt:"Justificar texto da célula",alCellTxtT:"Alinhar texto da célula no topo",alCellTxtM:"Alinhar texto da célula ao meio",alCellTxtB:"Alinhar texto da célula na parte inferior",dimsAlm:"Dimensões e alinhamento",alTblL:"Alinhar tabela à esquerda",tblC:"Centrar tabela",alTblR:"Alinhar tabela à direita",save:"Guardar",cancel:"Cancelar",colorMsg:'A cor é inválida. Tente "#FF0000" ou "rgb(255,0,0)" ou "vermelho".',dimsMsg:'O valor é inválido. Tente "10px" ou "2em" ou "2%" ou apenas "2".',colorPicker:"Selecionar cor",removeColor:"Remover cor",black:"Preto",dimGrey:"Cinzento escuro",grey:"Cinzento",lightGrey:"Cinzento claro",white:"Branco",red:"Vermelho",orange:"Laranja",yellow:"Amarelo",lightGreen:"Verde claro",green:"Verde",aquamarine:"Azul marinho",turquoise:"Azul turquesa",lightBlue:"Azul claro",blue:"Azul",purple:"Roxo"},ke={col:"列",insColL:"左に列を挿入",insColR:"右に列を挿入",delCol:"列を削除",selCol:"列を選択",row:"行",headerRow:"ヘッダー行",insRowAbv:"上に行を挿入",insRowBlw:"下に行を挿入",delRow:"行を削除",selRow:"行を選択",mCells:"セルを結合",sCell:"セルを分割",tblProps:"テーブルのプロパティ",cellProps:"セルのプロパティ",insParaOTbl:"テーブル外に段落を挿入",insB4:"前に挿入",insAft:"後に挿入",copyTable:"テーブルをコピー",delTable:"テーブルを削除",border:"枠線",color:"色",width:"幅",background:"背景",dims:"サイズ",height:"高さ",padding:"パディング",tblCellTxtAlm:"セルのテキスト配置",alCellTxtL:"セルのテキストを左揃え",alCellTxtC:"セルのテキストを中央揃え",alCellTxtR:"セルのテキストを右揃え",jusfCellTxt:"セルのテキストを両端揃え",alCellTxtT:"セルのテキストを上揃え",alCellTxtM:"セルのテキストを中央揃え(縦)",alCellTxtB:"セルのテキストを下揃え",dimsAlm:"サイズと配置",alTblL:"テーブルを左揃え",tblC:"テーブルを中央揃え",alTblR:"テーブルを右揃え",save:"保存",cancel:"キャンセル",colorMsg:'色が無効です。"#FF0000"や"rgb(255,0,0)"や"red"を試してください。',dimsMsg:'値が無効です。"10px"や"2em"や"2%"または単に"2"を試してください。',colorPicker:"カラーピッカー",removeColor:"色を削除",black:"黒",dimGrey:"ダークグレー",grey:"グレー",lightGrey:"ライトグレー",white:"白",red:"赤",orange:"オレンジ",yellow:"黄色",lightGreen:"ライトグリーン",green:"緑",aquamarine:"アクアマリン",turquoise:"ターコイズ",lightBlue:"ライトブルー",blue:"青",purple:"紫"},Te={col:"Coluna",insColL:"Inserir coluna à esquerda",insColR:"Inserir coluna à direita",delCol:"Excluir coluna",selCol:"Selecionar coluna",row:"Linha",headerRow:"Linha de título",insRowAbv:"Inserir linha acima",insRowBlw:"Inserir linha abaixo",delRow:"Excluir linha",selRow:"Selecionar linha",mCells:"Mesclar células",sCell:"Dividir célula",tblProps:"Propriedades da tabela",cellProps:"Propriedades da célula",insParaOTbl:"Inserir parágrafo fora da tabela",insB4:"Inserir parágrafo antes",insAft:"Inserir parágrafo depois",copyTable:"Copiar tabela",delTable:"Excluir tabela",border:"Borda",color:"Cor",width:"Largura",background:"Fundo",dims:"Dimensões",height:"Altura",padding:"Espaçamento",tblCellTxtAlm:"Alinhamento do texto da célula",alCellTxtL:"Alinhar texto à esquerda",alCellTxtC:"Centralizar texto",alCellTxtR:"Alinhar texto à direita",jusfCellTxt:"Justificar texto",alCellTxtT:"Alinhar texto ao topo",alCellTxtM:"Alinhar texto ao meio",alCellTxtB:"Alinhar texto à base",dimsAlm:"Dimensões e alinhamento",alTblL:"Alinhar tabela à esquerda",tblC:"Centralizar tabela",alTblR:"Alinhar tabela à direita",save:"Salvar",cancel:"Cancelar",colorMsg:'A cor é inválida. Tente "#FF0000" ou "rgb(255,0,0)" ou "vermelho".',dimsMsg:'O valor é inválido. Tente "10px" ou "2em" ou "2%" ou simplesmente "2".',colorPicker:"Seletor de cor",removeColor:"Remover cor",black:"Preto",dimGrey:"Cinza escuro",grey:"Cinza",lightGrey:"Cinza claro",white:"Branco",red:"Vermelho",orange:"Laranja",yellow:"Amarelo",lightGreen:"Verde claro",green:"Verde",aquamarine:"Água-marinha",turquoise:"Turquesa",lightBlue:"Azul claro",blue:"Azul",purple:"Roxo"},_e={col:"Sloupec",insColL:"Vložit sloupec vlevo",insColR:"Vložit sloupec vpravo",delCol:"Smazat sloupec",selCol:"Vybrat sloupec",row:"Řádek",headerRow:"Řádek záhlaví",insRowAbv:"Vložit řádek nad",insRowBlw:"Vložit řádek pod",delRow:"Smazat řádek",selRow:"Vybrat řádek",mCells:"Sloučit buňky",sCell:"Rozdělit buňku",tblProps:"Vlastnosti tabulky",cellProps:"Vlastnosti buňky",insParaOTbl:"Vložit odstavec mimo tabulku",insB4:"Vložit před",insAft:"Vložit za",copyTable:"Kopírovat tabulku",delTable:"Smazat tabulku",border:"Okraj",color:"Barva",width:"Šířka",background:"Pozadí",dims:"Rozměry",height:"Výška",padding:"Vnitřní okraj",tblCellTxtAlm:"Zarovnání textu v buňce",alCellTxtL:"Zarovnat text vlevo",alCellTxtC:"Zarovnat text na střed",alCellTxtR:"Zarovnat text vpravo",jusfCellTxt:"Zarovnat text do bloku",alCellTxtT:"Zarovnat text nahoru",alCellTxtM:"Zarovnat text na střed (vertikálně)",alCellTxtB:"Zarovnat text dolů",dimsAlm:"Rozměry a zarovnání",alTblL:"Zarovnat tabulku vlevo",tblC:"Zarovnat tabulku na střed",alTblR:"Zarovnat tabulku vpravo",save:"Uložit",cancel:"Zrušit",colorMsg:'Barva je neplatná. Zkuste např. "#FF0000", "rgb(255,0,0)" nebo "red".',dimsMsg:'Hodnota je neplatná. Zkuste "10px", "2em" nebo "2%" nebo jednoduše "2".',colorPicker:"Výběr barvy",removeColor:"Odebrat barvu",black:"Černá",dimGrey:"Tmavě šedá",grey:"Šedá",lightGrey:"Světle šedá",white:"Bílá",red:"Červená",orange:"Oranžová",yellow:"Žlutá",lightGreen:"Světle zelená",green:"Zelená",aquamarine:"Akvamarínová",turquoise:"Tyrkysová",lightBlue:"Světle modrá",blue:"Modrá",purple:"Fialová"},Ne={col:"Kolonne",insColL:"Indsæt kolonne til venstre",insColR:"Indsæt kolonne til højre",delCol:"Slet kolonne",selCol:"Vælg kolonne",row:"Række",headerRow:"Overskriftsrække",insRowAbv:"Indsæt række ovenfor",insRowBlw:"Indsæt række nedenfor",delRow:"Slet række",selRow:"Vælg række",mCells:"Flet celler",sCell:"Opdel celle",tblProps:"Tabellegenskaber",cellProps:"Celleegenskaber",insParaOTbl:"Indsæt afsnit uden for tabellen",insB4:"Indsæt før",insAft:"Indsæt efter",copyTable:"Kopiér tabel",delTable:"Slet tabel",border:"Kant",color:"Farve",width:"Bredde",background:"Baggrund",dims:"Mål",height:"Højde",padding:"Indre afstand",tblCellTxtAlm:"Justering",alCellTxtL:"Venstrejuster celletekst",alCellTxtC:"Centrer celletekst",alCellTxtR:"Højrejuster celletekst",jusfCellTxt:"Juster celletekst",alCellTxtT:"Topjuster celletekst",alCellTxtM:"Centrer celletekst (lodret)",alCellTxtB:"Bundjuster celletekst",dimsAlm:"Mål og justering",alTblL:"Venstrejuster tabel",tblC:"Centrer tabel",alTblR:"Højrejuster tabel",save:"Gem",cancel:"Annuller",colorMsg:'Farven er ugyldig. Prøv "#FF0000", "rgb(255,0,0)" eller "red".',dimsMsg:'Værdien er ugyldig. Prøv "10px", "2em" eller "2%" eller blot "2".',colorPicker:"Farvevælger",removeColor:"Fjern farve",black:"Sort",dimGrey:"Mørkegrå",grey:"Grå",lightGrey:"Lysegrå",white:"Hvid",red:"Rød",orange:"Orange",yellow:"Gul",lightGreen:"Lysegrøn",green:"Grøn",aquamarine:"Akvamarin",turquoise:"Turkis",lightBlue:"Lyseblå",blue:"Blå",purple:"Lilla"},Ae={col:"Kolonne",insColL:"Sett inn kolonne til venstre",insColR:"Sett inn kolonne til høyre",delCol:"Slett kolonne",selCol:"Velg kolonne",row:"Rad",headerRow:"Overskriftsrad",insRowAbv:"Sett inn rad over",insRowBlw:"Sett inn rad under",delRow:"Slett rad",selRow:"Velg rad",mCells:"Slå sammen celler",sCell:"Del celle",tblProps:"Tabellegenskaper",cellProps:"Celleegenskaper",insParaOTbl:"Sett inn avsnitt utenfor tabellen",insB4:"Sett inn før",insAft:"Sett inn etter",copyTable:"Kopier tabell",delTable:"Slett tabell",border:"Ramme",color:"Farge",width:"Bredde",background:"Bakgrunn",dims:"Mål",height:"Høyde",padding:"Polstring",tblCellTxtAlm:"Justering",alCellTxtL:"Venstrejuster celletekst",alCellTxtC:"Sentrer celletekst",alCellTxtR:"Høyrejuster celletekst",jusfCellTxt:"Blokjuster celletekst",alCellTxtT:"Toppjuster celletekst",alCellTxtM:"Sentrer celletekst (loddrett)",alCellTxtB:"Bunnjuster celletekst",dimsAlm:"Mål og justering",alTblL:"Venstrejuster tabell",tblC:"Sentrer tabell",alTblR:"Høyrejuster tabell",save:"Lagre",cancel:"Avbryt",colorMsg:'Fargen er ugyldig. Prøv "#FF0000", "rgb(255,0,0)" eller "red".',dimsMsg:'Verdien er ugyldig. Prøv "10px", "2em" eller "2%" eller bare "2".',colorPicker:"Fargevelger",removeColor:"Fjern farge",black:"Svart",dimGrey:"Mørkegrå",grey:"Grå",lightGrey:"Lysegrå",white:"Hvit",red:"Rød",orange:"Oransje",yellow:"Gul",lightGreen:"Lysegrønn",green:"Grønn",aquamarine:"Akvamarin",turquoise:"Turkis",lightBlue:"Lyseblå",blue:"Blå",purple:"Lilla"},Le={col:"Colonna",insColL:"Inserisci colonna a sinistra",insColR:"Inserisci colonna a destra",delCol:"Elimina colonna",selCol:"Seleziona colonna",row:"Riga",headerRow:"Riga di intestazione",insRowAbv:"Inserisci riga sopra",insRowBlw:"Inserisci riga sotto",delRow:"Elimina riga",selRow:"Seleziona riga",mCells:"Unisci celle",sCell:"Dividi cella",tblProps:"Proprietà tabella",cellProps:"Proprietà cella",insParaOTbl:"Inserisci paragrafo fuori dalla tabella",insB4:"Inserisci prima",insAft:"Inserisci dopo",copyTable:"Copia tabella",delTable:"Elimina tabella",border:"Bordo",color:"Colore",width:"Larghezza",background:"Sfondo",dims:"Dimensioni",height:"Altezza",padding:"Spaziatura interna",tblCellTxtAlm:"Allineamento testo cella",alCellTxtL:"Allinea testo cella a sinistra",alCellTxtC:"Allinea testo cella al centro",alCellTxtR:"Allinea testo cella a destra",jusfCellTxt:"Giustifica testo cella",alCellTxtT:"Allinea testo cella in alto",alCellTxtM:"Allinea testo cella al centro verticale",alCellTxtB:"Allinea testo cella in basso",dimsAlm:"Dimensioni e allineamento",alTblL:"Allinea tabella a sinistra",tblC:"Centra tabella",alTblR:"Allinea tabella a destra",save:"Salva",cancel:"Annulla",colorMsg:'Il colore non è valido. Prova con "#FF0000", "rgb(255,0,0)" o "red".',dimsMsg:'Il valore non è valido. Prova con "10px", "2em", "2%" oppure semplicemente "2".',colorPicker:"Selettore colore",removeColor:"Rimuovi colore",black:"Nero",dimGrey:"Grigio scuro",grey:"Grigio",lightGrey:"Grigio chiaro",white:"Bianco",red:"Rosso",orange:"Arancione",yellow:"Giallo",lightGreen:"Verde chiaro",green:"Verde",aquamarine:"Acquamarina",turquoise:"Turchese",lightBlue:"Azzurro",blue:"Blu",purple:"Viola"},Se={col:"Kolumn",insColL:"Infoga kolumn till vänster",insColR:"Infoga kolumn till höger",delCol:"Ta bort kolumn",selCol:"Markera kolumn",row:"Rad",headerRow:"Rubrikrad",insRowAbv:"Infoga rad ovanför",insRowBlw:"Infoga rad nedanför",delRow:"Ta bort rad",selRow:"Markera rad",mCells:"Sammanfoga celler",sCell:"Dela cell",tblProps:"Tabellinställningar",cellProps:"Cellinställningar",insParaOTbl:"Infoga stycke utanför tabellen",insB4:"Infoga före",insAft:"Infoga efter",copyTable:"Kopiera tabell",delTable:"Ta bort tabell",border:"Kant",color:"Färg",width:"Bredd",background:"Bakgrund",dims:"Dimensioner",height:"Höjd",padding:"Inre avstånd",tblCellTxtAlm:"Cellens textjustering",alCellTxtL:"Justera text vänster",alCellTxtC:"Centrera text",alCellTxtR:"Justera text höger",jusfCellTxt:"Justera text",alCellTxtT:"Justera text upptill",alCellTxtM:"Justera text i mitten",alCellTxtB:"Justera text nederst",dimsAlm:"Dimensioner och justering",alTblL:"Justera tabell vänster",tblC:"Centrera tabell",alTblR:"Justera tabell höger",save:"Spara",cancel:"Avbryt",colorMsg:'Färgen är ogiltig. Testa "#FF0000" eller "rgb(255,0,0)" eller "red".',dimsMsg:'Värdet är ogiltigt. Testa "10px", "2em", "2%" eller bara "2".',colorPicker:"Färgval",removeColor:"Ta bort färg",black:"Svart",dimGrey:"Mörkgrå",grey:"Grå",lightGrey:"Ljusgrå",white:"Vit",red:"Röd",orange:"Orange",yellow:"Gul",lightGreen:"Ljusgrön",green:"Grön",aquamarine:"Akvamarin",turquoise:"Turkos",lightBlue:"Ljusblå",blue:"Blå",purple:"Lila"},je={col:"欄",insColL:"向左插入欄",insColR:"向右插入欄",delCol:"刪除欄",selCol:"選取欄",row:"列",headerRow:"標題列",insRowAbv:"在上方插入列",insRowBlw:"在下方插入列",delRow:"刪除列",selRow:"選取列",mCells:"合併儲存格",sCell:"拆分儲存格",tblProps:"表格屬性",cellProps:"儲存格屬性",insParaOTbl:"在表格外插入段落",insB4:"在表格前插入",insAft:"在表格後插入",copyTable:"複製表格",delTable:"刪除表格",border:"邊框",color:"顏色",width:"寬度",background:"背景",dims:"尺寸",height:"高度",padding:"內距",tblCellTxtAlm:"儲存格文字對齊方式",alCellTxtL:"左對齊",alCellTxtC:"水平置中",alCellTxtR:"右對齊",jusfCellTxt:"左右對齊",alCellTxtT:"頂端對齊",alCellTxtM:"垂直置中",alCellTxtB:"底部對齊",dimsAlm:"尺寸與對齊方式",alTblL:"表格左對齊",tblC:"表格置中",alTblR:"表格右對齊",save:"儲存",cancel:"取消",colorMsg:'無效的顏色,請使用 "#FF0000"、"rgb(255,0,0)" 或 "red"',dimsMsg:'無效的值,請使用 "10px"、"2em"、"2%" 或 "2"',colorPicker:"顏色選擇器",removeColor:"移除顏色",black:"黑色",dimGrey:"深灰色",grey:"灰色",lightGrey:"淺灰色",white:"白色",red:"紅色",orange:"橘色",yellow:"黃色",lightGreen:"淺綠色",green:"綠色",aquamarine:"海藍色",turquoise:"青綠色",lightBlue:"淺藍色",blue:"藍色",purple:"紫色"},qe=class{constructor(e){this.config={en_US:ge,zh_CN:be,fr_FR:me,pl_PL:ve,de_DE:ye,ru_RU:we,tr_TR:Ce,pt_PT:xe,ja_JP:ke,pt_BR:Te,cs_CZ:_e,da_DK:Ne,nb_NO:Ae,it_IT:Le,sv_SE:Se,zh_TW:je},this.init(e)}changeLanguage(e){this.name=e}init(e){if(void 0===e||"string"==typeof e)this.changeLanguage(e||"en_US");else{const{name:t,content:r}=e;r&&this.registry(t,r),t&&this.changeLanguage(t)}}registry(e,t){this.config=Object.assign(Object.assign({},this.config),{[e]:t})}useLanguage(e){return this.config[this.name][e]}},Ee=(e=>(e[e.TYPE=3]="TYPE",e[e.LEVEL=12]="LEVEL",e[e.ATTRIBUTE=13]="ATTRIBUTE",e[e.BLOT=14]="BLOT",e[e.INLINE=7]="INLINE",e[e.BLOCK=11]="BLOCK",e[e.BLOCK_BLOT=10]="BLOCK_BLOT",e[e.INLINE_BLOT=6]="INLINE_BLOT",e[e.BLOCK_ATTRIBUTE=9]="BLOCK_ATTRIBUTE",e[e.INLINE_ATTRIBUTE=5]="INLINE_ATTRIBUTE",e[e.ANY=15]="ANY",e))(Ee||{});class Me{constructor(e,t,r={}){this.attrName=e,this.keyName=t;const n=Ee.TYPE&Ee.ATTRIBUTE;this.scope=null!=r.scope?r.scope&Ee.LEVEL|n:Ee.ATTRIBUTE,null!=r.whitelist&&(this.whitelist=r.whitelist)}static keys(e){return Array.from(e.attributes).map((e=>e.name))}add(e,t){return!!this.canAdd(e,t)&&(e.setAttribute(this.keyName,t),!0)}canAdd(e,t){return null==this.whitelist||("string"==typeof t?this.whitelist.indexOf(t.replace(/["']/g,""))>-1:this.whitelist.indexOf(t)>-1)}remove(e){e.removeAttribute(this.keyName)}value(e){const t=e.getAttribute(this.keyName);return this.canAdd(e,t)&&t?t:""}}class Be extends Error{constructor(e){super(e="[Parchment] "+e),this.message=e,this.name=this.constructor.name}}const Re=class e{constructor(){this.attributes={},this.classes={},this.tags={},this.types={}}static find(e,t=!1){if(null==e)return null;if(this.blots.has(e))return this.blots.get(e)||null;if(t){let r=null;try{r=e.parentNode}catch{return null}return this.find(r,t)}return null}create(t,r,n){const i=this.query(r);if(null==i)throw new Be(`Unable to create ${r} blot`);const l=i,o=r instanceof Node||r.nodeType===Node.TEXT_NODE?r:l.create(n),s=new l(t,o,n);return e.blots.set(s.domNode,s),s}find(t,r=!1){return e.find(t,r)}query(e,t=Ee.ANY){let r;return"string"==typeof e?r=this.types[e]||this.attributes[e]:e instanceof Text||e.nodeType===Node.TEXT_NODE?r=this.types.text:"number"==typeof e?e&Ee.LEVEL&Ee.BLOCK?r=this.types.block:e&Ee.LEVEL&Ee.INLINE&&(r=this.types.inline):e instanceof Element&&((e.getAttribute("class")||"").split(/\s+/).some((e=>(r=this.classes[e],!!r))),r=r||this.tags[e.tagName]),null==r?null:"scope"in r&&t&Ee.LEVEL&r.scope&&t&Ee.TYPE&r.scope?r:null}register(...e){return e.map((e=>{const t="blotName"in e,r="attrName"in e;if(!t&&!r)throw new Be("Invalid definition");if(t&&"abstract"===e.blotName)throw new Be("Cannot register abstract class");const n=t?e.blotName:r?e.attrName:void 0;return this.types[n]=e,r?"string"==typeof e.keyName&&(this.attributes[e.keyName]=e):t&&(e.className&&(this.classes[e.className]=e),e.tagName&&(Array.isArray(e.tagName)?e.tagName=e.tagName.map((e=>e.toUpperCase())):e.tagName=e.tagName.toUpperCase(),(Array.isArray(e.tagName)?e.tagName:[e.tagName]).forEach((t=>{(null==this.tags[t]||null==e.className)&&(this.tags[t]=e)})))),e}))}};Re.blots=new WeakMap;let Oe=Re;function Pe(e,t){return(e.getAttribute("class")||"").split(/\s+/).filter((e=>0===e.indexOf(`${t}-`)))}const Ie=class extends Me{static keys(e){return(e.getAttribute("class")||"").split(/\s+/).map((e=>e.split("-").slice(0,-1).join("-")))}add(e,t){return!!this.canAdd(e,t)&&(this.remove(e),e.classList.add(`${this.keyName}-${t}`),!0)}remove(e){Pe(e,this.keyName).forEach((t=>{e.classList.remove(t)})),0===e.classList.length&&e.removeAttribute("class")}value(e){const t=(Pe(e,this.keyName)[0]||"").slice(this.keyName.length+1);return this.canAdd(e,t)?t:""}};function ze(e){const t=e.split("-"),r=t.slice(1).map((e=>e[0].toUpperCase()+e.slice(1))).join("");return t[0]+r}const De=class extends Me{static keys(e){return(e.getAttribute("style")||"").split(";").map((e=>e.split(":")[0].trim()))}add(e,t){return!!this.canAdd(e,t)&&(e.style[ze(this.keyName)]=t,!0)}remove(e){e.style[ze(this.keyName)]="",e.getAttribute("style")||e.removeAttribute("style")}value(e){const t=e.style[ze(this.keyName)];return this.canAdd(e,t)?t:""}},He=class{constructor(e){this.attributes={},this.domNode=e,this.build()}attribute(e,t){t?e.add(this.domNode,t)&&(null!=e.value(this.domNode)?this.attributes[e.attrName]=e:delete this.attributes[e.attrName]):(e.remove(this.domNode),delete this.attributes[e.attrName])}build(){this.attributes={};const e=Oe.find(this.domNode);if(null==e)return;const t=Me.keys(this.domNode),r=Ie.keys(this.domNode),n=De.keys(this.domNode);t.concat(r).concat(n).forEach((t=>{const r=e.scroll.query(t,Ee.ATTRIBUTE);r instanceof Me&&(this.attributes[r.attrName]=r)}))}copy(e){Object.keys(this.attributes).forEach((t=>{const r=this.attributes[t].value(this.domNode);e.format(t,r)}))}move(e){this.copy(e),Object.keys(this.attributes).forEach((e=>{this.attributes[e].remove(this.domNode)})),this.attributes={}}values(){return Object.keys(this.attributes).reduce(((e,t)=>(e[t]=this.attributes[t].value(this.domNode),e)),{})}},Fe=class{constructor(e,t){this.scroll=e,this.domNode=t,Oe.blots.set(t,this),this.prev=null,this.next=null}static create(e){if(null==this.tagName)throw new Be("Blot definition missing tagName");let t,r;return Array.isArray(this.tagName)?("string"==typeof e?(r=e.toUpperCase(),parseInt(r,10).toString()===r&&(r=parseInt(r,10))):"number"==typeof e&&(r=e),t="number"==typeof r?document.createElement(this.tagName[r-1]):r&&this.tagName.indexOf(r)>-1?document.createElement(r):document.createElement(this.tagName[0])):t=document.createElement(this.tagName),this.className&&t.classList.add(this.className),t}get statics(){return this.constructor}attach(){}clone(){const e=this.domNode.cloneNode(!1);return this.scroll.create(e)}detach(){null!=this.parent&&this.parent.removeChild(this),Oe.blots.delete(this.domNode)}deleteAt(e,t){this.isolate(e,t).remove()}formatAt(e,t,r,n){const i=this.isolate(e,t);if(null!=this.scroll.query(r,Ee.BLOT)&&n)i.wrap(r,n);else if(null!=this.scroll.query(r,Ee.ATTRIBUTE)){const e=this.scroll.create(this.statics.scope);i.wrap(e),e.format(r,n)}}insertAt(e,t,r){const n=null==r?this.scroll.create("text",t):this.scroll.create(t,r),i=this.split(e);this.parent.insertBefore(n,i||void 0)}isolate(e,t){const r=this.split(e);if(null==r)throw new Error("Attempt to isolate at end");return r.split(t),r}length(){return 1}offset(e=this.parent){return null==this.parent||this===e?0:this.parent.children.offset(this)+this.parent.offset(e)}optimize(e){this.statics.requiredContainer&&!(this.parent instanceof this.statics.requiredContainer)&&this.wrap(this.statics.requiredContainer.blotName)}remove(){null!=this.domNode.parentNode&&this.domNode.parentNode.removeChild(this.domNode),this.detach()}replaceWith(e,t){const r="string"==typeof e?this.scroll.create(e,t):e;return null!=this.parent&&(this.parent.insertBefore(r,this.next||void 0),this.remove()),r}split(e,t){return 0===e?this:this.next}update(e,t){}wrap(e,t){const r="string"==typeof e?this.scroll.create(e,t):e;if(null!=this.parent&&this.parent.insertBefore(r,this.next||void 0),"function"!=typeof r.appendChild)throw new Be(`Cannot wrap ${e}`);return r.appendChild(this),r}};Fe.blotName="abstract";let Ve=Fe;const We=class extends Ve{static value(e){return!0}index(e,t){return this.domNode===e||this.domNode.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_CONTAINED_BY?Math.min(t,1):-1}position(e,t){let r=Array.from(this.parent.domNode.childNodes).indexOf(this.domNode);return e>0&&(r+=1),[this.parent.domNode,r]}value(){return{[this.statics.blotName]:this.statics.value(this.domNode)||!0}}};We.scope=Ee.INLINE_BLOT;const Ue=We;class Ge{constructor(){this.head=null,this.tail=null,this.length=0}append(...e){if(this.insertBefore(e[0],null),e.length>1){const t=e.slice(1);this.append(...t)}}at(e){const t=this.iterator();let r=t();for(;r&&e>0;)e-=1,r=t();return r}contains(e){const t=this.iterator();let r=t();for(;r;){if(r===e)return!0;r=t()}return!1}indexOf(e){const t=this.iterator();let r=t(),n=0;for(;r;){if(r===e)return n;n+=1,r=t()}return-1}insertBefore(e,t){null!=e&&(this.remove(e),e.next=t,null!=t?(e.prev=t.prev,null!=t.prev&&(t.prev.next=e),t.prev=e,t===this.head&&(this.head=e)):null!=this.tail?(this.tail.next=e,e.prev=this.tail,this.tail=e):(e.prev=null,this.head=this.tail=e),this.length+=1)}offset(e){let t=0,r=this.head;for(;null!=r;){if(r===e)return t;t+=r.length(),r=r.next}return-1}remove(e){this.contains(e)&&(null!=e.prev&&(e.prev.next=e.next),null!=e.next&&(e.next.prev=e.prev),e===this.head&&(this.head=e.next),e===this.tail&&(this.tail=e.prev),this.length-=1)}iterator(e=this.head){return()=>{const t=e;return null!=e&&(e=e.next),t}}find(e,t=!1){const r=this.iterator();let n=r();for(;n;){const i=n.length();if(el?r(s,e-l,Math.min(t,l+n-e)):r(s,0,Math.min(n,e+t-l)),l+=n,s=o()}}map(e){return this.reduce(((t,r)=>(t.push(e(r)),t)),[])}reduce(e,t){const r=this.iterator();let n=r();for(;n;)t=e(t,n),n=r();return t}}function $e(e,t){const r=t.find(e);if(r)return r;try{return t.create(e)}catch{const r=t.create(Ee.INLINE);return Array.from(e.childNodes).forEach((e=>{r.domNode.appendChild(e)})),e.parentNode&&e.parentNode.replaceChild(r.domNode,e),r.attach(),r}}const Ke=class e extends Ve{constructor(e,t){super(e,t),this.uiNode=null,this.build()}appendChild(e){this.insertBefore(e)}attach(){super.attach(),this.children.forEach((e=>{e.attach()}))}attachUI(t){null!=this.uiNode&&this.uiNode.remove(),this.uiNode=t,e.uiClass&&this.uiNode.classList.add(e.uiClass),this.uiNode.setAttribute("contenteditable","false"),this.domNode.insertBefore(this.uiNode,this.domNode.firstChild)}build(){this.children=new Ge,Array.from(this.domNode.childNodes).filter((e=>e!==this.uiNode)).reverse().forEach((e=>{try{const t=$e(e,this.scroll);this.insertBefore(t,this.children.head||void 0)}catch(e){if(e instanceof Be)return;throw e}}))}deleteAt(e,t){if(0===e&&t===this.length())return this.remove();this.children.forEachAt(e,t,((e,t,r)=>{e.deleteAt(t,r)}))}descendant(t,r=0){const[n,i]=this.children.find(r);return null==t.blotName&&t(n)||null!=t.blotName&&n instanceof t?[n,i]:n instanceof e?n.descendant(t,i):[null,-1]}descendants(t,r=0,n=Number.MAX_VALUE){let i=[],l=n;return this.children.forEachAt(r,n,((r,n,o)=>{(null==t.blotName&&t(r)||null!=t.blotName&&r instanceof t)&&i.push(r),r instanceof e&&(i=i.concat(r.descendants(t,n,l))),l-=o})),i}detach(){this.children.forEach((e=>{e.detach()})),super.detach()}enforceAllowedChildren(){let t=!1;this.children.forEach((r=>{t||this.statics.allowedChildren.some((e=>r instanceof e))||(r.statics.scope===Ee.BLOCK_BLOT?(null!=r.next&&this.splitAfter(r),null!=r.prev&&this.splitAfter(r.prev),r.parent.unwrap(),t=!0):r instanceof e?r.unwrap():r.remove())}))}formatAt(e,t,r,n){this.children.forEachAt(e,t,((e,t,i)=>{e.formatAt(t,i,r,n)}))}insertAt(e,t,r){const[n,i]=this.children.find(e);if(n)n.insertAt(i,t,r);else{const e=null==r?this.scroll.create("text",t):this.scroll.create(t,r);this.appendChild(e)}}insertBefore(e,t){null!=e.parent&&e.parent.children.remove(e);let r=null;this.children.insertBefore(e,t||null),e.parent=this,null!=t&&(r=t.domNode),(this.domNode.parentNode!==e.domNode||this.domNode.nextSibling!==r)&&this.domNode.insertBefore(e.domNode,r),e.attach()}length(){return this.children.reduce(((e,t)=>e+t.length()),0)}moveChildren(e,t){this.children.forEach((r=>{e.insertBefore(r,t)}))}optimize(e){if(super.optimize(e),this.enforceAllowedChildren(),null!=this.uiNode&&this.uiNode!==this.domNode.firstChild&&this.domNode.insertBefore(this.uiNode,this.domNode.firstChild),0===this.children.length)if(null!=this.statics.defaultChild){const e=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(e)}else this.remove()}path(t,r=!1){const[n,i]=this.children.find(t,r),l=[[this,t]];return n instanceof e?l.concat(n.path(i,r)):(null!=n&&l.push([n,i]),l)}removeChild(e){this.children.remove(e)}replaceWith(t,r){const n="string"==typeof t?this.scroll.create(t,r):t;return n instanceof e&&this.moveChildren(n),super.replaceWith(n)}split(e,t=!1){if(!t){if(0===e)return this;if(e===this.length())return this.next}const r=this.clone();return this.parent&&this.parent.insertBefore(r,this.next||void 0),this.children.forEachAt(e,this.length(),((e,n,i)=>{const l=e.split(n,t);null!=l&&r.appendChild(l)})),r}splitAfter(e){const t=this.clone();for(;null!=e.next;)t.appendChild(e.next);return this.parent&&this.parent.insertBefore(t,this.next||void 0),t}unwrap(){this.parent&&this.moveChildren(this.parent,this.next||void 0),this.remove()}update(e,t){const r=[],n=[];e.forEach((e=>{e.target===this.domNode&&"childList"===e.type&&(r.push(...e.addedNodes),n.push(...e.removedNodes))})),n.forEach((e=>{if(null!=e.parentNode&&"IFRAME"!==e.tagName&&document.body.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_CONTAINED_BY)return;const t=this.scroll.find(e);null!=t&&(null==t.domNode.parentNode||t.domNode.parentNode===this.domNode)&&t.detach()})),r.filter((e=>e.parentNode===this.domNode&&e!==this.uiNode)).sort(((e,t)=>e===t?0:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?1:-1)).forEach((e=>{let t=null;null!=e.nextSibling&&(t=this.scroll.find(e.nextSibling));const r=$e(e,this.scroll);(r.next!==t||null==r.next)&&(null!=r.parent&&r.parent.removeChild(this),this.insertBefore(r,t||void 0))})),this.enforceAllowedChildren()}};Ke.uiClass="";const Ze=Ke,Ye=class e extends Ze{static create(e){return super.create(e)}static formats(t,r){const n=r.query(e.blotName);if(null==n||t.tagName!==n.tagName){if("string"==typeof this.tagName)return!0;if(Array.isArray(this.tagName))return t.tagName.toLowerCase()}}constructor(e,t){super(e,t),this.attributes=new He(this.domNode)}format(t,r){if(t!==this.statics.blotName||r){const e=this.scroll.query(t,Ee.INLINE);if(null==e)return;e instanceof Me?this.attributes.attribute(e,r):r&&(t!==this.statics.blotName||this.formats()[t]!==r)&&this.replaceWith(t,r)}else this.children.forEach((t=>{t instanceof e||(t=t.wrap(e.blotName,!0)),this.attributes.copy(t)})),this.unwrap()}formats(){const e=this.attributes.values(),t=this.statics.formats(this.domNode,this.scroll);return null!=t&&(e[this.statics.blotName]=t),e}formatAt(e,t,r,n){null!=this.formats()[r]||this.scroll.query(r,Ee.ATTRIBUTE)?this.isolate(e,t).format(r,n):super.formatAt(e,t,r,n)}optimize(t){super.optimize(t);const r=this.formats();if(0===Object.keys(r).length)return this.unwrap();const n=this.next;n instanceof e&&n.prev===this&&function(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}(r,n.formats())&&(n.moveChildren(this),n.remove())}replaceWith(e,t){const r=super.replaceWith(e,t);return this.attributes.copy(r),r}update(e,t){super.update(e,t),e.some((e=>e.target===this.domNode&&"attributes"===e.type))&&this.attributes.build()}wrap(t,r){const n=super.wrap(t,r);return n instanceof e&&this.attributes.move(n),n}};Ye.allowedChildren=[Ye,Ue],Ye.blotName="inline",Ye.scope=Ee.INLINE_BLOT,Ye.tagName="SPAN";const Je=Ye,Xe=class e extends Ze{static create(e){return super.create(e)}static formats(t,r){const n=r.query(e.blotName);if(null==n||t.tagName!==n.tagName){if("string"==typeof this.tagName)return!0;if(Array.isArray(this.tagName))return t.tagName.toLowerCase()}}constructor(e,t){super(e,t),this.attributes=new He(this.domNode)}format(t,r){const n=this.scroll.query(t,Ee.BLOCK);null!=n&&(n instanceof Me?this.attributes.attribute(n,r):t!==this.statics.blotName||r?r&&(t!==this.statics.blotName||this.formats()[t]!==r)&&this.replaceWith(t,r):this.replaceWith(e.blotName))}formats(){const e=this.attributes.values(),t=this.statics.formats(this.domNode,this.scroll);return null!=t&&(e[this.statics.blotName]=t),e}formatAt(e,t,r,n){null!=this.scroll.query(r,Ee.BLOCK)?this.format(r,n):super.formatAt(e,t,r,n)}insertAt(e,t,r){if(null==r||null!=this.scroll.query(t,Ee.INLINE))super.insertAt(e,t,r);else{const n=this.split(e);if(null==n)throw new Error("Attempt to insertAt after block boundaries");{const e=this.scroll.create(t,r);n.parent.insertBefore(e,n)}}}replaceWith(e,t){const r=super.replaceWith(e,t);return this.attributes.copy(r),r}update(e,t){super.update(e,t),e.some((e=>e.target===this.domNode&&"attributes"===e.type))&&this.attributes.build()}};Xe.blotName="block",Xe.scope=Ee.BLOCK_BLOT,Xe.tagName="P",Xe.allowedChildren=[Je,Xe,Ue];const Qe=Xe,et=class extends Ze{checkMerge(){return null!==this.next&&this.next.statics.blotName===this.statics.blotName}deleteAt(e,t){super.deleteAt(e,t),this.enforceAllowedChildren()}formatAt(e,t,r,n){super.formatAt(e,t,r,n),this.enforceAllowedChildren()}insertAt(e,t,r){super.insertAt(e,t,r),this.enforceAllowedChildren()}optimize(e){super.optimize(e),this.children.length>0&&null!=this.next&&this.checkMerge()&&(this.next.moveChildren(this),this.next.remove())}};et.blotName="container",et.scope=Ee.BLOCK_BLOT;const tt=et,rt=class extends Ue{static formats(e,t){}format(e,t){super.formatAt(0,this.length(),e,t)}formatAt(e,t,r,n){0===e&&t===this.length()?this.format(r,n):super.formatAt(e,t,r,n)}formats(){return this.statics.formats(this.domNode,this.scroll)}},nt={attributes:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0},it=class extends Ze{constructor(e,t){super(null,t),this.registry=e,this.scroll=this,this.build(),this.observer=new MutationObserver((e=>{this.update(e)})),this.observer.observe(this.domNode,nt),this.attach()}create(e,t){return this.registry.create(this,e,t)}find(e,t=!1){const r=this.registry.find(e,t);return r?r.scroll===this?r:t?this.find(r.scroll.domNode.parentNode,!0):null:null}query(e,t=Ee.ANY){return this.registry.query(e,t)}register(...e){return this.registry.register(...e)}build(){null!=this.scroll&&super.build()}detach(){super.detach(),this.observer.disconnect()}deleteAt(e,t){this.update(),0===e&&t===this.length()?this.children.forEach((e=>{e.remove()})):super.deleteAt(e,t)}formatAt(e,t,r,n){this.update(),super.formatAt(e,t,r,n)}insertAt(e,t,r){this.update(),super.insertAt(e,t,r)}optimize(e=[],t={}){super.optimize(t);const r=t.mutationsMap||new WeakMap;let n=Array.from(this.observer.takeRecords());for(;n.length>0;)e.push(n.pop());const i=(e,t=!0)=>{null==e||e===this||null!=e.domNode.parentNode&&(r.has(e.domNode)||r.set(e.domNode,[]),t&&i(e.parent))},l=e=>{r.has(e.domNode)&&(e instanceof Ze&&e.children.forEach(l),r.delete(e.domNode),e.optimize(t))};let o=e;for(let t=0;o.length>0;t+=1){if(t>=100)throw new Error("[Parchment] Maximum optimize iterations reached");for(o.forEach((e=>{const t=this.find(e.target,!0);null!=t&&(t.domNode===e.target&&("childList"===e.type?(i(this.find(e.previousSibling,!1)),Array.from(e.addedNodes).forEach((e=>{const t=this.find(e,!1);i(t,!1),t instanceof Ze&&t.children.forEach((e=>{i(e,!1)}))}))):"attributes"===e.type&&i(t.prev)),i(t))})),this.children.forEach(l),o=Array.from(this.observer.takeRecords()),n=o.slice();n.length>0;)e.push(n.pop())}}update(e,t={}){e=e||this.observer.takeRecords();const r=new WeakMap;e.map((e=>{const t=this.find(e.target,!0);return null==t?null:r.has(t.domNode)?(r.get(t.domNode).push(e),null):(r.set(t.domNode,[e]),t)})).forEach((e=>{null!=e&&e!==this&&r.has(e.domNode)&&e.update(r.get(e.domNode)||[],t)})),t.mutationsMap=r,r.has(this.domNode)&&super.update(r.get(this.domNode),t),this.optimize(e,t)}};it.blotName="scroll",it.defaultChild=Qe,it.allowedChildren=[Qe,tt],it.scope=Ee.BLOCK_BLOT,it.tagName="DIV";const lt=class e extends Ue{static create(e){return document.createTextNode(e)}static value(e){return e.data}constructor(e,t){super(e,t),this.text=this.statics.value(this.domNode)}deleteAt(e,t){this.domNode.data=this.text=this.text.slice(0,e)+this.text.slice(e+t)}index(e,t){return this.domNode===e?t:-1}insertAt(e,t,r){null==r?(this.text=this.text.slice(0,e)+t+this.text.slice(e),this.domNode.data=this.text):super.insertAt(e,t,r)}length(){return this.text.length}optimize(t){super.optimize(t),this.text=this.statics.value(this.domNode),0===this.text.length?this.remove():this.next instanceof e&&this.next.prev===this&&(this.insertAt(this.length(),this.next.value()),this.next.remove())}position(e,t=!1){return[this.domNode,e]}split(e,t=!1){if(!t){if(0===e)return this;if(e===this.length())return this.next}const r=this.scroll.create(this.domNode.splitText(e));return this.parent.insertBefore(r,this.next||void 0),this.text=this.statics.value(this.domNode),r}update(e,t){e.some((e=>"characterData"===e.type&&e.target===this.domNode))&&(this.text=this.statics.value(this.domNode))}value(){return this.text}};lt.blotName="text",lt.scope=Ee.INLINE_BLOT;const ot=["bold","italic","underline","strike","size","color","background","font","list","header","align","link","image"],st=["link","image"];var at,ct,dt,ut,ht,pt=class{constructor(e,t){this.quill=e,this.selectedTds=[],this.startTd=null,this.endTd=null,this.disabledList=[],this.singleList=[],this.tableBetter=t,this.quill.root.addEventListener("click",this.handleClick.bind(this)),this.initDocumentListener(),this.initWhiteList()}attach(e){let t=Array.from(e.classList).find((e=>0===e.indexOf("ql-")));if(!t)return;const[r,n]=this.getButtonsWhiteList(),i=this.getCorrectDisabled(e,t);t=t.slice(3),r.includes(t)||this.disabledList.push(...i),n.includes(t)&&this.singleList.push(...i)}clearSelected(){for(const e of this.selectedTds)e.classList&&e.classList.remove("ql-cell-focused","ql-cell-selected");this.selectedTds=[],this.startTd=null,this.endTd=null}exitTableFocus(e,r){const n=B(e).table(),i=r?-1:n.length(),l=n.offset(this.quill.scroll)+i;this.tableBetter.hideTools(),this.quill.setSelection(l,0,t().sources.USER)}getButtonsWhiteList(){const{options:e={}}=this.tableBetter,{toolbarButtons:t={}}=e,{whiteList:r=ot,singleWhiteList:n=st}=t;return[r,n]}getCopyColumns(e){const t=e.querySelector("tr");return Array.from(t.querySelectorAll("td,th")).reduce(((e,t)=>e+(~~t.getAttribute("colspan")||1)),0)}getCopyData(){const e=t().find(this.selectedTds[0]).table();if(e.descendants(Z).length===this.selectedTds.length){const t=e.getCopyTable();return{html:t,text:this.getText(t)}}let r="";const n={};for(const e of this.selectedTds){const t=e.getAttribute("data-row");n[t]||(n[t]=[]),n[t].push(e)}for(const e of Object.values(n)){let t="";for(const r of e)t+=E(r.outerHTML);t=`${t}`,r+=t}return r=`${r}
`,r=e.getCopyTable(r),{html:r,text:this.getText(r)}}getCorrectDisabled(e,t){if("SELECT"!==e.tagName)return[e];const r=e.closest("span.ql-formats");return r?[...r.querySelectorAll(`span.${t}.ql-picker`),e]:[e]}getCorrectRow(e,r){const n="next"===r?0:-1;let i=(~~e.getAttribute("rowspan")||1)+n||1,l=t().find(e).parent;for(;l&&i;)l=l[r],i--;return null==l?void 0:l.domNode}getCorrectValue(e,r){for(const n of this.selectedTds){const i=t().find(n).html()||n.outerHTML,l=this.quill.clipboard.convert({html:i,text:"\n"});for(const t of l.ops)if(!this.isContinue(t)&&(r=this.getListCorrectValue(e,r,null==t?void 0:t.attributes))!=((null==t?void 0:t.attributes)&&(null==t?void 0:t.attributes[e])||!1))return r}return!r}getListCorrectValue(e,t,r={}){return"list"!==e?t:"check"===t?"checked"!==r[e]&&"unchecked"!==r[e]&&"unchecked":t}getPasteComputeBounds(e,t,r){const n=e.getBoundingClientRect(),i=t.getBoundingClientRect(),l=r.domNode.getBoundingClientRect(),o=this.quill.container.getBoundingClientRect(),s=this.quill.container.scrollLeft,a=this.quill.container.scrollTop;return{left:n.left-o.left-s,right:i.right-o.left-s,top:n.top-o.top-a,bottom:l.bottom-o.top-a}}getPasteInfo(e,t,r){let n=0,i=null,l=null,o=e.parentElement;for(;e;){if(n+=~~e.getAttribute("colspan")||1,n>=t){n=t,i=e;break}e=e.nextElementSibling}for(;--r;){if(!o.nextElementSibling){l=o.firstElementChild;break}o=o.nextElementSibling}return[{clospan:Math.abs(t-n),cloTd:i},{rowspan:r,rowTd:l}]}getPasteLastRow(e,t){for(;--t&&e;)e=e.next;return e}getPasteTds(e){const t={};for(const r of e){const e=r.getAttribute("data-row");t[e]||(t[e]=[]),t[e].push(r)}return Object.values(t)}getTableArrowVerticalRow(e,t){var r,n;const i=e.table(),l=i.tbody(),o=i.thead(),s=t?"prev":"next",a=e.parent.statics.blotName;let c=e.parent[s];return!c&&t&&a===J.blotName&&(c=null===(r=null==o?void 0:o.children)||void 0===r?void 0:r.tail),c||t||a!==X.blotName||(c=null===(n=null==l?void 0:l.children)||void 0===n?void 0:n.head),c}getText(e){return this.quill.clipboard.convert({html:e}).filter((e=>"string"==typeof e.insert)).map((e=>e.insert)).join("")}handleClick(e){if(e.detail<3||!this.selectedTds.length)return;const{index:r,length:n}=this.quill.getSelection(!0);this.quill.setSelection(r,n-1,t().sources.SILENT),this.quill.scrollSelectionIntoView()}handleDeleteKeyup(e){var t;(null===(t=this.selectedTds)||void 0===t?void 0:t.length)<2||"Backspace"!==e.key&&"Delete"!==e.key||(e.ctrlKey?(this.tableBetter.tableMenus.deleteColumn(!0),this.tableBetter.tableMenus.deleteRow(!0)):this.removeSelectedTdsContent())}handleKeyup(e){switch(e.key){case"ArrowLeft":case"ArrowRight":this.makeTableArrowLevelHandler(e.key);break;case"ArrowUp":case"ArrowDown":this.makeTableArrowVerticalHandler(e.key)}}handleMousedown(e){const t=e.target.closest("table");if(!t)return;this.tableBetter.tableMenus.destroyTablePropertiesForm();const r=e.target.closest("td,th");if(!r)return;this.clearSelected(),this.startTd=r,this.endTd=r,this.selectedTds=[r],r.classList.add("ql-cell-focused"),this.setHeaderRowSwitch(),this.setMenuDisable("merge");const n=e=>{const n=e.target.closest("td,th");if(!n)return;const i=r.isEqualNode(n);if(i)return;this.clearSelected(),this.startTd=r,this.endTd=n;const l=S(M(r,this.quill.container),M(n,this.quill.container));this.selectedTds=q(l,t,this.quill.container);for(const e of this.selectedTds)e.classList&&e.classList.add("ql-cell-selected");i||this.quill.blur()},i=e=>{this.setSingleDisabled(),this.setCorrectPositionTds(this.startTd,this.endTd,this.selectedTds),this.setHeaderRowSwitch(),this.setMenuDisable("merge"),this.quill.root.removeEventListener("mousemove",n),this.quill.root.removeEventListener("mouseup",i)};this.quill.root.addEventListener("mousemove",n),this.quill.root.addEventListener("mouseup",i)}hasTdTh(e){return{hasTd:e.some((e=>"TD"===e.tagName)),hasTh:e.some((e=>"TH"===e.tagName))}}initDocumentListener(){document.addEventListener("copy",(e=>this.onCaptureCopy(e,!1))),document.addEventListener("cut",(e=>this.onCaptureCopy(e,!0))),document.addEventListener("keyup",this.handleDeleteKeyup.bind(this)),document.addEventListener("paste",this.onCapturePaste.bind(this))}initWhiteList(){const e=this.quill.getModule("toolbar");Array.from(e.container.querySelectorAll("button, select")).forEach((e=>{this.attach(e)}))}insertColumnCell(e,t){const r=e.tbody();r&&r.children.forEach((r=>{const n=r.children.tail.domNode.getAttribute("data-row");for(let i=0;i{let r=[];return e.children.forEach((e=>{e instanceof tt?r=r.concat(t(e)):function(e){return e instanceof Qe||e instanceof rt}(e)&&r.push(e)})),r};return t(e)}makeTableArrowLevelHandler(e){const t="ArrowLeft"===e?this.startTd:this.endTd,r=this.quill.getSelection();if(!r)return;const[n]=this.quill.getLine(r.index),i=B(n);if(!i)return this.tableBetter.hideTools();!i||t&&t.isEqualNode(i.domNode)||(this.setSelected(i.domNode,!1),this.tableBetter.showTools(!1))}makeTableArrowVerticalHandler(e){const r="ArrowUp"===e,n=this.quill.getSelection();if(!n)return;const[i,l]=this.quill.getLine(n.index),o=r?"prev":"next";if(i[o]&&this.selectedTds.length){const e=i[o].offset(this.quill.scroll)+Math.min(l,i[o].length()-1);this.quill.setSelection(e,0,t().sources.USER)}else{if(!this.selectedTds.length){const e=B(i);if(!e)return;return this.tableArrowSelection(r,e),void this.tableBetter.showTools(!1)}const e=r?this.startTd:this.endTd,n=t().find(e),l=this.getTableArrowVerticalRow(n,r),{left:s,right:a}=e.getBoundingClientRect();if(l){let e=null,t=l;for(;t&&!e;){let r=t.children.head;for(;r;){const{left:t,right:n}=r.domNode.getBoundingClientRect();if(Math.abs(t-s)<=2){e=r;break}if(Math.abs(n-a)<=2){e=r;break}r=r.next}t=t[o]}e?this.tableArrowSelection(r,e):this.exitTableFocus(i,r)}else this.exitTableFocus(i,r)}}onCaptureCopy(e,t=!1){var r,n,i;if((null===(r=this.selectedTds)||void 0===r?void 0:r.length)<2)return;if(e.defaultPrevented)return;e.preventDefault();const{html:l,text:o}=this.getCopyData();null===(n=e.clipboardData)||void 0===n||n.setData("text/plain",o),null===(i=e.clipboardData)||void 0===i||i.setData("text/html",l),t&&this.removeSelectedTdsContent()}onCapturePaste(e){var r,n,i;if(!(null===(r=this.selectedTds)||void 0===r?void 0:r.length))return;e.preventDefault();const l=null===(n=e.clipboardData)||void 0===n?void 0:n.getData("text/html"),o=(null===(i=e.clipboardData)||void 0===i||i.getData("text/plain"),document.createElement("div"));o.innerHTML=l;const s=Array.from(o.querySelectorAll("tr"));if(!s.length)return;const a=t().find(this.startTd),c=a.row(),d=a.table();this.quill.history.cutoff();const u=this.getCopyColumns(o),[h,p]=this.getPasteInfo(this.startTd,u,s.length),{clospan:f,cloTd:g}=h,{rowspan:b,rowTd:m}=p;f&&this.insertColumnCell(d,f),b&&this.insertRow(d,b,m);const v=f?c.children.tail.domNode:g,y=this.getPasteLastRow(c,s.length),w=this.getPasteComputeBounds(this.startTd,v,y),C=this.getPasteTds(q(w,d.domNode,this.quill.container)),x=s.reduce(((e,t)=>(e.push(Array.from(t.querySelectorAll("td,th"))),e)),[]),k=[];for(;x.length;){const e=x.shift(),r=C.shift();let n=null,i=null;for(;e.length;){const l=e.shift(),o=r.shift();if(o)n=o,i=this.pasteSelectedTd(o,l);else{const e=n.getAttribute("data-row"),r=t().find(n);i=d.insertColumnCell(r.parent,e,r.next),i=this.pasteSelectedTd(i.domNode,l),n=i.domNode}i&&k.push(i.domNode)}for(;r.length;)r.shift().remove()}this.quill.blur(),this.setSelectedTds(k),this.tableBetter.tableMenus.updateMenus(),this.quill.scrollSelectionIntoView()}pasteSelectedTd(e,r){const n=e.getAttribute("data-row"),i=Z.formats(r);Object.assign(i,{"data-row":n});const o=t().find(e),s=o.replaceWith(o.statics.blotName,i);this.quill.setSelection(s.offset(this.quill.scroll)+s.length()-1,0,t().sources.USER);const a=this.quill.getSelection(!0),c=this.quill.getFormat(a.index),d=r.innerHTML,u=this.getText(d),h=this.quill.clipboard.convert({text:u,html:d}),p=(new(l())).retain(a.index).delete(a.length).concat(de(h,c));return this.quill.updateContents(p,t().sources.USER),s}removeCursor(){const e=this.quill.getSelection(!0);e&&0===e.length&&(this.quill.selection.cursor.remove(),this.quill.blur())}removeSelectedTdContent(e){const r=t().find(e);let n=r.children.head;const i=n.formats()[$.blotName],l=this.quill.scroll.create($.blotName,i);for(r.insertBefore(l,n);n;)n.remove(),n=n.next}removeSelectedTdsContent(){if(!(this.selectedTds.length<2)){for(const e of this.selectedTds)this.removeSelectedTdContent(e);this.tableBetter.tableMenus.updateMenus()}}setCorrectPositionTds(e,t,r){if(!e||!t||r.length<2)return;const n=r[0],i=r[r.length-1],l=[...new Set([e,t,n,i])];l.sort(((e,t)=>{const r=e.getBoundingClientRect(),n=t.getBoundingClientRect();return(r.top<=n.top||r.bottom<=n.bottom)&&(r.left<=n.left||r.right<=n.right)?-1:1})),this.startTd=l[0],this.endTd=l[l.length-1]}setDisabled(e){for(const t of this.disabledList)e?t.classList.add("ql-table-button-disabled"):t.classList.remove("ql-table-button-disabled");this.setSingleDisabled()}setHeaderRowSwitch(){const{hasTd:e,hasTh:t}=this.hasTdTh(this.selectedTds);t&&!e?this.tableBetter.tableMenus.toggleHeaderRowSwitch("true"):this.tableBetter.tableMenus.toggleHeaderRowSwitch("false")}setMenuDisable(e){const{hasTd:t,hasTh:r}=this.hasTdTh(this.selectedTds),n=t&&r;this.tableBetter.tableMenus.disableMenu(e,n)}setSelected(e,r=!0){const n=t().find(e);this.clearSelected(),this.startTd=e,this.endTd=e,this.selectedTds=[e],e.classList.add("ql-cell-focused"),r&&this.quill.setSelection(n.offset(this.quill.scroll)+n.length()-1,0,t().sources.USER)}setSelectedTds(e){this.clearSelected(),this.startTd=e[0],this.endTd=e[e.length-1],this.selectedTds=e;for(const e of this.selectedTds)e.classList&&e.classList.add("ql-cell-selected")}setSelectedTdsFormat(e,r){const n=[],i=this.quill.getModule("toolbar");for(const l of this.selectedTds)if(null!=i.handlers[e]){const o=t().find(l),s=this.lines(o),a=i.handlers[e].call(i,r,s);a&&n.push(B(a).domNode)}else{const n=window.getSelection();n.selectAllChildren(l),this.quill.format(e,r,t().sources.USER),n.removeAllRanges()}this.quill.blur(),n.length&&this.setSelectedTds(n)}setSingleDisabled(){for(const e of this.singleList)this.selectedTds.length>1?e.classList.add("ql-table-button-disabled"):e.classList.remove("ql-table-button-disabled")}tableArrowSelection(e,r){const n=e?"tail":"head",i=e?r.children[n].length()-1:0;this.setSelected(r.domNode,!1);const l=r.children[n].offset(this.quill.scroll)+i;this.quill.setSelection(l,0,t().sources.USER)}updateSelected(e){switch(e){case"column":{const e=this.endTd.nextElementSibling||this.startTd.previousElementSibling;if(!e)return this.tableBetter.hideTools();this.setSelected(e)}break;case"row":{const e=this.getCorrectRow(this.endTd,"next")||this.getCorrectRow(this.startTd,"prev");if(!e)return this.tableBetter.hideTools();const t=M(this.startTd,this.quill.container);let r=e.firstElementChild;for(;r;){const e=M(r,this.quill.container);if(e.left+2>=t.left||e.right-2>=t.left)return void this.setSelected(r);r=r.nextElementSibling}this.setSelected(e.firstElementChild)}}}},ft=class{constructor(e,t){this.quill=e,this.options=null,this.drag=!1,this.line=null,this.dragBlock=null,this.dragTable=null,this.direction=null,this.tableBetter=t,this.quill.root.addEventListener("mousemove",this.handleMouseMove.bind(this))}createDragBlock(){const e=document.createElement("div");e.classList.add("ql-operate-block");const{dragBlockProps:t}=this.getProperty(this.options);H(e,t),this.dragBlock=e,this.quill.container.appendChild(e),this.updateCell(e)}createDragTable(e){const t=document.createElement("div"),r=this.getDragTableProperty(e);t.classList.add("ql-operate-drag-table"),H(t,r),this.dragTable=t,this.quill.container.appendChild(t)}createOperateLine(){const e=document.createElement("div"),t=document.createElement("div");e.classList.add("ql-operate-line-container");const{containerProps:r,lineProps:n}=this.getProperty(this.options);H(e,r),H(t,n),e.appendChild(t),this.quill.container.appendChild(e),this.line=e,this.updateCell(e)}getCorrectCol(e,t){let r=e.children.head;for(;r&&--t;)r=r.next;return r}getDragTableProperty(e){const{left:t,top:r,width:n,height:i}=e.getBoundingClientRect(),l=this.quill.container.getBoundingClientRect();return{left:t-l.left+"px",top:r-l.top+"px",width:`${n}px`,height:`${i}px`,display:"block"}}getLevelColSum(e){let t=e,r=0;for(;t;)r+=~~t.getAttribute("colspan")||1,t=t.previousSibling;return r}getMaxColNum(e){const t=e.parentElement.children;let r=0;for(const e of t)r+=~~e.getAttribute("colspan")||1;return r}getProperty(e){const t=this.quill.container.getBoundingClientRect(),{tableNode:r,cellNode:n,mousePosition:i}=e,{clientX:l,clientY:o}=i,s=r.getBoundingClientRect(),a=n.getBoundingClientRect(),c=a.left+a.width,d=a.top+a.height,u={width:"8px",height:"8px",top:s.bottom-t.top+"px",left:s.right-t.left+"px",display:s.bottom>t.bottom?"none":"block"};return Math.abs(c-l)<=5?(this.direction="level",{dragBlockProps:u,containerProps:{width:"5px",height:`${t.height}px`,top:"0",left:c-t.left-2.5+"px",display:"flex",cursor:"col-resize"},lineProps:{width:"1px",height:"100%"}}):Math.abs(d-o)<=5?(this.direction="vertical",{dragBlockProps:u,containerProps:{width:`${t.width}px`,height:"5px",top:d-t.top-2.5+"px",left:"0",display:"flex",cursor:"row-resize"},lineProps:{width:"100%",height:"1px"}}):(this.hideLine(),{dragBlockProps:u})}getVerticalCells(e,t){let r=e.parentElement;for(;t>1&&r;)r=r.nextSibling,t--;return r.children}handleMouseMove(e){if(!this.quill.isEnabled())return;const t=e.target.closest("table");if(t&&!this.quill.root.contains(t))return;const r=e.target.closest("td,th"),n={clientX:e.clientX,clientY:e.clientY};if(!t||!r)return void(this.line&&!this.drag&&(this.hideLine(),this.hideDragBlock()));const i={tableNode:t,cellNode:r,mousePosition:n};if(this.line){if(this.drag||!r)return;this.updateProperty(i)}else this.options=i,this.createOperateLine(),this.createDragBlock()}hideDragBlock(){this.dragBlock&&H(this.dragBlock,{display:"none"})}hideDragTable(){this.dragTable&&H(this.dragTable,{display:"none"})}hideLine(){this.line&&H(this.line,{display:"none"})}isLine(e){return e.classList.contains("ql-operate-line-container")}setCellLevelRect(e,r){const{right:n}=e.getBoundingClientRect(),i=~~(r-n),l=this.getLevelColSum(e),o=t().find(e).table(),s=o.isPercent(),a=o.colgroup(),c=o.domNode.getBoundingClientRect();if(a){const e=this.getCorrectCol(a,l),t=e.next,{width:r}=e.domNode.getBoundingClientRect();if(this.setColWidth(e.domNode,`${r+i}`,s),t){const{width:e}=t.domNode.getBoundingClientRect();this.setColWidth(t.domNode,""+(e-i),s)}}else{const t=null==e.nextElementSibling,r=e.parentElement.parentElement.children,n=[];for(const e of r){const r=e.children;if(t){const e=r[r.length-1],{width:t}=e.getBoundingClientRect();n.push([e,""+~~(t+i)]);continue}let o=0;for(const e of r){if(o+=~~e.getAttribute("colspan")||1,o>l)break;if(o===l){const{width:t}=e.getBoundingClientRect(),r=e.nextElementSibling;if(!r)continue;const{width:l}=r.getBoundingClientRect();n.push([e,""+~~(t+i)],[r,""+~~(l-i)])}}}for(const[e,t]of n){const r=O(~~t,s);D(e,{width:r}),H(e,{width:r})}}null==e.nextElementSibling&&F(o.domNode,c,i)}setCellRect(e,t,r){"level"===this.direction?this.setCellLevelRect(e,t):"vertical"===this.direction&&this.setCellVerticalRect(e,r)}setCellsRect(e,r,n){const i=e.parentElement.parentElement.children,l=r/this.getMaxColNum(e),o=n/i.length,s=[],a=t().find(e).table(),c=a.isPercent(),d=a.colgroup(),u=a.domNode.getBoundingClientRect();for(const e of i){const t=e.children;for(const e of t){const t=~~e.getAttribute("colspan")||1,{width:r,height:n}=e.getBoundingClientRect();s.push([e,`${Math.ceil(r+l*t)}`,`${Math.ceil(n+o)}`])}}if(d){let e=d.children.head;for(const[e,,t]of s)D(e,{height:t}),H(e,{height:`${t}px`});for(;e;){const{width:t}=e.domNode.getBoundingClientRect();this.setColWidth(e.domNode,`${Math.ceil(t+l)}`,c),e=e.next}}else for(const[e,t,r]of s){const n=O(~~t,c);D(e,{height:r,width:n}),H(e,{height:r,width:n})}F(a.domNode,u,r)}setColWidth(e,t,r){r?(t=O(parseFloat(t),r),e.style.setProperty("width",t)):D(e,{width:t})}setCellVerticalRect(e,t){const r=~~e.getAttribute("rowspan")||1,n=r>1?this.getVerticalCells(e,r):e.parentElement.children;for(const e of n){const{top:r}=e.getBoundingClientRect(),n=""+~~(t-r);D(e,{height:n}),H(e,{height:`${n}px`})}}toggleLineChildClass(e){const t=this.line.firstElementChild;e?t.classList.add("ql-operate-line"):t.classList.remove("ql-operate-line")}updateCell(e){if(!e)return;const t=this.isLine(e),r=e=>{e.preventDefault(),this.drag&&(t?(this.updateDragLine(e.clientX,e.clientY),this.hideDragBlock()):(this.updateDragBlock(e.clientX,e.clientY),this.hideLine()))},n=e=>{e.preventDefault();const{cellNode:i,tableNode:l}=this.options;if(t)this.setCellRect(i,e.clientX,e.clientY),this.toggleLineChildClass(!1);else{const{right:t,bottom:r}=l.getBoundingClientRect(),n=e.clientX-t,o=e.clientY-r;this.setCellsRect(i,n,o),this.dragBlock.classList.remove("ql-operate-block-move"),this.hideDragBlock(),this.hideDragTable()}this.drag=!1,document.removeEventListener("mousemove",r,!1),document.removeEventListener("mouseup",n,!1),this.tableBetter.tableMenus.updateMenus(l)};e.addEventListener("mousedown",(e=>{e.preventDefault();const{tableNode:i}=this.options;if(t)this.toggleLineChildClass(!0);else if(this.dragTable){const e=this.getDragTableProperty(i);H(this.dragTable,e)}else this.createDragTable(i);this.drag=!0,document.addEventListener("mousemove",r),document.addEventListener("mouseup",n)}))}updateDragBlock(e,t){const r=this.quill.container.getBoundingClientRect();this.dragBlock.classList.add("ql-operate-block-move"),H(this.dragBlock,{top:~~(t-r.top-4)+"px",left:~~(e-r.left-4)+"px"}),this.updateDragTable(e,t)}updateDragLine(e,t){const r=this.quill.container.getBoundingClientRect();"level"===this.direction?H(this.line,{left:~~(e-r.left-2.5)+"px"}):"vertical"===this.direction&&H(this.line,{top:~~t-r.top-2.5+"px"})}updateDragTable(e,t){const{top:r,left:n}=this.dragTable.getBoundingClientRect(),i=e-n,l=t-r;H(this.dragTable,{width:`${i}px`,height:`${l}px`,display:"block"})}updateProperty(e){const{containerProps:t,lineProps:r,dragBlockProps:n}=this.getProperty(e);t&&r&&(this.options=e,H(this.line,t),H(this.line.firstChild,r),H(this.dragBlock,n))}},gt='',bt='',mt={},vt=[],yt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i;function wt(e,t){for(var r in t)e[r]=t[r];return e}function Ct(e){var t=e.parentNode;t&&t.removeChild(e)}function xt(e,t,r){var n,i,l,o,s=arguments;if(t=wt({},t),arguments.length>3)for(r=[r],n=3;n-1,n=parseFloat(e);return r?t/100*n:n}function ar(e){return parseInt(e,16)}function cr(e){return e.toString(16).padStart(2,"0")}var dr=function(){function e(e,t){this.$={h:0,s:0,v:0,a:1},e&&this.set(e),this.onChange=t,this.initialValue=Ft({},this.$)}var t,r,n=e.prototype;return n.set=function(t){if("string"==typeof t)/^(?:#?|0x?)[0-9a-fA-F]{3,8}$/.test(t)?this.hexString=t:/^rgba?/.test(t)?this.rgbString=t:/^hsla?/.test(t)&&(this.hslString=t);else{if("object"!=typeof t)throw new Error("Invalid color value");t instanceof e?this.hsva=t.hsva:"r"in t&&"g"in t&&"b"in t?this.rgb=t:"h"in t&&"s"in t&&"v"in t?this.hsv=t:"h"in t&&"s"in t&&"l"in t?this.hsl=t:"kelvin"in t&&(this.kelvin=t.kelvin)}},n.setChannel=function(e,t,r){var n;this[e]=Ft({},this[e],((n={})[t]=r,n))},n.reset=function(){this.hsva=this.initialValue},n.clone=function(){return new e(this)},n.unbind=function(){this.onChange=void 0},e.hsvToRgb=function(e){var t=e.h/60,r=e.s/100,n=e.v/100,i=lr(t),l=t-i,o=n*(1-r),s=n*(1-l*r),a=n*(1-(1-l)*r),c=i%6,d=[a,n,n,s,o,o][c],u=[o,o,a,n,n,s][c];return{r:or(255*[n,s,o,o,a,n][c],0,255),g:or(255*d,0,255),b:or(255*u,0,255)}},e.rgbToHsv=function(e){var t=e.r/255,r=e.g/255,n=e.b/255,i=Math.max(t,r,n),l=Math.min(t,r,n),o=i-l,s=0,a=i,c=0===i?0:o/i;switch(i){case l:s=0;break;case t:s=(r-n)/o+(r.4;){r=.5*(o+l);var s=e.kelvinToRgb(r);s.b/s.r>=i/n?o=r:l=r}return r},t=e,r=[{key:"hsv",get:function(){var e=this.$;return{h:e.h,s:e.s,v:e.v}},set:function(e){var t=this.$;if(e=Ft({},t,e),this.onChange){var r={h:!1,v:!1,s:!1,a:!1};for(var n in t)r[n]=e[n]!=t[n];this.$=e,(r.h||r.s||r.v||r.a)&&this.onChange(this,r)}else this.$=e}},{key:"hsva",get:function(){return Ft({},this.$)},set:function(e){this.hsv=e}},{key:"hue",get:function(){return this.$.h},set:function(e){this.hsv={h:e}}},{key:"saturation",get:function(){return this.$.s},set:function(e){this.hsv={s:e}}},{key:"value",get:function(){return this.$.v},set:function(e){this.hsv={v:e}}},{key:"alpha",get:function(){return this.$.a},set:function(e){this.hsv=Ft({},this.hsv,{a:e})}},{key:"kelvin",get:function(){return e.rgbToKelvin(this.rgb)},set:function(t){this.rgb=e.kelvinToRgb(t)}},{key:"red",get:function(){return this.rgb.r},set:function(e){this.rgb=Ft({},this.rgb,{r:e})}},{key:"green",get:function(){return this.rgb.g},set:function(e){this.rgb=Ft({},this.rgb,{g:e})}},{key:"blue",get:function(){return this.rgb.b},set:function(e){this.rgb=Ft({},this.rgb,{b:e})}},{key:"rgb",get:function(){var t=e.hsvToRgb(this.$),r=t.r,n=t.g,i=t.b;return{r:ir(r),g:ir(n),b:ir(i)}},set:function(t){this.hsv=Ft({},e.rgbToHsv(t),{a:void 0===t.a?1:t.a})}},{key:"rgba",get:function(){return Ft({},this.rgb,{a:this.alpha})},set:function(e){this.rgb=e}},{key:"hsl",get:function(){var t=e.hsvToHsl(this.$),r=t.h,n=t.s,i=t.l;return{h:ir(r),s:ir(n),l:ir(i)}},set:function(t){this.hsv=Ft({},e.hslToHsv(t),{a:void 0===t.a?1:t.a})}},{key:"hsla",get:function(){return Ft({},this.hsl,{a:this.alpha})},set:function(e){this.hsl=e}},{key:"rgbString",get:function(){var e=this.rgb;return"rgb("+e.r+", "+e.g+", "+e.b+")"},set:function(e){var t,r,n,i,l=1;if((t=Gt.exec(e))?(r=sr(t[1],255),n=sr(t[2],255),i=sr(t[3],255)):(t=$t.exec(e))&&(r=sr(t[1],255),n=sr(t[2],255),i=sr(t[3],255),l=sr(t[4],1)),!t)throw new Error("Invalid rgb string");this.rgb={r:r,g:n,b:i,a:l}}},{key:"rgbaString",get:function(){var e=this.rgba;return"rgba("+e.r+", "+e.g+", "+e.b+", "+e.a+")"},set:function(e){this.rgbString=e}},{key:"hexString",get:function(){var e=this.rgb;return"#"+cr(e.r)+cr(e.g)+cr(e.b)},set:function(e){var t,r,n,i,l=255;if((t=Qt.exec(e))?(r=17*ar(t[1]),n=17*ar(t[2]),i=17*ar(t[3])):(t=er.exec(e))?(r=17*ar(t[1]),n=17*ar(t[2]),i=17*ar(t[3]),l=17*ar(t[4])):(t=tr.exec(e))?(r=ar(t[1]),n=ar(t[2]),i=ar(t[3])):(t=rr.exec(e))&&(r=ar(t[1]),n=ar(t[2]),i=ar(t[3]),l=ar(t[4])),!t)throw new Error("Invalid hex string");this.rgb={r:r,g:n,b:i,a:l/255}}},{key:"hex8String",get:function(){var e=this.rgba;return"#"+cr(e.r)+cr(e.g)+cr(e.b)+cr(lr(255*e.a))},set:function(e){this.hexString=e}},{key:"hslString",get:function(){var e=this.hsl;return"hsl("+e.h+", "+e.s+"%, "+e.l+"%)"},set:function(e){var t,r,n,i,l=1;if((t=Kt.exec(e))?(r=sr(t[1],360),n=sr(t[2],100),i=sr(t[3],100)):(t=Zt.exec(e))&&(r=sr(t[1],360),n=sr(t[2],100),i=sr(t[3],100),l=sr(t[4],1)),!t)throw new Error("Invalid hsl string");this.hsl={h:r,s:n,l:i,a:l}}},{key:"hslaString",get:function(){var e=this.hsla;return"hsla("+e.h+", "+e.s+"%, "+e.l+"%, "+e.a+")"},set:function(e){this.hslString=e}}],r&&Ht(t.prototype,r),e}();function ur(e){var t,r=e.width,n=e.sliderSize,i=e.borderWidth,l=e.handleRadius,o=e.padding,s=e.sliderShape,a="horizontal"===e.layoutDirection;return n=null!=(t=n)?t:2*o+2*l,"circle"===s?{handleStart:e.padding+e.handleRadius,handleRange:r-2*o-2*l,width:r,height:r,cx:r/2,cy:r/2,radius:r/2-i/2}:{handleStart:n/2,handleRange:r-n,radius:n/2,x:0,y:0,width:a?n:r,height:a?r:n}}var hr,pr=2*Math.PI,fr=function(e,t){return(e%t+t)%t},gr=function(e,t){return Math.sqrt(e*e+t*t)};function br(e){return e.width/2-e.padding-e.handleRadius-e.borderWidth}function mr(e){var t=e.width/2;return{width:e.width,radius:t-e.borderWidth,cx:t,cy:t}}function vr(e,t,r){var n=e.wheelAngle,i=e.wheelDirection;return r&&"clockwise"===i?t=n+t:"clockwise"===i?t=360-n+t:r&&"anticlockwise"===i?t=n+180-t:"anticlockwise"===i&&(t=n-t),fr(t,360)}function yr(e,t,r){var n=mr(e),i=n.cx,l=n.cy,o=br(e);t=i-t,r=l-r;var s=vr(e,Math.atan2(-r,-t)*(360/pr)),a=Math.min(gr(t,r),o);return{h:Math.round(s),s:Math.round(100/o*a)}}function wr(e){var t=e.width,r=e.boxHeight;return{width:t,height:null!=r?r:t,radius:e.padding+e.handleRadius}}function Cr(e,t,r){var n=wr(e),i=n.width,l=n.height,o=n.radius,s=(t-o)/(i-2*o)*100,a=(r-o)/(l-2*o)*100;return{s:Math.max(0,Math.min(s,100)),v:Math.max(0,Math.min(100-a,100))}}function xr(e){hr||(hr=document.getElementsByTagName("base"));var t=window.navigator.userAgent,r=/^((?!chrome|android).)*safari/i.test(t),n=/iPhone|iPod|iPad/i.test(t),i=window.location;return(r||n)&&hr.length>0?i.protocol+"//"+i.host+i.pathname+i.search+e:e}function kr(e,t,r,n){for(var i=0;i0&&(l[n?"marginLeft":"marginTop"]=i),xt(Tt,null,e.children(this.uid,r,l))},t.prototype.handleEvent=function(e){var t=this,r=this.props.onInput,n=this.base.getBoundingClientRect();e.preventDefault();var i=e.touches?e.changedTouches[0]:e,l=i.clientX-n.left,o=i.clientY-n.top;switch(e.type){case"mousedown":case"touchstart":!1!==r(l,o,0)&&Ar.forEach((function(e){document.addEventListener(e,t,{passive:!1})}));break;case"mousemove":case"touchmove":r(l,o,1);break;case"mouseup":case"touchend":r(l,o,2),Ar.forEach((function(e){document.removeEventListener(e,t,{passive:!1})}))}},t}(_t);function Sr(e){var t=e.r,r=e.url,n=t,i=t;return xt("svg",{className:"IroHandle IroHandle--"+e.index+" "+(e.isActive?"IroHandle--isActive":""),style:{"-webkit-tap-highlight-color":"rgba(0, 0, 0, 0);",transform:"translate("+Nr(e.x)+", "+Nr(e.y)+")",willChange:"transform",top:Nr(-t),left:Nr(-t),width:Nr(2*t),height:Nr(2*t),position:"absolute",overflow:"visible"}},r&&xt("use",Object.assign({xlinkHref:xr(r)},e.props)),!r&&xt("circle",{cx:n,cy:i,r:t,fill:"none","stroke-width":2,stroke:"#000"}),!r&&xt("circle",{cx:n,cy:i,r:t-2,fill:e.fill,"stroke-width":2,stroke:"#fff"}))}function jr(e){var t=e.activeIndex,r=void 0!==t&&t0?t.colors:[t.color]).forEach((function(e){return r.addColor(e)})),this.setActiveColor(0),this.state=Object.assign({},t,{color:this.color,colors:this.colors,layout:t.layout})}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.addColor=function(e,t){void 0===t&&(t=this.colors.length);var r=new dr(e,this.onColorChange.bind(this));this.colors.splice(t,0,r),this.colors.forEach((function(e,t){return e.index=t})),this.state&&this.setState({colors:this.colors}),this.deferredEmit("color:init",r)},t.prototype.removeColor=function(e){var t=this.colors.splice(e,1)[0];t.unbind(),this.colors.forEach((function(e,t){return e.index=t})),this.state&&this.setState({colors:this.colors}),t.index===this.color.index&&this.setActiveColor(0),this.emit("color:remove",t)},t.prototype.setActiveColor=function(e){this.color=this.colors[e],this.state&&this.setState({color:this.color}),this.emit("color:setActive",this.color)},t.prototype.setColors=function(e,t){var r=this;void 0===t&&(t=0),this.colors.forEach((function(e){return e.unbind()})),this.colors=[],e.forEach((function(e){return r.addColor(e)})),this.setActiveColor(t),this.emit("color:setAll",this.colors)},t.prototype.on=function(e,t){var r=this,n=this.events;(Array.isArray(e)?e:[e]).forEach((function(e){(n[e]||(n[e]=[])).push(t),r.deferredEvents[e]&&(r.deferredEvents[e].forEach((function(e){t.apply(null,e)})),r.deferredEvents[e]=[])}))},t.prototype.off=function(e,t){var r=this;(Array.isArray(e)?e:[e]).forEach((function(e){var n=r.events[e];n&&n.splice(n.indexOf(t),1)}))},t.prototype.emit=function(e){for(var t=this,r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];var i=this.activeEvents;i.hasOwnProperty(e)&&i[e]||(i[e]=!0,(this.events[e]||[]).forEach((function(e){return e.apply(t,r)})),i[e]=!1)},t.prototype.deferredEmit=function(e){for(var t,r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];var i=this.deferredEvents;(t=this).emit.apply(t,[e].concat(r)),(i[e]||(i[e]=[])).push(r)},t.prototype.setOptions=function(e){this.setState(e)},t.prototype.resize=function(e){this.setOptions({width:e})},t.prototype.reset=function(){this.colors.forEach((function(e){return e.reset()})),this.setState({colors:this.colors})},t.prototype.onMount=function(e){this.el=e,this.deferredEmit("mount",this)},t.prototype.onColorChange=function(e,t){this.setState({color:this.color}),this.inputActive&&(this.inputActive=!1,this.emit("input:change",e,t)),this.emit("color:change",e,t)},t.prototype.emitInputEvent=function(e,t){0===e?this.emit("input:start",this.color,t):1===e?this.emit("input:move",this.color,t):2===e&&this.emit("input:end",this.color,t)},t.prototype.render=function(e,t){var r=this,n=t.layout;return Array.isArray(n)||(n=[{component:Er},{component:jr}],t.transparency&&n.push({component:jr,options:{sliderType:"alpha"}})),xt("div",{class:"IroColorPicker",id:t.id,style:{display:t.display}},n.map((function(e,n){var i=e.component,l=e.options;return xt(i,Object.assign({},t,l,{ref:void 0,onInput:r.emitInputEvent.bind(r),parent:r,index:n}))})))},t}(_t);Mr.defaultProps=Object.assign({},{width:300,height:300,color:"#fff",colors:[],padding:6,layoutDirection:"vertical",borderColor:"#fff",borderWidth:0,handleRadius:8,activeHandleRadius:null,handleSvg:null,handleProps:{x:0,y:0},wheelLightness:!0,wheelAngle:0,wheelDirection:"anticlockwise",sliderSize:null,sliderMargin:12,boxHeight:null},{colors:[],display:"block",id:null,layout:"default",margin:null});var Br,Rr,Or,Pr=(Rr=function(e,t){var r,n=document.createElement("div");function i(){var t=e instanceof Element?e:document.querySelector(e);t.appendChild(r.base),r.onMount(t)}return function(e,t,r){var n,i,l;at.__p&&at.__p(e,t),i=(n=r===ht)?null:t.__k,e=xt(Tt,null,[e]),l=[],Rt(t,t.__k=e,i||mt,mt,void 0!==t.ownerSVGElement,i?null:vt.slice.call(t.childNodes),l,!1,mt,n),Ot(l,e)}(xt(Br,Object.assign({},{ref:function(e){return r=e}},t)),n),"loading"!==document.readyState?i():document.addEventListener("DOMContentLoaded",i),r},Rr.prototype=(Br=Mr).prototype,Object.assign(Rr,Br),Rr.__component=Br,Rr);!function(e){var t;e.version="5.5.2",e.Color=dr,e.ColorPicker=Pr,(t=e.ui||(e.ui={})).h=xt,t.ComponentBase=Lr,t.Handle=Sr,t.Slider=jr,t.Wheel=Er,t.Box=qr}(Or||(Or={}));var Ir=Or;const zr=[{icon:'',label:"save",type:"button"},{icon:'',label:"cancel",type:"button"}],Dr=[{value:"#000000",describe:"black"},{value:"#4d4d4d",describe:"dimGrey"},{value:"#808080",describe:"grey"},{value:"#e6e6e6",describe:"lightGrey"},{value:"#ffffff",describe:"white"},{value:"#ff0000",describe:"red"},{value:"#ffa500",describe:"orange"},{value:"#ffff00",describe:"yellow"},{value:"#99e64d",describe:"lightGreen"},{value:"#008000",describe:"green"},{value:"#7fffd4",describe:"aquamarine"},{value:"#40e0d0",describe:"turquoise"},{value:"#4d99e6",describe:"lightBlue"},{value:"#0000ff",describe:"blue"},{value:"#800080",describe:"purple"}];var Hr,Fr=class{constructor(e,t){this.tableMenus=e,this.options=t,this.attrs=Object.assign({},t.attribute),this.borderForm=[],this.saveButton=null,this.form=this.createPropertiesForm(t)}checkBtnsAction(e){"save"===e&&this.saveAction(this.options.type),this.removePropertiesForm(),this.tableMenus.showMenus(),this.tableMenus.updateMenus()}createActionBtns(e,t){const r=this.getUseLanguage(),n=document.createElement("div"),i=document.createDocumentFragment();n.classList.add("properties-form-action-row");for(const{icon:e,label:n,type:l}of zr){const o=document.createElement("button"),s=document.createElement("span");if(s.innerHTML=e,o.appendChild(s),D(o,{label:n,type:l}),t){const e=document.createElement("span");e.innerText=r(n),o.appendChild(e)}i.appendChild(o)}return n.addEventListener("click",(t=>e(t))),n.appendChild(i),n}createCheckBtns(e){const{menus:t,propertyName:r}=e,n=document.createElement("div"),i=document.createDocumentFragment();for(const{icon:e,describe:n,align:l}of t){const t=document.createElement("span");t.innerHTML=e,t.setAttribute("data-align",l),t.classList.add("ql-table-tooltip-hover"),this.options.attribute[r]===l&&t.classList.add("ql-table-btns-checked");const o=k(n);t.appendChild(o),i.appendChild(t)}return n.classList.add("ql-table-check-container"),n.appendChild(i),n.addEventListener("click",(e=>{const t=e.target.closest("span.ql-table-tooltip-hover"),i=t.getAttribute("data-align");this.switchButton(n,t),this.setAttribute(r,i)})),n}createColorContainer(e){const t=document.createElement("div");t.classList.add("ql-table-color-container");const r=this.createColorInput(e),n=this.createColorPicker(e);return t.appendChild(r),t.appendChild(n),t}createColorInput(e){const t=this.createInput(e);return t.classList.add("label-field-view-color"),t}createColorList(e){const t=this.getUseLanguage(),r=document.createElement("ul"),n=document.createDocumentFragment();r.classList.add("color-list");for(const{value:e,describe:r}of Dr){const i=document.createElement("li"),l=k(t(r));i.setAttribute("data-color",e),i.classList.add("ql-table-tooltip-hover"),H(i,{"background-color":e}),i.appendChild(l),n.appendChild(i)}return r.appendChild(n),r.addEventListener("click",(t=>{const n=t.target,i=("DIV"===n.tagName?n.parentElement:n).getAttribute("data-color");this.setAttribute(e,i,r),this.updateInputStatus(r,!1,!0)})),r}createColorPicker(e){const{propertyName:t,value:r}=e,n=document.createElement("span"),i=document.createElement("span");n.classList.add("color-picker"),i.classList.add("color-button"),r?H(i,{"background-color":r}):i.classList.add("color-unselected");const l=this.createColorPickerSelect(t);return i.addEventListener("click",(()=>{this.toggleHidden(l);const e=this.getColorClosest(n),t=null==e?void 0:e.querySelector(".property-input");this.updateSelectedStatus(l,null==t?void 0:t.value,"color")})),n.appendChild(i),n.appendChild(l),n}createColorPickerIcon(e,t,r){const n=document.createElement("div"),i=document.createElement("span"),l=document.createElement("button");return i.innerHTML=e,l.innerText=t,n.classList.add("erase-container"),n.appendChild(i),n.appendChild(l),n.addEventListener("click",r),n}createColorPickerSelect(e){const t=this.getUseLanguage(),r=document.createElement("div"),n=this.createColorPickerIcon('',t("removeColor"),(()=>{this.setAttribute(e,"",r),this.updateInputStatus(r,!1,!0)})),i=this.createColorList(e),l=this.createPalette(e,t,r);return r.classList.add("color-picker-select","ql-hidden"),r.appendChild(n),r.appendChild(i),r.appendChild(l),r}createDropdown(e,t){const r=document.createElement("div"),n=document.createElement("span"),i=document.createElement("span");return"dropdown"===t&&(i.innerHTML=bt,i.classList.add("ql-table-dropdown-icon")),e&&(n.innerText=e),r.classList.add("ql-table-dropdown-properties"),n.classList.add("ql-table-dropdown-text"),r.appendChild(n),"dropdown"===t&&r.appendChild(i),{dropdown:r,dropText:n}}createInput(e){const{attribute:t,message:r,propertyName:n,value:i,valid:l}=e,{placeholder:o=""}=t,s=document.createElement("div"),a=document.createElement("div"),c=document.createElement("label"),d=document.createElement("input"),u=document.createElement("div");return s.classList.add("label-field-view"),a.classList.add("label-field-view-input-wrapper"),c.innerText=o,D(d,t),d.classList.add("property-input"),d.value=i,d.addEventListener("input",(e=>{const t=e.target.value;l&&this.switchHidden(u,l(t)),this.updateInputStatus(a,l&&!l(t)),this.setAttribute(n,t,s)})),u.classList.add("label-field-view-status","ql-hidden"),r&&(u.innerText=r),a.appendChild(d),a.appendChild(c),s.appendChild(a),l&&s.appendChild(u),s}createList(e,t){const{options:r,propertyName:n}=e;if(!r.length)return null;const i=document.createElement("ul");for(const e of r){const t=document.createElement("li");t.innerText=e,i.appendChild(t)}return i.classList.add("ql-table-dropdown-list","ql-hidden"),i.addEventListener("click",(e=>{const r=e.target.innerText;t.innerText=r,this.toggleBorderDisabled(r),this.setAttribute(n,r)})),i}createPalette(e,t,r){const n=document.createElement("div"),i=document.createElement("div"),l=document.createElement("div"),o=document.createElement("div"),s=new Ir.ColorPicker(o,{width:110,layout:[{component:Ir.ui.Wheel,options:{}}]}),a=this.createColorPickerIcon('',t("colorPicker"),(()=>this.toggleHidden(i))),c=this.createActionBtns((t=>{const l=t.target.closest("button");l&&("save"===l.getAttribute("label")&&(this.setAttribute(e,s.color.hexString,r),this.updateInputStatus(n,!1,!0)),i.classList.add("ql-hidden"),r.classList.add("ql-hidden"))}),!1);return i.classList.add("color-picker-palette","ql-hidden"),l.classList.add("color-picker-wrap"),o.classList.add("iro-container"),l.appendChild(o),l.appendChild(c),i.appendChild(l),n.appendChild(a),n.appendChild(i),n}createProperty(e){const{content:t,children:r}=e,n=this.getUseLanguage(),i=document.createElement("div"),l=document.createElement("label");l.innerText=t,l.classList.add("ql-table-dropdown-label"),i.classList.add("properties-form-row"),1===r.length&&i.classList.add("properties-form-row-full"),i.appendChild(l);for(const e of r){const r=this.createPropertyChild(e);r&&i.appendChild(r),r&&t===n("border")&&this.borderForm.push(r)}return i}createPropertyChild(e){const{category:t,value:r}=e;switch(t){case"dropdown":const{dropdown:n,dropText:i}=this.createDropdown(r,t),l=this.createList(e,i);return n.appendChild(l),n.addEventListener("click",(()=>{this.toggleHidden(l),this.updateSelectedStatus(n,i.innerText,"dropdown")})),n;case"color":return this.createColorContainer(e);case"menus":return this.createCheckBtns(e);case"input":return this.createInput(e)}}createPropertiesForm(e){const t=this.getUseLanguage(),{title:r,properties:n}=function({type:e,attribute:t},r){return"table"===e?function(e,t){return{title:t("tblProps"),properties:[{content:t("border"),children:[{category:"dropdown",propertyName:"border-style",value:e["border-style"],options:["dashed","dotted","double","groove","inset","none","outset","ridge","solid"]},{category:"color",propertyName:"border-color",value:e["border-color"],attribute:{type:"text",placeholder:t("color")},valid:I,message:t("colorMsg")},{category:"input",propertyName:"border-width",value:x(e["border-width"]),attribute:{type:"text",placeholder:t("width")},valid:z,message:t("dimsMsg")}]},{content:t("background"),children:[{category:"color",propertyName:"background-color",value:e["background-color"],attribute:{type:"text",placeholder:t("color")},valid:I,message:t("colorMsg")}]},{content:t("dimsAlm"),children:[{category:"input",propertyName:"width",value:x(e.width),attribute:{type:"text",placeholder:t("width")},valid:z,message:t("dimsMsg")},{category:"input",propertyName:"height",value:x(e.height),attribute:{type:"text",placeholder:t("height")},valid:z,message:t("dimsMsg")},{category:"menus",propertyName:"align",value:e.align,menus:[{icon:s,describe:t("alTblL"),align:"left"},{icon:o,describe:t("tblC"),align:"center"},{icon:a,describe:t("alTblR"),align:"right"}]}]}]}}(t,r):function(e,t){return{title:t("cellProps"),properties:[{content:t("border"),children:[{category:"dropdown",propertyName:"border-style",value:e["border-style"],options:["dashed","dotted","double","groove","inset","none","outset","ridge","solid"]},{category:"color",propertyName:"border-color",value:e["border-color"],attribute:{type:"text",placeholder:t("color")},valid:I,message:t("colorMsg")},{category:"input",propertyName:"border-width",value:x(e["border-width"]),attribute:{type:"text",placeholder:t("width")},valid:z,message:t("dimsMsg")}]},{content:t("background"),children:[{category:"color",propertyName:"background-color",value:e["background-color"],attribute:{type:"text",placeholder:t("color")},valid:I,message:t("colorMsg")}]},{content:t("dims"),children:[{category:"input",propertyName:"width",value:x(e.width),attribute:{type:"text",placeholder:t("width")},valid:z,message:t("dimsMsg")},{category:"input",propertyName:"height",value:x(e.height),attribute:{type:"text",placeholder:t("height")},valid:z,message:t("dimsMsg")},{category:"input",propertyName:"padding",value:x(e.padding),attribute:{type:"text",placeholder:t("padding")},valid:z,message:t("dimsMsg")}]},{content:t("tblCellTxtAlm"),children:[{category:"menus",propertyName:"text-align",value:e["text-align"],menus:[{icon:s,describe:t("alCellTxtL"),align:"left"},{icon:o,describe:t("alCellTxtC"),align:"center"},{icon:a,describe:t("alCellTxtR"),align:"right"},{icon:'',describe:t("jusfCellTxt"),align:"justify"}]},{category:"menus",propertyName:"vertical-align",value:e["vertical-align"],menus:[{icon:'',describe:t("alCellTxtT"),align:"top"},{icon:'',describe:t("alCellTxtM"),align:"middle"},{icon:'',describe:t("alCellTxtB"),align:"bottom"}]}]}]}}(t,r)}(e,t),i=document.createElement("div");i.classList.add("ql-table-properties-form");const l=document.createElement("h2"),c=this.createActionBtns((e=>{const t=e.target.closest("button");t&&this.checkBtnsAction(t.getAttribute("label"))}),!0);l.innerText=r,l.classList.add("properties-form-header"),i.appendChild(l);for(const e of n){const t=this.createProperty(e);i.appendChild(t)}return i.appendChild(c),this.setBorderDisabled(),this.tableMenus.quill.container.appendChild(i),this.updatePropertiesForm(i,e.type),this.setSaveButton(c),i.addEventListener("click",(e=>{const t=e.target;this.hiddenSelectList(t)})),i}getCellStyle(e,t){const r=(e.getAttribute("style")||"").split(";").filter((e=>e.trim())).reduce(((e,t)=>{const r=t.split(":");return Object.assign(Object.assign({},e),{[r[0].trim()]:r[1].trim()})}),{});return Object.assign(r,t),Object.keys(r).reduce(((e,t)=>e+`${t}: ${r[t]}; `),"")}getColorClosest(e){return L(e,".ql-table-color-container")}getComputeBounds(e){if("table"===e){const{table:e}=this.tableMenus,[t,r]=this.tableMenus.getCorrectBounds(e);return t.bottom>r.bottom?Object.assign(Object.assign({},t),{bottom:r.height}):t}{const{computeBounds:e}=this.tableMenus.getSelectedTdsInfo();return e}}getDiffProperties(){const e=this.attrs,t=this.options.attribute;return Object.keys(e).reduce(((r,n)=>{var i;return e[n]!==t[n]&&(r[n]=function(e){return!(!e.endsWith("width")&&!e.endsWith("height"))}(n)?(i=e[n])?i.replace(/\d+\.?\d*/,"")?i:i+"px":i:e[n]),r}),{})}getUseLanguage(){const{language:e}=this.tableMenus.tableBetter;return e.useLanguage.bind(e)}getViewportSize(){return{viewWidth:document.documentElement.clientWidth,viewHeight:document.documentElement.clientHeight}}hiddenSelectList(e){var t,r;const n=".ql-table-dropdown-properties",i=".color-picker",l=this.form.querySelectorAll(".ql-table-dropdown-list"),o=this.form.querySelectorAll(".color-picker-select");for(const s of[...l,...o])(null===(t=s.closest(n))||void 0===t?void 0:t.isEqualNode(e.closest(n)))||(null===(r=s.closest(i))||void 0===r?void 0:r.isEqualNode(e.closest(i)))||s.classList.add("ql-hidden")}removePropertiesForm(){this.form.remove(),this.borderForm=[]}saveAction(e){"table"===e?this.saveTableAction():this.saveCellAction()}saveCellAction(){var e;const{selectedTds:r}=this.tableMenus.tableBetter.cellSelection,{quill:n,table:i}=this.tableMenus,l=t().find(i),o=l.colgroup(),s=l.isPercent(),a=this.getDiffProperties(),c=parseFloat(a.width),d=(null===(e=a.width)||void 0===e?void 0:e.endsWith("%"))?c*R()/100:c,u=a["text-align"];u&&delete a["text-align"];const h=[];if(o&&d){delete a.width;const{operateLine:e}=this.tableMenus.tableBetter,{computeBounds:t}=this.tableMenus.getSelectedTdsInfo(),r=j(t,i,n.container);for(const t of r)e.setColWidth(t,`${d}`,s)}for(const e of r){const r=t().find(e),n=r.statics.blotName,i=r.formats()[n],l=this.getCellStyle(e,a);if(u){const e="left"===u?"":u;r.children.forEach((t=>{t.statics.blotName===m.blotName?t.children.forEach((t=>{t.format&&t.format("align",e)})):t.format("align",e)}))}const o=r.replaceWith(n,Object.assign(Object.assign({},i),{style:l}));h.push(o.domNode)}this.tableMenus.tableBetter.cellSelection.setSelectedTds(h),s||this.updateTableWidth(i,l,s)}saveTableAction(){var e;const{table:r,tableBetter:n}=this.tableMenus,i=null===(e=t().find(r).temporary())||void 0===e?void 0:e.domNode,l=r.querySelector("td,th"),o=this.getDiffProperties(),s=o.align;switch(delete o.align,s){case"center":Object.assign(o,{margin:"0 auto"});break;case"left":Object.assign(o,{margin:""});break;case"right":Object.assign(o,{"margin-left":"auto","margin-right":""})}H(i||r,o),n.cellSelection.setSelected(l)}setAttribute(e,t,r){this.attrs[e]=t,e.includes("-color")&&this.updateSelectColor(this.getColorClosest(r),t)}setBorderDisabled(){const[e]=this.borderForm,t=e.querySelector(".ql-table-dropdown-text").innerText;this.toggleBorderDisabled(t)}setSaveButton(e){const t=e.querySelector('button[label="save"]');this.saveButton=t}setSaveButtonDisabled(e){this.saveButton&&(e?this.saveButton.setAttribute("disabled","true"):this.saveButton.removeAttribute("disabled"))}switchButton(e,t){const r=e.querySelectorAll("span.ql-table-tooltip-hover");for(const e of r)e.classList.remove("ql-table-btns-checked");t.classList.add("ql-table-btns-checked")}switchHidden(e,t){t?e.classList.add("ql-hidden"):e.classList.remove("ql-hidden")}toggleBorderDisabled(e){const[,t,r]=this.borderForm;"none"!==e&&e?(t.classList.remove("ql-table-disabled"),r.classList.remove("ql-table-disabled")):(this.attrs["border-color"]="",this.attrs["border-width"]="",this.updateSelectColor(t,""),this.updateInputValue(r,""),t.classList.add("ql-table-disabled"),r.classList.add("ql-table-disabled"))}toggleHidden(e){e.classList.toggle("ql-hidden")}updateInputValue(e,t){e.querySelector(".property-input").value=t}updateInputStatus(e,t,r){const n=(r?this.getColorClosest(e):L(e,".label-field-view")).querySelector(".label-field-view-input-wrapper");t?(n.classList.add("label-field-view-error"),this.setSaveButtonDisabled(!0)):(n.classList.remove("label-field-view-error"),this.form.querySelectorAll(".label-field-view-error").length||this.setSaveButtonDisabled(!1))}updatePropertiesForm(e,t){e.classList.remove("ql-table-triangle-none");const{height:r,width:n}=e.getBoundingClientRect(),i=this.tableMenus.quill.container.getBoundingClientRect(),{top:l,left:o,right:s,bottom:a}=this.getComputeBounds(t),{viewHeight:c}=this.getViewportSize();let d=a+10,u=o+s-n>>1;d+i.top+r>c?(d=l-r-10,d<0?(d=i.height-r>>1,e.classList.add("ql-table-triangle-none")):(e.classList.add("ql-table-triangle-up"),e.classList.remove("ql-table-triangle-down"))):(e.classList.add("ql-table-triangle-down"),e.classList.remove("ql-table-triangle-up")),ui.right&&(u=i.right-n,e.classList.add("ql-table-triangle-none")),H(e,{left:`${u}px`,top:`${d}px`})}updateSelectColor(e,t){const r=e.querySelector(".property-input"),n=e.querySelector(".color-button"),i=e.querySelector(".color-picker-select"),l=e.querySelector(".label-field-view-status");t?n.classList.remove("color-unselected"):n.classList.add("color-unselected"),r.value=t,H(n,{"background-color":t}),i.classList.add("ql-hidden"),this.switchHidden(l,I(t))}updateSelectedStatus(e,t,r){const n="color"===r?".color-list":".ql-table-dropdown-list",i=e.querySelector(n);if(!i)return;const l=Array.from(i.querySelectorAll("li"));for(const e of l)e.classList.remove(`ql-table-${r}-selected`);const o=l.find((e=>("color"===r?e.getAttribute("data-color"):e.innerText)===t));o&&o.classList.add(`ql-table-${r}-selected`)}updateTableWidth(e,t,r){const n=t.temporary();H(e,{width:"auto"});const{width:i}=e.getBoundingClientRect();e.style.removeProperty("width"),H(n.domNode,{width:O(i,r)})}};!function(e){e.left="margin-left",e.right="margin-right"}(Hr||(Hr={}));var Vr=class{constructor(e,t){this.quill=e,this.table=null,this.prevList=null,this.prevTooltip=null,this.scroll=!1,this.tableBetter=t,this.tablePropertiesForm=null,this.tableHeaderRow=null,this.quill.root.addEventListener("click",this.handleClick.bind(this)),this.root=this.createMenus()}convertToRow(){var e;const r=t().find(this.table),n=r.tbody(),i=n||this.quill.scroll.create(Q.blotName),l=null===(e=null==i?void 0:i.children)||void 0===e?void 0:e.head,o=this.getCorrectRows(),s=[];let a=o[0].next;for(;a;)o.unshift(a),a=a.next;for(const e of o){const t=this.quill.scroll.create(J.blotName);e.children.forEach((e=>{const r=e.formats()[e.statics.blotName],n=e.domNode.cloneNode(!0),i=this.quill.scroll.create(n).replaceWith(Z.blotName,r);t.insertBefore(i,null)})),s.unshift([t,l]),e.remove()}for(const[e,t]of s)i.insertBefore(e,t);n||r.insertBefore(i,null);const[c]=i.descendant(Z);this.tableBetter.cellSelection.setSelected(c.domNode)}convertToHeaderRow(){const e=t().find(this.table);let r=e.thead();if(!r){const t=e.tbody();r=this.quill.scroll.create(ee.blotName),e.insertBefore(r,t)}const n=this.getCorrectRows();let i=n[0].prev;for(;i;)n.unshift(i),i=i.prev;for(const e of n){const t=this.quill.scroll.create(X.blotName);e.children.forEach((e=>{const r=e.formats()[e.statics.blotName],n=e.domNode.cloneNode(!0),i=this.quill.scroll.create(n).replaceWith(Y.blotName,r);t.insertBefore(i,null)})),r.insertBefore(t,null),e.remove()}const[l]=r.descendant(Y);this.tableBetter.cellSelection.setSelected(l.domNode)}copyTable(){return function(e,t,r,n){return new(r||(r=Promise))((function(i,l){function o(e){try{a(n.next(e))}catch(e){l(e)}}function s(e){try{a(n.throw(e))}catch(e){l(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,s)}a((n=n.apply(e,t||[])).next())}))}(this,void 0,void 0,(function*(){if(!this.table)return;const e=t().find(this.table);if(!e)return;const r="


"+e.getCopyTable(),n=this.tableBetter.cellSelection.getText(r),i=new ClipboardItem({"text/html":new Blob([r],{type:"text/html"}),"text/plain":new Blob([n],{type:"text/plain"})});try{yield navigator.clipboard.write([i]);const r=this.quill.getIndex(e),n=e.length();this.quill.setSelection(r+n,t().sources.SILENT),this.tableBetter.hideTools(),this.quill.scrollSelectionIntoView()}catch(e){console.error("Failed to copy table:",e)}}))}createList(e){if(!e)return null;const t=document.createElement("ul");for(const[,r]of Object.entries(e)){const{content:e,divider:n,createSwitch:i,handler:l}=r,o=document.createElement("li");if(i?(o.classList.add("ql-table-header-row"),o.appendChild(this.createSwitch(e)),this.tableHeaderRow=o):o.innerText=e,o.addEventListener("click",l.bind(this)),t.appendChild(o),n){const e=document.createElement("li");e.classList.add("ql-table-divider"),t.appendChild(e)}}return t.classList.add("ql-table-dropdown-list","ql-hidden"),t}createMenu(e,t,r,n){const i=document.createElement("div"),l=document.createElement("span");return l.innerHTML=r?e+t:e,i.classList.add("ql-table-dropdown"),l.classList.add("ql-table-tooltip-hover"),i.setAttribute("data-category",n),i.appendChild(l),i}createMenus(){const{language:e,options:t={}}=this.tableBetter,{menus:r}=t,n=e.useLanguage.bind(e),i=document.createElement("div");i.classList.add("ql-table-menus-container","ql-hidden");for(const[e,t]of Object.entries(function(e,t){const r={column:{content:e("col"),icon:'',handler(e,t){this.toggleAttribute(e,t)},children:{left:{content:e("insColL"),handler(){const{leftTd:e}=this.getSelectedTdsInfo(),t=this.table.getBoundingClientRect();this.insertColumn(e,0),F(this.table,t,72),this.updateMenus()}},right:{content:e("insColR"),handler(){const{rightTd:e}=this.getSelectedTdsInfo(),t=this.table.getBoundingClientRect();this.insertColumn(e,1),F(this.table,t,72),this.updateMenus()}},delete:{content:e("delCol"),handler(){this.deleteColumn()}},select:{content:e("selCol"),handler(){this.selectColumn()}}}},row:{content:e("row"),icon:'',handler(e,t,r){this.toggleAttribute(e,t,r)},children:{header:{content:e("headerRow"),divider:!0,createSwitch:!0,handler(){this.toggleHeaderRow(),this.toggleHeaderRowSwitch()}},above:{content:e("insRowAbv"),handler(){const{leftTd:e}=this.getSelectedTdsInfo();this.insertRow(e,0),this.updateMenus()}},below:{content:e("insRowBlw"),handler(){const{rightTd:e}=this.getSelectedTdsInfo();this.insertRow(e,1),this.updateMenus()}},delete:{content:e("delRow"),handler(){this.deleteRow()}},select:{content:e("selRow"),handler(){this.selectRow()}}}},merge:{content:e("mCells"),icon:'',handler(e,t){this.toggleAttribute(e,t)},children:{merge:{content:e("mCells"),handler(){this.mergeCells(),this.updateMenus()}},split:{content:e("sCell"),handler(){this.splitCell(),this.updateMenus()}}}},table:{content:e("tblProps"),icon:gt,handler(e,t){const r=Object.assign(Object.assign({},P(this.table,p)),{align:this.getTableAlignment(this.table)});this.toggleAttribute(e,t),this.tablePropertiesForm=new Fr(this,{attribute:r,type:"table"}),this.hideMenus()}},cell:{content:e("cellProps"),icon:'',handler(e,t){const{selectedTds:r}=this.tableBetter.cellSelection,n=r.length>1?this.getSelectedTdsAttrs(r):this.getSelectedTdAttrs(r[0]);this.toggleAttribute(e,t),this.tablePropertiesForm=new Fr(this,{attribute:n,type:"cell"}),this.hideMenus()}},wrap:{content:e("insParaOTbl"),icon:'',handler(e,t){this.toggleAttribute(e,t)},children:{before:{content:e("insB4"),handler(){this.insertParagraph(-1)}},after:{content:e("insAft"),handler(){this.insertParagraph(1)}}}},delete:{content:e("delTable"),icon:'',handler(){this.deleteTable()}}},n={copy:{content:e("copyTable"),icon:'',handler(){this.copyTable()}}};return(null==t?void 0:t.length)?Object.values(t).reduce(((e,t)=>{const i=Object.assign({},r,n);return"string"==typeof t&&(e[t]=i[t]),null!=t&&"object"==typeof t&&t.name&&(e[t.name]=ae()(i[t.name],t)),e}),{}):r}(n,r))){const{content:r,icon:n,children:l,handler:o}=t,s=this.createList(l),a=k(r),c=this.createMenu(n,bt,!!l,e);c.appendChild(a),s&&c.appendChild(s),i.appendChild(c),c.addEventListener("click",o.bind(this,s,a))}return this.quill.container.appendChild(i),i}createSwitch(e){const t=document.createDocumentFragment(),r=document.createElement("span"),n=document.createElement("span"),i=document.createElement("span");return r.innerText=e,n.classList.add("ql-table-switch"),i.classList.add("ql-table-switch-inner"),i.setAttribute("aria-checked","false"),n.appendChild(i),t.append(r,n),t}deleteColumn(e=!1){const{computeBounds:r,leftTd:n,rightTd:i}=this.getSelectedTdsInfo(),l=this.table.getBoundingClientRect(),o=q(r,this.table,this.quill.container,"column"),s=j(r,this.table,this.quill.container),a=t().find(n).table(),{changeTds:c,selTds:d}=this.getCorrectTds(o,r,n,i);e&&d.length!==this.tableBetter.cellSelection.selectedTds.length||(this.tableBetter.cellSelection.updateSelected("column"),a.deleteColumn(c,d,this.deleteTable.bind(this),s),F(this.table,l,r.left-r.right),this.updateMenus())}deleteRow(e=!1){const r=this.tableBetter.cellSelection.selectedTds,n=this.getCorrectRows();if(e){if(n.reduce(((e,t)=>e+t.children.length),0)!==r.length)return}this.tableBetter.cellSelection.updateSelected("row"),t().find(r[0]).table().deleteRow(n,this.deleteTable.bind(this)),this.updateMenus()}deleteTable(){const e=t().find(this.table);if(!e)return;const r=e.offset(this.quill.scroll);e.remove(),this.tableBetter.hideTools(),this.quill.setSelection(r-1,0,t().sources.USER)}destroyTablePropertiesForm(){this.tablePropertiesForm&&(this.tablePropertiesForm.removePropertiesForm(),this.tablePropertiesForm=null)}disableMenu(e,t){if(!this.root)return;const r=this.root.querySelector(`[data-category=${e}]`);r&&(t?r.classList.add("ql-table-disabled"):r.classList.remove("ql-table-disabled"))}getCellsOffset(e,r,n,i){const l=t().find(this.table).descendants(Z),o=Math.max(r.left,e.left),s=Math.min(r.right,e.right),a=new Map,c=new Map,d=new Map;for(const t of l){const{left:n,right:i}=M(t.domNode,this.quill.container);n+2>=o&&i<=s+2?this.setCellsMap(t,a):n+2>=e.left&&i<=r.left+2?this.setCellsMap(t,c):n+2>=r.right&&i<=e.right+2&&this.setCellsMap(t,d)}return this.getDiffOffset(a)||this.getDiffOffset(c,n)+this.getDiffOffset(d,i)}getColsOffset(e,t,r){let n=e.children.head;const i=Math.max(r.left,t.left),l=Math.min(r.right,t.right);let o=null,s=null,a=0;for(;n;){const{width:e}=n.domNode.getBoundingClientRect();if(o||s?(o=s,s+=e):(o=M(n.domNode,this.quill.container).left,s=o+e),o>l)break;o>=i&&s<=l&&a--,n=n.next}return a}getCorrectBounds(e){const t=this.quill.container.getBoundingClientRect(),r=M(e,this.quill.container);return r.width>=t.width?[Object.assign(Object.assign({},r),{left:0,right:t.width}),t]:[r,t]}getCorrectTds(e,r,n,i){const l=[],o=[],s=t().find(n).table().colgroup(),a=~~n.getAttribute("colspan")||1,c=~~i.getAttribute("colspan")||1;if(s)for(const t of e){const e=M(t,this.quill.container);if(e.left+2>=r.left&&e.right<=r.right+2)o.push(t);else{const n=this.getColsOffset(s,r,e);l.push([t,n])}}else for(const t of e){const e=M(t,this.quill.container);if(e.left+2>=r.left&&e.right<=r.right+2)o.push(t);else{const n=this.getCellsOffset(r,e,a,c);l.push([t,n])}}return{changeTds:l,selTds:o}}getCorrectRows(){const e=this.tableBetter.cellSelection.selectedTds,r={};for(const n of e){let e=~~n.getAttribute("rowspan")||1,i=t().find(n.parentElement);if(e>1)for(;i&&e;){const t=i.children.head.domNode.getAttribute("data-row");r[t]||(r[t]=i),i=i.next,e--}else{const e=n.getAttribute("data-row");r[e]||(r[e]=i)}}return Object.values(r)}getDiffOffset(e,t){let r=0;const n=this.getTdsFromMap(e);if(n.length)if(t){for(const e of n)r+=~~e.getAttribute("colspan")||1;r-=t}else for(const e of n)r-=~~e.getAttribute("colspan")||1;return r}getRefInfo(e,t){let r=null;if(!e)return{id:oe(),ref:r};let n=e.children.head;const i=n.domNode.getAttribute("data-row");for(;n;){const{left:e}=n.domNode.getBoundingClientRect();if(Math.abs(e-t)<=2)return{id:i,ref:n};Math.abs(e-t)>=2&&!r&&(r=n),n=n.next}return{id:i,ref:r}}getSelectedTdAttrs(e){const r=function(e){const t="left";let r=null;const n=e.descendants($),i=e.descendants(v),l=e.descendants(C);function o(e){for(const t of e.domNode.classList)if(/ql-align-/.test(t))return t.split("ql-align-")[1];return t}for(const e of[...n,...i,...l]){const n=o(e);if(null!=(s=r)&&s!==n)return t;r=n}var s;return null!=r?r:t}(t().find(e));return r?Object.assign(Object.assign({},P(e,u)),{"text-align":r}):P(e,u)}getSelectedTdsAttrs(e){const t=new Map;let r=null;for(const n of e){const e=this.getSelectedTdAttrs(n);if(r)for(const n of Object.keys(r))t.has(n)||e[n]!==r[n]&&t.set(n,!1);else r=e}for(const e of Object.keys(r))t.has(e)&&(r[e]=d[e]);return r}getSelectedTdsInfo(){const{startTd:e,endTd:t}=this.tableBetter.cellSelection,r=M(e,this.quill.container),n=M(t,this.quill.container),i=S(r,n);return r.left<=n.left&&r.top<=n.top?{computeBounds:i,leftTd:e,rightTd:t}:{computeBounds:i,leftTd:t,rightTd:e}}getTableAlignment(e){const t=e.getAttribute("align");if(!t){const{[Hr.left]:t,[Hr.right]:r}=P(e,[Hr.left,Hr.right]);return"auto"===t?"auto"===r?"center":"right":"left"}return t||"center"}getTdsFromMap(e){return Object.values(Object.fromEntries(e)).reduce(((e,t)=>e.length>t.length?e:t),[])}handleClick(e){if(!this.quill.isEnabled())return;const t=e.target.closest("table");if(!t||this.quill.root.contains(t)){if(this.prevList&&this.prevList.classList.add("ql-hidden"),this.prevTooltip&&this.prevTooltip.classList.remove("ql-table-tooltip-hidden"),this.prevList=null,this.prevTooltip=null,!t&&!this.tableBetter.cellSelection.selectedTds.length)return this.hideMenus(),void this.destroyTablePropertiesForm();this.tablePropertiesForm||(this.showMenus(),this.updateMenus(t),(t&&!t.isEqualNode(this.table)||this.scroll)&&this.updateScroll(!1),this.table=t)}}hideMenus(){this.root.classList.add("ql-hidden")}insertColumn(e,r){const{left:n,right:i,width:l}=e.getBoundingClientRect(),o=t().find(e).table(),s=e.parentElement.lastChild.isEqualNode(e),a=r>0?i:n;o.insertColumn(a,s,l,r),this.quill.scrollSelectionIntoView()}insertParagraph(e){const r=t().find(this.table),n=this.quill.getIndex(r),i=e>0?r.length():0,o=(new(l())).retain(n+i).insert("\n");this.quill.updateContents(o,t().sources.USER),this.quill.setSelection(n+i,t().sources.SILENT),this.tableBetter.hideTools(),this.quill.scrollSelectionIntoView()}insertRow(e,r){const n=t().find(e),i=n.rowOffset(),l=n.table(),o=n.statics.blotName===Y.blotName;if(r>0){const t=~~e.getAttribute("rowspan")||1;l.insertRow(i+r+t-1,r,o)}else l.insertRow(i+r,r,o);this.quill.scrollSelectionIntoView()}mergeCells(){var e,r;const{selectedTds:n}=this.tableBetter.cellSelection,{computeBounds:i,leftTd:l}=this.getSelectedTdsInfo(),o=t().find(l),[s,a]=N(o),c=o.children.head,d=o.table().tbody().children,u=o.row(),h=u.children.reduce(((e,t)=>{const r=M(t.domNode,this.quill.container);return r.left>=i.left&&r.right<=i.right&&(e+=~~t.domNode.getAttribute("colspan")||1),e}),0),p=d.reduce(((e,t)=>{const r=M(t.domNode,this.quill.container);if(r.top>=i.top&&r.bottom<=i.bottom){let r=Number.MAX_VALUE;t.children.forEach((e=>{const t=~~e.domNode.getAttribute("rowspan")||1;r=Math.min(r,t)})),e+=r}return e}),0);let f=0;for(const i of n){if(l.isEqualNode(i))continue;const n=t().find(i);n.moveChildren(o),n.remove(),(null===(r=null===(e=n.parent)||void 0===e?void 0:e.children)||void 0===r?void 0:r.length)||f++}f&&u.children.forEach((e=>{if(e.domNode.isEqualNode(l))return;const t=e.domNode.getAttribute("rowspan"),[r]=N(e);e.replaceWith(e.statics.blotName,Object.assign(Object.assign({},r),{rowspan:t-f}))})),o.setChildrenId(a),c.format(o.statics.blotName,Object.assign(Object.assign({},s),{colspan:h,rowspan:p-f})),this.tableBetter.cellSelection.setSelected(c.parent.domNode),this.quill.scrollSelectionIntoView()}selectColumn(){const{computeBounds:e,leftTd:t,rightTd:r}=this.getSelectedTdsInfo(),n=q(e,this.table,this.quill.container,"column"),{selTds:i}=this.getCorrectTds(n,e,t,r);this.tableBetter.cellSelection.setSelectedTds(i),this.updateMenus()}selectRow(){const e=this.getCorrectRows().reduce(((e,t)=>(e.push(...Array.from(t.domNode.children)),e)),[]);this.tableBetter.cellSelection.setSelectedTds(e),this.updateMenus()}setCellsMap(e,t){const r=e.domNode.getAttribute("data-row");t.has(r)?t.set(r,[...t.get(r),e.domNode]):t.set(r,[e.domNode])}showMenus(){this.root.classList.remove("ql-hidden")}splitCell(){const{selectedTds:e}=this.tableBetter.cellSelection,{leftTd:r}=this.getSelectedTdsInfo(),n=t().find(r).children.head;for(const r of e){const e=~~r.getAttribute("colspan")||1,n=~~r.getAttribute("rowspan")||1;if(1===e&&1===n)continue;const i=[],{width:l,right:o}=r.getBoundingClientRect(),s=t().find(r),a=s.table(),c=s.next,d=s.row();if(n>1)if(e>1){let t=d.next;for(let r=1;r1){const t=r.getAttribute("data-row");for(let r=1;r{this.root.classList.remove("ql-table-triangle-none");const[t,r]=this.getCorrectBounds(e),{left:n,right:i,top:l,bottom:o}=t,{height:s,width:a}=this.root.getBoundingClientRect(),c=this.quill.getModule("toolbar"),d=getComputedStyle(c.container);let u=l-s-10,h=n+i-a>>1;u>-parseInt(d.paddingBottom)?(this.root.classList.add("ql-table-triangle-up"),this.root.classList.remove("ql-table-triangle-down")):(u=o>r.height?r.height+10:o+10,this.root.classList.add("ql-table-triangle-down"),this.root.classList.remove("ql-table-triangle-up")),hr.right&&(h=r.right-a,this.root.classList.add("ql-table-triangle-none")),H(this.root,{left:`${h}px`,top:`${u}px`})}))}updateScroll(e){this.scroll=e}updateTable(e){this.table=e}};const Wr=t().import("blots/inline");t().import("ui/icons")["table-better"]=gt;class Ur extends Wr{}class Gr{constructor(){this.computeChildren=[],this.root=this.createContainer()}clearSelected(e){for(const t of e)t.classList&&t.classList.remove("ql-cell-selected");this.computeChildren=[],this.root&&this.setLabelContent(this.root.lastElementChild,null)}createContainer(){const e=document.createElement("div"),t=document.createElement("div"),r=document.createElement("div"),n=document.createDocumentFragment();for(let e=1;e<=10;e++)for(let t=1;t<=10;t++){const r=document.createElement("span");r.setAttribute("row",`${e}`),r.setAttribute("column",`${t}`),n.appendChild(r)}return r.innerHTML="0 x 0",e.classList.add("ql-table-select-container","ql-hidden"),t.classList.add("ql-table-select-list"),r.classList.add("ql-table-select-label"),t.appendChild(n),e.appendChild(t),e.appendChild(r),e.addEventListener("mousemove",(t=>this.handleMouseMove(t,e))),e}getClickInfo(e){const t=e.target,r=t.closest("div.ql-table-select-container"),n=t.closest("span[row]");return r&&!n?[!0,n]:[!1,n]}getComputeChildren(e,t){const r=[],{clientX:n,clientY:i}=t;for(const t of e){const{left:e,top:l}=t.getBoundingClientRect();n>=e&&i>=l&&r.push(t)}return r}getSelectAttrs(e){return[~~e.getAttribute("row"),~~e.getAttribute("column")]}handleClick(e,t){const[r,n]=this.getClickInfo(e);if(this.toggle(this.root,r),n)this.insertTable(n,t);else{const e=this.computeChildren[this.computeChildren.length-1];e&&this.insertTable(e,t)}}handleMouseMove(e,t){const r=t.firstElementChild.children;this.clearSelected(this.computeChildren);const n=this.getComputeChildren(r,e);for(const e of n)e.classList&&e.classList.add("ql-cell-selected");this.computeChildren=n,this.setLabelContent(t.lastElementChild,n[n.length-1])}hide(e){this.clearSelected(this.computeChildren),e&&e.classList.add("ql-hidden")}insertTable(e,t){const[r,n]=this.getSelectAttrs(e);t(r,n),this.hide(this.root)}setLabelContent(e,t){if(t){const[r,n]=this.getSelectAttrs(t);e.innerHTML=`${r} x ${n}`}else e.innerHTML="0 x 0"}show(e){this.clearSelected(this.computeChildren),e&&e.classList.remove("ql-hidden")}toggle(e,t){t||this.clearSelected(this.computeChildren),e&&e.classList.toggle("ql-hidden")}}t().import("core/module");const $r=t().import("blots/container"),Kr=t().import("modules/toolbar");class Zr extends Kr{attach(e){let t=Array.from(e.classList).find((e=>0===e.indexOf("ql-")));if(!t)return;if(t=t.slice(3),"BUTTON"===e.tagName&&e.setAttribute("type","button"),null==this.handlers[t]&&null==this.quill.scroll.query(t))return void console.warn("ignoring attaching to nonexistent format",t,e);const r="SELECT"===e.tagName?"change":"click";e.addEventListener(r,(r=>{var n;const{cellSelection:i}=this.getTableBetter();(null===(n=null==i?void 0:i.selectedTds)||void 0===n?void 0:n.length)>1?this.cellSelectionAttach(e,t,r,i):this.toolbarAttach(e,t,r)})),this.controls.push([t,e])}cellSelectionAttach(e,t,r,n){if("SELECT"===e.tagName){if(e.selectedIndex<0)return;const r=e.options[e.selectedIndex],i="string"!=typeof(null==r?void 0:r.value)||(null==r?void 0:r.value),l=n.getCorrectValue(t,i);n.setSelectedTdsFormat(t,l)}else{const i=(null==e?void 0:e.value)||!0,l=n.getCorrectValue(t,i);n.setSelectedTdsFormat(t,l),r.preventDefault()}}getTableBetter(){return this.quill.getModule("table-better")}setTableFormat(e,r,n,i,l){let o=null;const{cellSelection:s,tableMenus:a}=this.getTableBetter(),c=function(e,r,n){if(1===r.length){const i=function(e,t=0,r=Number.MAX_VALUE){const n=(e,t,r)=>{let i=[],l=r;return e.children.forEachAt(t,r,((e,t,r)=>{e instanceof $r&&(i.push(e),i=i.concat(n(e,t,l))),l-=r})),i};return n(e,t,r)}(t().find(r[0]),e.index,e.length);return Jr(i)===Jr(n)}return!!(r.length>1)}(e,r,l);for(const e of l){const t=Yr(r,i,e,c);o=e.format(i,n,t)}if(r.length<2){if(c||1===l.length){const e=B(o);Promise.resolve().then((()=>{e&&this.quill.root.contains(e.domNode)?s.setSelected(e.domNode,!1):s.setSelected(r[0],!1)}))}else s.setSelected(r[0],!1);this.quill.setSelection(e,t().sources.SILENT)}return a.updateMenus(),o}toolbarAttach(e,r,n){let i;if("SELECT"===e.tagName){if(e.selectedIndex<0)return;const t=e.options[e.selectedIndex];i=!t.hasAttribute("selected")&&(t.value||!1)}else i=!e.classList.contains("ql-active")&&(e.value||!e.hasAttribute("value")),n.preventDefault();this.quill.focus();const[o]=this.quill.selection.getRange();if(null!=this.handlers[r])this.handlers[r].call(this,i);else if(this.quill.scroll.query(r).prototype instanceof rt){if(i=prompt(`Enter ${r}`),!i)return;this.quill.updateContents((new(l())).retain(o.index).delete(o.length).insert({[r]:i}),t().sources.USER)}else this.quill.format(r,i,t().sources.USER);this.update(o)}}function Yr(e,t,r,n){return 1===e.length&&"list"===t&&r.statics.blotName===C.blotName||n}function Jr(e){return e.reduce(((e,t)=>e+t.length()),0)}function Xr(e,t,r,n){const i=this.quill.getSelection();if(!n)if(i.length||1!==t.length)n=this.quill.getLines(i);else{const[e]=this.quill.getLine(i.index);n=[e]}return this.setTableFormat(i,t,e,r,n)}Zr.DEFAULTS=ae()({},Kr.DEFAULTS,{handlers:{header(e,r){const{cellSelection:n}=this.getTableBetter(),i=null==n?void 0:n.selectedTds;if(null==i?void 0:i.length)return Xr.call(this,e,i,"header",r);this.quill.format("header",e,t().sources.USER)},list(e,r){const{cellSelection:n}=this.getTableBetter(),i=null==n?void 0:n.selectedTds;if(null==i?void 0:i.length){if(1===i.length){const t=this.quill.getSelection(!0),r=this.quill.getFormat(t);e=n.getListCorrectValue("list",e,r)}return Xr.call(this,e,i,"list",r)}const l=this.quill.getSelection(!0),o=this.quill.getFormat(l);"check"===e?"checked"===o.list||"unchecked"===o.list?this.quill.format("list",!1,t().sources.USER):this.quill.format("list","unchecked",t().sources.USER):this.quill.format("list",e,t().sources.USER)},"table-better"(){}}});var Qr=Zr;const en=["error","warn","log","info"];let tn="warn";function rn(e){if(tn&&en.indexOf(e)<=en.indexOf(tn)){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n(t[r]=rn.bind(console,r,e),t)),{})}nn.level=e=>{tn=e},rn.level=nn.level;var ln=nn;t().import("core/module");const on=t().import("modules/clipboard"),sn=ln("quill:clipboard");var an=class extends on{onPaste(e,{text:r,html:n}){const i=this.quill.getFormat(e.index),o=this.getTableDelta({text:r,html:n},i);sn.log("onPaste",o,{text:r,html:n});const s=(new(l())).retain(e.index).delete(e.length).concat(o);this.quill.updateContents(s,t().sources.USER),this.quill.setSelection(s.length()-e.length,t().sources.SILENT),this.quill.scrollSelectionIntoView()}getTableDelta({html:e,text:t},r){var n,i,o,s,a;const c=this.convert({text:t,html:e},r);if(r[$.blotName]||r[K.blotName])for(const e of c.ops){if(null===(n=null==e?void 0:e.attributes)||void 0===n?void 0:n[te.blotName])return new(l());!(null===(i=null==e?void 0:e.attributes)||void 0===i?void 0:i.header)&&!(null===(o=null==e?void 0:e.attributes)||void 0===o?void 0:o.list)&&(null===(s=null==e?void 0:e.attributes)||void 0===s?void 0:s[$.blotName])&&(null===(a=null==e?void 0:e.attributes)||void 0===a?void 0:a[K.blotName])||(e.attributes=Object.assign(Object.assign({},e.attributes),r))}return c}};const cn=t().import("core/module");class dn extends cn{constructor(e,t){super(e,t),e.clipboard.addMatcher("td, th",he),e.clipboard.addMatcher("tr",ue),e.clipboard.addMatcher("col",pe),e.clipboard.addMatcher("table",fe),this.language=new qe(null==t?void 0:t.language),this.cellSelection=new pt(e,this),this.operateLine=new ft(e,this),this.tableMenus=new Vr(e,this),this.tableSelect=new Gr,e.root.addEventListener("keyup",this.handleKeyup.bind(this)),e.root.addEventListener("mousedown",this.handleMousedown.bind(this)),e.root.addEventListener("scroll",this.handleScroll.bind(this)),this.listenDeleteTable(),this.registerToolbarTable(null==t?void 0:t.toolbarTable)}static register(){t().register($,!0),t().register(K,!0),t().register(Z,!0),t().register(Y,!0),t().register(J,!0),t().register(X,!0),t().register(Q,!0),t().register(ee,!0),t().register(te,!0),t().register(ie,!0),t().register(re,!0),t().register(ne,!0),t().register({"modules/toolbar":Qr,"modules/clipboard":an},!0)}clearHistorySelected(){const[e]=this.getTable();if(!e)return;const t=Array.from(e.domNode.querySelectorAll("td.ql-cell-focused, td.ql-cell-selected"));for(const e of t)e.classList&&e.classList.remove("ql-cell-focused","ql-cell-selected")}deleteTable(){const[e]=this.getTable();if(null==e)return;const r=e.offset();e.remove(),this.hideTools(),this.quill.update(t().sources.USER),this.quill.setSelection(r,t().sources.SILENT)}deleteTableTemporary(e=t().sources.API){const r=this.quill.scroll.descendants(te);for(const e of r)e.remove();this.hideTools(),this.quill.update(e)}getTable(e=this.quill.getSelection()){if(null==e)return[null,null,null,-1];const[t,r]=this.quill.getLine(e.index);if(null==t||t.statics.blotName!==$.blotName)return[null,null,null,-1];const n=t.parent,i=n.parent;return[i.parent.parent,i,n,r]}handleKeyup(e){this.quill.isEnabled()&&(this.cellSelection.handleKeyup(e),!e.ctrlKey||"z"!==e.key&&"y"!==e.key||(this.hideTools(),this.clearHistorySelected()),this.updateMenus(e))}handleMousedown(e){var t;if(!this.quill.isEnabled())return;null===(t=this.tableSelect)||void 0===t||t.hide(this.tableSelect.root);const r=e.target.closest("table");if(!r||this.quill.root.contains(r)){if(!r)return this.hideTools(),void this.handleMouseMove();this.cellSelection.handleMousedown(e),this.cellSelection.setDisabled(!0)}else this.hideTools()}handleMouseMove(){let e=null;const r=t=>{e||(e=t.target.closest("table"))},n=i=>{if(e){const r=t().find(e);if(!r)return;const n=r.offset(this.quill.scroll),i=r.length(),l=this.quill.getSelection(),o=Math.min(l.index,n),s=Math.max(l.index+l.length,n+i);this.quill.setSelection(o,s-o,t().sources.USER)}this.quill.root.removeEventListener("mousemove",r),this.quill.root.removeEventListener("mouseup",n)};this.quill.root.addEventListener("mousemove",r),this.quill.root.addEventListener("mouseup",n)}handleScroll(){var e;this.quill.isEnabled()&&(this.hideTools(),null===(e=this.tableMenus)||void 0===e||e.updateScroll(!0))}hideTools(){var e,t,r,n,i,l,o;null===(e=this.cellSelection)||void 0===e||e.clearSelected(),null===(t=this.cellSelection)||void 0===t||t.setDisabled(!1),null===(r=this.operateLine)||void 0===r||r.hideDragBlock(),null===(n=this.operateLine)||void 0===n||n.hideDragTable(),null===(i=this.operateLine)||void 0===i||i.hideLine(),null===(l=this.tableMenus)||void 0===l||l.hideMenus(),null===(o=this.tableMenus)||void 0===o||o.destroyTablePropertiesForm()}insertTable(e,r){const n=this.quill.getSelection(!0);if(null==n)return;if(this.isTable(n))return;const i=this.quill.getFormat(n.index-1),[,o]=this.quill.getLine(n.index),s=!!i[$.blotName]||0!==o,a=s?2:1,c=s?(new(l())).insert("\n"):new(l()),d=(new(l())).retain(n.index).delete(n.length).concat(c).insert("\n",{[te.blotName]:{style:"width: 100%"}}),u=new Array(e).fill(0).reduce((e=>{const t=oe();return new Array(r).fill("\n").reduce(((e,r)=>e.insert(r,{[$.blotName]:le(),[Z.blotName]:{"data-row":t}})),e)}),d);this.quill.updateContents(u,t().sources.USER),this.quill.setSelection(n.index+a,t().sources.SILENT),this.showTools()}isTable(e){return!!this.quill.getFormat(e.index)[$.blotName]}listenDeleteTable(){this.quill.on(t().events.TEXT_CHANGE,((e,r,n)=>{if(n!==t().sources.USER)return;const i=this.quill.scroll.descendants(ie);if(!i.length)return;const l=[];if(i.forEach((e=>{const t=e.tbody(),r=e.thead();t||r||l.push(e)})),l.length){for(const e of l)e.remove();this.hideTools(),this.quill.update(t().sources.API)}}))}registerToolbarTable(e){if(!e)return;t().register({"formats/table-better":Ur},!0);const r=this.quill.getModule("toolbar").container.querySelector("button.ql-table-better");r&&this.tableSelect.root&&(r.appendChild(this.tableSelect.root),r.addEventListener("click",(e=>{this.tableSelect.handleClick(e,this.insertTable.bind(this))})),document.addEventListener("click",(e=>{e.composedPath().includes(r)||this.tableSelect.root.classList.contains("ql-hidden")||this.tableSelect.hide(this.tableSelect.root)})))}showTools(e){const[t,,r]=this.getTable();t&&r&&(this.cellSelection.setDisabled(!0),this.cellSelection.setSelected(r.domNode,e),this.tableMenus.showMenus(),this.tableMenus.updateMenus(t.domNode),this.tableMenus.updateTable(t.domNode))}updateMenus(e){this.cellSelection.selectedTds.length&&("Enter"===e.key||e.ctrlKey&&"v"===e.key)&&this.tableMenus.updateMenus()}}const un={"table-cell down":pn(!1),"table-cell up":pn(!0),"table-cell-block backspace":hn("Backspace"),"table-cell-block delete":hn("Delete"),"table-header backspace":fn("Backspace"),"table-header delete":fn("Delete"),"table-header enter":{key:"Enter",collapsed:!0,format:["table-header"],suffix:/^$/,handler(e,r){const[n,i]=this.quill.getLine(e.index),o=(new(l())).retain(e.index).insert("\n",r.format).retain(n.length()-i-1).retain(1,{header:null});this.quill.updateContents(o,t().sources.USER),this.quill.setSelection(e.index+1,t().sources.SILENT),this.quill.scrollSelectionIntoView()}},"table-list backspace":gn("Backspace"),"table-list delete":gn("Delete"),"table-list empty enter":{key:"Enter",collapsed:!0,format:["table-list"],empty:!0,handler(e,t){const{line:r}=t,{cellId:n}=r.parent.formats()[r.parent.statics.blotName],i=r.replaceWith($.blotName,n),l=this.quill.getModule("table-better"),o=B(i);o&&l.cellSelection.setSelected(o.domNode,!1)}}};function hn(e){return{key:e,format:["table-cell-block","table-th-block"],collapsed:!0,handler(t,r){var n;const[i]=this.quill.getLine(t.index),{offset:l,suffix:o}=r;if(0===l&&!i.prev)return!1;const s=null===(n=i.prev)||void 0===n?void 0:n.statics.blotName;return 0!==l||s!==m.blotName&&s!==$.blotName&&s!==C.blotName?!(0!==l&&!o&&"Delete"===e):bn.call(this,i,t)}}}function pn(e){return{key:e?"ArrowUp":"ArrowDown",collapsed:!0,format:["table-cell","table-th"],handler(){return!1}}}function fn(e){return{key:e,format:["table-header"],collapsed:!0,empty:!0,handler(e,t){const[r]=this.quill.getLine(e.index);if(r.prev)return bn.call(this,r,e);{const e=A(r.formats()[r.statics.blotName]);r.replaceWith($.blotName,e)}}}}function gn(e){return{key:e,format:["table-list"],collapsed:!0,empty:!0,handler(e,t){const[r]=this.quill.getLine(e.index),n=A(r.parent.formats()[r.parent.statics.blotName]);r.replaceWith($.blotName,n)}}}function bn(e,r){const n=this.quill.getModule("table-better");return e.remove(),null==n||n.tableMenus.updateMenus(),this.quill.setSelection(r.index-1,t().sources.SILENT),!1}dn.keyboardBindings=un;var mn=dn}(),i.default}()}));