1!function(){try{var e="u">typeof window?window:"u">typeof global?global:"u">typeof globalThis?globalThis:"u">typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="6cad5e21-5797-445f-8fb1-7eb9c05cd163",e._sentryDebugIdIdentifier="sentry-dbid-6cad5e21-5797-445f-8fb1-7eb9c05cd163")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1384],{6761:(e,t,l)=>{l.d(t,{$3:()=>lo,$A:()=>tY,$h:()=>eu,Ad:()=>eA,B2:()=>eP,BE:()=>ed,Bt:()=>t9,CR:()=>lM,Cb:()=>lb,Cd:()=>tZ,D2:()=>e6,D4:()=>tu,D7:()=>e2,Dn:()=>R,Do:()=>tW,Fj:()=>lT,GE:()=>eJ,GG:()=>ta,GW:()=>lC,G_:()=>e7,Gi:()=>G,HF:()=>tT,HZ:()=>tw,J_:()=>lN,Jg:()=>Y,Ji:()=>ea,Jr:()=>ec,Jw:()=>tH,KE:()=>H,KK:()=>M,Ke:()=>P,LI:()=>ls,Lu:()=>j,Mp:()=>e1,Mt:()=>t_,ND:()=>th,Ne:()=>lA,O9:()=>I,OA:()=>ek,Oe:()=>ee,Ok:()=>tF,PN:()=>O,PU:()=>ln,P_:()=>tz,Pg:()=>L,QS:()=>eO,QT:()=>eb,RZ:()=>$,Ro:()=>e3,Rq:()=>eD,Sb:()=>ty,Sd:()=>eI,Sn:()=>tb,T1:()=>ew,TB:()=>td,TL:()=>t4,Tv:()=>lc,Tx:()=>x,Tz:()=>tf,U1:()=>tO,U8:()=>ti,UJ:()=>em,UP:()=>lk,V:()=>lS,V6:()=>lF,VQ:()=>ez,W3:()=>er,W8:()=>D,WA:()=>t8,WO:()=>Q,Wg:()=>lV,Wi:()=>m,XI:()=>tr,XR:()=>lh,Xj:()=>l_,Xk:()=>e5,Xs:()=>K,Yf:()=>eQ,Yi:()=>Z,Zr:()=>eC,_0:()=>eN,_K:()=>U,ar:()=>eW,cC:()=>lu,cm:()=>tl,dJ:()=>ei,dk:()=>la,e1:()=>ly,f5:()=>eZ,f9:()=>e_,fE:()=>lr,fS:()=>X,fU:()=>tv,fh:()=>lv,gD:()=>eB,gy:()=>E,hA:()=>ej,hZ:()=>t5,i7:()=>tp,iC:()=>ld,iX:()=>to,jS:()=>en,jU:()=>eT,jV:()=>tN,k1:()=>ts,k_:()=>tA,l$:()=>e4,l0:()=>et,lf:()=>tV,mc:()=>tj,mm:()=>tK,mx:()=>eS,n:()=>ep,n0:()=>z,n4:()=>eE,nB:()=>lx,nW:()=>lt,ow:()=>tm,pL:()=>tL,pd:()=>t7,qK:()=>tE,qq:()=>tC,qt:()=>lL,r2:()=>g,r6:()=>lP,rL:()=>el,sI:()=>tX,sl:()=>eh,tf:()=>eX,tt:()=>lf,u0:()=>tR,uJ:()=>tD,uO:()=>ef,v2:()=>t6,v3:()=>eR,vG:()=>t2,vK:()=>tM,vR:()=>p,vc:()=>ey,vq:()=>tU,w2:()=>tP,w5:()=>w,wP:()=>B,wg:()=>J,wx:()=>ev,x6:()=>f,xc:()=>t$,yy:()=>ex,z4:()=>eF,zb:()=>eo,zf:()=>eL,zr:()=>N});var i=l(72494),o=l(68019),n=l(18430),r=l(37202),a=l(30209),s=l(54542),d=l(53606),u=l(33719),c=l(7717),h=l(2032),b=l(53509);function g(e,t){let{modelAttribute:l,styleName:i,attributeName:o,attributeType:n,viewElement:r,defaultValue:a,shouldUpcast:s=()=>!0,reduceBoxSides:d=!1}=t;e.for("upcast").attributeToAttribute({view:{name:r,styles:{[i]:/[\s\S]+/}},model:{key:l,value:(e,t,l)=>{if(!s(e))return;let o=w(a,"",l),n=e.getNormalizedStyle(i),r=d?C(n):n;if(o!==r)return r;t.consumable.consume(e,{styles:i})}}}),o&&e.for("upcast").attributeToAttribute({view:{name:r,attributes:{[o]:/.+/}},model:{key:l,value:(e,t,l)=>{if("figure"==e.name||e.hasStyle(i)||"table"==e.name&&"figure"==e.parent.name&&e.parent.hasStyle(i))return;let r=w(a,"",l),s=e.getAttribute(o);if(s&&"length"==n){let e=parseFloat(s);s=isNaN(e)?r:e+(s.includes("%")?"%":"px")}if(r!==s)return s;t.consumable.consume(e,{attributes:o})}}})}function m(e,t,l,i){let{conversion:o}=e;o.for("upcast").add(e=>e.on("element:"+t,(e,t,o)=>{if(!t.modelRange)return;let n=["border-top-width","border-top-color","border-top-style","border-bottom-width","border-bottom-color","border-bottom-style","border-right-width","border-right-color","border-right-style","border-left-width","border-left-color","border-left-style"].filter(e=>t.viewItem.hasStyle(e));if(!n.length)return;let r={styles:n};if(!o.consumable.test(t.viewItem,r))return;let a=[...t.modelRange.getItems({shallow:!0})].pop(),s=a.findAncestor("table",{includeSelf:!0}),d=i;s&&"layout"==s.getAttribute("tableType")&&(d={style:"none",color:"",width:""}),o.consumable.consume(t.viewItem,r);let u={style:t.viewItem.getNormalizedStyle("border-style"),color:t.viewItem.getNormalizedStyle("border-color"),width:t.viewItem.getNormalizedStyle("border-width")},c={style:C(u.style),color:C(u.color),width:C(u.width)};c.style!==d.style&&o.writer.setAttribute(l.style,c.style,a),c.color!==d.color&&o.writer.setAttribute(l.color,c.color,a),c.width!==d.width&&o.writer.setAttribute(l.width,c.width,a)})),e.config.get("experimentalFlags.upcastTableBorderZeroAttributes")&&o.for("upcast").add(e=>{e.on(`element:${t}`,(e,t,i)=>{let{modelRange:o,viewItem:n}
1=t,r=n.is("element","table")?n:n.findAncestor("table");if(!i.consumable.test(r,{attributes:"border"})||"0"!==r.getAttribute("border"))return;let a=o?.start?.nodeAfter;!(!a||Object.values(l).some(e=>a.hasAttribute(e)))&&(i.writer.setAttribute(l.style,"none",a),n.is("element","table")&&i.consumable.consume(n,{attributes:"border"}))})})}function f(e,t){let{modelElement:l,modelAttribute:i,styleName:o}=t;e.for("downcast").attributeToAttribute({model:{name:l,key:i},view:e=>({key:"style",value:{[o]:e}})})}function p(e,t){let{modelAttribute:l,styleName:i}=t;e.for("downcast").add(e=>e.on(`attribute:${l}:table`,(e,t,l)=>{let{item:o,attributeNewValue:n}=t,{mapper:r,writer:a}=l;if(!l.consumable.consume(t.item,e.name))return;let s=[...r.toViewElement(o).getChildren()].find(e=>e.is("element","table"));n?a.setStyle(i,n,s):a.removeStyle(i,s)}))}function w(e,t,l){let i=l.modelRange&&(0,n.$1)(l.modelRange.getItems({shallow:!0})),o=i&&i.is("element")&&i.findAncestor("table",{includeSelf:!0});return o&&"layout"===o.getAttribute("tableType")?t:e}function C(e){if(!e)return;let t=["top","right","bottom","left"];if(!t.every(t=>e[t]))return e;let l=e.top;return t.every(t=>e[t]===l)?l:e}let y="table-style-align-left",_="table-style-align-center",v="table-style-align-right",T="table-style-block-align-left",A="table-style-block-align-right",k=[{view:{name:/^(table|figure)$/,styles:{float:/^(left|none|right)$/}},getAlign:e=>{let t=e.getStyle("float");return"none"===t&&(t="center"),t},getConsumables(e){let t=e.getStyle("float"),l=["float"];return"left"===t&&e.hasStyle("margin-right")?l.push("margin-right"):"right"===t&&e.hasStyle("margin-left")&&l.push("margin-left"),{styles:l}}},{view:{name:/^(table|figure)$/,styles:{"margin-left":"auto","margin-right":"auto"}},getAlign:()=>"center",getConsumables:()=>({styles:["margin-left","margin-right"]})},{view:{name:/^(table|figure)$/,key:"class",value:"table-style-align-left"},getAlign:()=>"left",getConsumables:()=>({classes:y})},{view:{name:/^(table|figure)$/,key:"class",value:v},getAlign:()=>"right",getConsumables:()=>({classes:v})},{view:{name:/^(table|figure)$/,key:"class",value:_},getAlign:()=>"center",getConsumables:()=>({classes:_})},{view:{name:/^(table|figure)$/,key:"class",value:T},getAlign:()=>"blockLeft",getConsumables:()=>({classes:T})},{view:{name:/^(table|figure)$/,key:"class",value:A},getAlign:()=>"blockRight",getConsumables:()=>({classes:A})},{view:{name:/^(table|figure)$/,styles:{"margin-left":"0","margin-right":"auto"}},getAlign:()=>"blockLeft",getConsumables:()=>({styles:["margin-left","margin-right"]})},{view:{name:/^(table|figure)$/,styles:{"margin-left":"auto","margin-right":"0"}},getAlign:()=>"blockRight",getConsumables:()=>({styles:["margin-left","margin-right"]})},{view:{name:"table",attributes:{align:/^(left|center|right)$/}},getAlign:e=>e.getAttribute("align"),getConsumables:()=>({attributes:"align"})}],V={center:{align:"center",style:"margin-left: auto; margin-right: auto;",className:"table-style-align-center"},left:{align:"left",style:"float: left;",className:"table-style-align-left"},right:{align:"right",style:"float: right;",className:"table-style-align-right"},blockLeft:{align:void 0,style:"margin-left: 0; margin-right: auto;",className:T},blockRight:{align:void 0,style:"margin-left: auto; margin-right: 0;",className:A}};class x{_table;_startRow;_endRow;_startColumn;_endColumn;_includeAllSlots;_skipRows;_row;_rowIndex;_column;_cellIndex;_spannedCells;_nextCellAtColumn;_jumpedToStartRow=!1;constructor(e,t={}){this._table=e,this._startRow=void 0!==t.row?t.row:t.startRow||0,this._endRow=void 0!==t.row?t.row:t.endRow,this._startColumn=void 0!==t.column?t.column:t.startColumn||0,this._endColumn=void 0!==t.column?t.column:t.endColumn,this._includeAllSlots=!!t.includeAllSlots,this._skipRows=new Set,this._row=0,this._rowIndex=0,this._column=0,this._cellIndex=0,this._spannedCells=new Map,this._nextCellAtColumn=-1}[Symbol.iterator](){return this}next(){this._canJumpToStartRow()&&this._jumpToNonSpannedRowClosestToStartRow();let e=this._table.getChild(this._rowIndex);if(!e||this._isOverEndRow())return{done:!0,value:void 0};if(!e.is("element","tableRow"))return this._rowIndex++,this.next();if(this._isOverEndColumn())return this._advanceToNextRow();let t=null,l=this._getSpanned();if(l)this._includeAllSlots&&!this._shouldSkipSlot()&&(t=this._formatOutValue(l.cell,l.row,l.column));else{let l=e.getChild(this._cellIndex);if(!l)return this._advanceToNextRow();let i=parseInt(l.getAttribute("colspan")||"1"),o=parseInt(l.getAttribute("rowspan")||"1");(i>1||o>1)&&this._recordSpans(l,o,i),this._shouldSkipSlot()||(t=this._formatOutValue(l)),this._nextCellAtColumn=this._column+i}return this._column++,this._column==this._nextCellAtColumn&&this._cellIndex++,t||this.next()}
1skipRow(e){this._skipRows.add(e)}_advanceToNextRow(){return this._row++,this._rowIndex++,this._column=0,this._cellIndex=0,this._nextCellAtColumn=-1,this.next()}_isOverEndRow(){return void 0!==this._endRow&&this._row>this._endRow}_isOverEndColumn(){return void 0!==this._endColumn&&this._column>this._endColumn}_formatOutValue(e,t=this._row,l=this._column){return{done:!1,value:new S(this,e,t,l)}}_shouldSkipSlot(){let e=this._skipRows.has(this._row),t=this._row<this._startRow,l=this._column<this._startColumn,i=void 0!==this._endColumn&&this._column>this._endColumn;return e||t||l||i}_getSpanned(){let e=this._spannedCells.get(this._row);return e&&e.get(this._column)||null}_recordSpans(e,t,l){let i={cell:e,row:this._row,column:this._column};for(let e=this._row;e<this._row+t;e++)for(let t=this._column;t<this._column+l;t++)(e!=this._row||t!=this._column)&&this._markSpannedCell(e,t,i)}_markSpannedCell(e,t,l){this._spannedCells.has(e)||this._spannedCells.set(e,new Map),this._spannedCells.get(e).set(t,l)}_canJumpToStartRow(){return!!this._startRow&&this._startRow>0&&!this._jumpedToStartRow}_jumpToNonSpannedRowClosestToStartRow(){let e=this._getRowLength(0);for(let t=this._startRow;!this._jumpedToStartRow;t--)e===this._getRowLength(t)&&(this._row=t,this._rowIndex=t,this._jumpedToStartRow=!0)}_getRowLength(e){return[...this._table.getChild(e).getChildren()].reduce((e,t)=>e+parseInt(t.getAttribute("colspan")||"1"),0)}}class S{cell;row;column;cellAnchorRow;cellAnchorColumn;_cellIndex;_rowIndex;_table;constructor(e,t,l,i){this.cell=t,this.row=e._row,this.column=e._column,this.cellAnchorRow=l,this.cellAnchorColumn=i,this._cellIndex=e._cellIndex,this._rowIndex=e._rowIndex,this._table=e._table}get isAnchor(){return this.row===this.cellAnchorRow&&this.column===this.cellAnchorColumn}get cellWidth(){return parseInt(this.cell.getAttribute("colspan")||"1")}get cellHeight(){return parseInt(this.cell.getAttribute("rowspan")||"1")}get rowIndex(){return this._rowIndex}getPositionBefore(){return this._table.root.document.model.createPositionAt(this._table.getChild(this.row),this._cellIndex)}}function P(e,t,l,i,o=1){null!=t&&null!=o&&t>o?i.setAttribute(e,t,l):i.removeAttribute(e,l)}function R(e,t,l={}){let i=e.createElement("tableCell",l);return e.insertElement("paragraph",i),e.insert(i,t),i}function E(e,t){let l=parseInt(t.parent.parent.getAttribute("headingColumns")||"0"),{column:i}=e.getCellLocation(t);return!!l&&i<l}function I(e,t,l){let{modelAttribute:i}=l;e.extend("tableCell",{allowAttributes:[i]}),e.setAttributeProperties(i,{isFormatting:!0}),g(t,{viewElement:/^(td|th)$/,...l}),f(t,{modelElement:"tableCell",...l})}function B(e){let t=e.getSelectedElement();return t&&t.is("element","table")?t:e.getFirstPosition().findAncestor("table")}function F({table:e,row:t,column:l}){for(let{cell:i}of new x(e,{row:t,column:l}))if("header"!==i.getAttribute("tableCellType"))return!1;return!0}function W(e){let{model:t,config:l}=e;return t.schema.checkAttribute("tableCell","tableCellType")&&!0===l.get("experimentalFlags.tableCellTypeSupport")}function D(e,t,l){var i,o,n,r,a;let s,d,{startRow:u,startColumn:c,endRow:h,endColumn:b}=t,g=l.createElement("table"),m=e.getAttribute("tableType");m&&l.setAttribute("tableType",m,g);let f=h-u+1;for(let e=0;e<f;e++)l.insertElement("tableRow",g,"end");for(let{row:t,column:i,cell:o,isAnchor:n,cellAnchorRow:r,cellAnchorColumn:a}of[...new x(e,{startRow:u,endRow:h,startColumn:c,endColumn:b,includeAllSlots:!0})]){let e=t-u,s=g.getChild(e);if(n){let e=l.cloneElement(o);l.append(e,s),M(e,t,i,h,b,l)}else(r<u||a<c)&&R(l,l.createPositionAt(s,"end"))}return i=g,o=e,n=u,r=c,a=l,(s=parseInt(o.getAttribute("headingRows")||"0"))>0&&P("headingRows",s-n,i,a,0),(d=parseInt(o.getAttribute("headingColumns")||"0"))>0&&P("headingColumns",d-r,i,a,0),g}function L(e,t,l=0){let i=[];for(let o of new x(e,{startRow:l,endRow:t-1})){let{row:e,cellHeight:l}=o,n=e+l-1;e<t&&t<=n&&i.push(o)}return i}function N(e,t,l){let i,o=e.parent,n=o.parent,r=o.index,a=parseInt(e.getAttribute("rowspan")),s=t-r,d={},u=a-s;u>1&&(d.rowspan=u);let c=parseInt(e.getAttribute("colspan")||"1");c>1&&(d.colspan=c);let h=r+s,b=[...new x(n,{startRow:r,endRow:h,includeAllSlots:!0})],g=null;for(let t of b){let{row:o,column:n,cell:r}=t;r===e&&void 0===i&&(i=n),void 0!==i&&i===n&&o===h&&(g=R(l,t.getPositionBefore(),d))}
1return P("rowspan",s,e,l),g}function O(e,t){let l=[];for(let i of new x(e)){let{column:e,cellWidth:o}=i,n=e+o-1;e<t&&t<=n&&l.push(i)}return l}function z(e,t,l,i){let o=parseInt(e.getAttribute("colspan")),n=l-t,r={},a=o-n;a>1&&(r.colspan=a);let s=parseInt(e.getAttribute("rowspan")||"1");s>1&&(r.rowspan=s);let d=R(i,i.createPositionAfter(e),r);return P("colspan",n,e,i),d}function M(e,t,l,i,o,n){let r=parseInt(e.getAttribute("colspan")||"1"),a=parseInt(e.getAttribute("rowspan")||"1");l+r-1>o&&P("colspan",o-l+1,e,n,1),t+a-1>i&&P("rowspan",i-t+1,e,n,1)}function H(e,t){let l=Array(t.getColumns(e)).fill(0);for(let{column:t}of new x(e))l[t]++;let i=l.reduce((e,t,l)=>t?e:[...e,l],[]);if(i.length>0){let l=i[i.length-1];return t.removeColumns(e,{at:l}),!0}return!1}function U(e,t){let l=[],i=t.getRows(e);for(let t=0;t<i;t++)e.getChild(t).isEmpty&&l.push(t);if(l.length>0){let i=l[l.length-1];return t.removeRows(e,{at:i}),!0}return!1}function $(e,t){H(e,t)||U(e,t)}function K(e,t){let l=Array.from(new x(e,{startColumn:t.firstColumn,endColumn:t.lastColumn,row:t.lastRow}));if(l.every(({cellHeight:e})=>1===e))return t.lastRow;let i=l[0].cellHeight-1;return t.lastRow+i}function j(e,t){let l=Array.from(new x(e,{startRow:t.firstRow,endRow:t.lastRow,column:t.lastColumn}));if(l.every(({cellWidth:e})=>1===e))return t.lastColumn;let i=l[0].cellWidth-1;return t.lastColumn+i}function q(e){for(let t of e.getChildren())if(t.is("element","table"))return t}function G(){return e=>{e.on("element:figure",(e,t,l)=>{if(!l.consumable.test(t.viewItem,{name:!0,classes:"table"}))return;let i=q(t.viewItem);if(!i||!l.consumable.test(i,{name:!0}))return;l.consumable.consume(t.viewItem,{name:!0,classes:"table"});let o=l.convertItem(i,t.modelCursor),r=(0,n.$1)(o.modelRange.getItems());if(!r||!r.is("element","table")){l.consumable.revert(t.viewItem,{name:!0,classes:"table"}),o.modelRange&&!o.modelRange.isCollapsed&&(t.modelRange=o.modelRange,t.modelCursor=o.modelCursor);return}l.convertChildren(t.viewItem,l.writer.createPositionAt(r,"end")),l.updateConversionResult(r,t)})}}function Q(){return e=>{e.on("element:table",(e,t,l)=>{let i=t.viewItem;if(!l.consumable.test(i,{name:!0}))return;let{rows:o,headingRows:n,headingColumns:r}=function(e){let t,l,i=!0,o=[],n=[];for(let l of Array.from(e.getChildren())){if("tbody"!==l.name&&"thead"!==l.name&&"tfoot"!==l.name)continue;"thead"!==l.name||t||(i=!0,t=l);let e=Array.from(l.getChildren()).filter(e=>e.is("element","tr")),r=null;for(let a of e){let e=Array.from(a.getChildren()).filter(e=>e.is("element","td")||e.is("element","th"));t&&l===t||"tbody"===l.name&&e.length>0&&(null===r||e.length===r)&&e.every(e=>e.is("element","th"))&&i?(o.push(a),i=!0):(n.push(a),i=!1),r=Math.max(r||0,e.length)}}for(let e of function(e){let t=new Map,l=0,i=e.map(e=>{let i=[],o=Array.from(e.getChildren()).filter(e=>"th"===e.name||"td"===e.name),n=new Map;for(;o.length||i.length<l;){let e=t.get(i.length);if(e&&e.remaining>0)i.push(e.cell);else{let e=o.shift();if(e){let t=parseInt(e.getAttribute("colspan")||"1"),l=parseInt(e.getAttribute("rowspan")||"1");for(let o=0;o<t;o++)l>1&&n.set(i.length,{cell:e,remaining:l-1}),i.push(e)}else{i.push(null);continue}}}for(let[e,l]of t.entries())l.remaining-=1,l.remaining>0&&!n.has(e)&&n.set(e,l);return t=n,l=Math.max(l,i.length),i});for(let e of i)for(;e.length<l;)e.push(null);return i}(n)){let t=0;for(;t<e.length&&e[t]?.name==="th";)t+=1;(void 0===l||t<l)&&(l=t)}return{headingRows:o.length,headingColumns:l||0,rows:[...o,...n]}}(i),a={};r&&(a.headingColumns=r),n&&(a.headingRows=n);let s=l.writer.createElement("table",a);if(l.safeInsert(s,t.modelCursor)){if(l.consumable.consume(i,{name:!0}),o.forEach(e=>l.convertItem(e,l.writer.createPositionAt(s,"end"))),l.convertChildren(i,l.writer.createPositionAt(s,"end")),s.isEmpty){let e=l.writer.createElement("tableRow");l.writer.insert(e,l.writer.createPositionAt(s,"end")),R(l.writer,l.writer.createPositionAt(e,"end"))}l.updateConversionResult(s,t)}})}}function J(){return e=>{e.on("element:tr",(e,t)=>{t.viewItem.isEmpty&&0==t.modelCursor.index&&e.stop()},{priority:"high"})}}function X(e){return t=>{t.on(`element:${e}
1`,(e,t,{writer:l})=>{if(!t.modelRange)return;let i=t.modelRange.start.nodeAfter,o=l.createPositionAt(i,0);if(t.viewItem.isEmpty)return void l.insertElement("paragraph",o);let n=Array.from(i.getChildren());if(n.every(e=>e.is("element","$marker"))){let e=l.createElement("paragraph");for(let t of(l.insert(e,l.createPositionAt(i,0)),n))l.move(l.createRangeOn(t),l.createPositionAt(e,"end"))}},{priority:"low"})}}function Z(e){if(!e||!(0,r.G)(e))return e;let{top:t,right:l,bottom:i,left:o}=e;if(t==l&&l==i&&i==o)return t}function Y(e,t){let l=parseFloat(e);return Number.isNaN(l)||String(l)!==String(e)?e:`${l}${t}`}function ee(e,t={}){let l={borderStyle:"none",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:"",...e};return t.includeAlignmentProperty&&!l.alignment&&(l.alignment="center"),t.includePaddingProperty&&!l.padding&&(l.padding=""),t.includeVerticalAlignmentProperty&&!l.verticalAlignment&&(l.verticalAlignment="middle"),t.includeHorizontalAlignmentProperty&&!l.horizontalAlignment&&(l.horizontalAlignment=t.isRightToLeftContent?"right":"left"),l}function et(e,t){return ee({borderStyle:"double",borderColor:"hsl(0, 0%, 70%)",borderWidth:"1px",...e},t)}function el(e,t){return ee({borderStyle:"solid",borderColor:"hsl(0, 0%, 75%)",borderWidth:"1px",...e},t)}function ei(e,t){return(l,{writer:i})=>{var n,r;let a=l.getAttribute("headingRows")||0,s=i.createContainerElement("table",null,[]),d=i.createContainerElement("figure",{class:"table"},s);for(let{positionOffset:o,filter:n}of(a>0&&i.insert(i.createPositionAt(s,"end"),i.createContainerElement("thead",null,i.createSlot(e=>e.is("element","tableRow")&&e.index<a))),a<e.getRows(l)&&i.insert(i.createPositionAt(s,"end"),i.createContainerElement("tbody",null,i.createSlot(e=>e.is("element","tableRow")&&e.index>=a))),t.additionalSlots))i.insert(i.createPositionAt(s,o),i.createSlot(n));return i.insert(i.createPositionAt(s,"after"),i.createSlot(e=>!e.is("element","tableRow")&&!t.additionalSlots.some(({filter:t})=>t(e)))),t.asWidget?(n=d,(r=i).setCustomProperty("table",!0,n),(0,o.Ex)(n,r,{hasSelectionHandle:!0})):d}}function eo(){return(e,{writer:t})=>e.isEmpty?t.createEmptyElement("tr"):t.createContainerElement("tr")}function en(e){return(l,{writer:i})=>{if(e.cellTypeEnabled?.())return t(i,"header"===l.getAttribute("tableCellType")?"th":"td");let o=l.parent,n=o.parent,r=n.getChildIndex(o),a=new x(n,{row:r}),s=n.getAttribute("headingRows")||0,d=n.getAttribute("headingColumns")||0,u=null;for(let e of a)if(e.cell==l){u=t(i,e.row<s||e.column<d?"th":"td");break}return u};function t(t,l){return e.asWidget?(0,o.YN)(t.createEditableElement(l),t,{withAriaRole:!1}):t.createContainerElement(l)}}function er(e={}){return(t,{writer:l})=>{if(!t.parent.is("element","tableCell")||!ea(t))return null;if(e.asWidget)return l.createContainerElement("span",{class:"ck-table-bogus-paragraph"});{let e=l.createContainerElement("p");return l.setCustomProperty("dataPipeline:transparentRendering",!0,e),e}}}function ea(e){return 1==e.parent.childCount&&!function(e){for(let t of e.getAttributeKeys())if(!t.startsWith("selection:")&&"htmlEmptyBlock"!=t)return!0;return!1}(e)}function es(e,t){let l=e.plugins.has("TableLayoutEditing"),i=e.config.get("table.tableLayout.stripFigureFromContentTable")??!0,o=t.findAncestor("table",{includeSelf:!0}),n=o?.getAttribute("tableType");return l&&(i||"layout"===n)}class ed extends i.uB{refresh(){var e,t;let l,i,o=this.editor.model,n=o.document.selection,r=o.schema;this.isEnabled=(e=n,t=r,i=(l=e.getFirstPosition().parent)===l.root?l:l.parent,t.checkChild(i,"table"))}execute(e={}){let t=this.editor,l=t.model,i=t.plugins.get("TableUtils"),o=t.config.get("table.defaultHeadings.rows"),n=t.config.get("table.defaultHeadings.columns");void 0===e.headingRows&&o&&(e.headingRows=o),void 0===e.headingColumns&&n&&(e.headingColumns=n),l.change(t=>{let o=i.createTable(t,e);l.insertObject(o,null,null,{findOptimalPosition:"auto"}),t.setSelection(t.createPositionAt(o.getNodeByPath([0,0,0]),0))})}}class eu extends i.uB{order;constructor(e,t={}){super(e),this.order=t.order||"below"}refresh(){let e=this.editor.model.document.selection,t=!!this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(e).length;this.isEnabled=t}execute(){let e=this.editor,t=e.model.document.selection,l=e.plugins.get("TableUtils"),i="above"===this.order,o=l.getSelectionAffectedTableCells(t),n=l.getRowIndexes(o),r=i?n.first:n.last,a=o[0].findAnce
1stor("table");l.insertRows(a,{at:i?r:r+1,copyStructureFromAbove:!i})}}class ec extends i.uB{order;constructor(e,t={}){super(e),this.order=t.order||"right"}refresh(){let e=this.editor.model.document.selection,t=!!this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(e).length;this.isEnabled=t}execute(){let e=this.editor,t=e.model.document.selection,l=e.plugins.get("TableUtils"),i="left"===this.order,o=l.getSelectionAffectedTableCells(t),n=l.getColumnIndexes(o),r=i?n.first:n.last,a=o[0].findAncestor("table");l.insertColumns(a,{columns:1,at:i?r:r+1})}}class eh extends i.uB{direction;constructor(e,t={}){super(e),this.direction=t.direction||"horizontally"}refresh(){let e=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=1===e.length}execute(){let e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection)[0];"horizontally"===this.direction?e.splitCellHorizontally(t,2):e.splitCellVertically(t,2)}}class eb extends i.uB{direction;isHorizontal;constructor(e,t){super(e),this.direction=t.direction,this.isHorizontal="right"==this.direction||"left"==this.direction}refresh(){let e=this._getMergeableCell();this.value=e,this.isEnabled=!!e}execute(){let e=this.editor.model,t=e.document,l=this.editor.plugins.get("TableUtils").getTableCellsContainingSelection(t.selection)[0],i=this.value,o=this.direction;e.change(e=>{var t,n,r;let a="right"==o||"down"==o,s=a?l:i,d=a?i:l,u=d.parent;t=d,n=s,r=e,eg(t)||(eg(n)&&r.remove(r.createRangeIn(n)),r.move(r.createRangeIn(t),r.createPositionAt(n,"end"))),r.remove(t);let c=this.isHorizontal?"colspan":"rowspan",h=parseInt(l.getAttribute(c)||"1"),b=parseInt(i.getAttribute(c)||"1");e.setAttribute(c,h+b,s),e.setSelection(e.createRangeIn(s));let g=this.editor.plugins.get("TableUtils");$(u.findAncestor("table"),g)})}_getMergeableCell(){let e=this.editor.model.document,t=this.editor.plugins.get("TableUtils"),l=t.getTableCellsContainingSelection(e.selection)[0];if(!l)return;let i=this.isHorizontal?function(e,t,l){let i=e.parent.parent,o="right"==t?e.nextSibling:e.previousSibling,n=(i.getAttribute("headingColumns")||0)>0;if(!o)return;let r="right"==t?e:o,a="right"==t?o:e,{column:s}=l.getCellLocation(r),{column:d}=l.getCellLocation(a),u=parseInt(r.getAttribute("colspan")||"1"),c=E(l,r),h=E(l,a);if(!n||c==h)return s+u===d?o:void 0}(l,this.direction,t):function(e,t,l){let i=e.parent,o=i.parent,n=o.getChildIndex(i);if("down"==t&&n===l.getRows(o)-1||"up"==t&&0===n)return null;let r=parseInt(e.getAttribute("rowspan")||"1"),a=o.getAttribute("headingRows")||0;if(a&&("down"==t&&n+r===a||"up"==t&&n===a))return null;let s=parseInt(e.getAttribute("rowspan")||"1"),d="down"==t?n+s:n,u=[...new x(o,{endRow:d})],c=u.find(t=>t.cell===e).column,h=u.find(({row:e,cellHeight:l,column:i})=>i===c&&("down"==t?e===d:d===e+l));return h&&h.cell?h.cell:null}(l,this.direction,t);if(!i)return;let o=this.isHorizontal?"rowspan":"colspan",n=parseInt(l.getAttribute(o)||"1");if(parseInt(i.getAttribute(o)||"1")===n)return i}}function eg(e){let t=e.getChild(0);return 1==e.childCount&&t.is("element","paragraph")&&t.isEmpty}class em extends i.uB{refresh(){let e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection),l=t[0];if(l){let i=l.findAncestor("table"),o=e.getRows(i),n=e.getRowIndexes(t),r=0===n.first&&n.last===o-1;this.isEnabled=!r}else this.isEnabled=!1}execute(){let e=this.editor.model,t=this.editor.plugins.get("TableUtils"),l=t.getSelectionAffectedTableCells(e.document.selection),i=t.getRowIndexes(l),o=l[0],n=o.findAncestor("table"),r=t.getCellLocation(o).column;e.change(e=>{let l=i.last-i.first+1;t.removeRows(n,{at:i.first,rows:l});let o=function(e,t,l,i){let o=e.getChild(Math.min(t,i-1)),n=o.getChild(0),r=0;for(let e of o.getChildren()){if(r>l)break;n=e,r+=parseInt(e.getAttribute("colspan")||"1")}return n}(n,i.first,r,t.getRows(n));e.setSelection(e.createPositionAt(o,0))})}}class ef extends i.uB{refresh(){let e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection),l=t[0];
1if(l){let i=l.findAncestor("table"),o=e.getColumns(i),{first:n,last:r}=e.getColumnIndexes(t);this.isEnabled=r-n<o-1}else this.isEnabled=!1}execute(){var e,t,l,i,o;let n,r,a,s,d=this.editor.plugins.get("TableUtils"),[u,c]=(e=this.editor.model.document.selection,r=(n=d.getSelectionAffectedTableCells(e))[0],s=[r,a=n.pop()],r.isBefore(a)?s:s.reverse()),h=u.parent.parent,b=[...new x(h)],g={first:b.find(e=>e.cell===u).column,last:b.find(e=>e.cell===c).column},m=(t=b,l=u,i=c,o=g,parseInt(i.getAttribute("colspan")||"1")>1?i:l.previousSibling||i.nextSibling?i.nextSibling||l.previousSibling:o.first?t.reverse().find(({column:e})=>e<o.first).cell:t.reverse().find(({column:e})=>e>o.last).cell);this.editor.model.change(e=>{let t=g.last-g.first+1;d.removeColumns(h,{at:g.first,columns:t}),e.setSelection(e.createPositionAt(m,0))})}}class ep extends i.uB{refresh(){let e=this.editor.plugins.get("TableUtils"),t=this.editor.model,l=e.getSelectionAffectedTableCells(t.document.selection);if(0===l.length){this.isEnabled=!1,this.value=!1;return}
1let i=l[0].findAncestor("table");this.isEnabled=t.schema.checkAttribute(i,"headingRows"),this.value=l.every(e=>this._isInHeading(e,e.parent.parent))}execute(e={}){if(e.forceValue===this.value)return;let t=this.editor.plugins.get("TableUtils"),l=this.editor.model,i=t.getSelectionAffectedTableCells(l.document.selection),o=i[0].findAncestor("table"),{first:n,last:r}=t.getRowIndexes(i),a=this.value?n:r+1,s=o.getAttribute("headingRows")||0;l.change(e=>{if(a){let t=a>s?s:0;for(let{cell:l}of L(o,a,t))N(l,a,e)}t.setHeadingRowsCount(e,o,a)})}_isInHeading(e,t){let l=parseInt(t.getAttribute("headingRows")||"0");return!!l&&e.parent.index<l}}class ew extends i.uB{refresh(){let e=this.editor.plugins.get("TableUtils"),t=this.editor.model,l=e.getSelectionAffectedTableCells(t.document.selection);if(0===l.length){this.isEnabled=!1,this.value=!1;return}let i=l[0].findAncestor("table");this.isEnabled=t.schema.checkAttribute(i,"headingColumns"),this.value=l.every(t=>E(e,t))}execute(e={}){if(e.forceValue===this.value)return;let t=this.editor.plugins.get("TableUtils"),l=this.editor.model,i=t.getSelectionAffectedTableCells(l.document.selection),o=i[0].findAncestor("table"),{first:n,last:r}=t.getColumnIndexes(i),a=this.value?n:r+1;l.change(e=>{if(a)for(let{cell:t,column:l}of O(o,a))z(t,l,a,e);t.setHeadingColumnsCount(e,o,a)})}}let eC=5,ey=40,e_=2,ev=3;function eT(e){let t=new Set;for(let l of e.document.differ.getChanges()){let i=null;switch(l.type){case"insert":i=["table","tableRow","tableCell"].includes(l.name)?l.position:null;break;case"remove":i=["tableRow","tableCell"].includes(l.name)?l.position:null;break;case"attribute":l.range.start.nodeAfter&&(i=["table","tableRow","tableCell"].includes(l.range.start.nodeAfter.name)?l.range.start:null)}if(!i)continue;let o=i.nodeAfter&&i.nodeAfter.is("element","table")?i.nodeAfter:i.findAncestor("table");for(let l of e.createRangeOn(o).getItems())l.is("element","table")&&eD(l)&&t.add(l)}return t}function eA(e,t){return 100*ey/ek(e,t)}function ek(e,t){let l=eV(e,"tbody",t)||eV(e,"thead",t);return ex(t.editing.view.domConverter.mapViewToDom(l))}function eV(e,t,l){return[...[...l.editing.mapper.toViewElement(e).getChildren()].find(e=>e.is("element","table")).getChildren()].find(e=>e.is("element",t))}function ex(e){let t=n.Sf.window.getComputedStyle(e);return"border-box"===t.boxSizing?parseFloat(t.width)-parseFloat(t.paddingLeft)-parseFloat(t.paddingRight)-parseFloat(t.borderLeftWidth)-parseFloat(t.borderRightWidth):parseFloat(t.width)}function eS(e,t){let l=t.getCellLocation(e).column;return{leftEdge:l,rightEdge:l+(e.getAttribute("colspan")||1)-1}}function eP(e){let t=Math.pow(10,e_);return Math.round(("number"==typeof e?e:parseFloat(e))*t)/t}function eR(e,t,l){return e<=t?eP(t):e>=l?eP(l):eP(e)}function eE(e,t){return Array(e).fill(t)}function eI(e){return e.map(e=>"number"==typeof e?e:parseFloat(e)).filter(e=>!Number.isNaN(e)).reduce((e,t)=>e+t,0)}function eB(e){let t=function(e){let t=e.filter(e=>"auto"===e).length;if(0===t)return e.map(e=>eP(e));let l=Math.max((100-eI(e))/t,eC);return e.map(e=>"auto"===e?l:e).map(e=>eP(e))}(e.map(e=>"auto"===e||void 0===e?"auto":parseFloat(e.replace("%","")))),l=eI(t);return 100!==l&&(t=t.map(e=>eP(100*e/l)).map((e,t,l)=>t!==l.length-1?e:eP(e+100-eI(l)))),t.map(e=>e+"%")}function eF(e){let t=n.Sf.window.getComputedStyle(e);return"border-box"===t.boxSizing?parseInt(t.width):parseFloat(t.width)+parseFloat(t.paddingLeft)+parseFloat(t.paddingRight)+parseFloat(t.borderWidth)}function eW(e,t,l,i){for(let o=0;o<Math.max(l.length,e.length);o++){let n=e[o],r=l[o];r?n?i.setAttribute("columnWidth",r,n):i.appendElement("tableColumn",{columnWidth:r},t):i.remove(n)}}function eD(e){return e.is("element","tableColumnGroup")?e:Array.from(e.getChildren()).find(e=>e.is("element","tableColumnGroup"))}function eL(e){let t=eD(e);return t?Array.from(t.getChildren()):[]}function eN(e){return eL(e).map(e=>e.getAttribute("columnWidth"))}function eO(e,t){return eL(e).reduce((e,l)=>{let i=l.getAttribute("columnWidth"),o=l.getAttribute("colSpan");if(!o)return e.push(i),e;for(let t=0;t<o;t++)e.push(i);return t.removeAttribute("colSpan",l),e},[])}class ez extends i.k_{static get pluginName(){return"TableUtils"}static get isOfficialPlugin(){return!0}init(){this.decorate("insertColumns"),this.decorate("insertRows")}getCellLocation(e){let t=e.parent,l=t.parent,i=l.getChildIndex(t);for(let{cell:t,row:o,column:n}of new x(l,{row:i}))if(t===e)return{row:o,column:n}}createTable(e,t){let l=e.createElement("table"),i=t.rows||2,o=t.columns||2;return eM(e,l,0,i,o),t.headingRows&&this.setHeadingRowsCount(e,l,Math.min(t.headingRows,i)),t.headingColumns&&this.setHeadingColumnsCount(e,l,Math.min(t.headingColumns,o)),l}insertRows(e,t={}){let l=this.editor.model,i=t.at||0,o=t.rows||1,r=void 0!==t.copyStructureFromAbove,a=t.copyStructureFromAbove?i-1:i,s=W(this.editor),d=this.getRows(e),u=this.getColumns(e);if(i>d)throw new n.Yb("tableutils-insertrows-insert-out-of-range",this,{options:t});l.change(t=>{let l=e.getAttribute("headingRows")||0,n=e.getAttribute("headingColumns")||0;if(l>i&&(l+=o,this.setHeadingRowsCount(t,e,l,{shallow:!0})),!r&&(0===i||i===d)){let r=eM(t,e,i,o,u);if(s)for(let e=0;e<r.length;e++){let o=r[e];for(let r=0;r<u;r++){let a=o[r];(i+e<l||r<n)&&t.setAttribute("tableCellType","header",a)}}return}let c=new x(e,{endRow:r?Math.max(i,a):i}),h=Array(u).fill(1);
1for(let{row:e,column:l,cellHeight:n,cellWidth:s,cell:d}of c){let u=e+n-1,c=e<i&&i<=u,b=e<=a&&a<=u;c?(t.setAttribute("rowspan",n+o,d),h[l]=-s):r&&b&&(h[l]=s)}for(let r=0;r<o;r++){let o=t.createElement("tableRow");t.insert(o,e,i);for(let e=0;e<h.length;e++){let a=h[e],d=t.createPositionAt(o,"end");if(a>0){let o=R(t,d,a>1?{colspan:a}:void 0);s&&(i+r<l||e<n)&&t.setAttribute("tableCellType","header",o)}e+=Math.abs(a)-1}}})}insertColumns(e,t={}){let l=this.editor.model,i=t.at||0,o=t.columns||1,n=W(this.editor);l.change(t=>{let l=e.getAttribute("headingRows")||0,r=e.getAttribute("headingColumns");i<r&&(r+=o,this.setHeadingColumnsCount(t,e,r,{shallow:!0}));let a=this.getColumns(e);if(0===i||a===i){let a=0;for(let s of e.getChildren()){if(!s.is("element","tableRow"))continue;let e=eH(o,t,t.createPositionAt(s,i?"end":0));if(n)for(let o=0;o<e.length;o++)(i+o<r||a<l)&&t.setAttribute("tableCellType","header",e[o]);a++}return}let s=new x(e,{column:i,includeAllSlots:!0});for(let e of s){let{row:a,cell:d,cellAnchorColumn:u,cellAnchorRow:c,cellWidth:h,cellHeight:b}=e;if(u<i){t.setAttribute("colspan",h+o,d);let e=c+b-1;for(let t=a;t<=e;t++)s.skipRow(t)}else{let s=eH(o,t,e.getPositionBefore());if(n)for(let e=0;e<s.length;e++)(i+e<r||a<l)&&t.setAttribute("tableCellType","header",s[e])}}})}removeRows(e,t){let l=this.editor.model,i=t.rows||1,o=this.getRows(e),r=t.at,a=r+i-1;if(a>o-1)throw new n.Yb("tableutils-removerows-row-index-out-of-range",this,{table:e,options:t});l.change(t=>{let l={first:r,last:a},{cellsToMove:i,cellsToTrim:o}=function(e,{first:t,last:l}){let i=new Map,o=[];for(let{row:n,column:r,cellHeight:a,cell:s}of new x(e,{endRow:l})){let e=n+a-1;if(n>=t&&n<=l&&e>l){let e=a-(l-n+1);i.set(r,{cell:s,rowspan:e})}if(n<t&&e>=t){let i;i=e>=l?l-t+1:e-t+1,o.push({cell:s,rowspan:a-i})}}return{cellsToMove:i,cellsToTrim:o}}(e,l);i.size&&function(e,t,l,i){let o,n=[...new x(e,{includeAllSlots:!0,row:t})],r=e.getChild(t);for(let{column:e,cell:t,isAnchor:a}of n)if(l.has(e)){let{cell:t,rowspan:n}=l.get(e),a=o?i.createPositionAfter(o):i.createPositionAt(r,0);i.move(i.createRangeOn(t),a),P("rowspan",n,t,i),o=t}else a&&(o=t)}(e,a+1,i,t);for(let l=a;l>=r;l--)t.remove(e.getChild(l));for(let{rowspan:e,cell:l}of o)P("rowspan",e,l,t);if(function(e,{first:t,last:l},i){let o=e.getAttribute("headingRows")||0;t<o&&P("headingRows",l<o?o-(l-t+1):t,e,i,0)}(e,l,t),H(e,this)||U(e,this),W(this.editor)){let l=e.getAttribute("headingRows")||0,i=this.getRows(e);for(;l<i&&F({table:e,row:l});)l++;this.setHeadingRowsCount(t,e,l,{shallow:!0})}})}removeColumns(e,t){let l=this.editor.model,i=t.at,o=t.columns||1,n=t.at+o-1;l.change(t=>{var l=e,o={first:i,last:n},r=t;let a=l.getAttribute("headingColumns")||0;if(a&&o.first<a){let e=Math.min(a-1,o.last)-o.first+1;r.setAttribute("headingColumns",a-e,l)}let s=eL(e);for(let l=n;l>=i;l--){for(let{cell:i,column:o,cellWidth:n}of[...new x(e)])o<=l&&n>1&&o+n>l?P("colspan",n-1,i,t):o===l&&t.remove(i);if(s[l]){let e=0===l?s[1]:s[l-1],i=parseFloat(s[l].getAttribute("columnWidth")),o=parseFloat(e.getAttribute("columnWidth"));t.remove(s[l]),t.setAttribute("columnWidth",i+o+"%",e)}}if(U(e,this)||H(e,this),W(this.editor)){let l=e.getAttribute("headingColumns")||0,i=this.getColumns(e);for(;l<i&&F({table:e,column:l});)l++;this.setHeadingColumnsCount(t,e,l,{shallow:!0})}})}splitCellVertically(e,t=2){let l=this.editor.model,i=e.parent.parent,o=parseInt(e.getAttribute("rowspan")||"1"),n=parseInt(e.getAttribute("colspan")||"1");l.change(l=>{if(n>1){let{newCellsSpan:i,updatedSpan:r}=eU(n,t);P("colspan",r,e,l);let a={};i>1&&(a.colspan=i),o>1&&(a.rowspan=o),eH(n>t?t-1:n-1,l,l.createPositionAfter(e),a)}if(n<t){let r=t-n,a=[...new x(i)],{column:s}=a.find(({cell:t})=>t===e);for(let{cell:t,cellWidth:i}of a.filter(({cell:t,cellWidth:l,column:i})=>t!==e&&i===s||i<s&&i+l>s))l.setAttribute("colspan",i+r,t);let d={};o>1&&(d.rowspan=o),eH(r,l,l.createPositionAfter(e),d);let u=i.getAttribute("headingColumns")||0;u>s&&P("headingColumns",u+r,i,l)}})}splitCellHorizontally(e,t=2){let l=this.editor.model,i=e.parent,o=i.parent,n=o.getChildIndex(i),r=parseInt(e.getAttribute("rowspan")||"1"),a=parseInt(e.getAttribute("colspan")||"1");l.change(l=>{if(r>1){let i=[...new x(o,{startRow:n,endRow:n+r-1,includeAllSlots:!0})],{newCellsSpan:s,updatedSpan:d}=eU(r,t);P("rowspan",d,e,l);let{column:u}=i.find(({cell:t})=>t===e),c={};s>1&&(c.rowspan=s),a>1&&(c.colspan=a);let h=0;for(let e of i){let{column:t,row:i}=e,o=t===u;h>=s&&o&&(h=0),i>=n+d&&o&&(h||eH(1,l,e.getPositionBefore(),c),h++)}}if(r<t){let i=t-r;for(let{cell:t,cellHeight:r,row:a}of[...new x(o,{startRow:0,endRow:n})])if(t!==e&&a+r>n){let e=r+i;
1l.setAttribute("rowspan",e,t)}let s={};a>1&&(s.colspan=a),eM(l,o,n+1,i,1,s);let d=o.getAttribute("headingRows")||0;d>n&&P("headingRows",d+i,o,l)}})}getColumns(e){return[...e.getChild(0).getChildren()].filter(e=>e.is("element","tableCell")).reduce((e,t)=>e+parseInt(t.getAttribute("colspan")||"1"),0)}getRows(e){return Array.from(e.getChildren()).reduce((e,t)=>t.is("element","tableRow")?e+1:e,0)}createTableWalker(e,t={}){return new x(e,t)}getSelectedTableCells(e){let t=[];for(let l of this.sortRanges(e.getRanges())){let e=l.getContainedElement();e&&e.is("element","tableCell")&&t.push(e)}return t}setHeadingRowsCount(e,t,l,i={}){let{shallow:o,resetFormerHeadingCells:n=!0,autoExpand:r=!0}=i,a=t.getAttribute("headingRows")||0;if(l!==a&&(P("headingRows",l,t,e,0),!o&&W(this.editor))){for(let{cell:i,row:o,column:n}of new x(t,{endRow:l-1}))eK({table:t,writer:e,cell:i,row:o,column:n});if(n&&l<a)for(let i=l;i<a&&F({table:t,row:i});i++)for(let{cell:l,row:o,column:n}of new x(t,{row:i}))eK({table:t,writer:e,cell:l,row:o,column:n});if(r&&l>a){let i=this.getRows(t);for(;l<i&&F({table:t,row:l});)l++;P("headingRows",l,t,e,0)}}}setHeadingColumnsCount(e,t,l,i={}){let{shallow:o,resetFormerHeadingCells:n=!0,autoExpand:r=!0}=i,a=t.getAttribute("headingColumns")||0;if(l!==a&&(P("headingColumns",l,t,e,0),!o&&W(this.editor))){for(let{cell:i,row:o,column:n}of new x(t,{endColumn:l-1}))eK({table:t,writer:e,cell:i,row:o,column:n});if(n&&l<a)for(let i=l;i<a&&F({table:t,column:i});i++)for(let{cell:l,row:o,column:n}of new x(t,{column:i}))eK({table:t,writer:e,cell:l,row:o,column:n});if(r&&l>a){let i=this.getColumns(t);for(;l<i&&F({table:t,column:l});)l++;P("headingColumns",l,t,e,0)}}}getTableCellsContainingSelection(e){let t=[];for(let l of e.getRanges()){let e=l.start.findAncestor("tableCell");e&&t.push(e)}return t}getSelectionAffectedTableCells(e){let t=this.getSelectedTableCells(e);return t.length?t:this.getTableCellsContainingSelection(e)}getRowIndexes(e){let t=e.map(e=>e.parent.index);return this._getFirstLastIndexesObject(t)}
1getColumnIndexes(e){let t=[...new x(e[0].findAncestor("table"))].filter(t=>e.includes(t.cell)).map(e=>e.column);return this._getFirstLastIndexesObject(t)}isSelectionRectangular(e){var t,l;let i,o;if(e.length<2||!this._areCellInTheSameTableSection(e))return!1;let n=new Set,r=new Set,a=0;for(let t of e){let{row:e,column:l}=this.getCellLocation(t),i=parseInt(t.getAttribute("rowspan"))||1,o=parseInt(t.getAttribute("colspan"))||1;n.add(e),r.add(l),i>1&&n.add(e+i-1),o>1&&r.add(l+o-1),a+=i*o}return t=n,l=r,i=Array.from(t.values()),(Math.max(...i)-Math.min(...i)+1)*(Math.max(...o=Array.from(l.values()))-Math.min(...o)+1)==a}sortRanges(e){return Array.from(e).sort(e$)}_getFirstLastIndexesObject(e){let t=e.sort((e,t)=>e-t);return{first:t[0],last:t[t.length-1]}}_areCellInTheSameTableSection(e){let t=e[0].findAncestor("table"),l=this.getRowIndexes(e),i=parseInt(t.getAttribute("headingRows"))||0;if(!this._areIndexesInSameSection(l,i))return!1;let o=this.getColumnIndexes(e),n=parseInt(t.getAttribute("headingColumns"))||0;return this._areIndexesInSameSection(o,n)}_areIndexesInSameSection({first:e,last:t},l){return e<l==t<l}}function eM(e,t,l,i,o,n={}){let r=[];for(let a=0;a<i;a++){let i=e.createElement("tableRow");e.insert(i,t,l),r.push(eH(o,e,e.createPositionAt(i,"end"),n))}return r}function eH(e,t,l,i={}){let o=[],n=l;for(let l=0;l<e;l++){let e=R(t,n,i);o.push(e),n=t.createPositionAfter(e)}return o}function eU(e,t){if(e<t)return{newCellsSpan:1,updatedSpan:1};let l=Math.floor(e/t);return{newCellsSpan:l,updatedSpan:e-l*t+l}}function e$(e,t){let l=e.start,i=t.start;return l.isBefore(i)?-1:1}function eK({writer:e,table:t,row:l,column:i,cell:o}){let n=t.getAttribute("headingRows")||0,r=t.getAttribute("headingColumns")||0;l>=n&&i>=r?e.removeAttribute("tableCellType",o):e.setAttribute("tableCellType","header",o)}class ej extends i.uB{refresh(){let e=this.editor.plugins.get(ez),t=e.getSelectedTableCells(this.editor.model.document.selection);this.isEnabled=e.isSelectionRectangular(t)}execute(){let e=this.editor.model,t=this.editor.plugins.get(ez);e.change(l=>{let i=t.getSelectedTableCells(e.document.selection),o=i.shift(),{mergeWidth:n,mergeHeight:r}=function(e,t,l){let i=0,o=0;for(let e of t){let{row:t,column:n}=l.getCellLocation(e);i=eG(e,n,i,"colspan"),o=eG(e,t,o,"rowspan")}let{row:n,column:r}=l.getCellLocation(e);return{mergeWidth:i-r,mergeHeight:o-n}}(o,i,t);for(let e of(P("colspan",n,o,l),P("rowspan",r,o,l),i)){var a,s,d;a=e,s=o,d=l,eq(a)||(eq(s)&&d.remove(d.createRangeIn(s)),d.move(d.createRangeIn(a),d.createPositionAt(s,"end"))),d.remove(a)}$(o.findAncestor("table"),t),l.setSelection(o,"in")})}}function eq(e){let t=e.getChild(0);return 1==e.childCount&&t.is("element","paragraph")&&t.isEmpty}function eG(e,t,l,i){return Math.max(l,t+parseInt(e.getAttribute(i)||"1"))}class eQ extends i.uB{constructor(e){super(e),this.affectsData=!1}refresh(){let e=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=e.length>0}execute(){let e=this.editor.model,t=this.editor.plugins.get("TableUtils"),l=t.getSelectionAffectedTableCells(e.document.selection),i=t.getRowIndexes(l),o=l[0].findAnce
1stor("table"),n=[];for(let t=i.first;t<=i.last;t++)for(let l of o.getChild(t).getChildren())n.push(e.createRangeOn(l));e.change(e=>{e.setSelection(n)})}}class eJ extends i.uB{constructor(e){super(e),this.affectsData=!1}refresh(){let e=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=e.length>0}execute(){let e=this.editor.plugins.get("TableUtils"),t=this.editor.model,l=e.getSelectionAffectedTableCells(t.document.selection),i=l[0],o=l.pop(),n=i.findAncestor("table"),r=e.getCellLocation(i),a=e.getCellLocation(o),s=Math.min(r.column,a.column),d=Math.max(r.column,a.column),u=[];for(let e of new x(n,{startColumn:s,endColumn:d}))u.push(t.createRangeOn(e.cell));t.change(e=>{e.setSelection(u)})}}function eX(e){e.document.registerPostFixer(t=>(function(e,t){let l=t.document.differ.getChanges(),i=!1,o=new Set;for(let t of l){let l=null;"insert"==t.type&&"table"==t.name&&(l=t.position.nodeAfter),("insert"==t.type||"remove"==t.type)&&("tableRow"==t.name||"tableCell"==t.name)&&(l=t.position.findAncestor("table")),function(e){if("attribute"!==e.type)return!1;let t=e.attributeKey;return"headingRows"===t||"colspan"===t||"rowspan"===t}(t)&&(l=t.range.start.findAncestor("table")),l&&!o.has(l)&&(i=function(e,t){let l=!1,i=function(e){let t=parseInt(e.getAttribute("headingRows")||"0"),l=Array.from(e.getChildren()).reduce((e,t)=>t.is("element","tableRow")?e+1:e,0),i=[];for(let{row:o,cell:n,cellHeight:r}of new x(e)){if(r<2)continue;let e=o<t?t:l;if(o+r>e){let t=e-o;i.push({cell:n,rowspan:t})}}return i}(e);if(i.length)for(let e of(l=!0,i))P("rowspan",e.rowspan,e.cell,t,1);return l}(l,e)||i,i=function(e,t){let l=!1,i=function(e){let t=Array(e.childCount).fill(0);for(let{rowIndex:l}of new x(e,{includeAllSlots:!0}))t[l]++;return t}(e),o=[];for(let[t,l]of i.entries())!l&&e.getChild(t).is("element","tableRow")&&o.push(t);if(o.length)for(let n of(l=!0,o.reverse()))t.remove(e.getChild(n)),i.splice(n,1);let n=i.filter((t,l)=>e.getChild(l).is("element","tableRow")),r=n[0];if(!n.every(e=>e===r)){let i=n.reduce((e,t)=>t>e?t:e,0);for(let[o,r]of n.entries()){let n=i-r;if(n){for(let l=0;l<n;l++)R(t,t.createPositionAt(e.getChild(o),"end"));l=!0}}}return l}(l,e)||i,o.add(l))}return i})(t,e))}function eZ(e){e.document.registerPostFixer(t=>(function(e,t){let l=t.document.differ.getChanges(),i=!1;for(let t of l){var o;"insert"==t.type&&"table"==t.name&&(i=function(e,t){let l=!1;for(let i of e.getChildren())i.is("element","tableRow")&&(l=eY(i,t)||l);return l}(t.position.nodeAfter,e)||i),"insert"==t.type&&"tableRow"==t.name&&(i=eY(t.position.nodeAfter,e)||i),"insert"==t.type&&"tableCell"==t.name&&(i=e0(t.position.nodeAfter,e)||i),("remove"==t.type||"insert"==t.type)&&(o=t).position.parent.is("element","tableCell")&&("insert"==o.type&&"$text"==o.name||"remove"==o.type)&&(i=e0(t.position.parent,e)||i)}return i})(t,e))}function eY(e,t){let l=!1;for(let i of e.getChildren())l=e0(i,t)||l;return l}function e0(e,t){if(0==e.childCount)return t.insertElement("paragraph",e),!0;let l=Array.from(e.getChildren()).filter(e=>e.is("$text"));for(let e of l)t.wrap(t.createRangeOn(e),"paragraph");return!!l.length}function e1(e,t){for(let l of e.document.differ.getChanges()){let e,i=!1;if("attribute"==l.type){let t=l.range.start.nodeAfter;if(!t||!t.is("element","table")||"headingRows"!=l.attributeKey&&"headingColumns"!=l.attributeKey)continue;e=t,i="headingRows"==l.attributeKey}else("tableRow"==l.name||"tableCell"==l.name)&&(e=l.position.findAncestor("table"),i="tableRow"==l.name);if(!e)continue;let o=e.getAttribute("headingRows")||0,n=e.getAttribute("headingColumns")||0;for(let l of new x(e)){let e=l.row<o||l.column<n?"th":"td",r=t.mapper.toViewElement(l.cell);r&&r.is("element")&&r.name!=e&&t.reconvertItem(i?l.cell.parent:l.cell)}}}function e5(e,t){let l=e.document.differ,i=new Set;for(let e of l.getChanges()){let t="attribute"==e.type?e.range.start.parent:e.position.parent;t.is("element","tableCell")&&i.add(t)}for(let e of i.values())for(let l of Array.from(e.getChildren()).filter(e=>(function(e,t){if(!e.is("element","paragraph"))return!1;let l=t.toViewElement(e);return!!l&&ea(e)!==l.is("element","span")}
1)(e,t.mapper)))t.reconvertItem(l)}class e2 extends i.k_{_additionalSlots;static get pluginName(){return"TableEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[ez]}constructor(e){super(e),this._additionalSlots=[]}init(){let e=this.editor,t=e.model,l=t.schema,i=e.conversion,o=e.plugins.get(ez);l.register("table",{inheritAllFrom:"$blockObject",allowAttributes:["headingRows","headingColumns"]}),l.register("tableRow",{allowIn:"table",isLimit:!0}),l.register("tableCell",{allowContentOf:"$container",allowIn:"tableRow",allowAttributes:["colspan","rowspan"],isLimit:!0,isSelectable:!0}),i.for("upcast").add(G()),i.for("upcast").add(Q()),i.for("editingDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:ei(o,{asWidget:!0,additionalSlots:this._additionalSlots})}),i.for("dataDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:ei(o,{additionalSlots:this._additionalSlots})}),i.for("upcast").elementToElement({model:"tableRow",view:"tr"}),i.for("upcast").add(J()),i.for("downcast").elementToElement({model:"tableRow",view:eo()}),i.for("upcast").elementToElement({model:"tableCell",view:"td"}),i.for("upcast").elementToElement({model:"tableCell",view:"th"}),i.for("upcast").add(X("td")),i.for("upcast").add(X("th")),i.for("editingDowncast").elementToElement({model:"tableCell",view:en({asWidget:!0,cellTypeEnabled:()=>W(this.editor)})}),i.for("dataDowncast").elementToElement({model:"tableCell",view:en({cellTypeEnabled:()=>W(this.editor)})}),i.for("editingDowncast").elementToElement({model:"paragraph",view:er({asWidget:!0}),converterPriority:"high"}),i.for("dataDowncast").elementToElement({model:"paragraph",view:er(),converterPriority:"high"}),i.for("downcast").attributeToAttribute({model:"colspan",view:"colspan"}),i.for("upcast").attributeToAttribute({model:{key:"colspan",value:e9("colspan")},view:"colspan"}),i.for("downcast").attributeToAttribute({model:"rowspan",view:"rowspan"}),i.for("upcast").attributeToAttribute({model:{key:"rowspan",value:e9("rowspan")},view:"rowspan"}),this._addPlainTableOutputConverters(),e.config.define("table.defaultHeadings.rows",0),e.config.define("table.defaultHeadings.columns",0),e.config.define("table.showHiddenBorders",!0),e.config.get("table.showHiddenBorders")&&e.editing.view.change(t=>{for(let l of e.editing.view.document.roots)t.addClass("ck-table-show-hidden-borders",l)}),e.commands.add("insertTable",new ed(e)),e.commands.add("insertTableRowAbove",new eu(e,{order:"above"})),e.commands.add("insertTableRowBelow",new eu(e,{order:"below"})),e.commands.add("insertTableColumnLeft",new ec(e,{order:"left"})),e.commands.add("insertTableColumnRight",new ec(e,{order:"right"})),e.commands.add("removeTableRow",new em(e)),e.commands.add("removeTableColumn",new ef(e)),e.commands.add("splitTableCellVertically",new eh(e,{direction:"vertically"})),e.commands.add("splitTableCellHorizontally",new eh(e,{direction:"horizontally"})),e.commands.add("mergeTableCells",new ej(e)),e.commands.add("mergeTableCellRight",new eb(e,{direction:"right"})),e.commands.add("mergeTableCellLeft",new eb(e,{direction:"left"})),e.commands.add("mergeTableCellDown",new eb(e,{direction:"down"})),e.commands.add("mergeTableCellUp",new eb(e,{direction:"up"})),e.commands.add("setTableColumnHeader",new ew(e)),e.commands.add("setTableRowHeader",new ep(e)),e.commands.add("selectTableRow",new eQ(e)),e.commands.add("selectTableColumn",new eJ(e)),eX(t),eZ(t),this.listenTo(t.document,"change:data",()=>{W(e)||e1(t,e.editing),e5(t,e.editing)})}registerAdditionalSlot(e){this._additionalSlots.push(e)}_addPlainTableOutputConverters(){let e=this.editor;e.conversion.for("dataDowncast").elementToStructure({model:"table",view:(t,l)=>{let i=e.plugins.has("PlainTableOutput"),o=l.options.isClipboardPipeline,n=e.config.get("experimentalFlags.useExtendedTableBlockAlignment"),r=es(e,t);return i||r||n&&o?function(e,t,l){let i=t.writer,o=e.getAttribute("headingRows")||0,n=i.createSlot(e=>e.is("element","tableRow")&&e.index<o),r=i.createSlot(e=>e.is("element","tableRow")&&e.index>=o),a=i.createSlot(e=>!e.is("element","tableRow")),s=i.createContainerElement("thead",null,n),d=i.createContainerElement("tbody",null,r),u=[];o&&u.push(s),o<e.childCount&&u.push(d);let c={class:"table"};if(l.plugins.has("TablePropertiesEditing")&&t.options.isClipboardPipeline){let t=et(l.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0}),i=e.getAttribute("tableAlignment"),o=t.alignment;"layout"===e.getAttribute("tableType")&&(o="");let n=i||o;n&&(c.class+=" "+V[n].className,c.style=V[n].style,void 0!==V[n].align&&(c.align=V[n].align))}return i.createContainerElement("table",c,[a,...u])}(t,l,e):null},converterPriority:"high"}),e.plugins.has("TableCaptionEditing")&&e.conversion.for("dataDowncast").elementToElement({model:"caption",view:(t,{writer
1:l,options:i})=>{let o=e.plugins.has("PlainTableOutput"),n=i.isClipboardPipeline,r=e.config.get("experimentalFlags.useExtendedTableBlockAlignment"),a=es(e,t);return(o||a||r&&n)&&"table"===t.parent.name?l.createContainerElement("caption"):null},converterPriority:"high"}),e.plugins.has("TablePropertiesEditing")&&function(e){for(let[t,l]of Object.entries({"border-width":"tableBorderWidth","border-color":"tableBorderColor","border-style":"tableBorderStyle","background-color":"tableBackgroundColor"}))e.conversion.for("dataDowncast").add(i=>i.on(`attribute:${l}:table`,(l,i,o)=>{let{item:n,attributeNewValue:r}=i,{mapper:a,writer:s}=o,d=e.plugins.has("PlainTableOutput"),u=o.options.isClipboardPipeline,c=e.config.get("experimentalFlags.useExtendedTableBlockAlignment"),h=es(e,n);if(!(d||h||c&&u)||!o.consumable.consume(n,l.name))return;let b=a.toViewElement(n);r?s.setStyle(t,r,b):s.removeStyle(t,b)},{priority:"high"}))}(e)}}function e9(e){return t=>{let l=parseInt(t.getAttribute(e));return Number.isNaN(l)||l<=0?null:l}}class e7 extends c.Ss{items;keystrokes;focusTracker;constructor(e){super(e);const t=this.bindTemplate;this.items=this._createGridCollection(),this.keystrokes=new n.EP,this.focusTracker=new n.$x,this.set("rows",0),this.set("columns",0),this.bind("label").to(this,"columns",this,"rows",(e,t)=>`${t} \xd7 ${e}`),this.setTemplate({tag:"div",attributes:{class:["ck"]},children:[{tag:"div",attributes:{class:["ck-insert-table-dropdown__grid"]},on:{"[email protected]":t.to("boxover")},children:this.items},{tag:"div",attributes:{class:["ck","ck-insert-table-dropdown__label"],"aria-hidden":!0},children:[{text:t.to("label")}]}],on:{mousedown:t.to(e=>{e.preventDefault()}),click:t.to(()=>{this.fire("execute")})}}),this.on("boxover",(e,t)=>{let{row:l,column:i}=t.target.dataset;this.items.get((parseInt(l,10)-1)*10+(parseInt(i,10)-1)).focus()}),this.focusTracker.on("change:focusedElement",(e,t,l)=>{if(!l)return;let{row:i,column:o}=l.dataset;this.set({rows:parseInt(i),columns:parseInt(o)})}),this.on("change:columns",()=>this._highlightGridBoxes()),this.on("change:rows",()=>this._highlightGridBoxes())}render(){for(let e of(super.render(),(0,c.l1)({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.items,numberOfColumns:10,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection}),this.items))this.focusTracker.add(e.element);this.keystrokes.listenTo(this.element)}reset(){this.set({rows:1,columns:1})}focus(){this.items.get(0).focus()}focusLast(){this.items.get(0).focus()}_highlightGridBoxes(){let e=this.rows,t=this.columns;this.items.map((l,i)=>{let o=Math.floor(i/10);l.set("isOn",o<e&&i%10<t)})}_createGridButton(e,t,l,i){let o=new c._(e);return o.set({label:i,class:"ck-insert-table-dropdown-grid-box"}),o.extendTemplate({attributes:{"data-row":t,"data-column":l}}),o}_createGridCollection(){let e=[];for(let t=0;t<100;t++){let l=Math.floor(t/10),i=t%10,o=`${l+1} \xd7 ${i+1}`;e.push(this._createGridButton(this.locale,l+1,i+1,o))}return this.createCollection(e)}}class e3 extends i.k_{static get pluginName(){return"TableUI"}static get isOfficialPlugin(){return!0}init(){let e=this.editor,t=this.editor.t,l="ltr"===e.locale.contentLanguageDirection;e.ui.componentFactory.add("insertTable",l=>{let i,o=e.commands.get("insertTable"),n=(0,c.yu)(l);return n.bind("isEnabled").to(o),n.buttonView.set({icon:u.e8t,label:t("Insert table"),tooltip:!0}),n.on("change:isOpen",()=>{i||(i=new e7(l),n.panelView.children.add(i),i.delegate("execute").to(n),n.on("execute",()=>{e.execute("insertTable",{rows:i.rows,columns:i.columns}),e.editing.view.focus()}))}),n}),e.ui.componentFactory.add("menuBar:insertTable",l=>{let i=e.commands.get("insertTable"),o=new c.zj(l),n=new e7(l);return n.delegate("execute").to(o),o.on("change:isOpen",(e,t,l)=>{l||n.reset()}),n.on("execute",()=>{e.execute("insertTable",{rows:n.rows,columns:n.columns}),e.editing.view.focus()}),o.buttonView.set({label:t("Table"),icon:u.e8t}),o.panelView.children.add(n),o.bind("isEnabled").to(i),o}),e.ui.componentFactory.add("tableColumn",e=>{let i=[{type:"switchbutton",model:{commandName:"setTableColumnHeader",label:t("Header column"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:l?"insertTableColumnLeft":"insertTableColumnRight",label:t("Insert column left")}},{type:"button",model:{commandName:l?"insertTableColumnRight":"insertTableColumnLeft",label:t("Insert column right")}},{type:"button",model:{commandName:"removeTableColumn",label:t("Delete column")}},{type:"button",model:{commandName:"selectTableColumn",label:t("Select column")}}];return this._prepareDropdown(t("Column"),u.wIt,i,e)}),e.ui.componentFactory.add("tableRow",e=>{let l=[{type:"switchbutton",model:{commandName:"setTableRowHeader",label:t("Header row"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:"insertTableRowAbove",label:t("Insert row above")}},{type:"button",model:{commandName:"insertTableRowBelow",label:t("Insert row below")}},{type:"button",model:{commandName:"removeTableRow",label:t("Delete row")}},{type:"button",model:{commandName:"selectTableRow",label:t("Select row")}}];return this._prepareDropdown(t("Row"),u.EJg,l,e)}),e.ui.componentFactory.add("mergeTableCells",e=>{let i=[{type:"button",model:{commandName:"mergeTableCellUp",label:t("Merge cell up")}},{type:"button",model:{commandName:l?"mergeTableCellRight":"mergeTableCellLeft",label:t("Merge cell right")}},{type:"button",model:{commandName:"mergeTableCellDown",label:t("Merge cell down")}},{type:"button",model:{commandName:l?"mergeTableCellLeft":"mergeTableCellRight",label:t("Merge cell left")}},{type:"separator"},{type:"button",model:{commandName:"splitTableCellVertically",label:t("Split cell vertically")}},{type:"button",model:{commandName:"splitTableCellHorizontally",label:t("Split cell horizontally")}}];return this._prepareMergeSplitButtonDropdown(t("Merge cells"),u.cNs,i,e)})}_prepareDropdown(e,t,l,i){let o=this.editor,n=(0,c.yu)(i),r=this._fillDropdownWithListOptions(n,l);return n.buttonView.set({label:e,icon:t,tooltip:!0}),n.bind("isEnabled").toMany(r,"isEnabled",(...e)=>e.some(e=>e)),this.listenTo(n,"execute",e=>{o.execute(e.source.commandName),e.source instanceof c.Wm||o.editing.view.focus()}),n}_prepareMergeSplitButtonDropdown(e,t,l,i){let o=this.editor,n=(0,c.yu)(i,c.AO),r="mergeTableCells",a=o.commands.get(r),s=this._fillDropdownWithListOptions(n,l);return n.buttonView.set({label:e,icon:t,tooltip:!0,isEnabled:!0}),n.bind("isEnabled").toMany([a,...s],"isEnabled",(...e)=>e.some(e=>e)),this.listenTo(n.buttonView,"execute",()=>{o.execute(r),o.editing.view.focus()}),this.listenTo(n,"execute",e=>{o.execute(e.source.commandName),o.editing.view.focus()}),n}_fillDropdownWithListOptions(e,t){let l=this.editor,i=[],o=new n.pM;for(let e of t)!function(e,t,l,i){if("button"===e.type||"switchbutton"===e.type){let i=e.model=new c.e_(e.model),{commandName:o,bindIsOn:n}=e.model,r=t.commands.get(o);l.push(r),i.set({commandName:o}),i.bind("isEnabled").to(r),n&&i.bind("isOn").to(r,"value"),i.set({withText:!0})}i.add(e)}(e,l,i,o);return(0,c.O)(e,o),i}}class e6 extends i.k_{static get pluginName(){return"TableSelection"}static get isOfficialPlugin(){return!0}static get requires(){return[ez,ez]}init(){let e=this.editor,t=e.model,l=e.editing.view;this.listenTo(t,"deleteContent",(e,t)=>this._handleDeleteContent(e,t),{priority:"high"}),this.listenTo(l.document,"insertText",(e,t)=>this._handleInsertTextEvent(e,t),{priority:"high"}
1),this._defineSelectionConverter(),this._enablePluginDisabling()}getSelectedTableCells(){let e=this.editor.plugins.get(ez),t=this.editor.model.document.selection,l=e.getSelectedTableCells(t);return 0==l.length?null:l}getSelectionAsFragment(){let e=this.editor.plugins.get(ez),t=this.getSelectedTableCells();return t?this.editor.model.change(l=>{let i=l.createDocumentFragment(),{first:o,last:n}=e.getColumnIndexes(t),{first:r,last:a}=e.getRowIndexes(t),s=t[0].findAncestor("table"),d=a,u=n;if(e.isSelectionRectangular(t)){let e={firstColumn:o,lastColumn:n,firstRow:r,lastRow:a};d=K(s,e),u=j(s,e)}let c=D(s,{startRow:r,startColumn:o,endRow:d,endColumn:u},l);return l.insert(c,i,0),i}):null}setCellSelection(e,t){let l=this._getCellsToSelect(e,t);this.editor.model.change(e=>{e.setSelection(l.cells.map(t=>e.createRangeOn(t)),{backward:l.backward})})}getFocusCell(){let e=[...this.editor.model.document.selection.getRanges()].pop().getContainedElement();return e&&e.is("element","tableCell")?e:null}getAnchorCell(){let e=this.editor.model.document.selection,t=(0,n.$1)(e.getRanges()).getContainedElement();return t&&t.is("element","tableCell")?t:null}_defineSelectionConverter(){let e=this.editor,t=new Set;e.conversion.for("editingDowncast").add(e=>e.on("selection",(e,l,i)=>{let o=i.writer;var n=o;for(let e of t)n.removeClass("ck-editor__editable_selected",e);t.clear();let r=this.getSelectedTableCells();if(!r)return;for(let e of r){let l=i.mapper.toViewElement(e);o.addClass("ck-editor__editable_selected",l),t.add(l)}let a=i.mapper.toViewElement(r[r.length-1]);o.setSelection(a,0)},{priority:"lowest"}))}_enablePluginDisabling(){let e=this.editor;this.on("change:isEnabled",()=>{if(!this.isEnabled){let t=this.getSelectedTableCells();t&&e.model.change(l=>{let i=l.createPositionAt(t[0],0),o=e.model.schema.getNearestSelectionRange(i);l.setSelection(o)})}})}_handleDeleteContent(e,t){let l=this.editor.plugins.get(ez),i=t[0],o=t[1],n=this.editor.model,r=!o||"backward"==o.direction,a=l.getSelectedTableCells(i);a.length&&(e.stop(),n.change(e=>{let t=a[r?a.length-1:0];n.change(e=>{for(let t of a)n.deleteContent(e.createSelection(t,"in"))});let l=n.schema.getNearestSelectionRange(e.createPositionAt(t,0));i.is("documentSelection")?e.setSelection(l):i.setTo(l)}))}_handleInsertTextEvent(e,t){let l=this.editor,i=this.getSelectedTableCells();if(!i)return;let o=l.editing.view,n=l.editing.mapper,r=i.map(e=>o.createRangeOn(n.toViewElement(e)));t.selection=o.createSelection(r),t.preventDefault()}_getCellsToSelect(e,t){let l=this.editor.plugins.get("TableUtils"),i=l.getCellLocation(e),o=l.getCellLocation(t),n=Math.min(i.row,o.row),r=Math.max(i.row,o.row),a=Math.min(i.column,o.column),s=parseInt(t.getAttribute("colspan")||"1")-1,d=Math.max(i.column,o.column+s),u=Array(r-n+1).fill(null).map(()=>[]);for(let{row:t,cell:l}of new x(e.findAncestor("table"),{startRow:n,endRow:r,startColumn:a,endColumn:d}))u[t-n].push(l);let c=o.row<i.row,h=o.column<i.column;return c&&u.reverse(),h&&u.forEach(e=>e.reverse()),{cells:u.flat(),backward:c||h}}}class e4 extends i.k_{static get pluginName(){return"TableClipboard"}static get isOfficialPlugin(){return!0}static get requires(){return[h.$J,h.xz,e6,ez]}init(){let e=this.editor.editing.view.document;this.listenTo(e,"copy",(e,t)=>this._onCopyCut(e,t)),this.listenTo(e,"cut",(e,t)=>this._onCopyCut(e,t)),this._listenToContentInsertion(),this.decorate("_replaceTableSlotCell")}_listenToContentInsertion(){let{editor:e}=this,t=e.plugins.get(h.xz),l=e.plugins.get(e6),i=!1;t.on("contentInsertion",(e,t)=>{i="paste"===t.method}),this.listenTo(e.model,"insertContent",(e,[t,o])=>{(i||null!==l.getSelectedTableCells())&&this._onInsertContent(e,t,o)},{priority:"high"}),t.on("contentInsertion",()=>{i=!1},{priority:"lowest"})}_onCopyCut(e,t){let l=this.editor.editing.view,i=this.editor.plugins.get(e6),o=this.editor.plugins.get(h.$J);!i.getSelectedTableCells()||("cut"!=e.name||this.editor.model.canEditAt(this.editor.model.document.selection))&&(t.preventDefault(),e.stop(),this.editor.model.enqueueChange({isUndoable:"cut"===e.name},()=>{let n=o._copySelectedFragmentWithMarkers(e.name,this.editor.model.document.selection,()=>i.getSelectionAsFragment());l.document.fire("clipboardOutput",{dataTransfer:t.dataTransfer,content:this.editor.data.toView(n),method:e.name})}))}_onInsertContent(e,t,l){if(l&&!l.is("documentSelection"))return;let i=this.editor.model,o=this.editor.plugins.get(ez),n=this.editor.plugins.get(h.$J),r=this.getTableIfOnlyTableInContent(t,i);if(!r)return;let a=o.getSelectionAffectedTableCells(i.document.selection);a.length?(e.stop(),t.is("documentFragment")?n._pasteMarkersIntoTransformedElement(t.markers,e=>this._replaceSelectedCells(r,a,e)):this.editor.model.change(e=>{this._replaceSelectedCells(r,a,e)})):$(r,o)}_replaceSelectedCells(e,t,l){var i,o,n,r,a,s,d,u;let c,h,b,g,m,f,p,w=this.editor.plugins.get(ez),C={width:w.getColumns(e),height:w.getRows(e)}
1,y=(i=t,o=C,n=l,r=w,c=i[0].findAncestor("table"),h=r.getColumnIndexes(i),b=r.getRowIndexes(i),g={firstColumn:h.first,lastColumn:h.last,firstRow:b.first,lastRow:b.last},(m=1===i.length)&&(g.lastRow+=o.height-1,g.lastColumn+=o.width-1,a=c,s=g.lastRow+1,d=g.lastColumn+1,f=(u=r).getColumns(a),p=u.getRows(a),d>f&&u.insertColumns(a,{at:f,columns:d-f}),s>p&&u.insertRows(a,{at:p,rows:s-p})),m||!r.isSelectionRectangular(i)?function(e,t,l){let{firstRow:i,lastRow:o,firstColumn:n,lastColumn:r}=t,a={first:i,last:o},s={first:n,last:r};te(e,n,a,l),te(e,r+1,a,l),e8(e,i,s,l),e8(e,o+1,s,l,i)}(c,g,n):(g.lastRow=K(c,g),g.lastColumn=j(c,g)),g),_=y.lastRow-y.firstRow+1,v=y.lastColumn-y.firstColumn+1,T={startRow:0,startColumn:0,endRow:Math.min(_,C.height)-1,endColumn:Math.min(v,C.width)-1};e=D(e,T,l);let A=t[0].findAncestor("table"),k=this._replaceSelectedCellsWithPasted(e,C,A,y,l);if(this.editor.plugins.get("TableSelection").isEnabled){let e=w.sortRanges(k.map(e=>l.createRangeOn(e)));l.setSelection(e)}else l.setSelection(k[0],0);return A}_replaceSelectedCellsWithPasted(e,t,l,i,o){let n,{width:r,height:a}=t,s=function(e,t,l){let i=Array(l).fill(null).map(()=>Array(t).fill(null));for(let{column:t,row:l,cell:o}of new x(e))i[l][t]=o;return i}(e,r,a),d=[...new x(l,{startRow:i.firstRow,endRow:i.lastRow,startColumn:i.firstColumn,endColumn:i.lastColumn,includeAllSlots:!0})],u=[];for(let e of d){let{row:t,column:l}=e;l===i.firstColumn&&(n=e.getPositionBefore());let d=t-i.firstRow,c=l-i.firstColumn,h=s[d%a][c%r],b=h?o.cloneElement(h):null,g=this._replaceTableSlotCell(e,b,n,o);g&&(M(g,t,l,i.lastRow,i.lastColumn,o),u.push(g),n=o.createPositionAfter(g))}let c=parseInt(l.getAttribute("headingRows")||"0"),h=parseInt(l.getAttribute("headingColumns")||"0"),b=i.firstRow<c&&c<=i.lastRow,g=i.firstColumn<h&&h<=i.lastColumn;if(b){let e=e8(l,c,{first:i.firstColumn,last:i.lastColumn},o,i.firstRow);u.push(...e)}if(g){let e=te(l,h,{first:i.firstRow,last:i.lastRow},o);u.push(...e)}return u}_replaceTableSlotCell(e,t,l,i){let{cell:o,isAnchor:n}=e;return(n&&i.remove(o),t)?(i.insert(t,l),t):null}getTableIfOnlyTableInContent(e,t){if(!e.is("documentFragment")&&!e.is("element"))return null;if(e.is("element","table"))return e;if(1==e.childCount&&e.getChild(0).is("element","table"))return e.getChild(0);let l=t.createRangeIn(e);for(let e of l.getItems())if(e.is("element","table")){let i=t.createRange(l.start,t.createPositionBefore(e));if(t.hasContent(i,{ignoreWhitespaces:!0}))return null;let o=t.createRange(t.createPositionAfter(e),l.end);if(t.hasContent(o,{ignoreWhitespaces:!0}))return null;return e}return null}}function e8(e,t,l,i,o=0){if(!(t<1))return L(e,t,o).filter(({column:e,cellWidth:t})=>tt(e,t,l)).map(({cell:e})=>N(e,t,i))}function te(e,t,l,i){if(!(t<1))return O(e,t).filter(({row:e,cellHeight:t})=>tt(e,t,l)).map(({cell:e,column:l})=>z(e,l,t,i))}function tt(e,t,l){let{first:i,last:o}=l;return e>=i&&e<=o||e<i&&e+t-1>=i}class tl extends i.k_{static get pluginName(){return"TableKeyboard"}static get isOfficialPlugin(){return!0}static get requires(){return[e6,ez]}init(){let e=this.editor,t=e.editing.view.document,l=e.t;this.listenTo(t,"arrowKey",(...e)=>this._onArrowKey(...e),{context:"table"}),this.listenTo(t,"tab",(...e)=>this._handleTabOnSelectedTable(...e),{context:"figure"}),this.listenTo(t,"tab",(...e)=>this._handleTab(...e),{context:["th","td"]}),e.accessibility.addKeystrokeInfoGroup({id:"table",label:l("Keystrokes that can be used in a table cell"),keystrokes:[{label:l("Move the selection to the next cell"),keystroke:"Tab"},{label:l("Move the selection to the previous cell"),keystroke:"Shift+Tab"},{label:l("Insert a new table row (when in the last cell of a table)"),keystroke:"Tab"},{label:l("Navigate through the table"),keystroke:[["arrowup"],["arrowright"],["arrowdown"],["arrowleft"]]}]})}_handleTabOnSelectedTable(e,t){let l=this.editor.model.document.selection.getSelectedElement();l&&l.is("element","table")&&t.stopPropagation()}_handleTab(e,t){let l=this.editor,i=this.editor.plugins.get(ez),o=this.editor.plugins.get("TableSelection"),n=l.model.document.selection,r=!t.shiftKey,a=i.getTableCellsContainingSelection(n)[0];if(a||(a=o.getFocusCell()),!a)return;t.stopPropagation();let s=a.parent,d=s.parent,u=d.getChildIndex(s),c=s.getChildIndex(a)===s.childCount-1,h=u===i.getRows(d)-1;r&&h&&c&&l.execute("insertTableRowBelow")}_onArrowKey(e,t){let l=this.editor,i=t.keyCode,o=(0,n.Kf)(i,l.locale.contentLanguageDirection);this._handleArrowKeys(o,t.shiftKey)&&(t.preventDefault(),t.stopPropagation(),e.stop())}_handleArrowKeys(e,t){let l=this.editor.plugins.get(ez),i=this.editor.plugins.get("TableSelection"),o=this.editor.model,n=o.document.selection,r=["right","down"].includes(e),a=l.getSelectedTableCells(n);if(a.length){let l;return l=t?i.getFocusCell():r?a[a.length-1]:a[0],this._navigateFromCellInDirection(l,e,t),!0}
1let s=n.focus.findAncestor("tableCell");if(!s)return!1;if(!n.isCollapsed)if(t){if(n.isBackward==r&&!n.containsEntireContent(s))return!1}else{let e=n.getSelectedElement();if(!e||!o.schema.isObject(e))return!1}return!!this._isSelectionAtCellEdge(n,s,r)&&(this._navigateFromCellInDirection(s,e,t),!0)}_isSelectionAtCellEdge(e,t,l){let i=this.editor.model,o=this.editor.model.schema,n=l?e.getLastPosition():e.getFirstPosition();if(!o.getLimitElement(n).is("element","tableCell"))return i.createPositionAt(t,l?"end":0).isTouching(n);let r=i.createSelection(n);return i.modifySelection(r,{direction:l?"forward":"backward"}),n.isEqual(r.focus)}_navigateFromCellInDirection(e,t,l=!1){let i=this.editor.model,o=e.findAncestor("table"),n=[...new x(o,{includeAllSlots:!0})],{row:r,column:a}=n[n.length-1],s=n.find(({cell:t})=>t==e),{row:d,column:u}=s;switch(t){case"left":u--;break;case"up":d--;break;case"right":u+=s.cellWidth;break;case"down":d+=s.cellHeight}let c=d<0||d>r,h=u<0&&d<=0,b=u>a&&d>=r;if(c||h||b)return void i.change(e=>{e.setSelection(e.createRangeOn(o))});u<0?(u=l?0:a,d--):u>a&&(u=l?a:0,d++);let g=n.find(e=>e.row==d&&e.column==u).cell,m=["right","down"].includes(t),f=this.editor.plugins.get("TableSelection");if(l&&f.isEnabled){let t=f.getAnchorCell()||e;f.setCellSelection(t,g)}else{let e=i.createPositionAt(g,m?0:"end");i.change(t=>{t.setSelection(e)})}}}class ti extends b.$AX{domEventType=["mousemove","mouseleave"];onDomEvent(e){this.fire(e.type,e)}}class to extends i.k_{static get pluginName(){return"TableMouse"}static get isOfficialPlugin(){return!0}static get requires(){return[e6,ez]}init(){this.editor.editing.view.addObserver(ti),this._enableShiftClickSelection(),this._enableMouseDragSelection()}_enableShiftClickSelection(){let e=this.editor,t=e.plugins.get(ez),l=!1,i=e.plugins.get(e6);this.listenTo(e.editing.view.document,"mousedown",(o,n)=>{let r=e.model.document.selection;if(!this.isEnabled||!i.isEnabled||!n.domEvent.shiftKey)return;let a=i.getAnchorCell()||t.getTableCellsContainingSelection(r)[0];if(!a)return;let s=this._getModelTableCellFromDomEvent(n);s&&tn(a,s)&&(l=!0,i.setCellSelection(a,s),n.preventDefault())}),this.listenTo(e.editing.view.document,"mouseup",()=>{l=!1}),this.listenTo(e.editing.view.document,"selectionChange",e=>{l&&e.stop()},{priority:"highest"})}_enableMouseDragSelection(){let e,t,l=this.editor,i=!1,o=!1,n=l.plugins.get(e6);this.listenTo(l.editing.view.document,"mousedown",(t,l)=>{!this.isEnabled||!n.isEnabled||l.domEvent.shiftKey||l.domEvent.ctrlKey||l.domEvent.altKey||(e=this._getModelTableCellFromDomEvent(l))}),this.listenTo(l.editing.view.document,"mousemove",(l,r)=>{if(!r.domEvent.buttons||!e)return;let a=this._getModelTableCellFromDomEvent(r);a&&tn(e,a)&&(t=a,i||t==e||(i=!0)),i&&(o=!0,n.setCellSelection(e,t),r.preventDefault())}),this.listenTo(l.editing.view.document,"mouseup",()=>{i=!1,o=!1,e=null,t=null}),this.listenTo(l.editing.view.document,"selectionChange",e=>{o&&e.stop()},{priority:"highest"})}_getModelTableCellFromDomEvent(e){let t=e.target,l=this.editor.editing.view.createPositionAt(t,0);return this.editor.editing.mapper.toModelPosition(l).parent.findAncestor("tableCell",{includeSelf:!0})}}function tn(e,t){return e.parent.parent==t.parent.parent}class tr extends i.k_{static get requires(){return[e2,e3,e6,to,tl,e4,o.x0]}static get pluginName(){return"Table"}static get isOfficialPlugin(){return!0}}class ta extends i.k_{static get pluginName(){return"PlainTableOutput"}static get isOfficialPlugin(){return!0}static get requires(){return[tr]}init(){this.editor.conversion.for("upcast").add(e=>{e.on("element:table",(e,t,l)=>{l.consumable.consume(t.viewItem,{classes:"table"})})})}}function ts(e){let t=td(e);return t||tu(e)}function td(e){let t=e.getSelectedElement();return t&&tc(t)?t:null}function tu(e){let t=e.getFirstPosition();if(!t)return null;let l=t.parent;for(;l;){if(l.is("element")&&tc(l))return l;l=l.parent}return null}function tc(e){return e.is("element")&&!!e.getCustomProperty("table")&&(0,o.p4)(e)}class th extends i.k_{static get requires(){return[o.oP]}static get pluginName(){return"TableToolbar"}static get isOfficialPlugin(){return!0}afterInit(){let e=this.editor,t=e.t,l=e.plugins.get(o.oP),i=e.config.get("table.contentToolbar"),n=e.config.get("table.tableToolbar");i&&l.register("tableContent",{ariaLabel:t("Table toolbar"),items:i,getRelatedElement:tu}),n&&l.register("table",{ariaLabel:t("Table toolbar"),items:n,getRelatedElement:td})}}class tb extends c.Ss{options;focusTracker;focusCycler;_focusables;dropdownView;
1inputView;keystrokes;_stillTyping;constructor(e,t){super(e),this.set("value",""),this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isEmpty",!0),this.options=t,this.focusTracker=new n.$x,this._focusables=new c.s3,this.dropdownView=this._createDropdownView(),this.inputView=this._createInputTextView(),this.keystrokes=new n.EP,this._stillTyping=!1,this.focusCycler=new c.H({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-input-color"]},children:[this.dropdownView,this.inputView]}),this.on("change:value",(e,t,l)=>this._setInputValue(l))}render(){super.render(),[this.inputView,this.dropdownView.buttonView].forEach(e=>{this.focusTracker.add(e.element),this._focusables.add(e)}),this.keystrokes.listenTo(this.element)}focus(e){-1===e?this.focusCycler.focusLast():this.focusCycler.focusFirst()}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createDropdownView(){let e=this.locale,t=e.t,l=this.bindTemplate,i=this._createColorSelector(e),o=(0,c.yu)(e),n=new c.Ss;return n.setTemplate({tag:"span",attributes:{class:["ck","ck-input-color__button__preview"],style:{backgroundColor:l.to("value")}},children:[{tag:"span",attributes:{class:["ck","ck-input-color__button__preview__no-color-indicator",l.if("value","ck-hidden",e=>""!=e)]}}]}),o.buttonView.extendTemplate({attributes:{class:"ck-input-color__button"}}),o.buttonView.children.add(n),o.buttonView.label=t("Color picker"),o.buttonView.tooltip=!0,o.panelPosition="rtl"===e.uiLanguageDirection?"se":"sw",o.panelView.children.add(i),o.bind("isEnabled").to(this,"isReadOnly",e=>!e),o.on("change:isOpen",(e,t,l)=>{l&&(i.updateSelectedColors(),i.showColorGridsFragment())}),o}_createInputTextView(){let e=this.locale,t=new c.hK(e);return t.extendTemplate({on:{blur:t.bindTemplate.to("blur")}}),t.value=this.value,t.bind("isReadOnly","hasError").to(this),this.bind("isFocused","isEmpty").to(t),t.on("input",()=>{let e=t.element.value,l=this.options.colorDefinitions.find(t=>e===t.label);this._stillTyping=!0,this.value=l&&l.color||e}),t.on("blur",()=>{this._stillTyping=!1,this._setInputValue(t.element.value)}),t.delegate("input").to(this),t}_createColorSelector(e){let t=e.t,l=this.options.defaultColorValue||"",i=t(l?"Restore default":"Remove color"),o=new c.oB(e,{colors:this.options.colorDefinitions,columns:this.options.columns,removeButtonLabel:i,colorPickerLabel:t("Color picker"),colorPickerViewConfig:!1!==this.options.colorPickerConfig&&{...this.options.colorPickerConfig,hideInput:!0}});o.appendUI(),o.on("execute",(e,t)=>{if("colorPickerSaveButton"===t.source){this.dropdownView.isOpen=!1;return}this.value=t.value||l,this.fire("input"),"colorPicker"!==t.source&&(this.dropdownView.isOpen=!1)});let n=this.value;return o.on("colorPicker:cancel",()=>{this.value=n,this.fire("input"),this.dropdownView.isOpen=!1}),o.colorGridsFragmentView.colorPickerButtonView.on("execute",()=>{n=this.value}),o.bind("selectedColor").to(this,"value"),o}_setInputValue(e){if(!this._stillTyping){let t=tg(e),l=this.options.colorDefinitions.find(e=>t===tg(e.color));l?this.inputView.value=l.label:this.inputView.value=e||""}}}function tg(e){return e.replace(/([(,])\s+/g,"$1").replace(/^\s+|\s+(?=[),\s]|$)/g,"").replace(/,|\s/g," ")}function tm(e){return{none:e("None"),solid:e("Solid"),dotted:e("Dotted"),dashed:e("Dashed"),double:e("Double"),groove:e("Groove"),ridge:e("Ridge"),inset:e("Inset"),outset:e("Outset")}}function tf(e){return e('The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".')}function tp(e){return e('The value is invalid. Try "10px" or "2em" or simply "2".')}function tw(e){return""===(e=e.trim().toLowerCase())||(0,b.AA7)(e)}function tC(e){return""===(e=e.trim())||tk(e)||(0,b.n0Z)(e)||(0,b.r_y)(e)}function ty(e){return""===(e=e.trim())||tk(e)||(0,b.n0Z)(e)}function t_(e,t){let l=new n.pM,i=tm(e.t);for(let o in i){let n={type:"button",model:new c.e_({_borderStyleValue:o,label:i[o],role:"menuitemradio",withText:!0})};"none"===o?n.model.bind("isOn").to(e,"borderStyle",e=>"none"===t?!e:e===o):n.model.bind("isOn").to(e,"borderStyle",e=>e===o),l.add(n)}return l}function tv(e){let{view:t,icons:l,toolbar:i,labels:o,propertyName:n,nameToValue:r,defaultValue:a}=e;for(let e in o){let s=new c._(t.locale);s.set({role:"radio",isToggleable:!0,label:o[e],icon:l[e],tooltip:o[e]});let d=r?r(e):e;s.bind("isOn").to(t,n,e=>{let t=e;return""===e&&a&&(t=a),d===t}),s.on("execute",()=>{!a&&d&&t[n]===d?t[n]=void 0:t[n]=d}),i.items.add(s)}}let tT=[{color:"hsl(0, 0%, 0%)",label:"Black"},{color:"hsl(0, 0%, 30%)",label:"Dim grey"},{color:"hsl(0, 0%, 60%)",label:"Grey"},{color:"hsl(0, 0%, 90%)",label:"Light grey"},{color:"hsl(0, 0%, 100%)",label:"White",hasBorder:!0},{color:"hsl(0, 75%, 60%)",label:"Red"},{color:"hsl(30, 75%, 60%)",label:"Orange"},{color:"hsl(60, 75%, 60%)",label:"Yellow"},{color:"hsl(90, 75%, 60%)",label:"Light green"},{color:"hsl(120, 75%, 60%)",label:"Green"},{color:"hsl(150, 75%, 60%)",label:"Aquamarine"},{color:"hsl(180, 75%, 60%)",label:"Turquoise"},{color:"hsl(210, 75%, 60%)",label:"Light blue"},{color:"hsl(240, 75%, 60%)",label:"Blue"},{color:"hsl(270, 75%, 60%)",label:"Purple"}];
1function tA(e){return(t,l,i)=>{let o=new tb(t.locale,{colorDefinitions:e.colorConfig.map(e=>({color:e.model,label:e.label,options:{hasBorder:e.hasBorder}})),columns:e.columns,defaultColorValue:e.defaultColorValue,colorPickerConfig:e.colorPickerConfig});return o.inputView.set({id:l,ariaDescribedById:i}),o.bind("isReadOnly").to(t,"isEnabled",e=>!e),o.bind("hasError").to(t,"errorText",e=>!!e),o.on("input",()=>{t.errorText=null}),t.bind("isEmpty","isFocused").to(o),o}}function tk(e){let t=parseFloat(e);return!Number.isNaN(t)&&e===String(t)}class tV extends c.Ss{options;focusTracker;keystrokes;children;borderStyleDropdown;borderWidthInput;borderColorInput;backgroundInput;paddingInput;widthInput;heightInput;horizontalAlignmentToolbar;verticalAlignmentToolbar;saveButtonView;cancelButtonView;_focusables;_focusCycler;constructor(e,t){super(e),this.set({borderStyle:"",borderWidth:"",borderColor:"",padding:"",backgroundColor:"",width:"",height:"",horizontalAlignment:"",verticalAlignment:""}),this.options=t;const{borderStyleDropdown:l,borderWidthInput:i,borderColorInput:o,borderRowLabel:r}=this._createBorderFields(),{backgroundRowLabel:a,backgroundInput:s}=this._createBackgroundFields(),{widthInput:d,operatorLabel:u,heightInput:h,dimensionsLabel:b}=this._createDimensionFields(),{horizontalAlignmentToolbar:g,verticalAlignmentToolbar:m,alignmentLabel:f}=this._createAlignmentFields();this.focusTracker=new n.$x,this.keystrokes=new n.EP,this.children=this.createCollection(),this.borderStyleDropdown=l,this.borderWidthInput=i,this.borderColorInput=o,this.backgroundInput=s,this.paddingInput=this._createPaddingField(),this.widthInput=d,this.heightInput=h,this.horizontalAlignmentToolbar=g,this.verticalAlignmentToolbar=m;const{saveButtonView:p,cancelButtonView:w}=this._createActionButtons();this.saveButtonView=p,this.cancelButtonView=w,this._focusables=new c.s3,this._focusCycler=new c.H({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.add(new c.Dy(e,{label:this.t("Cell properties")})),this.children.add(new c.Q9(e,{labelView:r,children:[r,l,o,i],class:"ck-table-form__border-row"})),this.children.add(new c.Q9(e,{labelView:a,children:[a,s],class:"ck-table-form__background-row"})),this.children.add(new c.Q9(e,{children:[new c.Q9(e,{labelView:b,children:[b,d,u,h],class:"ck-table-form__dimensions-row"}),new c.Q9(e,{children:[this.paddingInput],class:"ck-table-cell-properties-form__padding-row"})]})),this.children.add(new c.Q9(e,{labelView:f,children:[f,g,m],class:"ck-table-cell-properties-form__alignment-row"})),this.children.add(new c.Q9(e,{children:[this.saveButtonView,this.cancelButtonView],class:"ck-table-form__action-row"})),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-table-form","ck-table-cell-properties-form"],tabindex:"-1"},children:this.children})}render(){super.render(),(0,c.Z5)({view:this}),[this.borderColorInput,this.backgroundInput].forEach(e=>{this._focusCycler.chain(e.fieldView.focusCycler)}),[this.borderStyleDropdown,this.borderColorInput,this.borderWidthInput,this.backgroundInput,this.widthInput,this.heightInput,this.paddingInput,this.horizontalAlignmentToolbar,this.verticalAlignmentToolbar,this.saveButtonView,this.cancelButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBorderFields(){let e=this.options.defaultTableCellProperties,t={style:e.borderStyle,width:e.borderWidth,color:e.borderColor},l=tA({colorConfig:this.options.borderColors,columns:5,defaultColorValue:t.color,colorPickerConfig:this.options.colorPickerConfig}),i=this.locale,o=this.t,n=o("Style"),r=new c.y0(i);r.text=o("Border");let a=tm(o),s=new c.xE(i,c.By);s.set({label:n,class:"ck-table-form__border-style"}),s.fieldView.buttonView.set({ariaLabel:n,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:n}),s.fieldView.buttonView.bind("label").to(this,"borderStyle",e=>a[e||"none"]),s.fieldView.on("execute",e=>{this.borderStyle=e.source._borderStyleValue}),s.bind("isEmpty").to(this,"borderStyle",e=>!e),(0,c.O)(s.fieldView,t_(this,t.style),{role:"menu",ariaLabel:n});let d=new c.xE(i,c.Vr);d.set({label:o("Width"),class:"ck-table-form__border-width"}),d.fieldView.bind("value").to(this,"borderWidth"),d.bind("isEnabled").to(this,"borderStyle",tx),d.fieldView.on("input",()=>{this.borderWidth=d.fieldView.element.value});let u=new c.xE(i,l);return u.set({label:o("Color"),class:"ck-table-form__border-color"}),u.fieldView.bind("value").to(this,"borderColor"),u.bind("isEnabled").to(this,"borderStyle",tx),u.fieldView.on("input",()=>{this.borderColor=u.fieldView.value}),this.on("change:borderStyle",(e,l,i,o)=>{tx(i)||(this.borderColor="",this.borderWidth=""),tx(o)||(this.borderColor=t.color,this.borderWidth=t.width)}),{borderRowLabel:r,borderStyleDropdown:s,borderColorInput:u,borderWidthInput:d}}
1_createBackgroundFields(){let e=this.locale,t=this.t,l=new c.y0(e);l.text=t("Background");let i=tA({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableCellProperties.backgroundColor,colorPickerConfig:this.options.colorPickerConfig}),o=new c.xE(e,i);return o.set({label:t("Color"),class:"ck-table-cell-properties-form__background"}),o.fieldView.bind("value").to(this,"backgroundColor"),o.fieldView.on("input",()=>{this.backgroundColor=o.fieldView.value}),{backgroundRowLabel:l,backgroundInput:o}}_createDimensionFields(){let e=this.locale,t=this.t,l=new c.y0(e);l.text=t("Dimensions");let i=new c.xE(e,c.Vr);i.set({label:t("Width"),class:"ck-table-form__dimensions-row__width"}),i.fieldView.bind("value").to(this,"width"),i.fieldView.on("input",()=>{this.width=i.fieldView.element.value});let o=new c.Ss(e);o.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"\xd7"}]});let n=new c.xE(e,c.Vr);return n.set({label:t("Height"),class:"ck-table-form__dimensions-row__height"}),n.fieldView.bind("value").to(this,"height"),n.fieldView.on("input",()=>{this.height=n.fieldView.element.value}),{dimensionsLabel:l,widthInput:i,operatorLabel:o,heightInput:n}}_createPaddingField(){let e=this.locale,t=this.t,l=new c.xE(e,c.Vr);return l.set({label:t("Padding"),class:"ck-table-cell-properties-form__padding"}),l.fieldView.bind("value").to(this,"padding"),l.fieldView.on("input",()=>{this.padding=l.fieldView.element.value}),l}_createAlignmentFields(){let e=this.locale,t=this.t,l=new c.y0(e),i={left:u.UFF,center:u.uG2,right:u.H5E,justify:u.VPN,top:u.uK8,middle:u.Gig,bottom:u._RK};l.text=t("Table cell text alignment");let o=new c.X3(e),n="rtl"===e.contentLanguageDirection;o.set({isCompact:!0,role:"radiogroup",ariaLabel:t("Horizontal text alignment toolbar")}),tv({view:this,icons:i,toolbar:o,labels:this._horizontalAlignmentLabels,propertyName:"horizontalAlignment",nameToValue:e=>{if(n){if("left"===e)return"right";else if("right"===e)return"left"}return e},defaultValue:this.options.defaultTableCellProperties.horizontalAlignment});let r=new c.X3(e);return r.set({isCompact:!0,role:"radiogroup",ariaLabel:t("Vertical text alignment toolbar")}),tv({view:this,icons:i,toolbar:r,labels:this._verticalAlignmentLabels,propertyName:"verticalAlignment",defaultValue:this.options.defaultTableCellProperties.verticalAlignment}),{horizontalAlignmentToolbar:o,verticalAlignmentToolbar:r,alignmentLabel:l}}_createActionButtons(){let e=this.locale,t=this.t,l=new c._(e),i=new c._(e),o=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.paddingInput];return l.set({label:t("Save"),icon:u.iWP,class:"ck-button-save",type:"submit",withText:!0}),l.bind("isEnabled").toMany(o,"errorText",(...e)=>e.every(e=>!e)),i.set({label:t("Cancel"),icon:u.AUn,class:"ck-button-cancel",withText:!0}),i.delegate("execute").to(this,"cancel"),{saveButtonView:l,cancelButtonView:i}}get _horizontalAlignmentLabels(){let e=this.locale,t=this.t,l=t("Align cell text to the left"),i=t("Align cell text to the center"),o=t("Align cell text to the right"),n=t("Justify cell text");return"rtl"===e.uiLanguageDirection?{right:o,center:i,left:l,justify:n}:{left:l,center:i,right:o,justify:n}}get _verticalAlignmentLabels(){let e=this.t;return{top:e("Align cell text to the top"),middle:e("Align cell text to the middle"),bottom:e("Align cell text to the bottom")}}}function tx(e){return"none"!==e}let tS=[c.Jr.defaultPositions.northArrowSouth,c.Jr.defaultPositions.northArrowSouthWest,c.Jr.defaultPositions.northArrowSouthEast,c.Jr.defaultPositions.southArrowNorth,c.Jr.defaultPositions.southArrowNorthWest,c.Jr.defaultPositions.southArrowNorthEast,c.Jr.defaultPositions.viewportStickyNorth];function tP(e,t){let l,i=e.plugins.get("ContextualBalloon"),o=e.editing.view.document.selection;"cell"===t?tu(o)&&(l=tE(e)):ts(o)&&(l=tR(e)),l&&i.updatePosition(l)}function tR(e){let t=B(e.model.document.selection),l=e.editing.mapper.toViewElement(t);return{target:e.editing.view.domConverter.mapViewToDom(l),positions:tS}}function tE(e){let t=e.editing.mapper,l=e.editing.view.domConverter,i=e.model.document.selection;if(i.rangeCount>1)return{target:()=>{var t,l;let o,r,a;return t=i.getRanges(),o=(l=e).editing.mapper,r=l.editing.view.domConverter,a=Array.from(t).map(e=>{let t=tI(e.start),l=o.toViewElement(t);return new n.rw(r.mapViewToDom(l))}
1),n.rw.getBoundingRect(a)},positions:tS};let o=tI(i.getFirstPosition()),r=t.toViewElement(o);return{target:l.mapViewToDom(r),positions:tS}}function tI(e){return e.nodeAfter&&e.nodeAfter.is("element","tableCell")?e.nodeAfter:e.findAncestor("tableCell")}let tB={borderStyle:"tableCellBorderStyle",borderColor:"tableCellBorderColor",borderWidth:"tableCellBorderWidth",height:"tableCellHeight",width:"tableCellWidth",padding:"tableCellPadding",backgroundColor:"tableCellBackgroundColor",horizontalAlignment:"tableCellHorizontalAlignment",verticalAlignment:"tableCellVerticalAlignment"};class tF extends i.k_{_defaultContentTableCellProperties;_defaultLayoutTableCellProperties;_balloon;view;_viewWithContentTableDefaults;_viewWithLayoutTableDefaults;_undoStepBatch;_isReady;static get requires(){return[c.pU]}static get pluginName(){return"TableCellPropertiesUI"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("table.tableCellProperties",{borderColors:tT,backgroundColors:tT})}init(){let e=this.editor,t=e.t;this._defaultContentTableCellProperties=el(e.config.get("table.tableCellProperties.defaultProperties"),{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,includePaddingProperty:!0,isRightToLeftContent:"rtl"===e.locale.contentLanguageDirection}),this._defaultLayoutTableCellProperties=ee(void 0,{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,isRightToLeftContent:"rtl"===e.locale.contentLanguageDirection}),this._balloon=e.plugins.get(c.pU),this.view=null,this._isReady=!1,e.ui.componentFactory.add("tableCellProperties",l=>{let i=new c._(l);i.set({label:t("Cell properties"),icon:u.VKv,tooltip:!0}),this.listenTo(i,"execute",()=>this._showView());let o=Object.values(tB).map(t=>e.commands.get(t));return i.bind("isEnabled").toMany(o,"isEnabled",(...e)=>e.some(e=>e)),i})}destroy(){super.destroy(),this.view&&this.view.destroy()}_createPropertiesView(e){let t=this.editor,l=t.config.get("table.tableCellProperties"),i=(0,c.lF)(l.borderColors),o=(0,c.b2)(t.locale,i),n=(0,c.lF)(l.backgroundColors),r=(0,c.b2)(t.locale,n),a=!1!==l.colorPicker,s=new tV(t.locale,{borderColors:o,backgroundColors:r,defaultTableCellProperties:e,colorPickerConfig:!!a&&(l.colorPicker||{})}),d=t.t;s.render(),this.listenTo(s,"submit",()=>{this._hideView()}),this.listenTo(s,"cancel",()=>{this._undoStepBatch.operations.length&&t.execute("undo",this._und
1oStepBatch),this._hideView()}),s.keystrokes.set("Esc",(e,t)=>{this._hideView(),t()}),(0,c.wy)({emitter:s,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});let u=tf(d),h=tp(d);return s.on("change:borderStyle",this._getPropertyChangeCallback("tableCellBorderStyle")),s.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:s.borderColorInput,commandName:"tableCellBorderColor",errorText:u,validator:tw})),s.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:s.borderWidthInput,commandName:"tableCellBorderWidth",errorText:h,validator:ty})),s.on("change:padding",this._getValidatedPropertyChangeCallback({viewField:s.paddingInput,commandName:"tableCellPadding",errorText:h,validator:tC})),s.on("change:width",this._getValidatedPropertyChangeCallback({viewField:s.widthInput,commandName:"tableCellWidth",errorText:h,validator:tC})),s.on("change:height",this._getValidatedPropertyChangeCallback({viewField:s.heightInput,commandName:"tableCellHeight",errorText:h,validator:tC})),s.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:s.backgroundInput,commandName:"tableCellBackgroun
1dColor",errorText:u,validator:tw})),s.on("change:horizontalAlignment",this._getPropertyChangeCallback("tableCellHorizontalAlignment")),s.on("change:verticalAlignment",this._getPropertyChangeCallback("tableCellVerticalAlignment")),s}_fillViewFormFromCommandValues(){let e=this.editor.commands,t=e.get("tableCellBorderStyle");Object.entries(tB).map(([t,l])=>{let i=this.view===this._viewWithContentTableDefaults?this._defaultContentTableCellProperties[t]||"":this._defaultLayoutTableCellProperties[t]||"";return[t,e.get(l).value||i]}).forEach(([e,l])=>{("borderColor"!==e&&"borderWidth"!==e||"none"!==t.value)&&this.view.set(e,l)}),this._isReady=!0}_showView(){let e=this.editor,t=ts(e.editing.view.document.selection),l=t&&e.editing.mapper.toModelElement(t),i=!l||"layout"!==l.getAttribute("tableType");i&&!this._viewWithContentTableDefaults?this._viewWithContentTableDefaults=this._createPropertiesView(this._defaultContentTableCellProperties):i||this._viewWithLayoutTableDefaults||(this._viewWithLayoutTableDefaults=this._createPropertiesView(this._defaultLayoutTableCellProperties)),this.view=i?this._viewWithContentTableDefaults:this._viewWithLayoutTableDefaults,this.listenTo(e.ui,"update",()=>{this._updateView()}),this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:tE(e)}),this._undoStepBatch=e.model.createBatch(),this.view.focus()}_hideView(){let e=this.editor;this.stopListening(e.ui,"update"),this._isReady=!1,this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}_updateView(){let e=this.editor;tu(e.editing.view.document.selection)?this._isViewVisible&&tP(e,"cell"):this._hideView()}get _isViewVisible(){return!!this.view&&this._balloon.visibleView===this.view}get _isViewInBalloon(){return!!this.view&&this._balloon.hasView(this.view)}_getPropertyChangeCallback(e){return(t,l,i)=>{this._isReady&&this.editor.execute(e,{value:i,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(e){let{commandName:t,viewField:l,validator:i,errorText:o}=e,n=(0,a.s)(()=>{l.errorText=o},500);return(e,o,r)=>{n.cancel(),this._isReady&&(i(r)?(this.editor.execute(t,{value:r,batch:this._undoStepBatch}),l.errorText=null):n())}}}class tW extends i.uB{attributeName;_defaultValue;_defaultContentTableValue;_defaultLayoutTableValue;constructor(e,t,l){switch(super(e),this.attributeName=t,this._defaultContentTableValue=l,t){case"tableCellType":this._defaultLayoutTableValue="data";break;case"tableCellBorderStyle":this._defaultLayoutTableValue="none";break;case"tableCellHorizontalAlignment":this._defaultLayoutTableValue="left";break;case"tableCellVerticalAlignment":this._defaultLayoutTableValue="middle";break;default:this._defaultLayoutTableValue=void 0}}refresh(){let e=this.editor.model.document.selection,t=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(e),l=B(e);this._defaultValue=l&&"layout"===l.getAttribute("tableType")?this._defaultLayoutTableValue:this._defaultContentTableValue,this.isEnabled=!!t.length,this.value=this._getSingleValue(t)}execute(e={}){let{value:t,batch:l}=e,i=this.editor.model,o=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(i.document.selection),n=this._getValueToSet(t);i.enqueueChange(l,e=>{n?o.forEach(t=>e.setAttribute(this.attributeName,n,t)):o.forEach(t=>e.removeAttribute(this.attributeName,t)),this.fire("afterExecute",{writer:e,tableCells:o,valueToSet:n})})}_getAttribute(e){if(!e)return;let t=e.getAttribute(this.attributeName);if(t!==this._defaultValue)return t}_getValueToSet(e){if(e!==this._defaultValue)return e}_getSingleValue(e){let t=this._getAttribute(e[0]);return e.every(e=>this._getAttribute(e)===t)?t:void 0}}class tD extends tW{constructor(e,t){super(e,"tableCellWidth",t)}_getValueToSet(e){if((e=Y(e,"px"))!==this._defaultValue)return e}}class tL extends i.k_{static get pluginName(){return"TableCellWidthEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[e2]}init(){let e=this.editor,t=el(e.config.get("table.tableCellProperties.defaultProperties"));I(e.model.schema,e.conversion,{modelAttribute:"tableCellWidth",styleName:"width",attributeName:"width",attributeType:"length",defaultValue:t.width}),e.commands.add("tableCellWidth",new tD(e,t.width))}}class tN extends tW{constructor(e,t){super(e,"tableCellPadding",t)}_getAttribute(e){if(!e)return;let t=Z(e.getAttribute(this.attributeName));if(t!==this._defaultValue)return t}_getValueToSet(e){let t=Y(e,"px");if(t!==this._defaultValue)return t}}class tO extends tW{constructor(e,t){super(e,"tableCellHeight",t)}_getValueToSet(e){let t=Y(e,"px");if(t!==this._defaultValue)return t}}class tz extends tW{constructor(e,t){super(e,"tableCellBackgroun
1dColor",t)}}class tM extends tW{constructor(e,t){super(e,"tableCellVerticalAlignment",t)}}class tH extends tW{constructor(e,t){super(e,"tableCellHorizontalAlignment",t)}}class tU extends tW{constructor(e,t){super(e,"tableCellBorderStyle",t)}_getAttribute(e){if(!e)return;let t=Z(e.getAttribute(this.attributeName));if(t!==this._defaultValue)return t}}class t$ extends tW{constructor(e,t){super(e,"tableCellBorderColor",t)}_getAttribute(e){if(!e)return;let t=Z(e.getAttribute(this.attributeName));if(t!==this._defaultValue)return t}}class tK extends tW{constructor(e,t){super(e,"tableCellBorderWidth",t)}_getAttribute(e){if(!e)return;let t=Z(e.getAttribute(this.attributeName));if(t!==this._defaultValue)return t}_getValueToSet(e){let t=Y(e,"px");if(t!==this._defaultValue)return t}}class tj extends tW{constructor(e){super(e,"tableCellType","data"),this.on("afterExecute",(e,t)=>{let{writer:l,tableCells:i}=t;tq(this.editor.plugins.get(ez),l,(function(e){let t=new Map;for(let l of e){let e=l.findAncestor("table");t.has(e)||t.set(e,[]),t.get(e).push(l)}return t})(i).keys())})}refresh(){super.refresh();let e=B(this.editor.model.document.selection);this.isEnabled&&e&&"layout"===e.getAttribute("tableType")&&(this.isEnabled=!1)}_getAttribute(e){return e?.getAttribute(this.attributeName)||"data"}}function tq(e,t,l){let i=!1;for(let o of l){let l=o.getAttribute("headingRows")||0,n=o.getAttribute("headingColumns")||0,r=n>l;if(r){let r=tG(e,o,"column",n,l);r!==n&&(e.setHeadingColumnsCount(t,o,r,{shallow:!0}),n=r,i=!0)}let a=tG(e,o,"row",l,n);if(a!==l&&(e.setHeadingRowsCount(t,o,a,{shallow:!0}),l=a,i=!0),!r){let r=tG(e,o,"column",n,l);r!==n&&(e.setHeadingColumnsCount(t,o,r,{shallow:!0}),i=!0)}}return i}function tG(e,t,l,i,o){let n="row"===l?e.getRows(t):e.getColumns(t),r=i;for(let e=0;e<n;e++){let i=new x(t,{[l]:e}),n=!0,a=!1;for(let{cell:e,row:t,column:r}of i){if("header"!==e.getAttribute("tableCellType")){n=!1;break}("row"===l?r:t)>=o&&(a=!0)}if(!n)return Math.min(r,e);a&&(r=Math.max(r,e+1))}return Math.min(r,n)}let tQ=/^(top|middle|bottom)$/,tJ=/^(left|center|right|justify)$/;class tX extends i.k_{static get pluginName(){return"TableCellPropertiesEditing"}static get licenseFeatureCode(){return"TCP"}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}static get requires(){return[e2,tL]}init(){var e,t,l,i,o,r;let a=this.editor,s=a.model.schema,d=a.conversion;a.config.define("table.tableCellProperties.defaultProperties",{});let u=el(a.config.get("table.tableCellProperties.defaultProperties"),{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,includePaddingProperty:!0,isRightToLeftContent:"rtl"===a.locale.contentLanguageDirection});a.data.addStyleProcessorRules(b.fY7),function(e,t){let{conversion:l}=e,{schema:i}=e.model,o={width:"tableCellBorderWidth",color:"tableCellBorderColor",style:"tableCellBorderStyle"};for(let e of(i.extend("tableCell",{allowAttributes:Object.values(o)}),Object.values(o)))i.setAttributeProperties(e,{isFormatting:!0});m(e,"td",o,t),m(e,"th",o,t),f(l,{modelElement:"tableCell",modelAttribute:o.style,styleName:"border-style"}),f(l,{modelElement:"tableCell",modelAttribute:o.color,styleName:"border-color"}),f(l,{modelElement:"tableCell",modelAttribute:o.width,styleName:"border-width"})}(a,{color:u.borderColor,style:u.borderStyle,width:u.borderWidth}),a.commands.add("tableCellBorderStyle",new tU(a,u.borderStyle)),a.commands.add("tableCellBorderColor",new t$(a,u.borderColor)),a.commands.add("tableCellBorderWidth",new tK(a,u.borderWidth)),I(s,d,{modelAttribute:"tableCellHeight",styleName:"height",attributeName:"height",attributeType:"length",defaultValue:u.height}),a.commands.add("tableCellHeight",new tO(a,u.height)),a.data.addStyleProcessorRules(b.mtt),I(s,d,{modelAttribute:"tableCellPadding",styleName:"padding",reduceBoxSides:!0,defaultValue:u.padding}),a.commands.add("tableCellPadding",new tN(a,u.padding)),a.data.addStyleProcessorRules(b.$xF),I(s,d,{modelAttribute:"tableCellBackgroun
1dColor",styleName:"background-color",attributeName:"bgcolor",attributeType:"color",defaultValue:u.backgroundColor}),a.commands.add("tableCellBackgroundColor",new tz(a,u.backgroundColor)),e=s,t=d,l=u.horizontalAlignment,e.extend("tableCell",{allowAttributes:["tableCellHorizontalAlignment"]}),e.setAttributeProperties("tableCellHorizontalAlignment",{isFormatting:!0}),t.for("downcast").attributeToAttribute({model:{name:"tableCell",key:"tableCellHorizontalAlignment"},view:e=>({key:"style",value:{"text-align":e}})}),t.for("upcast").attributeToAttribute({view:{name:/^(td|th)$/,styles:{"text-align":tJ}},model:{key:"tableCellHorizontalAlignment",value:(e,t,i)=>{let o=w(l,"left",i),n=e.getStyle("text-align");if(n!==o)return n;t.consumable.consume(e,{styles:"text-align"})}}}).attributeToAttribute({view:{name:/^(td|th)$/,attributes:{align:tJ}},model:{key:"tableCellHorizontalAlignment",value:(e,t,i)=>{let o=w(l,"left",i),n=e.getAttribute("align");if(n!==o)return n;t.consumable.consume(e,{attributes:"align"})}}}),a.commands.add("tableCellHorizontalAlignment",new tH(a,u.horizontalAlignment)),i=s,o=d,r=u.verticalAlignment,i.extend("tableCell",{allowAttributes:["tableCellVerticalAlignment"]}),i.setAttributeProperties("tableCellVerticalAlignment",{isFormatting:!0}),o.for("downcast").attributeToAttribute({model:{name:"tableCell",key:"tableCellVerticalAlignment"},view:e=>({key:"style",value:{"vertical-align":e}})}),o.for("upcast").attributeToAttribute({view:{name:/^(td|th)$/,styles:{"vertical-align":tQ}},model:{key:"tableCellVerticalAlignment",value:(e,t,l)=>{let i=w(r,"middle",l),o=e.getStyle("vertical-align");if(o!==i)return o;t.consumable.consume(e,{styles:"vertical-align"})}}}).attributeToAttribute({view:{name:/^(td|th)$/,attributes:{valign:tQ}},model:{key:"tableCellVerticalAlignment",value:(e,t,l)=>{let i=w(r,"middle",l),o=e.getAttribute("valign");if(o!==i)return o;t.consumable.consume(e,{attributes:"valign"})}}}),a.commands.add("tableCellVerticalAlignment",new tM(a,u.verticalAlignment)),a.config.get("experimentalFlags.tableCellTypeSupport")&&(function(e){let{model:t,conversion:l,editing:i}=e,{schema:o}=t,r=e.plugins.get(ez);o.extend("tableCell",{allowAttributes:["tableCellType"]}),o.setAttributeProperties("tableCellType",{isFormatting:!0}),o.addAttributeCheck(e=>{let t=Array.from(e).reverse().find(e=>"table"===e.name);if(t?.getAttribute("tableType")==="layout")return!1},"tableCellType"),l.for("upcast").add(e=>{e.on("element:th",(e,t,l)=>{let{writer:i}=l,{modelRange:o}=t,n=o?.start.nodeAfter;n?.is("element","tableCell")&&i.setAttribute("tableCellType","header",n)}),e.on("element:table",(e,t,l)=>{let{writer:i}=l,{modelRange:o}=t,n=o?.start.nodeAfter;if(n?.is("element","table")&&"layout"===n.getAttribute("tableType")){for(let{cell:e}of new x(n))if("header"===e.getAttribute("tableCellType")){i.setAttribute("tableType","content",n);break}}},{priority:n.vx.low-1})}),t.document.registerPostFixer(e=>{let l=t.document.differ.getChanges(),i=new Set;for(let e of l){if("attribute"===e.type&&("headingRows"===e.attributeKey||"headingColumns"===e.attributeKey)){let t=e.range.start.nodeAfter;t?.is("element","table")&&"$graveyard"!==t.root.rootName&&i.add(t)}if("attribute"===e.type&&"tableCellType"===e.attributeKey){let t=e.range.start.nodeAfter;if(t?.is("element","tableCell")&&"$graveyard"!==t.root.rootName){let e=t.findAncestor("table");e&&i.add(e)}}if("insert"===e.type&&e.position.nodeAfter){for(let{item:l}of t.createRangeOn(e.position.nodeAfter))if(l.is("element","tableCell")&&l.getAttribute("tableCellType")&&"$graveyard"!==l.root.rootName){let e=l.findAncestor("table");e&&i.add(e)}}}return tq(r,e,i)}),t.document.on("change:data",()=>{let{differ:e}=t.document,l=new Set;for(let t of e.getChanges())if("attribute"===t.type&&"tableCellType"===t.attributeKey){let e=t.range.start.nodeAfter;e.is("element","tableCell")&&l.add(e)}for(let e of l){let t=i.mapper.toViewElement(e),l="header"===e.getAttribute("tableCellType")?"th":"td";t?.name!==l&&i.reconvertItem(e)}})}(a),a.commands.add("tableCellType",new tj(a)))}}class tZ extends i.k_{static get pluginName(){return"TableCellProperties"}static get isOfficialPlugin(){return!0}static get requires(){return[tX,tF]}}class tY extends i.k_{static get pluginName(){return"TableLayoutUI"}static get isOfficialPlugin(){return!0}init(){let e=this.editor,t=this.editor.t;e.ui.componentFactory.add("insertTableLayout",l=>{let i,o=e.commands.get("insertTableLayout"),n=(0,c.yu)(l);return n.bind("isEnabled").to(o),n.buttonView.set({icon:u.qvW,label:t("Insert table layout"),tooltip:!0}),n.on("change:isOpen",()=>{i||(i=new e7(l),n.panelView.children.add(i),i.delegate("execute").to(n),n.on("execute",()=>{e.execute("insertTableLayout",{rows:i.rows,columns:i.columns}),e.editing.view.focus()}))}),n}),e.ui.componentFactory.add("menuBar:insertTableLayout",l=>{let i=e.commands.get("insertTableLayout"),o=new c.zj(l),n=new e7(l);return n.delegate("execute").to(o),o.on("change:isOpen",(e,t,l)=>{l||n.reset()}),n.on("execute",()=>{e.execute("insertTableLayout",{rows:n.rows,columns:n.columns}),e.editing.view.focus()}),o.buttonView.set({label:t("Table layout"),icon:u.qvW}),o.panelView.children.add(n),o.bind("isEnabled").to(i),o}),e.ui.componentFactory.add("tableType",()=>{let e=this.editor,t=e.t,l=new c.lU(e.locale);return l.set({label:t("Table type"),icon:u.FYj,tooltip:!0}),t0(e,l)})}afterInit(){let e,{editor:t}=this,{ui:l,plugins:i}=t;if(i.has("TablePropertiesUIExperimental"))e=i.get("TablePropertiesUIExperimental");else{if(!i.has("TablePropertiesUI"))return;e=i.get("TablePropertiesUI")}l.componentFactory.add("tableProperties",l=>{let i=e._createTablePropertiesButton();
1return t0(t,new c.AO(l,i))})}}function t0(e,t){var l;let i,o,r,a=e.t,s=e.locale,d=e.commands.get("tableType"),u=(0,c.yu)(s,t),h=(i=(l=e).t,o=l.commands.get("tableType"),(r=new n.pM).add(t1(o,"layout",i("Layout table"))),r.add(t1(o,"content",i("Content table"))),r);return(0,c.O)(u,h,{ariaLabel:a("Table type options"),role:"menu"}),t.tooltip=a("Choose table type"),u.on("execute",e=>{let t=e.source.tableType;t&&d.execute(t)}),u}function t1(e,t,l){let i=new c.e_({label:l,role:"menuitemradio",withText:!0,tableType:t});return i.bind("isEnabled").to(e,"isEnabled"),i.bind("isOn").to(e,"value",e=>e===t),{type:"button",model:i}}class t5 extends i.uB{refresh(){var e,t;let l,i,o=this.editor.model,n=o.document.selection,r=o.schema;this.isEnabled=(e=n,t=r,i=(l=e.getFirstPosition().parent)===l.root?l:l.parent,t.checkChild(i,"table"))}execute(e={}){let t=this.editor,l=t.model,i=t.plugins.get("TableUtils");l.change(o=>{let n={rows:e.rows||2,columns:e.columns||2},r=i.createTable(o,n);o.setAttribute("tableType","layout",r),l.insertObject(r,null,null,{findOptimalPosition:"auto"});let a=`${100/n.columns}%`,s=Array(n.columns).fill(a);t.commands.get("resizeColumnWidths").execute({tableWidth:"100%",columnWidths:s,table:r}),o.setSelection(o.createPositionAt(r.getNodeByPath([0,0,0]),0))})}}class t2 extends i.uB{refresh(){this.isEnabled=!0}execute(e={}){let{model:t,plugins:l}=this.editor,{table:i=t.document.selection.getSelectedElement(),columnWidths:o,tableWidth:n}=e;o&&(o=Array.isArray(o)?o:o.split(",")),t.change(e=>{n?e.setAttribute("tableWidth",n,i):e.removeAttribute("tableWidth",i);let t=l.get("TableColumnResizeEditing").getColumnGroupElement(i);if(!o&&!t)return;if(!o)return e.remove(t);let r=eB(o);if(t)Array.from(t.getChildren()).forEach((t,l)=>e.setAttribute("columnWidth",r[l],t));else{let t=e.createElement("tableColumnGroup");r.forEach(l=>e.appendElement("tableColumn",{columnWidth:l},t)),e.append(t,i)}})}}function t9(e){return t=>t.on("element:colgroup",(t,l,i)=>{let o=l.modelCursor.findAncestor("table"),n=eD(o);if(!n)return;let r=eL(n),a=e.getColumns(o),s=eO(n,i.writer);((s=Array.from({length:a},(e,t)=>s[t]||"auto")).length!=r.length||s.includes("auto"))&&eW(r,n,eB(s),i.writer)},{priority:"low"})}function t7(){return e=>e.on("insert:table",(e,t,l)=>{let i=l.writer,o=t.item,n=l.mapper.toViewElement(o),r=n.is("element","table")?n:Array.from(n.getChildren()).find(e=>e.is("element","table"));eD(o)?i.addClass("ck-table-resized",r):i.removeClass("ck-table-resized",r)},{priority:"low"})}let t3=(0,n.To)("px");class t6 extends i.k_{_isResizingActive;_resizingData;_domEmitter;_tableUtilsPlugin;_initialMouseEventData=null;static get requires(){return[e2,ez]}static get pluginName(){return"TableColumnResizeEditing"}static get licenseFeatureCode(){return"TCR"}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}constructor(e){super(e),this._isResizingActive=!1,this.set("_isResizingAllowed",!0),this._resizingData=null,this._domEmitter=new((0,n.c5)()),this._tableUtilsPlugin=e.plugins.get("TableUtils"),this.on("change:_isResizingAllowed",(t,l,i)=>{let o=i?"removeClass":"addClass";e.editing.view.change(t=>{for(let l of e.editing.view.document.roots)t[o]("ck-column-resize_disabled",e.editing.view.document.getRoot(l.rootName))})})}init(){this._extendSchema(),this._registerPostFixer(),this._registerConverters(),this._registerResizingListeners(),this._registerResizerInserter();let e=this.editor,t=e.plugins.get("TableColumnResize");e.plugins.get("TableEditing").registerAdditionalSlot({filter:e=>e.is("element","tableColumnGroup"),positionOffset:0});let l=new t2(e);e.commands.add("resizeTableWidth",l),e.commands.add("resizeColumnWidths",l),this.bind("_isResizingAllowed").to(e,"isReadOnly",t,"isEnabled",l,"isEnabled",(e,t,l)=>!e&&t&&l)}destroy(){this._domEmitter.stopListening(),super.destroy()}getColumnGroupElement(e){return eD(e)}getTableColumnElements(e){return eL(e)}getTableColumnsWidths(e){return eN(e)}_extendSchema(){let e=this.editor.model.schema;e.extend("table",{allowAttributes:["tableWidth"]}),e.register("tableColumnGroup",{allowIn:"table",isLimit:!0}),e.register("tableColumn",{allowIn:"tableColumnGroup",allowAttributes:["columnWidth","colSpan"],isLimit:!0}),e.setAttributeProperties("columnWidth",{isFormatting:!0})}_registerPostFixer(){let e=this.editor.model;e.document.registerPostFixer(t=>{let l=!1;for(let i of eT(e)){let e=this.getColumnGroupElement(i),o=this.getTableColumnElements(e),n=this.getTableColumnsWidths(e),r=eB(n);r=function(e,t,l){let i=l._tableUtilsPlugin.getColumns(t);if(0==i-e.length)return e;let o=e.map(e=>Number(e.replace("%","")));for(let e of function(e,t){let l=new Set;for(let i of e.getChanges())if("insert"==i.type&&i.position.nodeAfter&&"tableCell"==i.position.nodeAfter.name&&i.position.nodeAfter.getAncestors().includes(t))l.add(i.position.nodeAfter);else if("remove"==i.type){let e=i.position.nodeBefore||i.position.nodeAfter;"tableCell"==e.name&&e.getAncestors().includes(t)&&l.add(e)}return l}(l.editor.model.document.differ,t)){let n=i-o.length;if(0===n)continue;let r=n>0,a=l._tableUtilsPlugin.getCellLocation(e).column;if(r){let e=eE(n,eA(t,l.editor));o.splice(a,0,...e)}else{let e=o.splice(a,Math.abs(n));o[a]+=eI(e)}}return o.map(e=>e+"%")}(r,i,this),(0,s.n)(n,r)||(eW(o,e,r,t),l=!0)}return l})}_registerConverters(){let e=this.editor.conversion;e.for("upcast").attributeToAttribute({view:{name:/^(figure|table)$/,styles:{width:/[\s\S]+/}},model:{key:"tableWidth",value:e=>{if(!e.parent.is("element","figure"))return e.getStyle("width")}}}),e.for("downcast").attributeToAttribute({model:{name:"table",key:"tableWidth"},view:e=>({name:"figure",key:"style",value:{width:e}})}),e.elementToElement({model:"tableColumnGroup",view:"colgroup"}),e.elementToElement({model:"tableColumn",view:"col"}),e.for("downcast").add(t7()),e.for("upcast").add(e=>{e.on("element:table",(e,t,l)=>{l.consumable.consume(t.viewItem,{classes:"ck-table-resized"})})}),e.for("upcast").add(t9(this._tableUtilsPlugin)),e.for("upcast").attributeToAttribute({view:{name:"col",styles:{width:/.*/}},model:{key:"columnWidth",value:e=>{let t=e.getStyle("width");return t&&(t.endsWith("%")||t.endsWith("pt"))?t:"auto"}}}),e.for("upcast").attributeToAttribute({view:{name:"col",key:"span"},model:"colSpan"}),e.for("downcast").attributeToAttribute({model:{name:"tableColumn",key:"columnWidth"},view:e=>({key:"style",value:{width:e}})})}_registerResizingListeners(){let e=this.editor.editing.view;e.addObserver(ti),e.document.on("mouseover",this._onMouseOverHandler.bind(this),{priority:"high"}),e.document.on("mousedown",this._onMouseDownHandler.bind(this),{priority:"high"}),e.document.on("mouseout",this._onMouseOutHandler.bind(this),{priority:"high"}),this._domEmitter.listenTo(n.Sf.window.document,"mousemove",(0,d.n)(this._onMouseMoveHandler.bind(this),50)),this._domEmitter.listenTo(n.Sf.window.document,"mouseup",this._onMouseUpHandler.bind(this))}_recalculateResizerElement(e){let t=this.editor,l=t.editing.view.domConverter,i=l.mapViewToDom(e.findAnce
1stor("table")),o=l.mapViewToDom(e.findAncestor(e=>["td","th"].includes(e.name))),r=new n.rw(i),a=new n.rw(o),s=t3(Number((r.top-a.top).toFixed(4))),d=t3(Number((a.bottom-r.bottom).toFixed(4)));t.editing.view.change(t=>{t.setStyle("top",s,e),t.setStyle("bottom",d,e)})}_resetResizerStyles(e){this.editor.editing.view.change(t=>{t.removeStyle("top",e),t.removeStyle("bottom",e)})}_onMouseOverHandler(e,t){let l=t.target;!l.hasClass("ck-table-column-resizer")||this._isResizingAllowed&&this._recalculateResizerElement(l)}_onMouseOutHandler(e,t){let l=t.target;l.hasClass("ck-table-column-resizer")&&this._isResizingAllowed&&(this._isResizingActive||this._resetResizerStyles(l))}_onMouseDownHandler(e,t){let l=t.target;if(!l.hasClass("ck-table-column-resizer")||!this._isResizingAllowed)return;let i=this.editor,o=i.editing.mapper.toModelElement(l.findAncestor("figure"));i.model.canEditAt(o)&&(t.preventDefault(),e.stop(),this._initialMouseEventData=t)}_startResizingAfterThreshold(){let e=this._initialMouseEventData,{target:t}=e,l=this.editor.editing.mapper.toModelElement(t.findAncestor("figure")),i=t.findAncestor("table"),o=function(e,t,l){let i=Array(t.getColumns(e));for(let t of new x(e)){let e=l.editing.mapper.toViewElement(t.cell),o=eF(l.editing.view.domConverter.mapViewToDom(e));(!i[t.column]||o<i[t.column])&&(i[t.column]=eP(o))}return i}(l,this._tableUtilsPlugin,this.editor);Array.from(i.getChildren()).find(e=>e.is("element","colgroup"))||this.editor.editing.view.change(e=>{var t=e,l=o,n=i;let r=t.createContainerElement("colgroup");for(let e=0;e<l.length;e++){let i=t.createEmptyElement("col"),o=`${eP(l[e]/eI(l)*100)}%`;t.setStyle("width",o,i),t.insert(t.createPositionAt(r,"end"),i)}t.insert(t.createPositionAt(n,0),r)}),this._isResizingActive=!0,this._resizingData=this._getResizingData(e,o),this.editor.editing.view.change(e=>{var t,l,o;let n;return t=e,l=i,n=(o=this._resizingData).widths.viewFigureWidth/o.widths.viewFigureParentWidth,void(t.addClass("ck-table-resized",l),t.addClass("ck-table-column-resizer__active",o.elements.viewResizer),t.setStyle("width",`${eP(100*n)}%`,l.findAncestor("figure")))})}_onMouseMoveHandler(e,t){if(this._initialMouseEventData){let e=this._initialMouseEventData.domEvent;if(!(Math.abs(t.clientX-e.clientX)>=ev))return;this._startResizingAfterThreshold(),this._initialMouseEventData=null}if(!this._isResizingActive)return;if(!this._isResizingAllowed)return void this._onMouseUpHandler();let{columnPosition:l,flags:{isRightEdge:i,isTableCentered:o,isLtrContent:n},elements:{viewFigure:r,viewLeftColumn:a,viewRightColumn:s,viewResizer:d},widths:{viewFigureParentWidth:u,tableWidth:c,leftColumnWidth:h,rightColumnWidth:b}}=this._resizingData,g=eR((t.clientX-l)*((n?1:-1)*(i&&o?2:1)),Math.min(-h+ey,0),Math.max(i?u-c:b-ey,0));0!==g&&(this.editor.editing.view.change(e=>{let t=eP((h+g)*100/c);if(e.setStyle("width",`${t}%`,a),i){let t=eP((c+g)*100/u);e.setStyle("width",`${t}%`,r)}else{let t=eP((b-g)*100/c);e.setStyle("width",`${t}%`,s)}}),this._recalculateResizerElement(d))}_onMouseUpHandler(){if(this._initialMouseEventData=null,!this._isResizingActive)return;let{viewResizer:e,modelTable:t,viewFigure:l,viewColgroup:i}=this._resizingData.elements,o=this.editor,n=o.editing.view,r=this.getColumnGroupElement(t),a=Array.from(i.getChildren()).filter(e=>e.is("view:element")),d=r?this.getTableColumnsWidths(r):null,u=a.map(e=>e.getStyle("width")),c=!(0,s.n)(d,u),h=t.getAttribute("tableWidth"),b=l.getStyle("width"),g=h!==b;(c||g)&&(this._isResizingAllowed?o.execute("resizeTableWidth",{table:t,tableWidth:`${eP(b)}%`,columnWidths:u}):n.change(e=>{if(d)for(let t of a)e.setStyle("width",d.shift(),t);else e.remove(i);g&&(h?e.setStyle("width",h,l):e.removeStyle("width",l)),d||h||e.removeClass("ck-table-resized",[...l.getChildren()].find(e=>"table"===e.name))})),n.change(t=>{t.removeClass("ck-table-column-resizer__active",e)}),n.domConverter.mapViewToDom(e).matches(":hover")||this._resetResizerStyles(e),this._isResizingActive=!1,this._resizingData=null}_getResizingData(e,t){let l=this.editor,i=e.domEvent.clientX,o=e.target,n=o.findAncestor("td")||o.findAnce
1stor("th"),r=l.editing.mapper.toModelElement(n),a=r.findAncestor("table"),s=eS(r,this._tableUtilsPlugin).rightEdge,d=this._tableUtilsPlugin.getColumns(a)-1,u=a.getAttribute("tableAlignment");"layout"!==a.getAttribute("tableType")&&(u||=l.config.get("table.tableProperties.defaultProperties.alignment"),u||="center");let c=s===d,h="rtl"!==l.locale.contentLanguageDirection,b="center"===u,g=n.findAncestor("table"),m=g.findAncestor("figure"),f=[...g.getChildren()].find(e=>e.is("element","colgroup")),p=f.getChild(s),w=c?void 0:f.getChild(s+1),C=ex(l.editing.view.domConverter.mapViewToDom(m.parent)),y=ex(l.editing.view.domConverter.mapViewToDom(m)),_=ek(a,l),v=t[s],T=c?void 0:t[s+1];return{columnPosition:i,flags:{isRightEdge:c,isTableCentered:b,isLtrContent:h},elements:{viewResizer:o,modelTable:a,viewFigure:m,viewColgroup:f,viewLeftColumn:p,viewRightColumn:w},widths:{viewFigureParentWidth:C,viewFigureWidth:y,tableWidth:_,leftColumnWidth:v,rightColumnWidth:T}}}_registerResizerInserter(){this.editor.conversion.for("editingDowncast").add(e=>{e.on("insert:tableCell",(e,t,l)=>{let i=t.item,o=l.mapper.toViewElement(i),n=l.writer;n.insert(n.createPositionAt(o,"end"),n.createUIElement("div",{class:"ck-table-column-resizer"}))},{priority:"lowest"})})}}class t4 extends i.k_{static get requires(){return[t6,tL]}static get pluginName(){return"TableColumnResize"}static get isOfficialPlugin(){return!0}}class t8 extends i.uB{refresh(){let e=B(this.editor.model.document.selection);e?(this.isEnabled=!0,this.value=e.getAttribute("tableType")):(this.isEnabled=!1,this.value=null)}execute(e){let t=this.editor.model,l=B(t.document.selection);l.getAttribute("tableType")!==e&&t.change(i=>{for(let o of(i.setAttribute("tableType",e,l),t.schema.removeDisallowedAttributes([l],i),l.getChildren()))t.schema.checkChild(l,o)||i.remove(o)})}}let le=["content","layout"];class lt extends i.k_{static get pluginName(){return"TableLayoutEditing"}static get licenseFeatureCode(){return"TL"}static get requires(){return[t4]}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}init(){this._defineSchema(),this._defineConverters(),this._defineClipboardPasteHandlers(),this._registerTableTypeAttributePostfixer(),this.editor.commands.add("insertTableLayout",new t5(this.editor)),this.editor.commands.add("tableType",new t8(this.editor))}_defineSchema(){let{schema:e}=this.editor.model;e.extend("table",{allowAttributes:"tableType"}),e.addChildCheck(li,"caption"),e.addAttributeCheck(li,"headingRows"),e.addAttributeCheck(li,"headingColumns")}_defineConverters(){var e,t;let{editor:l}=this,{conversion:i}=l,o=l.config.get("table.tableLayout.preferredExternalTableType");
1i.for("upcast").add((e=l,t=o,l=>{l.on("element:table",(l,i,o)=>{let n=i.viewItem;if(!o.consumable.test(n,{name:!0})||"content"==ll(n,t))return;let r=o.writer.createElement("table",{tableType:"layout"});if(o.safeInsert(r,i.modelCursor)){for(let t of(o.consumable.consume(n,{name:!0}),o.consumable.consume(n,{attributes:["role"]}),o.consumable.consume(n,{classes:["layout-table"]}),e.config.get("experimentalFlags.upcastTableBorderZeroAttributes")&&"0"===n.getAttribute("border")&&o.consumable.consume(n,{attributes:["border"]}),n.getChildren()))if(t.is("element"))for(let e of t.getChildren())e.is("element","tr")&&o.convertItem(e,o.writer.createPositionAt(r,"end"));if(o.convertChildren(n,o.writer.createPositionAt(r,"end")),r.isEmpty){let e=o.writer.createElement("tableRow");o.writer.insert(e,o.writer.createPositionAt(r,"end")),R(o.writer,o.writer.createPositionAt(e,"end"))}o.updateConversionResult(r,i)}},{priority:"high"}),l.on("element:table",(e,l,i)=>{let{viewItem:o,modelRange:n}=l;n&&(i.writer.setAttribute("tableType",ll(o,t),n),i.consumable.consume(o,{classes:["layout-table"]}),i.consumable.consume(o,{classes:["content-table"]}))},{priority:"low"})})),i.for("dataDowncast").add(e=>e.on("attribute:tableType:table",(e,t,l)=>{let{item:i,attributeNewValue:o}=t,{mapper:n,writer:r}=l;if(!l.consumable.test(i,e.name))return;let a=n.toViewElement(i);r.addClass(`${o}-table`,a),"layout"==o&&r.setAttribute("role","presentation",a),l.consumable.consume(i,e.name)})),i.for("editingDowncast").attributeToAttribute({model:{key:"tableType",values:["layout","content"]},view:{layout:{key:"class",value:["layout-table"]},content:{key:"class",value:["content-table"]}}})}_defineClipboardPasteHandlers(){let{plugins:e}=this.editor;if(!e.has("ClipboardPipeline"))return;let t=e.get("ClipboardPipeline");this.listenTo(t,"contentInsertion",(e,t)=>{t.sourceEditorId||this.editor.model.change(e=>{for(let{item:l}of e.createRangeIn(t.content))l.is("element","table")&&e.setAttribute("tableType","content",l)})})}_registerTableTypeAttributePostfixer(){let e=this.editor;e.model.document.registerPostFixer(t=>{let l=e.model.document.differ.getChanges(),i=!1;for(let o of l){if("insert"==o.type&&"$text"!=o.name){let e=o.position.nodeAfter;for(let l of t.createRangeOn(e).getItems())l.is("element","table")&&!l.hasAttribute("tableType")&&(t.setAttribute("tableType","content",l),i=!0)}if("attribute"==o.type&&"tableType"==o.attributeKey){for(let l of o.range.getItems())if(l.is("element","table"))for(let o of(e.model.schema.removeDisallowedAttributes([l],t),l.getChildren()))e.model.schema.checkChild(l,o)||(t.remove(o),i=!0)}}return i})}}function ll(e,t){return e.hasClass("content-table")?"content":e.hasClass("layout-table")?"layout":t&&le.includes(t)?t:e.parent.is("element","figure")||Array.from(e.getChildren()).some(e=>e.is("element","caption"))?"content":"layout"}function li(e){if(e.endsWith("table")&&"layout"==e.last.getAttribute("tableType"))return!1}class lo extends i.k_{static get pluginName(){return"TableLayout"}static get isOfficialPlugin(){return!0}static get requires(){return[t4,lt,tY]}}class ln extends i.uB{attributeName;_defaultValue;_defaultContentTableValue;_defaultLayoutTableValue;constructor(e,t,l){super(e),this.attributeName=t,this._defaultContentTableValue=l,this._defaultLayoutTableValue="tableBorderStyle"===t?"none":void 0}refresh(){let e=B(this.editor.model.document.selection);this._defaultValue=e&&"layout"===e.getAttribute("tableType")?this._defaultLayoutTableValue:this._defaultContentTableValue,this.isEnabled=!!e,this.value=this._getValue(e)}execute(e={}){let t=this.editor.model,l=t.document.selection,{value:i,batch:o}=e,n=B(l),r=this._getValueToSet(i);t.enqueueChange(o,e=>{r?e.setAttribute(this.attributeName,r,n):e.removeAttribute(this.attributeName,n)})}_getValue(e){if(!e)return;let t=e.getAttribute(this.attributeName);if(t!==this._defaultValue)return t}_getValueToSet(e){if(e!==this._defaultValue)return e}}class lr extends ln{constructor(e,t){super(e,"tableBackgroundColor",t)}}class la extends ln{constructor(e,t){super(e,"tableBorderColor",t)}_getValue(e){if(!e)return;let t=Z(e.getAttribute(this.attributeName));if(t!==this._defaultValue)return t}}class ls extends ln{constructor(e,t){super(e,"tableBorderStyle",t)}_getValue(e){if(!e)return;let t=Z(e.getAttribute(this.attributeName));if(t!==this._defaultValue)return t}}class ld extends ln{constructor(e,t){super(e,"tableBorderWidth",t)}_getValue(e){if(!e)return;let t=Z(e.getAttribute(this.attributeName));if(t!==this._defaultValue)return t}_getValueToSet(e){let t=Y(e,"px");if(t!==this._defaultValue)return t}}class lu extends ln{constructor(e,t){super(e,"tableWidth",t)}_getValueToSet(e){if((e=Y(e,"px"))!==this._defaultValue)return e}}class lc extends ln{constructor(e,t){super(e,"tableHeight",t)}_getValueToSet(e){if((e=Y(e,"px"))!==this._defaultValue)return e}}class lh extends ln{constructor(e,t){super(e,"tableAlignment",t)}}class lb extends i.k_{static get pluginName(){return"TablePropertiesEditing"}static get licenseFeatureCode(){return"TCP"}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}static get requires(){return[e2]}init(){var e,t,l,i,o,r,a,s;let d=this.editor,u=d.model.schema,c=d.conversion;d.config.define("table.tableProperties.defaultProperties",{});let h=et(d.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0}),f=!1!==d.config.get("table.tableProperties.alignment.useInlineStyles");if(d.data.addStyleProcessorRules(b.FZK),d.data.addStyleProcessorRules(b.fY7),function(e,t){let{c
1onversion:l}=e,{schema:i}=e.model,o={width:"tableBorderWidth",color:"tableBorderColor",style:"tableBorderStyle"};for(let e of(i.extend("table",{allowAttributes:Object.values(o)}),Object.values(o)))i.setAttributeProperties(e,{isFormatting:!0});m(e,"table",o,t),p(l,{modelAttribute:o.color,styleName:"border-color"}),p(l,{modelAttribute:o.style,styleName:"border-style"}),p(l,{modelAttribute:o.width,styleName:"border-width"})}(d,{color:h.borderColor,style:h.borderStyle,width:h.borderWidth}),d.commands.add("tableBorderColor",new la(d,h.borderColor)),d.commands.add("tableBorderStyle",new ls(d,h.borderStyle)),d.commands.add("tableBorderWidth",new ld(d,h.borderWidth)),d.config.get("experimentalFlags.useExtendedTableBlockAlignment")?(e=u,t=c,l=h.alignment,i=f,e.extend("table",{allowAttributes:["tableAlignment"]}),e.setAttributeProperties("tableAlignment",{isFormatting:!0}),t.for("downcast").attributeToAttribute({model:{name:"table",key:"tableAlignment",values:["left","center","right","blockLeft","blockRight"]},view:{left:i?{key:"style",value:{float:"left","margin-right":"var(--ck-content-table-style-spacing, 1.5em)"}}:{key:"class",value:y},right:i?{key:"style",value:{float:"right","margin-left":"var(--ck-content-table-style-spacing, 1.5em)"}}:{key:"class",value:v},center:i?{key:"style",value:{"margin-left":"auto","margin-right":"auto"}}:{key:"class",value:_},blockLeft:i?{key:"style",value:{"margin-left":"0","margin-right":"auto"}}:{key:"class",value:T},blockRight:i?{key:"style",value:{"margin-left":"auto","margin-right":"0"}}:{key:"class",value:A}},converterPriority:"high"}),k.forEach(e=>{t.for("upcast").attributeToAttribute({view:e.view,model:{key:"tableAlignment",value:(t,i,o)=>{var n;if("figure"==(n=t).name&&!n.hasClass("table"))return;let r=w(l,"",o),a=e.getAlign(t),s=e.getConsumables(t);if(i.consumable.consume(t,s),a!==r)return a}}})}),t.for("upcast").add((o=l,e=>{e.on("element:div",(e,t,l)=>{if(!l.consumable.test(t.viewItem,{name:!0,attributes:"align"}))return;let i=q(t.viewItem);if(!i||!l.consumable.test(i,{name:!0}))return;l.consumable.consume(t.viewItem,{name:!0,attributes:"align"});let r=l.convertItem(i,t.modelCursor),a=(0,n.$1)(r.modelRange.getItems());if(!a||!a.is("element","table")){l.consumable.revert(t.viewItem,{name:!0,attributes:"align"}),r.modelRange&&!r.modelRange.isCollapsed&&(t.modelRange=r.modelRange,t.modelCursor=r.modelCursor);return}let s=function(e,t,l){if(e)switch(e){case"right":if("right"===t)return"right";if("left"===t)return"left";return"blockRight";case"center":return"center";case"left":return void 0===t?"blockLeft":"left";default:return l}}(t.viewItem.getAttribute("align"),i.getAttribute("align"),w(o,"",t));s&&l.writer.setAttribute("tableAlignment",s,a),l.convertChildren(t.viewItem,l.writer.createPositionAt(a,"end")),l.updateConversionResult(a,t)})}))):(r=u,a=c,s=h.alignment,r.extend("table",{allowAttributes:["tableAlignment"]}),r.setAttributeProperties("tableAlignment",{isFormatting:!0}),a.for("downcast").attributeToAttribute({model:{name:"table",key:"tableAlignment",values:["left","center","right"]},view:{left:{key:"style",value:{float:"left"}},right:{key:"style",value:{float:"right"}},center:(e,t,l)=>({key:"style",value:"layout"!==l.item.getAttribute("tableType")?{float:"none"}:{"margin-left":"auto","margin-right":"auto"}})},converterPriority:"high"}),a.for("upcast").attributeToAttribute({view:{name:/^(table|figure)$/,styles:{float:/^(left|none|right)$/}},model:{key:"tableAlignment",value:(e,t,l)=>{if("figure"==e.name&&!e.hasClass("table"))return;let i=w(s,"",l),o=e.getStyle("float");if("none"===o&&(o="center"),o!==i)return o;t.consumable.consume(e,{styles:"float"})}}}).attributeToAttribute({view:{name:/^(table|figure)$/,styles:{"margin-left":"auto","margin-right":"auto"}},model:{key:"tableAlignment",value:(e,t,l)=>{if("figure"==e.name&&!e.hasClass("table"))return;let i=w(s,"",l),o="center";if(o!==i)return o;t.consumable.consume(e,{styles:["margin-left","margin-right"]})}}}).attributeToAttribute({view:{name:"table",attributes:{align:/^(left|center|right)$/}},model:{key:"tableAlignment",value:(e,t,l)=>{let i=w(s,"",l),o=e.getAttribute("align");if(o!==i)return o;t.consumable.consume(e,{attributes:"align"})}}})),d.commands.add("tableAlignment",new lh(d,h.alignment)),lm(u,c,{modelAttribute:"tableWidth",styleName:"width",attributeName:"width",attributeType:"length",defaultValue:h.width}),d.commands.add("tableWidth",new lu(d,h.width)),lm(u,c,{modelAttribute:"tableHeight",styleName:"height",attributeName:"height",attributeType:"length",defaultValue:h.height}),d.commands.add("tableHeight",new lc(d,h.height)),d.data.addStyleProcessorRules(b.$xF),function(e,t,l){let{modelAttribute:i}=l;e.extend("table",{allowAttributes:[i]}),e.setAttributeProperties(i,{isFormatting:!0}),g(t,{viewElement:"table",...l}),p(t,l)}
1(u,c,{modelAttribute:"tableBackgroundColor",styleName:"background-color",attributeName:"bgcolor",attributeType:"color",defaultValue:h.backgroundColor}),d.commands.add("tableBackgroundColor",new lr(d,h.backgroundColor)),d.config.get("experimentalFlags.useExtendedTableBlockAlignment")){let e=d.editing.view.document;this.listenTo(e,"clipboardOutput",(e,t)=>{d.editing.view.change(e=>{for(let{item:l}of e.createRangeIn(t.content))!function(e,t){if(!e.is("element","table"))return;let l=e.getAttribute("align"),i=e.getStyle("float"),o=e.getStyle("margin-left"),n=e.getStyle("margin-right");l&&"center"===l||i&&"right"===i&&l&&"right"===l?lg(t,l,e):void 0===i&&"auto"===o&&"0"===n&&lg(t,"right",e)}(l,e);t.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(t.content))})},{priority:"lowest"})}}}function lg(e,t,l){let i=e.createPositionBefore(l),o=e.createContainerElement("div",{align:t},l);e.insert(i,o)}function lm(e,t,l){let{modelAttribute:i}=l;e.extend("table",{allowAttributes:[i]}),e.setAttributeProperties(i,{isFormatting:!0}),g(t,{viewElement:/^(table|figure)$/,shouldUpcast:e=>!("table"==e.name&&"figure"==e.parent.name||"figure"==e.name&&!e.hasClass("table")),...l}),f(t,{modelElement:"table",...l})}class lf extends c.Ss{options;focusTracker;keystrokes;children;borderStyleDropdown;borderWidthInput;borderColorInput;backgroundInput;widthInput;heightInput;alignmentToolbar;saveButtonView;cancelButtonView;_focusables;_focusCycler;constructor(e,t){super(e),this.set({borderStyle:"",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:"",alignment:""}),this.options=t;const{borderStyleDropdown:l,borderWidthInput:i,borderColorInput:o,borderRowLabel:r}=this._createBorderFields(),{backgroundRowLabel:a,backgroundInput:s}=this._createBackgroundFields(),{widthInput:d,operatorLabel:u,heightInput:h,dimensionsLabel:b}=this._createDimensionFields(),{alignmentToolbar:g,alignmentLabel:m}=this._createAlignmentFields();this.focusTracker=new n.$x,this.keystrokes=new n.EP,this.children=this.createCollection(),this.borderStyleDropdown=l,this.borderWidthInput=i,this.borderColorInput=o,this.backgroundInput=s,this.widthInput=d,this.heightInput=h,this.alignmentToolbar=g;const{saveButtonView:f,cancelButtonView:p}=this._createActionButtons();this.saveButtonView=f,this.cancelButtonView=p,this._focusables=new c.s3,this._focusCycler=new c.H({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.add(new c.Dy(e,{label:this.t("Table properties")})),this.children.add(new c.Q9(e,{labelView:r,children:[r,l,o,i],class:"ck-table-form__border-row"})),this.children.add(new c.Q9(e,{labelView:a,children:[a,s],class:"ck-table-form__background-row"})),this.children.add(new c.Q9(e,{children:[new c.Q9(e,{labelView:b,children:[b,d,u,h],class:"ck-table-form__dimensions-row"}),new c.Q9(e,{labelView:m,children:[m,g],class:"ck-table-properties-form__alignment-row"})]})),this.children.add(new c.Q9(e,{children:[this.saveButtonView,this.cancelButtonView],class:"ck-table-form__action-row"})),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-table-form","ck-table-properties-form"],tabindex:"-1"},children:this.children})}render(){super.render(),(0,c.Z5)({view:this}),[this.borderColorInput,this.backgroundInput].forEach(e=>{this._focusCycler.chain(e.fieldView.focusCycler)}),[this.borderStyleDropdown,this.borderColorInput,this.borderWidthInput,this.backgroundInput,this.widthInput,this.heightInput,this.alignmentToolbar,this.saveButtonView,this.cancelButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBorderFields(){let e=this.options.defaultTableProperties,t={style:e.borderStyle,width:e.borderWidth,color:e.borderColor},l=tA({colorConfig:this.options.borderColors,columns:5,defaultColorValue:t.color,colorPickerConfig:this.options.colorPickerConfig}),i=this.locale,o=this.t,n=o("Style"),r=new c.y0(i);r.text=o("Border");let a=tm(o),s=new c.xE(i,c.By);s.set({label:n,class:"ck-table-form__border-style"}),s.fieldView.buttonView.set({ariaLabel:n,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:n}),s.fieldView.buttonView.bind("label").to(this,"borderStyle",e=>a[e||"none"]),s.fieldView.on("execute",e=>{this.borderStyle=e.source._borderStyleValue}),s.bind("isEmpty").to(this,"borderStyle",e=>!e),(0,c.O)(s.fieldView,t_(this,t.style),{role:"menu",ariaLabel:n});let d=new c.xE(i,c.Vr);d.set({label:o("Width"),class:"ck-table-form__border-width"}),d.fieldView.bind("value").to(this,"borderWidth"),d.bind("isEnabled").to(this,"borderStyle",lp),d.fieldView.on("input",()=>{this.borderWidth=d.fieldView.element.value});let u=new c.xE(i,l);return u.set({label:o("Color"),class:"ck-table-form__border-color"}),u.fieldView.bind("value").to(this,"borderColor"),u.bind("isEnabled").to(this,"borderStyle",lp),u.fieldView.on("input",()=>{this.borderColor=u.fieldView.value}),this.on("change:borderStyle",(e,l,i,o)=>{lp(i)||(this.borderColor="",this.borderWidth=""),lp(o)||(this.borderColor=t.color,this.borderWidth=t.width)}),{borderRowLabel:r,borderStyleDropdown:s,borderColorInput:u,borderWidthInput:d}}
1_createBackgroundFields(){let e=this.locale,t=this.t,l=new c.y0(e);l.text=t("Background");let i=tA({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableProperties.backgroundColor,colorPickerConfig:this.options.colorPickerConfig}),o=new c.xE(e,i);return o.set({label:t("Color"),class:"ck-table-properties-form__background"}),o.fieldView.bind("value").to(this,"backgroundColor"),o.fieldView.on("input",()=>{this.backgroundColor=o.fieldView.value}),{backgroundRowLabel:l,backgroundInput:o}}_createDimensionFields(){let e=this.locale,t=this.t,l=new c.y0(e);l.text=t("Dimensions");let i=new c.xE(e,c.Vr);i.set({label:t("Width"),class:"ck-table-form__dimensions-row__width"}),i.fieldView.bind("value").to(this,"width"),i.fieldView.on("input",()=>{this.width=i.fieldView.element.value});let o=new c.Ss(e);o.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"\xd7"}]});let n=new c.xE(e,c.Vr);return n.set({label:t("Height"),class:"ck-table-form__dimensions-row__height"}),n.fieldView.bind("value").to(this,"height"),n.fieldView.on("input",()=>{this.height=n.fieldView.element.value}),{dimensionsLabel:l,widthInput:i,operatorLabel:o,heightInput:n}}_createAlignmentFields(){let e=this.locale,t=this.t,l=new c.y0(e);l.text=t("Alignment");let i=new c.X3(e);return i.set({role:"radiogroup",isCompact:!0,ariaLabel:t("Table alignment toolbar")}),tv({view:this,icons:{left:u.xhb,center:u.yHl,right:u.i_b},toolbar:i,labels:this._alignmentLabels,propertyName:"alignment",defaultValue:this.options.defaultTableProperties.alignment}),{alignmentLabel:l,alignmentToolbar:i}}_createActionButtons(){let e=this.locale,t=this.t,l=new c._(e),i=new c._(e),o=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.widthInput,this.heightInput];return l.set({label:t("Save"),icon:u.iWP,class:"ck-button-save",type:"submit",withText:!0}),l.bind("isEnabled").toMany(o,"errorText",(...e)=>e.every(e=>!e)),i.set({label:t("Cancel"),icon:u.AUn,class:"ck-button-cancel",withText:!0}),i.delegate("execute").to(this,"cancel"),{saveButtonView:l,cancelButtonView:i}}get _alignmentLabels(){let e=this.locale,t=this.t,l=t("Align table to the left"),i=t("Center table"),o=t("Align table to the right");return"rtl"===e.uiLanguageDirection?{right:o,center:i,left:l}:{left:l,center:i,right:o}}}function lp(e){return"none"!==e}let lw={borderStyle:"tableBorderStyle",borderColor:"tableBorderColor",borderWidth:"tableBorderWidth",backgroundColor:"tableBackgroundColor",width:"tableWidth",height:"tableHeight",alignment:"tableAlignment"};class lC extends i.k_{_defaultContentTableProperties;_defaultLayoutTableProperties;_balloon;view=null;_viewWithContentTableDefaults=null;_viewWithLayoutTableDefaults=null;_undoStepBatch;_isReady;static get requires(){return[c.pU]}static get pluginName(){return"TablePropertiesUI"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("table.tableProperties",{borderColors:tT,backgroundColors:tT})}init(){let e=this.editor;this._defaultContentTableProperties=et(e.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0}),this._defaultLayoutTableProperties=ee(),this._balloon=e.plugins.get(c.pU),e.ui.componentFactory.add("tableProperties",()=>this._createTablePropertiesButton())}_createTablePropertiesButton(){let e=this.editor,t=e.t,l=new c._(e.locale);l.set({label:t("Table properties"),icon:u.FYj,tooltip:!0}),this.listenTo(l,"execute",()=>this._showView());let i=Object.values(lw).map(t=>e.commands.get(t));return l.bind("isEnabled").toMany(i,"isEnabled",(...e)=>e.some(e=>e)),l}destroy(){super.destroy(),this.view&&this.view.destroy()}_createPropertiesView(e){let t=this.editor,l=t.config.get("table.tableProperties"),i=(0,c.lF)(l.borderColors),o=(0,c.b2)(t.locale,i),n=(0,c.lF)(l.backgroundColors),r=(0,c.b2)(t.locale,n),a=!1!==l.colorPicker,s=new lf(t.locale,{borderColors:o,backgroundColors:r,defaultTableProperties:e,colorPickerConfig:!!a&&(l.colorPicker||{})}),d=t.t;s.render(),this.listenTo(s,"submit",()=>{this._hideView()}),this.listenTo(s,"cancel",()=>
1{this._undoStepBatch.operations.length&&t.execute("undo",this._undoStepBatch),this._hideView()}),s.keystrokes.set("Esc",(e,t)=>{this._hideView(),t()}),(0,c.wy)({emitter:s,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});let u=tf(d),h=tp(d);return s.on("change:borderStyle",this._getPropertyChangeCallback("tableBorderStyle")),s.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:s.borderColorInput,commandName:"tableBorderColor",errorText:u,validator:tw})),s.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:s.borderWidthInput,commandName:"tableBorderWidth",errorText:h,validator:ty})),s.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:s.backgroundInput,commandName:"tableBackgroundColor",errorText:u,validator:tw})),s.on("change:width",this._getValidatedPropertyChangeCallback({viewField:s.widthInput,commandName:"tableWidth",errorText:h,validator:tC})),s.on("change:height",this._getValidatedPropertyChangeCallback({viewField:s.heightInput,commandName:"tableHeight",errorText:h,validator:tC})),s.on("change:alignment",this._getPropertyChangeCallback("tableAlignment")),s}_fillViewFormFromCommandValues(){let e=this.editor.commands,t=e.get("tableBorderStyle");Object.entries(lw).map(([t,l])=>{let i=this.view===this._viewWithContentTableDefaults?this._defaultContentTableProperties[t]||"":this._defaultLayoutTableProperties[t]||"";return[t,e.get(l).value||i]}).forEach(([e,l])=>{("borderColor"!==e&&"borderWidth"!==e||"none"!==t.value)&&this.view.set(e,l)}),this._isReady=!0}_showView(){let e=this.editor,t=ts(e.editing.view.document.selection),l=t&&e.editing.mapper.toModelElement(t),i=!l||"layout"!==l.getAttribute("tableType");i&&!this._viewWithContentTableDefaults?this._viewWithContentTableDefaults=this._createPropertiesView(this._defaultContentTableProperties):i||this._viewWithLayoutTableDefaults||(this._viewWithLayoutTableDefaults=this._createPropertiesView(this._defaultLayoutTableProperties)),this.view=i?this._viewWithContentTableDefaults:this._viewWithLayoutTableDefaults,this.listenTo(e.ui,"update",()=>{this._updateView()}),this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:tR(e)}),this._undoStepBatch=e.model.createBatch(),this.view.focus()}_hideView(){let e=this.editor;this.stopListening(e.ui,"update"),this._isReady=!1,this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}_updateView(){let e=this.editor;ts(e.editing.view.document.selection)?this._isViewVisible&&tP(e,"table"):this._hideView()}get _isViewVisible(){return!!this.view&&this._balloon.visibleView===this.view}get _isViewInBalloon(){return!!this.view&&this._balloon.hasView(this.view)}_getPropertyChangeCallback(e){return(t,l,i)=>{this._isReady&&this.editor.execute(e,{value:i,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(e){let{commandName:t,viewField:l,validator:i,errorText:o}=e,n=(0,a.s)(()=>{l.errorText=o},500);return(e,o,r)=>{n.cancel(),this._isReady&&(i(r)?(this.editor.execute(t,{value:r,batch:this._undoStepBatch}),l.errorText=null):n())}}}class ly extends i.k_{static get pluginName(){return"TableProperties"}static get isOfficialPlugin(){return!0}static get requires(){return[lb,lC]}}function l_(e){e.document.registerPostFixer(t=>(function(e,t){let l=t.document.differ.getChanges(),i=!1;for(let t of l){if("insert"!=t.type)continue;let l=t.position.parent;if(l.is("element","table")||"table"==t.name){let o="table"==t.name?t.position.nodeAfter:l,n=Array.from(o.getChildren()).filter(e=>e.is("element","caption")),r=n.shift();if(!r)continue;for(let t of n)e.move(e.createRangeIn(t),r,"end"),e.remove(t);r.nextSibling&&(e.move(e.createRangeOn(r),o,"end"),i=!0),i=!!n.length||i}}return i})(t,e))}function lv(e){return!!e&&e.is("element","table")}function lT(e){for(let t of e.getChildren())if(t.is("element","caption"))return t;return null}function lA(e){let t=B(e);return t?lT(t):null}function lk(e){let t=e.parent;return"figcaption"==e.name&&t&&t.is("element","figure")&&t.hasClass("table")||"caption"==e.name&&t&&t.is("element","table")?{name:!0}:null}class lV extends i.uB{refresh(){let e=this.editor,t=B(e.model.document.selection);this.isEnabled=!!t&&e.model.schema.checkChild(t,"caption"),this.isEnabled?this.value=!!lT(t):this.value=!1}execute({focusCaptionOnShow:e=!1}={}){this.editor.model.change(t=>{this.value?this._hideTableCaption(t):this._showTableCaption(t,e)})}_showTableCaption(e,t){let l=this.editor.model,i=B(l.document.selection),o=this.editor.plugins.get("TableCaptionEditing")._getSavedCaption(i)||e.createElement("caption");l.insertContent(o,i,"end"),t&&e.setSelection(o,"in")}_hideTableCaption(e){let t=this.editor.model,l=B(t.document.selection),i=this.editor.plugins.get("TableCaptionEditing"),o=lT(l);i._saveCaption(l,o),t.deleteContent(e.createSelection(o,"on"))}}class lx extends i.k_{_savedCaptionsMap=new WeakMap;_captionIdsMapping=new WeakMap;static get pluginName(){return"TableCaptionEditing"}static get isOfficialPlugin(){return!0}init(){let e=this.editor,t=e.model.schema,l=e.editing.view,i=e.t,r=e.config.get("table.tableCaption.useCaptionElement");t.isRegistered("caption")?t.extend("caption",{allowIn:"table"}):t.register("caption",{allowIn:"table",allowContentOf:"$block",isLimit:!0}),e.commands.add("toggleTableCaption",new lV(this.editor)),r&&e.plugins.get("TableEditing").registerAdditionalSlot({filter:e=>e.is("element","caption"),positionOffset:"end"}),e.conversion.for("upcast").elementToElement({view:lk,model:"caption"}),e.conversion.for("dataDowncast").elementToElement({model:"caption",view:(e,{writer
1:t})=>lv(e.parent)?t.createContainerElement(r?"caption":"figcaption"):null}),e.conversion.for("editingDowncast").elementToElement({model:"caption",view:(e,{writer:t})=>{if(!lv(e.parent))return null;let n=t.createEditableElement(r?"caption":"figcaption");return t.setCustomProperty("tableCaption",!0,n),n.placeholder=i("Enter table caption"),(0,b.M5m)({view:l,element:n,keepOnFocus:!0}),(0,o.YN)(n,t)}}),e.conversion.for("editingDowncast").add(e=>{e.on("insert:table",(e,t,{writer:l,mapper:i})=>{let o,r=t.item,a=i.toViewElement(r);if(!a)return;let s=Array.from(a.getChildren()).find(e=>e.is("element","table"));if(!s)return;let d=lT(r);if(!d)return void l.removeAttribute("aria-labelledby",s);let u=i.toViewElement(d);u&&(o=u.hasAttribute("id")?u.getAttribute("id"):this._captionIdsMapping.get(d)??`ck-editor__caption_${(0,n.Ld)()}`,this._captionIdsMapping.set(d,o),l.setAttribute("id",o,u),l.setAttribute("aria-labelledby",o,s))},{priority:"low"})}),l_(e.model)}_getSavedCaption(e){let t=this._savedCaptionsMap.get(e);return t?b.WXz.fromJSON(t):null}_saveCaption(e,t){this._savedCaptionsMap.set(e,t.toJSON())}}class lS extends i.k_{static get pluginName(){return"TableCaptionUI"}static get isOfficialPlugin(){return!0}init(){let e=this.editor,t=e.editing.view,l=e.t;e.ui.componentFactory.add("toggleTableCaption",i=>{let o=e.commands.get("toggleTableCaption"),n=new c._(i);return n.set({icon:u.UKq,tooltip:!0,isToggleable:!0}),n.bind("isOn","isEnabled").to(o,"value","isEnabled"),n.bind("label").to(o,"value",e=>e?l("Toggle caption off"):l("Toggle caption on")),this.listenTo(n,"execute",()=>{if(e.execute("toggleTableCaption",{focusCaptionOnShow:!0}),o.value){let l=lA(e.model.document.selection),i=e.editing.mapper.toViewElement(l);if(!i)return;t.scrollToTheSelection(),t.change(e=>{e.addClass("table__caption_highlighted",i)})}e.editing.view.focus()}),n})}}class lP extends i.k_{static get pluginName(){return"TableCaption"}static get isOfficialPlugin(){return!0}static get requires(){return[lx,lS]}}function lR(e){return{none:e("None"),solid:e("Solid"),dotted:e("Dotted"),dashed:e("Dashed"),double:e("Double"),groove:e("Groove"),ridge:e("Ridge"),inset:e("Inset"),outset:e("Outset")}}function lE(e,t){let l=new n.pM,i=lR(e.t);for(let o in i){let n={type:"button",model:new c.e_({_borderStyleValue:o,label:i[o],role:"menuitemradio",withText:!0})};"none"===o?n.model.bind("isOn").to(e,"borderStyle",e=>"none"===t?!e:e===o):n.model.bind("isOn").to(e,"borderStyle",e=>e===o),l.add(n)}return l}function lI(e){let{view:t,icons:l,toolbar:i,labels:o,propertyName:n,nameToValue:r,defaultValue:a}=e;for(let e in o){let s=new c._(t.locale);s.set({role:"radio",isToggleable:!0,label:o[e],icon:l[e],tooltip:o[e]});let d=r?r(e):e;s.bind("isOn").to(t,n,e=>{let t=e;return""===e&&a&&(t=a),d===t}),s.on("execute",()=>{!a&&d&&t[n]===d?t[n]=void 0:t[n]=d}),i.items.add(s)}}function lB(e){return(t,l,i)=>{let o=new tb(t.locale,{colorDefinitions:e.colorConfig.map(e=>({color:e.model,label:e.label,options:{hasBorder:e.hasBorder}})),columns:e.columns,defaultColorValue:e.defaultColorValue,colorPickerConfig:e.colorPickerConfig});return o.inputView.set({id:l,ariaDescribedById:i}),o.bind("isReadOnly").to(t,"isEnabled",e=>!e),o.bind("hasError").to(t,"errorText",e=>!!e),o.on("input",()=>{t.errorText=null}),t.bind("isEmpty","isFocused").to(o),o}}class lF extends c.Ss{options;focusTracker;keystrokes;children;borderStyleDropdown;borderWidthInput;borderColorInput;backgroundInput;widthInput;heightInput;alignmentToolbar;saveButtonView;cancelButtonView;backButtonView;_focusables;_focusCycler;constructor(e,t){super(e),this.set({borderStyle:"",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:"",alignment:""}),this.options=t;const{borderStyleDropdown:l,borderWidthInput:i,borderColorInput:o,borderRowLabel:r}=this._createBorderFields(),{backgroundRowLabel:a,backgroundInput:s}=this._createBackgroundFields(),{widthInput:d,operatorLabel:u,heightInput:h,dimensionsLabel:b}=this._createDimensionFields(),{alignmentToolbar:g,alignmentLabel:m}=this._createAlignmentFields();this.focusTracker=new n.$x,this.keystrokes=new n.EP,this.children=this.createCollection(),this.borderStyleDropdown=l,this.borderWidthInput=i,this.borderColorInput=o,this.backgroundInput
1=s,this.widthInput=d,this.heightInput=h,this.alignmentToolbar=g;const{saveButtonView:f,cancelButtonView:p}=this._createActionButtons();this.saveButtonView=f,this.cancelButtonView=p,this.backButtonView=this._createBackButton(),this._focusables=new c.s3,this._focusCycler=new c.H({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});const w=new c.Dy(e,{label:this.t("Table properties")});w.children.add(this.backButtonView,0),this.children.add(w),this.children.add(new c.Q9(e,{labelView:r,children:[r,l,i,o],class:"ck-table-form__border-row"})),this.children.add(new c.Q9(e,{children:[new c.Q9(e,{labelView:b,children:[b,d,u,h],class:"ck-table-form__dimensions-row"}),new c.Q9(e,{labelView:a,children:[a,s],class:"ck-table-form__background-row"})]})),this.children.add(new c.Q9(e,{labelView:m,children:[m,g],class:"ck-table-properties-form__alignment-row"})),this.children.add(new c.Q9(e,{children:[this.cancelButtonView,this.saveButtonView],class:"ck-table-form__action-row"})),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-table-form","ck-table-properties-form","ck-table-properties-form_experimental"],tabindex:"-1"},children:this.children})}render(){super.render(),(0,c.Z5)({view:this}),[this.borderColorInput,this.backgroundInput].forEach(e=>{this._focusCycler.chain(e.fieldView.focusCycler)}),[this.borderStyleDropdown,this.borderWidthInput,this.borderColorInput,this.widthInput,this.heightInput,this.backgroundInput,this.alignmentToolbar,this.cancelButtonView,this.saveButtonView,this.backButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBorderFields(){let e=this.options.defaultTableProperties,t={style:e.borderStyle,width:e.borderWidth,color:e.borderColor},l=lB({colorConfig:this.options.borderColors,columns:5,defaultColorValue:t.color,colorPickerConfig:this.options.colorPickerConfig}),i=this.locale,o=this.t,n=o("Style"),r=new c.y0(i);r.text=o("Border");let a=lR(o),s=new c.xE(i,c.By);s.set({label:n,class:"ck-table-form__border-style"}),s.fieldView.buttonView.set({ariaLabel:n,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:n}),s.fieldView.buttonView.bind("label").to(this,"borderStyle",e=>a[e||"none"]),s.fieldView.on("execute",e=>{this.borderStyle=e.source._borderStyleValue}),s.bind("isEmpty").to(this,"borderStyle",e=>!e),(0,c.O)(s.fieldView,lE(this,t.style),{role:"menu",ariaLabel:n});let d=new c.xE(i,c.Vr);d.set({label:o("Width"),class:"ck-table-form__border-width"}),d.fieldView.bind("value").to(this,"borderWidth"),d.bind("isEnabled").to(this,"borderStyle",lW),d.fieldView.on("input",()=>{this.borderWidth=d.fieldView.element.value});let u=new c.xE(i,l);return u.set({label:o("Color"),class:"ck-table-form__border-color"}),u.fieldView.bind("value").to(this,"borderColor"),u.bind("isEnabled").to(this,"borderStyle",lW),u.fieldView.on("input",()=>{this.borderColor=u.fieldView.value}),this.on("change:borderStyle",(e,l,i,o)=>{lW(i)||(this.borderColor="",this.borderWidth=""),lW(o)||(this.borderColor=t.color,this.borderWidth=t.width)}),{borderRowLabel:r,borderStyleDropdown:s,borderColorInput:u,borderWidthInput:d}}_createBackgroundFields(){let e=this.locale,t=this.t,l=new c.y0(e);l.text=t("Background");let i=lB({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableProperties.backgroundColor,colorPickerConfig:this.options.colorPickerConfig}),o=new c.xE(e,i);return o.set({label:t("Color"),class:"ck-table-properties-form__background"}),o.fieldView.bind("value").to(this,"backgroundColor"),o.fieldView.on("input",()=>{this.backgroundColor=o.fieldView.value}),{backgroundRowLabel:l,backgroundInput:o}}_createDimensionFields(){let e=this.locale,t=this.t,l=new c.y0(e);l.text=t("Dimensions");let i=new c.xE(e,c.Vr);i.set({label:t("Width"),class:"ck-table-form__dimensions-row__width"}),i.fieldView.bind("value").to(this,"width"),i.fieldView.on("input",()=>{this.width=i.fieldView.element.value});let o=new c.Ss(e);o.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"\xd7"}]});let n=new c.xE(e,c.Vr);return n.set({label:t("Height"),class:"ck-table-form__dimensions-row__height"}),n.fieldView.bind("value").to(this,"height"),n.fieldView.on("input",()=>{this.height=n.fieldView.element.value}),{dimensionsLabel:l,widthInput:i,operatorLabel:o,heightInput:n}}_createAlignmentFields(){let e=this.locale,t=this.t,l=new c.y0(e);l.text=t("Table Alignment");let i=new c.X3(e);return i.set({role:"radiogroup",isCompact:!0,ariaLabel:t("Table alignment toolbar")}),lI({view:this,icons:{left:u.xhb,center:u.yHl,right:u.i_b,blockLeft:u.m1L,blockRight:u.$_F},toolbar:i,labels:this._alignmentLabels,propertyName:"alignment",defaultValue:this.options.defaultTableProperties.alignment}),{alignmentLabel:l,alignmentToolbar:i}}_createActionButtons(){let e=this.locale,t=this.t,l=new c._(e),i=new c._(e),o=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.widthInput,this.heightInput];return l.set({label:t("Save"),class:"ck-button-action",type:"submit",withText:!0}),l.bind("isEnabled").toMany(o,"errorText",(...e)=>e.every(e=>!e)),i.set({label:t("Cancel"),withText:!0}),i.delegate("execute").to(this,"cancel"),{saveButtonView:l,cancelButtonView:i}}_createBackButton(){let e=this.locale.t,t=new c._(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:u.saM,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}get _alignmentLabels(){let e=this.locale,t=this.t,l=t("Align table to the left with no text wrapping"),i=t("Align table to the right with no text wrapping"),o=t("Align table to the left with text wrapping"),n=t("Center table with no text wrapping"),r=t("Align table to the right with text wrapping");return"rtl"===e.uiLanguageDirection?{right:r,left:o,blockRight:i,center:n,blockLeft:l}:{blockLeft:l,center:n,blockRight:i,left:o,right:r}}}function lW(e){return"none"!==e}let lD={borderStyle:"tableBorderStyle",borderColor:"tableBorderColor",borderWidth:"tableBorderWidth",backgroundColor:"tableBackgroun
1dColor",width:"tableWidth",height:"tableHeight",alignment:"tableAlignment"};class lL extends i.k_{_defaultContentTableProperties;_defaultLayoutTableProperties;_balloon;view=null;_viewWithContentTableDefaults=null;_viewWithLayoutTableDefaults=null;_undoStepBatch;_isReady;static get requires(){return[c.pU]}static get pluginName(){return"TablePropertiesUIExperimental"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("table.tableProperties",{borderColors:tT,backgroundColors:tT})}init(){let e=this.editor;this._defaultContentTableProperties=et(e.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0}),this._defaultLayoutTableProperties=ee(),this._balloon=e.plugins.get(c.pU),e.ui.componentFactory.add("tableProperties",()=>this._createTablePropertiesButton())}_createTablePropertiesButton(){let e=this.editor,t=e.t,l=new c._(e.locale);l.set({label:t("Table properties"),icon:u.FYj,tooltip:!0}),this.listenTo(l,"execute",()=>this._showView());let i=Object.values(lD).map(t=>e.commands.get(t));return l.bind("isEnabled").toMany(i,"isEnabled",(...e)=>e.some(e=>e)),l}destroy(){super.destroy(),this.view&&this.view.destroy()}_createPropertiesView(e){let t=this.editor,l=t.config.get("table.tableProperties"),i=(0,c.lF)(l.borderColors),o=(0,c.b2)(t.locale,i),n=(0,c.lF)(l.backgroundColors),r=(0,c.b2)(t.locale,n),a=!1!==l.colorPicker,s=new lF(t.locale,{borderColors:o,backgroundColors:r,defaultTableProperties:e,colorPickerConfig:!!a&&(l.colorPicker||{})}),d=t.t;s.render(),this.listenTo(s,"submit",()=>{this._hideView()}),this.listenTo(s,"cancel",()=>{this._undoStepBatch.operations.length&&t.execute("undo",this._und
1oStepBatch),this._hideView()}),s.keystrokes.set("Esc",(e,t)=>{this._hideView(),t()}),(0,c.wy)({emitter:s,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});let u=tf(d),h=tp(d);return s.on("change:borderStyle",this._getPropertyChangeCallback("tableBorderStyle")),s.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:s.borderColorInput,commandName:"tableBorderColor",errorText:u,validator:tw})),s.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:s.borderWidthInput,commandName:"tableBorderWidth",errorText:h,validator:ty})),s.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:s.backgroundInput,commandName:"tableBackgroundColor",errorText:u,validator:tw})),s.on("change:width",this._getValidatedPropertyChangeCallback({viewField:s.widthInput,commandName:"tableWidth",errorText:h,validator:tC})),s.on("change:height",this._getValidatedPropertyChangeCallback({viewField:s.heightInput,commandName:"tableHeight",errorText:h,validator:tC})),s.on("change:alignment",this._getPropertyChangeCallback("tableAlignment")),s}_fillViewFormFromCommandValues(){let e=this.editor.commands,t=e.get("tableBorderStyle");Object.entries(lD).map(([t,l])=>{let i=this.view===this._viewWithContentTableDefaults?this._defaultContentTableProperties[t]||"":this._defaultLayoutTableProperties[t]||"";return[t,e.get(l).value||i]}).forEach(([e,l])=>{("borderColor"!==e&&"borderWidth"!==e||"none"!==t.value)&&this.view.set(e,l)}),this._isReady=!0}_showView(){let e=this.editor,t=ts(e.editing.view.document.selection),l=t&&e.editing.mapper.toModelElement(t),i=!l||"layout"!==l.getAttribute("tableType");i&&!this._viewWithContentTableDefaults?this._viewWithContentTableDefaults=this._createPropertiesView(this._defaultContentTableProperties):i||this._viewWithLayoutTableDefaults||(this._viewWithLayoutTableDefaults=this._createPropertiesView(this._defaultLayoutTableProperties)),this.view=i?this._viewWithContentTableDefaults:this._viewWithLayoutTableDefaults,this.listenTo(e.ui,"update",()=>{this._updateView()}),this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:tR(e)}),this._undoStepBatch=e.model.createBatch(),this.view.focus()}_hideView(){let e=this.editor;this.stopListening(e.ui,"update"),this._isReady=!1,this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}_updateView(){let e=this.editor;ts(e.editing.view.document.selection)?this._isViewVisible&&tP(e,"table"):this._hideView()}get _isViewVisible(){return!!this.view&&this._balloon.visibleView===this.view}get _isViewInBalloon(){return!!this.view&&this._balloon.hasView(this.view)}_getPropertyChangeCallback(e){return(t,l,i)=>{this._isReady&&this.editor.execute(e,{value:i,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(e){let{commandName:t,viewField:l,validator:i,errorText:o}=e,n=(0,a.s)(()=>{l.errorText=o},500);return(e,o,r)=>{n.cancel(),this._isReady&&(i(r)?(this.editor.execute(t,{value:r,batch:this._undoStepBatch}),l.errorText=null):n())}}}class lN extends c.Ss{options;focusTracker;keystrokes;children;borderStyleDropdown;borderWidthInput;borderColorInput;backgroundInput;cellTypeDropdown;paddingInput;widthInput;heightInput;horizontalAlignmentToolbar;verticalAlignmentToolbar;saveButtonView;cancelButtonView;backButtonView;_focusables;_focusCycler;constructor(e,t){super(e),this.set({borderStyle:"",borderWidth:"",borderColor:"",padding:"",backgroundColor:"",width:"",height:"",horizontalAlignment:"",verticalAlignment:"",cellType:""}),this.options=t;const{borderStyleDropdown:l,borderWidthInput:i,borderColorInput:o,borderRowLabel:r}=this._createBorderFields(),{backgroundRowLabel:a,backgroundInput:s}=this._createBackgroundFields(),{cellTypeRowLabel:d,cellTypeDropdown:u}=this._createCellTypeField(),{widthInput:h,operatorLabel:b,heightInput:g,dimensionsLabel:m}=this._createDimensionFields(),{horizontalAlignmentToolbar:f,verticalAlignmentToolbar:p,alignmentLabel:w}=this._createAlignmentFields();this.focusTracker=new n.$x,this.keystrokes=new n.EP,this.children=this.createCollection(),this.borderStyleDropdown=l,this.borderWidthInput=i,this.borderColorInput=o,this.backgroundInput
1=s,this.cellTypeDropdown=u,this.paddingInput=this._createPaddingField(),this.widthInput=h,this.heightInput=g,this.horizontalAlignmentToolbar=f,this.verticalAlignmentToolbar=p;const{saveButtonView:C,cancelButtonView:y}=this._createActionButtons();this.saveButtonView=C,this.cancelButtonView=y,this.backButtonView=this._createBackButton(),this._focusables=new c.s3,this._focusCycler=new c.H({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});const _=new c.Dy(e,{label:this.t("Cell properties")});_.children.add(this.backButtonView,0),this.children.add(_),this.children.add(new c.Q9(e,{labelView:r,children:this.options.isTableCellTypeSupported?[r,l,i,o]:[r,l,o,i],class:`ck-table-form__border-row${this.options.isTableCellTypeSupported?" ck-table-form__border-row_experimental":""}`})),this.children.add(new c.Q9(e,{children:this.options.isTableCellTypeSupported?[new c.Q9(e,{labelView:d,children:[d,u],class:"ck-table-form__cell-type-row"}),new c.Q9(e,{labelView:a,children:[a,s],class:"ck-table-form__background-row"})]:[new c.Q9(e,{labelView:a,children:[a,s],class:"ck-table-form__background-row"})]})),this.children.add(new c.Q9(e,{children:[new c.Q9(e,{labelView:m,children:[m,h,b,g],class:"ck-table-form__dimensions-row"}),new c.Q9(e,{children:[this.paddingInput],class:"ck-table-cell-properties-form__padding-row"})]})),this.children.add(new c.Q9(e,{labelView:w,children:[w,f,p],class:"ck-table-cell-properties-form__alignment-row"})),this.children.add(new c.Q9(e,{children:[this.cancelButtonView,this.saveButtonView],class:"ck-table-form__action-row"})),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-table-form","ck-table-cell-properties-form","ck-table-cell-properties-form_experimental",this.options.isTableCellTypeSupported?"ck-table-cell-properties-form_experimental-no-cell-type":""],tabindex:"-1"},children:this.children})}render(){super.render(),(0,c.Z5)({view:this}),[this.borderColorInput,this.backgroundInput].forEach(e=>{this._focusCycler.chain(e.fieldView.focusCycler)}),[this.borderStyleDropdown,this.borderColorInput,this.borderWidthInput,this.cellTypeDropdown,this.backgroundInput,this.widthInput,this.heightInput,this.paddingInput,this.horizontalAlignmentToolbar,this.verticalAlignmentToolbar,this.cancelButtonView,this.saveButtonView,this.backButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBorderFields(){let e=this.options.defaultTableCellProperties,t={style:e.borderStyle,width:e.borderWidth,color:e.borderColor},l=lB({colorConfig:this.options.borderColors,columns:5,defaultColorValue:t.color,colorPickerConfig:this.options.colorPickerConfig}),i=this.locale,o=this.t,n=o("Style"),r=new c.y0(i);r.text=o("Border");let a=lR(o),s=new c.xE(i,c.By);s.set({label:n,class:"ck-table-form__border-style"}),s.fieldView.buttonView.set({ariaLabel:n,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:n}),s.fieldView.buttonView.bind("label").to(this,"borderStyle",e=>a[e||"none"]),s.fieldView.on("execute",e=>{this.borderStyle=e.source._borderStyleValue}),s.bind("isEmpty").to(this,"borderStyle",e=>!e),(0,c.O)(s.fieldView,lE(this,t.style),{role:"menu",ariaLabel:n});let d=new c.xE(i,c.Vr);d.set({label:o("Width"),class:"ck-table-form__border-width"}),d.fieldView.bind("value").to(this,"borderWidth"),d.bind("isEnabled").to(this,"borderStyle",lO),d.fieldView.on("input",()=>{this.borderWidth=d.fieldView.element.value});let u=new c.xE(i,l);return u.set({label:o("Color"),class:"ck-table-form__border-color"}),u.fieldView.bind("value").to(this,"borderColor"),u.bind("isEnabled").to(this,"borderStyle",lO),u.fieldView.on("input",()=>{this.borderColor=u.fieldView.value}),this.on("change:borderStyle",(e,l,i,o)=>{lO(i)||(this.borderColor="",this.borderWidth=""),lO(o)||(this.borderColor=t.color,this.borderWidth=t.width)}),{borderRowLabel:r,borderStyleDropdown:s,borderColorInput:u,borderWidthInput:d}}
1_createBackgroundFields(){let e=this.locale,t=this.t,l=new c.y0(e);l.text=t("Background");let i=lB({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableCellProperties.backgroundColor,colorPickerConfig:this.options.colorPickerConfig}),o=new c.xE(e,i);return o.set({label:t("Color"),class:"ck-table-cell-properties-form__background"}),o.fieldView.bind("value").to(this,"backgroundColor"),o.fieldView.on("input",()=>{this.backgroundColor=o.fieldView.value}),{backgroundRowLabel:l,backgroundInput:o}}_createCellTypeField(){let e=this.locale,t=this.t,l=new c.y0(e);l.text=t("Cell type");let i=this._cellTypeLabels,o=new c.xE(e,c.By);return o.set({label:t("Cell type"),class:"ck-table-cell-properties-form__cell-type"}),o.fieldView.buttonView.set({ariaLabel:t("Cell type"),ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:t("Cell type")}),o.fieldView.buttonView.bind("label").to(this,"cellType",e=>i[e||"data"]),o.fieldView.on("execute",e=>{this.cellType=e.source._cellTypeValue}),o.bind("isEmpty").to(this,"cellType",e=>!e),(0,c.O)(o.fieldView,this._getCellTypeDefinitions(),{role:"menu",ariaLabel:t("Cell type")}),{cellTypeRowLabel:l,cellTypeDropdown:o}}_createDimensionFields(){let e=this.locale,t=this.t,l=new c.y0(e);l.text=t("Dimensions");let i=new c.xE(e,c.Vr);i.set({label:t("Width"),class:"ck-table-form__dimensions-row__width"}),i.fieldView.bind("value").to(this,"width"),i.fieldView.on("input",()=>{this.width=i.fieldView.element.value});let o=new c.Ss(e);o.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"\xd7"}]});let n=new c.xE(e,c.Vr);return n.set({label:t("Height"),class:"ck-table-form__dimensions-row__height"}),n.fieldView.bind("value").to(this,"height"),n.fieldView.on("input",()=>{this.height=n.fieldView.element.value}),{dimensionsLabel:l,widthInput:i,operatorLabel:o,heightInput:n}}_createPaddingField(){let e=this.locale,t=this.t,l=new c.xE(e,c.Vr);return l.set({label:t("Padding"),class:"ck-table-cell-properties-form__padding"}),l.fieldView.bind("value").to(this,"padding"),l.fieldView.on("input",()=>{this.padding=l.fieldView.element.value}),l}_createAlignmentFields(){let e=this.locale,t=this.t,l=new c.y0(e),i={left:u.UFF,center:u.uG2,right:u.H5E,justify:u.VPN,top:u.uK8,middle:u.Gig,bottom:u._RK};l.text=t("Table cell text alignment");let o=new c.X3(e),n="rtl"===e.contentLanguageDirection;o.set({isCompact:!0,role:"radiogroup",ariaLabel:t("Horizontal text alignment toolbar"),class:"ck-table-cell-properties-form__horizontal-alignment-toolbar"}),lI({view:this,icons:i,toolbar:o,labels:this._horizontalAlignmentLabels,propertyName:"horizontalAlignment",nameToValue:e=>{if(n){if("left"===e)return"right";else if("right"===e)return"left"}return e},defaultValue:this.options.defaultTableCellProperties.horizontalAlignment});let r=new c.X3(e);return r.set({isCompact:!0,role:"radiogroup",ariaLabel:t("Vertical text alignment toolbar"),class:"ck-table-cell-properties-form__vertical-alignment-toolbar"}),lI({view:this,icons:i,toolbar:r,labels:this._verticalAlignmentLabels,propertyName:"verticalAlignment",defaultValue:this.options.defaultTableCellProperties.verticalAlignment}),{horizontalAlignmentToolbar:o,verticalAlignmentToolbar:r,alignmentLabel:l}}_createActionButtons(){let e=this.locale,t=this.t,l=new c._(e),i=new c._(e),o=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.paddingInput];return l.set({label:t("Save"),class:"ck-button-action",type:"submit",withText:!0}),l.bind("isEnabled").toMany(o,"errorText",(...e)=>e.every(e=>!e)),i.set({label:t("Cancel"),withText:!0}),i.delegate("execute").to(this,"cancel"),{saveButtonView:l,cancelButtonView:i}}_createBackButton(){let e=this.locale.t,t=new c._(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:u.saM,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_getCellTypeDefinitions(){let e=new n.pM,t=this._cellTypeLabels;for(let l of["data","header"]){let i={type:"button",model:new c.e_({_cellTypeValue:l,label:t[l],role:"menuitemradio",withText:!0})};i.model.bind("isOn").to(this,"cellType",e=>e===l),e.add(i)}return e}get _horizontalAlignmentLabels(){let e=this.locale,t=this.t,l=t("Align cell text to the left"),i=t("Align cell text to the center"),o=t("Align cell text to the right"),n=t("Justify cell text");return"rtl"===e.uiLanguageDirection?{right:o,center:i,left:l,justify:n}:{left:l,center:i,right:o,justify:n}}get _verticalAlignmentLabels(){let e=this.t;return{top:e("Align cell text to the top"),middle:e("Align cell text to the middle"),bottom:e("Align cell text to the bottom")}}get _cellTypeLabels(){let e=this.t;return{data:e("Data cell"),header:e("Header cell")}}}function lO(e){return"none"!==e}let lz={borderStyle:"tableCellBorderStyle",borderColor:"tableCellBorderColor",borderWidth:"tableCellBorderWidth",height:"tableCellHeight",width:"tableCellWidth",padding:"tableCellPadding",backgroundColor:"tableCellBackgroun
1dColor",horizontalAlignment:"tableCellHorizontalAlignment",verticalAlignment:"tableCellVerticalAlignment",cellType:"tableCellType"};class lM extends i.k_{_defaultContentTableCellProperties;_defaultLayoutTableCellProperties;_balloon;view;_viewWithContentTableDefaults;_viewWithLayoutTableDefaults;_undoStepBatch;_isReady;static get requires(){return[c.pU]}static get pluginName(){return"TableCellPropertiesUIExperimental"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("table.tableCellProperties",{borderColors:tT,backgroundColors:tT})}init(){let e=this.editor,t=e.t;this._defaultContentTableCellProperties=el(e.config.get("table.tableCellProperties.defaultProperties"),{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,includePaddingProperty:!0,isRightToLeftContent:"rtl"===e.locale.contentLanguageDirection}),this._defaultLayoutTableCellProperties=ee(void 0,{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,isRightToLeftContent:"rtl"===e.locale.contentLanguageDirection}),this._balloon=e.plugins.get(c.pU),this.view=null,this._isReady=!1,e.ui.componentFactory.add("tableCellProperties",l=>{let i=new c._(l);i.set({label:t("Cell properties"),icon:u.VKv,tooltip:!0}),this.listenTo(i,"execute",()=>this._showView());let o=Object.values(lz).map(t=>e.commands.get(t)).filter(e=>!!e);return i.bind("isEnabled").toMany(o,"isEnabled",(...e)=>e.some(e=>e)),i})}destroy(){super.destroy(),this.view&&this.view.destroy()}_createPropertiesView(e){let t=this.editor,l=t.config.get("table.tableCellProperties"),i=(0,c.lF)(l.borderColors),o=(0,c.b2)(t.locale,i),n=(0,c.lF)(l.backgroundColors),r=(0,c.b2)(t.locale,n),a=!1!==l.colorPicker,s=!!t.config.get("experimentalFlags.tableCellTypeSupport"),d=new lN(t.locale,{borderColors:o,backgroundColors:r,defaultTableCellProperties:e,colorPickerConfig:!!a&&(l.colorPicker||{}),isTableCellTypeSupported:s}),u=t.t;d.render(),this.listenTo(d,"submit",()=>{this._hideView()}),this.listenTo(d,"cancel",()=>{this._undoStepBatch.operations.length&&t.execute("undo",this._und
1oStepBatch),this._hideView()}),d.keystrokes.set("Esc",(e,t)=>{this._hideView(),t()}),(0,c.wy)({emitter:d,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});let h=tf(u),b=tp(u);d.on("change:borderStyle",this._getPropertyChangeCallback("tableCellBorderStyle")),d.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:d.borderColorInput,commandName:"tableCellBorderColor",errorText:h,validator:tw})),d.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:d.borderWidthInput,commandName:"tableCellBorderWidth",errorText:b,validator:ty})),d.on("change:padding",this._getValidatedPropertyChangeCallback({viewField:d.paddingInput,commandName:"tableCellPadding",errorText:b,validator:tC})),d.on("change:width",this._getValidatedPropertyChangeCallback({viewField:d.widthInput,commandName:"tableCellWidth",errorText:b,validator:tC})),d.on("change:height",this._getValidatedPropertyChangeCallback({viewField:d.heightInput,commandName:"tableCellHeight",errorText:b,validator:tC})),d.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:d.backgroundInput,commandName:"tableCellBackgroun
1dColor",errorText:h,validator:tw})),d.on("change:horizontalAlignment",this._getPropertyChangeCallback("tableCellHorizontalAlignment")),d.on("change:verticalAlignment",this._getPropertyChangeCallback("tableCellVerticalAlignment"));let g=t.commands.get("tableCellType");return g&&(d.cellTypeDropdown.bind("isEnabled").to(g,"isEnabled"),d.on("change:cellType",this._getPropertyChangeCallback("tableCellType"))),d}_fillViewFormFromCommandValues(){let e=this.editor.commands,t=e.get("tableCellBorderStyle");Object.entries(lz).flatMap(([t,l])=>{let i,o=e.get(l);return o?(i="cellType"===t?"":this.view===this._viewWithContentTableDefaults?this._defaultContentTableCellProperties[t]||"":this._defaultLayoutTableCellProperties[t]||"",[[t,o.value||i]]):[]}).forEach(([e,l])=>{("borderColor"!==e&&"borderWidth"!==e||"none"!==t.value)&&this.view.set(e,l)}),this._isReady=!0}_showView(){let e=this.editor,t=ts(e.editing.view.document.selection),l=t&&e.editing.mapper.toModelElement(t),i=!l||"layout"!==l.getAttribute("tableType");i&&!this._viewWithContentTableDefaults?this._viewWithContentTableDefaults=this._createPropertiesView(this._defaultContentTableCellProperties):i||this._viewWithLayoutTableDefaults||(this._viewWithLayoutTableDefaults=this._createPropertiesView(this._defaultLayoutTableCellProperties)),this.view=i?this._viewWithContentTableDefaults:this._viewWithLayoutTableDefaults,this.listenTo(e.ui,"update",()=>{this._updateView()}),this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:tE(e)}),this._undoStepBatch=e.model.createBatch(),this.view.focus()}_hideView(){let e=this.editor;this.stopListening(e.ui,"update"),this._isReady=!1,this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}_updateView(){let e=this.editor;tu(e.editing.view.document.selection)?this._isViewVisible&&tP(e,"cell"):this._hideView()}get _isViewVisible(){return!!this.view&&this._balloon.visibleView===this.view}get _isViewInBalloon(){return!!this.view&&this._balloon.hasView(this.view)}_getPropertyChangeCallback(e){return(t,l,i)=>{this._isReady&&this.editor.execute(e,{value:i,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(e){let{commandName:t,viewField:l,validator:i,errorText:o}=e,n=(0,a.s)(()=>{l.errorText=o},500);return(e,o,r)=>{n.cancel(),this._isReady&&(i(r)?(this.editor.execute(t,{value:r,batch:this._undoStepBatch}),l.errorText=null):n())}}}}}]); 2//# sourceMappingURL=ae4f560b.9c4d11e9c07b7c86.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.