exports.id=2931,exports.ids=[2931],exports.modules={2931:(e,t,l)=>{var o,r;window,r=l(74172),e.exports=function(e){var t,l,o,r,n=window.webpackHotUpdatequillBetterTable;window.webpackHotUpdatequillBetterTable=function(e,t){(function(e,t){if(y[e]&&v[e]){for(var l in v[e]=!1,t)Object.prototype.hasOwnProperty.call(t,l)&&(o[l]=t[l]);0==--f&&0===b&&C()}})(e,t),n&&n(e,t)};var i=!0,s="ced44c7892a78034ffe4",a={},d=[],c=[];function h(e){var l=A[e];if(!l)return S;var o=function(o){return l.hot.active?(A[o]?-1===A[o].parents.indexOf(e)&&A[o].parents.push(e):(d=[e],t=o),-1===l.children.indexOf(o)&&l.children.push(o)):(console.warn("[HMR] unexpected require("+o+") from disposed module "+e),d=[]),S(o)},r=function(e){return{configurable:!0,enumerable:!0,get:function(){return S[e]},set:function(t){S[e]=t}}};for(var n in S)Object.prototype.hasOwnProperty.call(S,n)&&"e"!==n&&"t"!==n&&Object.defineProperty(o,n,r(n));return o.e=function(e){return"ready"===p&&m("prepare"),b++,S.e(e).then(t,function(e){throw t(),e});function t(){b--,"prepare"===p&&(g[e]||N(e),0===b&&0===f&&C())}},o.t=function(e,t){return 1&t&&(e=o(e)),S.t(e,-2&t)},o}var u=[],p="idle";function m(e){p=e;for(var t=0;t0;){var n=r.pop(),i=n.id,s=n.chain;if((C=A[i])&&!C.hot._selfAccepted){if(C.hot._selfDeclined)return{type:"self-declined",chain:s,moduleId:i};if(C.hot._main)return{type:"unaccepted",chain:s,moduleId:i};for(var a=0;a ")),E.type){case"self-declined":t.onDeclined&&t.onDeclined(E),t.ignoreDeclined||(T=Error("Aborted because of self decline: "+E.moduleId+B));break;case"declined":t.onDeclined&&t.onDeclined(E),t.ignoreDeclined||(T=Error("Aborted because of declined dependency: "+E.moduleId+" in "+E.parentId+B));break;case"unaccepted":t.onUnaccepted&&t.onUnaccepted(E),t.ignoreUnaccepted||(T=Error("Aborted because "+q+" is not accepted"+B));break;case"accepted":t.onAccepted&&t.onAccepted(E),H=!0;break;case"disposed":t.onDisposed&&t.onDisposed(E),M=!0;break;default:throw Error("Unexception type "+E.type)}if(T)return m("abort"),Promise.reject(T);if(H)for(q in f[q]=o[q],l(u,E.outdatedModules),E.outdatedDependencies)Object.prototype.hasOwnProperty.call(E.outdatedDependencies,q)&&(h[q]||(h[q]=[]),l(h[q],E.outdatedDependencies[q]));M&&(l(u,[E.moduleId]),f[q]=b)}var O=[];for(x=0;x0;)if(C=A[q=R.pop()]){var L={},z=C.hot._disposeHandlers;for(N=0;N=0&&k.parents.splice(n,1)}}for(q in h)if(Object.prototype.hasOwnProperty.call(h,q)&&(C=A[q]))for(N=0,c=h[q];N=0&&C.children.splice(n,1);for(q in m("apply"),s=r,f)Object.prototype.hasOwnProperty.call(f,q)&&(e[q]=f[q]);var I=null;for(q in h)if(Object.prototype.hasOwnProperty.call(h,q)&&(C=A[q])){c=h[q];var D=[];for(x=0;x=0&&o._disposeHandlers.splice(t,1)},check:x,apply:q,status:function(e){if(!e)return p;u.push(e)},addStatusHandler:function(e){u.push(e)},removeStatusHandler:function(e){var t=u.indexOf(e);t>=0&&u.splice(t,1)},data:a[l]},t=void 0,o),parents:(c=d,d=[],c),children:[]};return e[l].call(r.exports,r,r.exports,h(l)),r.l=!0,r.exports}return S.m=e,S.c=A,S.d=function(e,t,l){S.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:l})},S.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},S.t=function(e,t){if(1&t&&(e=S(e)),8&t||4&t&&"object"==typeof e&&e&&e.__esModule)return e;var l=Object.create(null);if(S.r(l),Object.defineProperty(l,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)S.d(l,o,(function(t){return e[t]}).bind(null,o));return l},S.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return S.d(t,"a",t),t},S.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},S.p="",S.h=function(){return s},h(12)(S.s=12)}([function(e,t){e.exports=r},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t,l){"use strict";l.r(t);var o=l(0),r=l.n(o);function n(e,t){if("object"==typeof t)for(let l in t)e.style[l]=t[l]}function i(e,t){let l=t.getBoundingClientRect();return{x:e.x-l.x-t.scrollLeft,y:e.y-l.y-t.scrollTop,x1:e.x-l.x-t.scrollLeft+e.width,y1:e.y-l.y-t.scrollTop+e.height,width:e.width,height:e.height}}function s(e,t){return e&&Object.keys(e).reduce((l,o)=>t.includes(o)?l:Object.assign({},l,{[o]:e[o]}),{})}function a(e){let t;if(void 0==(t=e.path||e.composedPath&&e.composedPath())&&e.target){t=[];let l=e.target;for(t.push(l);l&&l.parentNode;)l=l.parentNode,t.push(l)}return t}class d{constructor(e,t,l){if(!e)return null;this.table=e,this.quill=t,this.options=l,this.domNode=null,this.initColTool()}initColTool(){let e=this.quill.root.parentNode;this.table.getBoundingClientRect();let t=e.getBoundingClientRect(),l=this.table.parentNode.getBoundingClientRect();this.domNode=document.createElement("div"),this.domNode.classList.add("qlbt-col-tool"),this.updateToolCells(),e.appendChild(this.domNode),n(this.domNode,{width:"".concat(l.width,"px"),height:"".concat(12,"px"),left:"".concat(l.left-t.left+e.scrollLeft,"px"),top:"".concat(l.top-t.top+e.scrollTop-12-5,"px")})}createToolCell(){let e=document.createElement("div");e.classList.add("qlbt-col-tool-cell");let t=document.createElement("div");return t.classList.add("qlbt-col-tool-cell-holder"),n(e,{height:"".concat(12,"px")}),e.appendChild(t),e}updateToolCells(){let e=r.a.find(this.table),t=e.children.tail.children.head.children,l=e.colGroup().children,o=t.reduce((e,t)=>e+=parseInt(t.formats().colspan,10),0),i=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"));for(let e=0;e=o?i[e].remove():n(s=i[e],{"min-width":"".concat(r,"px")}):(s=this.createToolCell(),this.domNode.appendChild(s),this.addColCellHolderHandler(s),n(s,{"min-width":"".concat(r,"px")}))}}destroy(){return this.domNode.remove(),null}addColCellHolderHandler(e){let t=r.a.find(this.table),l=e.querySelector(".qlbt-col-tool-cell-holder"),o=!1,i=0,s=0,a=0,d=0,c={},h={},u=null,p=e=>{e.preventDefault(),o&&(s=e.clientX,a=d+s-i>=50?s-i:50-d,n(u,{left:"".concat(h.left+h.width-1+a,"px")}))},m=r=>{r.preventDefault();let f=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell")).indexOf(e),b=t.colGroup().children.at(f);o&&(b.format("width",d+a),n(e,{"min-width":"".concat(d+a,"px")}),i=0,s=0,a=0,d=0,o=!1,l.classList.remove("dragging")),document.removeEventListener("mousemove",p,!1),document.removeEventListener("mouseup",m,!1),c={},h={},u.remove(),u=null,t.updateTableWidth();let g=this.quill.getModule("better-table").tableSelection;g&&g.clearSelection()};l.addEventListener("mousedown",t=>{document.addEventListener("mousemove",p,!1),document.addEventListener("mouseup",m,!1),c=this.table.getBoundingClientRect(),h=e.getBoundingClientRect(),n(u=document.createElement("div"),{position:"fixed",top:"".concat(h.top,"px"),left:"".concat(h.left+h.width-1,"px"),zIndex:"100",height:"".concat(c.height+12+4,"px"),width:"1px",backgroundColor:"#35A7ED"}),document.body.appendChild(u),o=!0,i=t.clientX,d=h.width,l.classList.add("dragging")},!1)}colToolCells(){return Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"))}}let c=r.a.import("blots/block");class h extends c{static create(e){"string"==typeof e&&(e={value:e});let t=super.create(e.value);return g.forEach(l=>{e[l]&&t.setAttribute("data-".concat(l),e[l])}),v.forEach(l=>{e[l]&&t.setAttribute("data-".concat(l),e[l])}),t}static formats(e){let t={};return t.value=this.tagName.indexOf(e.tagName)+1,v.concat(g).reduce((t,l)=>(e.hasAttribute("data-".concat(l))&&(t[l]=e.getAttribute("data-".concat(l))||void 0),t),t)}format(e,t){let{row:l,cell:o,rowspan:r,colspan:n}=h.formats(this.domNode);e===h.blotName?t?super.format(e,{value:t,row:l,cell:o,rowspan:r,colspan:n}):l?this.replaceWith(w.blotName,{row:l,cell:o,rowspan:r,colspan:n}):super.format(e,t):super.format(e,t)}optimize(e){let{row:t,rowspan:l,colspan:o}=h.formats(this.domNode);if(!t||this.parent instanceof x||this.wrap(x.blotName,{row:t,colspan:o,rowspan:l}),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){let e=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(e)}else this.remove();this.cache={}}}h.blotName="header",h.tagName=["H1","H2","H3","H4","H5","H6"];let u=r.a.import("blots/break"),p=r.a.import("blots/block"),m=r.a.import("blots/container"),f=["width"],b={width:100},g=["row","cell"],v=["rowspan","colspan"],y={rowspan:1,colspan:1};class w extends p{static create(e){let t=super.create(e);return g.forEach(l=>{t.setAttribute("data-".concat(l),e[l]||("row"===l?T:H)())}),v.forEach(l=>{t.setAttribute("data-".concat(l),e[l]||y[l])}),e["cell-bg"]&&t.setAttribute("data-cell-bg",e["cell-bg"]),t}static formats(e){return v.concat(g).concat(["cell-bg"]).reduce((t,l)=>(e.hasAttribute("data-".concat(l))&&(t[l]=e.getAttribute("data-".concat(l))||void 0),t),{})}format(e,t){if(v.concat(g).indexOf(e)>-1)t?this.domNode.setAttribute("data-".concat(e),t):this.domNode.removeAttribute("data-".concat(e));else if("cell-bg"===e)t?this.domNode.setAttribute("data-cell-bg",t):this.domNode.removeAttribute("data-cell-bg");else if("header"===e){if(!t)return;let{row:l,cell:o,rowspan:r,colspan:n}=w.formats(this.domNode);super.format(e,{value:t,row:l,cell:o,rowspan:r,colspan:n})}else super.format(e,t)}optimize(e){let t=this.domNode.getAttribute("data-row"),l=this.domNode.getAttribute("data-rowspan"),o=this.domNode.getAttribute("data-colspan"),r=this.domNode.getAttribute("data-cell-bg");!this.statics.requiredContainer||this.parent instanceof this.statics.requiredContainer||this.wrap(this.statics.requiredContainer.blotName,{row:t,colspan:o,rowspan:l,"cell-bg":r}),super.optimize(e)}tableCell(){return this.parent}}w.blotName="table-cell-line",w.className="qlbt-cell-line",w.tagName="P";class x extends m{checkMerge(){if(super.checkMerge()&&null!=this.next.children.head){let e=this.children.head.formats()[this.children.head.statics.blotName],t=this.children.tail.formats()[this.children.tail.statics.blotName],l=this.next.children.head.formats()[this.next.children.head.statics.blotName],o=this.next.children.tail.formats()[this.next.children.tail.statics.blotName];return e.cell===t.cell&&e.cell===l.cell&&e.cell===o.cell}return!1}static create(e){let t=super.create(e);return t.setAttribute("data-row",e.row),v.forEach(l=>{e[l]&&t.setAttribute(l,e[l])}),e["cell-bg"]&&(t.setAttribute("data-cell-bg",e["cell-bg"]),t.style.backgroundColor=e["cell-bg"]),t}static formats(e){let t={};return e.hasAttribute("data-row")&&(t.row=e.getAttribute("data-row")),e.hasAttribute("data-cell-bg")&&(t["cell-bg"]=e.getAttribute("data-cell-bg")),v.reduce((t,l)=>(e.hasAttribute(l)&&(t[l]=e.getAttribute(l)),t),t)}cellOffset(){return this.parent?this.parent.children.indexOf(this):-1}formats(){let e={};return this.domNode.hasAttribute("data-row")&&(e.row=this.domNode.getAttribute("data-row")),this.domNode.hasAttribute("data-cell-bg")&&(e["cell-bg"]=this.domNode.getAttribute("data-cell-bg")),v.reduce((e,t)=>(this.domNode.hasAttribute(t)&&(e[t]=this.domNode.getAttribute(t)),e),e)}toggleAttribute(e,t){t?this.domNode.setAttribute(e,t):this.domNode.removeAttribute(e)}formatChildren(e,t){this.children.forEach(l=>{l.format(e,t)})}format(e,t){v.indexOf(e)>-1?(this.toggleAttribute(e,t),this.formatChildren(e,t)):["row"].indexOf(e)>-1?(this.toggleAttribute("data-".concat(e),t),this.formatChildren(e,t)):"cell-bg"===e?(this.toggleAttribute("data-cell-bg",t),this.formatChildren(e,t),t?this.domNode.style.backgroundColor=t:this.domNode.style.backgroundColor="initial"):super.format(e,t)}optimize(e){let t=this.domNode.getAttribute("data-row");!this.statics.requiredContainer||this.parent instanceof this.statics.requiredContainer||this.wrap(this.statics.requiredContainer.blotName,{row:t}),super.optimize(e)}row(){return this.parent}rowOffset(){return this.row()?this.row().rowOffset():-1}table(){return this.row()&&this.row().table()}}x.blotName="table",x.tagName="TD";class N extends m{checkMerge(){if(super.checkMerge()&&null!=this.next.children.head){let e=this.children.head.formats(),t=this.children.tail.formats(),l=this.next.children.head.formats(),o=this.next.children.tail.formats();return e.row===t.row&&e.row===l.row&&e.row===o.row}return!1}static create(e){let t=super.create(e);return t.setAttribute("data-row",e.row),t}formats(){return["row"].reduce((e,t)=>(this.domNode.hasAttribute("data-".concat(t))&&(e[t]=this.domNode.getAttribute("data-".concat(t))),e),{})}optimize(e){!this.statics.requiredContainer||this.parent instanceof this.statics.requiredContainer||this.wrap(this.statics.requiredContainer.blotName),this.enforceAllowedChildren(),null!=this.uiNode&&this.uiNode!==this.domNode.firstChild&&this.domNode.insertBefore(this.uiNode,this.domNode.firstChild),this.children.length>0&&null!=this.next&&this.checkMerge()&&(this.next.moveChildren(this),this.next.remove())}rowOffset(){return this.parent?this.parent.children.indexOf(this):-1}table(){return this.parent&&this.parent.parent}}N.blotName="table-row",N.tagName="TR";class C extends m{}C.blotName="table-body",C.tagName="TBODY";class q extends p{static create(e){let t=super.create(e);return f.forEach(l=>{t.setAttribute("".concat(l),e[l]||b[l])}),t}static formats(e){return f.reduce((t,l)=>(e.hasAttribute("".concat(l))&&(t[l]=e.getAttribute("".concat(l))||void 0),t),{})}format(e,t){f.indexOf(e)>-1?this.domNode.setAttribute("".concat(e),t||b[e]):super.format(e,t)}html(){return this.domNode.outerHTML}}q.blotName="table-col",q.tagName="col";class A extends m{}A.blotName="table-col-group",A.tagName="colgroup";class S extends m{static create(){return super.create()}constructor(e,t){super(e,t),this.updateTableWidth()}updateTableWidth(){setTimeout(()=>{let e=this.colGroup();if(!e)return;let t=e.children.reduce((e,t)=>e+=parseInt(t.formats()[q.blotName].width,10),0);this.domNode.style.width="".concat(t,"px")},0)}cells(e){return this.rows().map(t=>t.children.at(e))}colGroup(){return this.children.head}deleteColumns(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],l=arguments.length>2?arguments[2]:void 0,[o]=this.descendants(C);if(null==o||null==o.children.head)return;let r=this.descendants(x),n=[],s=[];if(r.forEach(t=>{let o=i(t.domNode.getBoundingClientRect(),l);o.x+5>e.x&&o.x1-5e.x1-5&&s.push(t)}),n.length===r.length)return this.tableDestroy(),!0;t.forEach(e=>{this.colGroup().children.at(t[0]).remove()}),n.forEach(e=>{e.remove()}),s.forEach(e=>{let l=parseInt(e.formats().colspan,10);parseInt(e.formats().width,10),e.format("colspan",l-t.length)}),this.updateTableWidth()}deleteRow(e,t){let[l]=this.descendants(C);if(null==l||null==l.children.head)return;let o=this.descendants(x),r=this.descendants(N),n=[],s=[],a=[],d=r.filter(l=>{let o=i(l.domNode.getBoundingClientRect(),t);return o.y>e.y-5&&o.y1{let o=i(l.domNode.getBoundingClientRect(),t);o.y>e.y-5&&o.y1e.y1-5&&(s.push(l),5>Math.abs(o.y-e.y)&&a.push(l))}),n.length===o.length)return void this.tableDestroy();let c=this.rows().reduce((l,o)=>{let r=i(o.domNode.getBoundingClientRect(),t);return r.y>e.y-5&&r.y1{let l=i(e.domNode.getBoundingClientRect(),t),o=e.parent.next,r=o.children.reduce((e,o)=>{let r=i(o.domNode.getBoundingClientRect(),t);return 5>Math.abs(l.x1-r.x)&&(e=o),e},null);o.insertBefore(e,r),e.format("row",o.formats().row)}),n.forEach(e=>{e.remove()}),s.forEach(e=>{let t=parseInt(e.formats().rowspan,10);e.format("rowspan",t-c)}),d.forEach(e=>e.remove())}tableDestroy(){let e=r.a.find(this.scroll.domNode.parentNode),t=e.getModule("better-table");this.remove(),t.hideTableTools(),e.update(r.a.sources.USER)}insertCell(e,t){let l=H(),o=e.formats().row,r=this.scroll.create(x.blotName,Object.assign({},y,{row:o})),n=this.scroll.create(w.blotName,{row:o,cell:l});r.appendChild(n),t?e.insertBefore(r,t):e.appendChild(r)}insertColumn(e,t){let l=!(arguments.length>2)||void 0===arguments[2]||arguments[2],o=arguments.length>3?arguments[3]:void 0,[r]=this.descendants(C),[n]=this.descendants(A),s=this.descendants(q),a=[],d=[],c=[];if(null==r||null==r.children.head)return;this.descendants(x).forEach(t=>{let r=i(t.domNode.getBoundingClientRect(),o);l?5>Math.abs(r.x1-e.x1)?a.push(t):e.x1-r.x>5&&e.x1-r.x1<-5&&d.push(t):5>Math.abs(r.x-e.x)?a.push(t):e.x-r.x>5&&e.x-r.x1<-5&&d.push(t)}),a.forEach(e=>{let t=l?e.next:e,o=H(),r=e.parent,n=r.formats().row,i=e.formats(),s=this.scroll.create(x.blotName,Object.assign({},y,{row:n,rowspan:i.rowspan})),a=this.scroll.create(w.blotName,{row:n,cell:o,rowspan:i.rowspan});s.appendChild(a),t?r.insertBefore(s,t):r.appendChild(s),c.push(s)});let h=this.scroll.create(q.blotName,!0),u=l?s[t].next:s[t];return u?n.insertBefore(h,u):n.appendChild(h),d.forEach(e=>{let t=e.formats().colspan;e.format("colspan",parseInt(t,10)+1),c.push(e)}),c.sort((e,t)=>e.domNode.getBoundingClientRect().y-t.domNode.getBoundingClientRect().y),this.updateTableWidth(),c}insertRow(e,t,l){let[o]=this.descendants(C);if(null==o||null==o.children.head)return;let r=this.descendants(x),n=T(),s=this.scroll.create(N.blotName,{row:n}),a=[],d=[],c=[];r.forEach(o=>{let r=i(o.domNode.getBoundingClientRect(),l);t?5>Math.abs(r.y1-e.y1)?a.push(o):e.y1-r.y>5&&e.y1-r.y1<-5&&d.push(o):5>Math.abs(r.y-e.y)?a.push(o):e.y-r.y>5&&e.y-r.y1<-5&&d.push(o)});let h=(e,t)=>e.domNode.getBoundingClientRect().x-t.domNode.getBoundingClientRect().x;a.sort(h),a.forEach(e=>{let t=H(),l=e.formats(),o=this.scroll.create(x.blotName,Object.assign({},y,{row:n,colspan:l.colspan})),r=this.scroll.create(w.blotName,{row:n,cell:t,colspan:l.colspan}),i=this.scroll.create(u.blotName);r.appendChild(i),o.appendChild(r),s.appendChild(o),c.push(o)}),d.forEach(e=>{let t=parseInt(e.formats().rowspan,10);e.format("rowspan",t+1),c.push(e)});let p=this.rows().find(o=>{let r=i(o.domNode.getBoundingClientRect(),l);return t?5>Math.abs(r.y-e.y-e.height):5>Math.abs(r.y-e.y)});return o.insertBefore(s,p),c.sort(h),c}mergeCells(e,t,l,o,r){let n=t.reduce((e,t,r)=>(0!==r?(e&&t.moveChildren(e),t.remove()):(t.format("colspan",o),t.format("rowspan",l),e=t),e),null),i=n.domNode.getAttribute("data-row"),s=n.children.head.domNode.getAttribute("data-cell");return n.children.forEach(e=>{e.format("cell",s),e.format("row",i),e.format("colspan",o),e.format("rowspan",l)}),n}unmergeCells(e,t){let l={},o=1,r=1;e.forEach(e=>{if(o=(l=e.formats()).rowspan,(r=l.colspan)>1){let t=e.next,l=e.row();e.format("colspan",1);for(let e=r;e>1;e--)this.insertCell(l,t)}if(o>1){let l=o,n=e.row().next;for(;l>1;){let o=n.children.reduce((l,o)=>{let r=i(e.domNode.getBoundingClientRect(),t),n=i(o.domNode.getBoundingClientRect(),t);return 5>Math.abs(r.x1-n.x)&&(l=o),l},null);for(let e=r;e>0;e--)this.insertCell(n,o);l-=1,n=n.next}e.format("rowspan",1)}})}rows(){let e=this.children.tail;return null==e?[]:e.children.map(e=>e)}}S.blotName="table-container",S.className="quill-better-table",S.tagName="TABLE";class E extends m{constructor(e,t){super(e,t);let l=r.a.find(e.domNode.parentNode);t.addEventListener("scroll",e=>{let t=l.getModule("better-table");t.columnTool&&(t.columnTool.domNode.scrollLeft=e.target.scrollLeft),t.tableSelection&&t.tableSelection.selectedTds.length>0&&t.tableSelection.repositionHelpLines()},!1)}table(){return this.children.head}}function T(){let e=Math.random().toString(36).slice(2,6);return"row-".concat(e)}function H(){let e=Math.random().toString(36).slice(2,6);return"cell-".concat(e)}E.blotName="table-view",E.className="quill-better-table-wrapper",E.tagName="DIV",E.allowedChildren=[S],S.requiredContainer=E,S.allowedChildren=[C,A],C.requiredContainer=S,C.allowedChildren=[N],N.requiredContainer=C,N.allowedChildren=[x],x.requiredContainer=N,x.allowedChildren=[w,h],w.requiredContainer=x,A.allowedChildren=[q],A.requiredContainer=S,q.requiredContainer=A;let M=["left","right","top","bottom"];class B{constructor(e,t,l){if(!e)return null;this.table=e,this.quill=t,this.options=l,this.boundary={},this.selectedTds=[],this.dragging=!1,this.selectingHandler=this.mouseDownHandler.bind(this),this.clearSelectionHandler=this.clearSelection.bind(this),this.helpLinesInitial(),this.quill.root.addEventListener("mousedown",this.selectingHandler,!1),this.quill.on("text-change",this.clearSelectionHandler)}helpLinesInitial(){let e=this.quill.root.parentNode;M.forEach(t=>{this[t]=document.createElement("div"),this[t].classList.add("qlbt-selection-line"),this[t].classList.add("qlbt-selection-line-"+t),n(this[t],{position:"absolute",display:"none","background-color":"#0589f3"}),e.appendChild(this[t])})}mouseDownHandler(e){if(0!==e.button||!e.target.closest(".quill-better-table"))return;this.quill.root.addEventListener("mousemove",r,!1),this.quill.root.addEventListener("mouseup",function e(l){t.quill.root.removeEventListener("mousemove",r,!1),t.quill.root.removeEventListener("mouseup",e,!1),t.dragging=!1},!1);let t=this,l=e.target.closest("td[data-row]"),o=i(l.getBoundingClientRect(),this.quill.root.parentNode);function r(e){if(0!==e.button||!e.target.closest(".quill-better-table"))return;let r=e.target.closest("td[data-row]"),n=i(r.getBoundingClientRect(),t.quill.root.parentNode);t.boundary=O(o,n),t.correctBoundary(),t.selectedTds=t.computeSelectedTds(),t.repositionHelpLines(),l!==r&&t.quill.blur()}this.dragging=!0,this.boundary=O(o,o),this.correctBoundary(),this.selectedTds=this.computeSelectedTds(),this.repositionHelpLines()}correctBoundary(){r.a.find(this.table).descendants(x).forEach(e=>{let{x:t,y:l,width:o,height:r}=i(e.domNode.getBoundingClientRect(),this.quill.root.parentNode);(t+2>=this.boundary.x&&t+2<=this.boundary.x1||t-2+o>=this.boundary.x&&t-2+o<=this.boundary.x1)&&(l+2>=this.boundary.y&&l+2<=this.boundary.y1||l-2+r>=this.boundary.y&&l-2+r<=this.boundary.y1)&&(this.boundary=O(this.boundary,{x:t,y:l,width:o,height:r}))})}computeSelectedTds(){return r.a.find(this.table).descendants(x).reduce((e,t)=>{let{x:l,y:o,width:r,height:n}=i(t.domNode.getBoundingClientRect(),this.quill.root.parentNode);return l+2>=this.boundary.x&&l-2+r<=this.boundary.x1&&o+2>=this.boundary.y&&o-2+n<=this.boundary.y1&&e.push(t),e},[])}repositionHelpLines(){let e=this.table.parentNode.scrollLeft;n(this.left,{display:"block",left:"".concat(this.boundary.x-e-1,"px"),top:"".concat(this.boundary.y,"px"),height:"".concat(this.boundary.height+1,"px"),width:"1px"}),n(this.right,{display:"block",left:"".concat(this.boundary.x1-e,"px"),top:"".concat(this.boundary.y,"px"),height:"".concat(this.boundary.height+1,"px"),width:"1px"}),n(this.top,{display:"block",left:"".concat(this.boundary.x-1-e,"px"),top:"".concat(this.boundary.y,"px"),width:"".concat(this.boundary.width+1,"px"),height:"1px"}),n(this.bottom,{display:"block",left:"".concat(this.boundary.x-1-e,"px"),top:"".concat(this.boundary.y1+1,"px"),width:"".concat(this.boundary.width+1,"px"),height:"1px"})}refreshHelpLinesPosition(){let e=i(this.selectedTds[0].domNode.getBoundingClientRect(),this.quill.root.parentNode),t=i(this.selectedTds[this.selectedTds.length-1].domNode.getBoundingClientRect(),this.quill.root.parentNode);this.boundary=O(e,t),this.repositionHelpLines()}destroy(){return M.forEach(e=>{this[e].remove(),this[e]=null}),this.quill.root.removeEventListener("mousedown",this.selectingHandler,!1),this.quill.off("text-change",this.clearSelectionHandler),null}setSelection(e,t){this.boundary=O(i(e,this.quill.root.parentNode),i(t,this.quill.root.parentNode)),this.correctBoundary(),this.selectedTds=this.computeSelectedTds(),this.repositionHelpLines()}clearSelection(){this.boundary={},this.selectedTds=[],M.forEach(e=>{this[e]&&n(this[e],{display:"none"})})}}function O(e,t){let l=Math.min(e.x,t.x,e.x+e.width-1,t.x+t.width-1),o=Math.max(e.x,t.x,e.x+e.width-1,t.x+t.width-1),r=Math.min(e.y,t.y,e.y+e.height-1,t.y+t.height-1),n=Math.max(e.y,t.y,e.y+e.height-1,t.y+t.height-1);return{x:l,x1:o,y:r,y1:n,width:o-l,height:n-r}}var R=l(1),L=l.n(R),z=l(2),k=l.n(z),I=l(3),D=l.n(I),j=l(4),V=l.n(j),U=l(5),_=l.n(U),P=l(6),W=l.n(P),G=l(7),X=l.n(G),K=l(8),Y=l.n(K),$=l(9),J=l.n($);let F=["white","red","yellow","blue"],Q={insertColumnRight:{text:"Insert column right",iconSrc:L.a,handler(){let e=r.a.find(this.table),t=ee(this.columnToolCells,this.boundary,(e,t)=>5>=Math.abs(e.x+e.width-t.x1),this.quill.root.parentNode),l=e.insertColumn(this.boundary,t,!0,this.quill.root.parentNode);this.tableColumnTool.updateToolCells(),this.quill.update(r.a.sources.USER),this.quill.setSelection(this.quill.getIndex(l[0]),0,r.a.sources.SILENT),this.tableSelection.setSelection(l[0].domNode.getBoundingClientRect(),l[0].domNode.getBoundingClientRect())}},insertColumnLeft:{text:"Insert column left",iconSrc:k.a,handler(){let e=r.a.find(this.table),t=ee(this.columnToolCells,this.boundary,(e,t)=>5>=Math.abs(e.x-t.x),this.quill.root.parentNode),l=e.insertColumn(this.boundary,t,!1,this.quill.root.parentNode);this.tableColumnTool.updateToolCells(),this.quill.update(r.a.sources.USER),this.quill.setSelection(this.quill.getIndex(l[0]),0,r.a.sources.SILENT),this.tableSelection.setSelection(l[0].domNode.getBoundingClientRect(),l[0].domNode.getBoundingClientRect())}},insertRowUp:{text:"Insert row up",iconSrc:D.a,handler(){let e=r.a.find(this.table).insertRow(this.boundary,!1,this.quill.root.parentNode);this.quill.update(r.a.sources.USER),this.quill.setSelection(this.quill.getIndex(e[0]),0,r.a.sources.SILENT),this.tableSelection.setSelection(e[0].domNode.getBoundingClientRect(),e[0].domNode.getBoundingClientRect())}},insertRowDown:{text:"Insert row down",iconSrc:V.a,handler(){let e=r.a.find(this.table).insertRow(this.boundary,!0,this.quill.root.parentNode);this.quill.update(r.a.sources.USER),this.quill.setSelection(this.quill.getIndex(e[0]),0,r.a.sources.SILENT),this.tableSelection.setSelection(e[0].domNode.getBoundingClientRect(),e[0].domNode.getBoundingClientRect())}},mergeCells:{text:"Merge selected cells",iconSrc:_.a,handler(){let e=r.a.find(this.table),t=e.rows().reduce((e,t)=>{let l=i(t.domNode.getBoundingClientRect(),this.quill.root.parentNode);return l.y>this.boundary.y-5&&l.y+l.height{let l=i(t.getBoundingClientRect(),this.quill.root.parentNode);return l.x>this.boundary.x-5&&l.x+l.widthe.x+5>t.x&&e.x+e.width-5(l(i(n.getBoundingClientRect(),o),t)&&r.push(e.indexOf(n)),r),[]));n.deleteColumns(this.boundary,s,this.quill.root.parentNode)||(this.tableColumnTool.updateToolCells(),this.quill.update(r.a.sources.USER),this.tableSelection.clearSelection())}},deleteRow:{text:"Delete selected rows",iconSrc:Y.a,handler(){r.a.find(this.table).deleteRow(this.boundary,this.quill.root.parentNode),this.quill.update(r.a.sources.USER),this.tableSelection.clearSelection()}},deleteTable:{text:"Delete table",iconSrc:J.a,handler(){let e=this.quill.getModule("better-table"),t=r.a.find(this.table);e.hideTableTools(),t.remove(),this.quill.update(r.a.sources.USER)}}};class Z{constructor(e,t,l){let o=t.getModule("better-table");this.tableSelection=o.tableSelection,this.table=e.table,this.quill=t,this.options=l,this.menuItems=Object.assign({},Q,l.items),this.tableColumnTool=o.columnTool,this.boundary=this.tableSelection.boundary,this.selectedTds=this.tableSelection.selectedTds,this.destroyHandler=this.destroy.bind(this),this.columnToolCells=this.tableColumnTool.colToolCells(),this.colorSubTitle=l.color&&l.color.text?l.color.text:"Background Colors",this.cellColors=l.color&&l.color.colors?l.color.colors:F,this.menuInitial(e),this.mount(),document.addEventListener("click",this.destroyHandler,!1)}mount(){document.body.appendChild(this.domNode)}destroy(){return this.domNode.remove(),document.removeEventListener("click",this.destroyHandler,!1),null}menuInitial(e){let{table:t,left:l,top:o}=e;for(let e in this.domNode=document.createElement("div"),this.domNode.classList.add("qlbt-operation-menu"),n(this.domNode,{position:"absolute",left:"".concat(l,"px"),top:"".concat(o,"px"),"min-height":"".concat(150,"px"),width:"".concat(200,"px")}),this.menuItems)this.menuItems[e]&&(this.domNode.appendChild(this.menuItemCreator(Object.assign({},Q[e],this.menuItems[e]))),["insertRowDown","unmergeCells"].indexOf(e)>-1&&this.domNode.appendChild(r()));function r(){let e=document.createElement("div");return e.classList.add("qlbt-operation-menu-dividing"),e}this.options.color&&!1!==this.options.color&&(this.domNode.appendChild(r()),this.domNode.appendChild(function(e){let t=document.createElement("div");return t.classList.add("qlbt-operation-menu-subtitle"),t.innerText=e,t}(this.colorSubTitle)),this.domNode.appendChild(this.colorsItemCreator(this.cellColors)))}colorsItemCreator(e){let t=this,l=document.createElement("div");return l.classList.add("qlbt-operation-color-picker"),e.forEach(e=>{let o=function(e){let l=document.createElement("div");return l.classList.add("qlbt-operation-color-picker-item"),l.setAttribute("data-color",e),l.style.backgroundColor=e,l.addEventListener("click",function(){let l=t.tableSelection.selectedTds;l&&l.length>0&&l.forEach(t=>{t.format("cell-bg",e)})},!1),l}(e);l.appendChild(o)}),l}menuItemCreator(e){let{text:t,iconSrc:l,handler:o}=e,r=document.createElement("div");r.classList.add("qlbt-operation-menu-item");let n=document.createElement("span");n.classList.add("qlbt-operation-menu-icon"),n.innerHTML=l;let i=document.createElement("span");return i.classList.add("qlbt-operation-menu-text"),i.innerText=t,r.appendChild(n),r.appendChild(i),r.addEventListener("click",o.bind(this),!1),r}}function ee(e,t,l,o){return e.reduce((r,n)=>(l(i(n.getBoundingClientRect(),o),t)&&(r=e.indexOf(n)),r),!1)}let et=r.a.import("delta");function el(e,t,l){let o=e.parentNode,r=Array.from(("TABLE"===o.parentNode.tagName?o.parentNode:o.parentNode.parentNode).querySelectorAll("tr")),n=Array.from(o.querySelectorAll("td")),i=r.indexOf(o)+1,a=n.indexOf(e)+1,d=e.getAttribute("colspan")||!1,c=e.getAttribute("rowspan")||!1,h=e.getAttribute("data-cell-bg")||e.style.backgroundColor;return 0===t.length()?t=new et().insert("\n",{"table-cell-line":{row:i,cell:a,rowspan:c,colspan:d}}):(t=t.reduce((e,t)=>{if(t.insert&&"string"==typeof t.insert){let l=[],o=t.insert,r=0;for(let e=0;e{"\n"===l?e.insert("\n",t.attributes):e.insert(l,s(t.attributes,["table","table-cell-line"]))})}else e.insert(t.insert,t.attributes);return e},new et)).reduce((e,t)=>(t.insert&&"string"==typeof t.insert&&t.insert.startsWith("\n")?e.insert(t.insert,Object.assign({},Object.assign({},{row:i},t.attributes.table),{"table-cell-line":{row:i,cell:a,rowspan:c,colspan:d,"cell-bg":h}},s(t.attributes,["table"]))):t.attributes&&t.attributes.background&&t.attributes.background===function(e){if(/^(rgb|RGB)/.test(e)){for(var t=e.toString().match(/\d+/g),l="#",o=0;o<3;o++)l+=("0"+Number(t[o]).toString(16)).slice(-2);return l}if(/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(e)){var r=e.replace(/#/,"").split("");if(6===r.length);else if(3===r.length){for(var n="#",o=0;o{if(t.insert&&"string"==typeof t.insert){let l=[],o=t.insert,r=0;for(let e=0;el.indexOf("\n")&&l.push("\n"),l.forEach(l=>{"\n"===l?e.insert("\n",{"table-cell-line":{row:i,cell:a,rowspan:c,colspan:d}}):e.insert(l,t.attributes)})}else e.insert(t.insert,t.attributes);return e},new et)).reduce((e,t)=>(t.insert&&"string"==typeof t.insert&&t.insert.startsWith("\n")?e.insert(t.insert,Object.assign({},{"table-cell-line":{row:i,cell:a,rowspan:c,colspan:d}})):e.insert(t.insert,Object.assign({},s(t.attributes,["table","table-cell-line"]))),e),new et)}function er(e,t,l){let o=new et,r=e.querySelector("tr");if(null===r)return o;let n=Array.from(r.querySelectorAll("td")).concat(Array.from(r.querySelectorAll("th"))).reduce((e,t)=>e+=parseInt(t.getAttribute("colspan")||1,10),0),i=e.querySelectorAll("col").length;if(i===n)return t;{for(let e=0;e(t.insert(l.insert,l.attributes),l.attributes&&l.attributes["table-col"]&&(e+=l.insert.length)===i&&(t=t.concat(o)),t),new et)}}let en=r.a.import("core/module"),ei=r.a.import("delta");class es extends en{static register(){r.a.register(q,!0),r.a.register(A,!0),r.a.register(w,!0),r.a.register(x,!0),r.a.register(N,!0),r.a.register(C,!0),r.a.register(S,!0),r.a.register(E,!0),r.a.register(E,!0)}constructor(e,t){super(e,t),this.quill.root.addEventListener("click",l=>{let o=a(l);if(!o||o.length<=0)return;let r=o.filter(e=>e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("quill-better-table"))[0];if(r){if(this.table===r)return;this.table&&this.hideTableTools(),this.showTableTools(r,e,t)}else this.table&&this.hideTableTools()},!1),this.quill.root.addEventListener("contextmenu",l=>{if(!this.table)return!0;l.preventDefault();let o=a(l);if(!o||o.length<=0)return;let r=o.filter(e=>e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("quill-better-table"))[0],n=o.filter(e=>e.tagName&&"TR"===e.tagName.toUpperCase()&&e.getAttribute("data-row"))[0],i=o.filter(e=>e.tagName&&"TD"===e.tagName.toUpperCase()&&e.getAttribute("data-row"))[0],s=this.tableSelection.selectedTds.map(e=>e.domNode).includes(i);(this.tableSelection.selectedTds.length<=0||!s)&&this.tableSelection.setSelection(i.getBoundingClientRect(),i.getBoundingClientRect()),this.tableOperationMenu&&(this.tableOperationMenu=this.tableOperationMenu.destroy()),r&&(this.tableOperationMenu=new Z({table:r,row:n,cell:i,left:l.pageX,top:l.pageY},e,t.operationMenu))},!1),e.getModule("keyboard"),e.keyboard.addBinding({key:"Backspace"},{},function(e,t){if(0===e.index||1>=this.quill.getLength())return!0;let[l]=this.quill.getLine(e.index);if(0===t.offset){let[t]=this.quill.getLine(e.index-1);if(null!=t&&"table-cell-line"===t.statics.blotName&&"table-cell-line"!==l.statics.blotName)return!1}return!0});let l=e.keyboard.bindings.Backspace.pop();e.keyboard.bindings.Backspace.splice(0,1,l),e.clipboard.addMatcher("td",el),e.clipboard.addMatcher("th",eo),e.clipboard.addMatcher("table",er),e.clipboard.matchers=e.clipboard.matchers.filter(e=>"tr"!==e[0])}getTable(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.quill.getSelection();if(null==e)return[null,null,null,-1];let[t,l]=this.quill.getLine(e.index);if(null==t||t.statics.blotName!==w.blotName)return[null,null,null,-1];let o=t.tableCell(),r=o.row();return[r.table(),r,o,l]}insertTable(e,t){let l=this.quill.getSelection(!0);if(null==l)return;let o=this.quill.getLeaf(l.index)[0],n=new ei().retain(l.index);if(function e(t){return!!t&&!!t.parent&&(t.parent.statics.blotName===x.blotName||e(t.parent))}(o))return void console.warn("Can not insert table into a table cell.");n.insert("\n"),n=Array(t).fill("\n").reduce((e,t)=>(e.insert(t,{"table-col":!0}),e),n),n=Array(e).fill(0).reduce(e=>{let l=T();return Array(t).fill("\n").reduce((e,t)=>(e.insert(t,{"table-cell-line":{row:l,cell:H()}}),e),e)},n),this.quill.updateContents(n,r.a.sources.USER),this.quill.setSelection(l.index+t+1,r.a.sources.API)}showTableTools(e,t,l){this.table=e,this.columnTool=new d(e,t,l),this.tableSelection=new B(e,t,l)}hideTableTools(){this.columnTool&&this.columnTool.destroy(),this.tableSelection&&this.tableSelection.destroy(),this.tableOperationMenu&&this.tableOperationMenu.destroy(),this.columnTool=null,this.tableSelection=null,this.tableOperationMenu=null,this.table=null}}function ea(e){return{key:e?"ArrowUp":"ArrowDown",collapsed:!0,format:["table-cell-line"],handler(t,l){let o=e?"prev":"next";if(null!=l.line[o])return!0;let n=l.line.parent,i=n.parent[o];if(null!=i&&"table-row"===i.statics.blotName){let e=i.children.head,t=parseInt(e.formats().colspan,10),l=n,o=parseInt(l.formats().colspan,10);for(;null!=l.prev;)o+=parseInt((l=l.prev).formats().colspan,10);for(;null!=e.next&&t0&&this.quill.scroll.deleteAt(e.index,e.length);let o=Object.keys(t.format).reduce((e,o)=>(this.quill.scroll.query(o,l.BLOCK)&&!Array.isArray(t.format[o])&&(e[o]=t.format[o]),e),{});this.quill.insertText(e.index,"\n",o["table-cell-line"],r.a.sources.USER),this.quill.setSelection(e.index+1,r.a.sources.SILENT),this.quill.focus(),Object.keys(t.format).forEach(e=>{null!=o[e]||Array.isArray(t.format[e])||"link"!==e&&this.quill.format(e,t.format[e],r.a.sources.USER)})}},"table-cell-line up":ea(!0),"table-cell-line down":ea(!1),"down-to-table":{key:"ArrowDown",collapsed:!0,handler(e,t){let l=t.line.next;if(l&&"table-view"===l.statics.blotName){let e=l.table().rows()[0].children.head.children.head;return this.quill.setSelection(e.offset(this.quill.scroll),0,r.a.sources.USER),!1}return!0}},"up-to-table":{key:"ArrowUp",collapsed:!0,handler(e,t){let l=t.line.prev;if(l&&"table-view"===l.statics.blotName){let e=l.table().rows(),t=e[e.length-1].children.head.children.head;return this.quill.setSelection(t.offset(this.quill.scroll),0,r.a.sources.USER),!1}return!0}}},t.default=es},,function(e,t,l){e.exports=l(10)}]).default}};