!function(m){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),y=function(){},x=function(n,r){return function(){for(var e=[],t=0;tn.maxRow()||sn.maxCol()||(vn.getAt(t,l,s).filter(r).isNone()?(o=f,i=e[l].element(),u=Te.fromTag("td"),Ot(u,Te.fromTag("br")),(o?Ot:Dt)(i,u)):f=!0)}(m,g,h,d),o=e,f=h,s=I(un.firstLayer(o,"tr"),function(e){return 0===e.dom().childElementCount}),P(s,Pt),f.minCol()!==f.maxCol()&&f.minRow()!==f.maxRow()||P(un.firstLayer(o,"th,td"),function(e){we(e,"rowspan"),we(e,"colspan")}),we(o,"width"),we(o,"height"),We(o,"width"),We(o,"height"),e},yn=(Jt=me,$t="text",{get:function(e){if(!Jt(e))throw new Error("Can only get "+$t+" value of a "+$t+" node");return Qt(e).getOr("")},getOption:Qt=function(e){return Jt(e)?S.from(e.dom().nodeValue):S.none()},set:function(e,t){if(!Jt(e))throw new Error("Can only set raw "+$t+" value of a "+$t+" node");e.dom().nodeValue=t}}),xn=function(e){return yn.get(e)},Cn=function(e){return yn.getOption(e)},Sn=function(e,t){yn.set(e,t)},Rn=function(e){return"img"===ce(e)?1:Cn(e).fold(function(){return Ct(e).length},function(e){return e.length})},Tn=["img","br"],Dn=function(e){return Cn(e).filter(function(e){return 0!==e.trim().length||-1=e.startCol()&&t.column()+t.colspan()-1<=e.finishCol()&&t.row()>=e.startRow()&&t.row()+t.rowspan()-1<=e.finishRow()},zn=function(e,t){var n=t.column(),r=t.column()+t.colspan()-1,o=t.row(),i=t.row()+t.rowspan()-1;return n<=e.finishCol()&&r>=e.startCol()&&o<=e.finishRow()&&i>=e.startRow()},Hn=function(e,t){for(var n=!0,r=b(jn,t),o=t.startRow();o<=t.finishRow();o++)for(var i=t.startCol();i<=t.finishCol();i++)n=n&&vn.getAt(e,o,i).exists(r);return n?S.some(t):S.none()},Un=function(e,t,n){var r=vn.findItem(e,t,gt),o=vn.findItem(e,n,gt);return r.bind(function(r){return o.map(function(e){return t=r,n=e,qt(Math.min(t.row(),n.row()),Math.min(t.column(),n.column()),Math.max(t.row()+t.rowspan()-1,n.row()+n.rowspan()-1),Math.max(t.column()+t.colspan()-1,n.column()+n.colspan()-1));var t,n})})},qn=Un,Vn=function(t,e,n){return Un(t,e,n).bind(function(e){return Hn(t,e)})},Gn=function(r,e,o,i){return vn.findItem(r,e,gt).bind(function(e){var t=0=t.length-1)return S.none();var e=t[n].fold(function(){var e=U(t.slice(0,n));return To(e,function(e,t){return e.map(function(e){return{value:e,delta:t+1}})})},function(e){return S.some({value:e,delta:0})}),r=t[n+1].fold(function(){var e=t.slice(n+1);return To(e,function(e,t){return e.map(function(e){return{value:e,delta:t+1}})})},function(e){return S.some({value:e,delta:1})});return e.bind(function(n){return r.map(function(e){var t=e.delta+n.delta;return Math.abs(e.value-n.value)/t})})},Lo=function(e,t,n){var r=e();return M(r,t).orThunk(function(){return S.from(r[0]).orThunk(n)}).map(function(e){return e.element()})},Fo=function(n){var e=n.grid(),t=Mo(0,e.columns()),r=Mo(0,e.rows());return A(t,function(t){return Lo(function(){return z(r,function(e){return vn.getAt(n,e,t).filter(function(e){return e.column()===t}).fold(C([]),function(e){return[e]})})},function(e){return 1===e.colspan()},function(){return vn.getAt(n,0,t)})})},jo=function(n){var e=n.grid(),t=Mo(0,e.rows()),r=Mo(0,e.columns());return A(t,function(t){return Lo(function(){return z(r,function(e){return vn.getAt(n,t,e).filter(function(e){return e.row()===t}).fold(C([]),function(e){return[e]})})},function(e){return 1===e.rowspan()},function(){return vn.getAt(n,t,0)})})},zo=function(e){var t=e.replace(/\./g,"-");return{resolve:function(e){return t+"-"+e}}},Ho={resolve:zo("ephox-snooker").resolve},Uo=function(e,t,n,r,o){var i=Te.fromTag("div");return Ae(i,{position:"absolute",left:t-r/2+"px",top:n+"px",height:o+"px",width:r+"px"}),pe(i,{"data-column":e,role:"presentation"}),i},qo=function(e,t,n,r,o){var i=Te.fromTag("div");return Ae(i,{position:"absolute",left:t+"px",top:n-o/2+"px",height:o+"px",width:r+"px"}),pe(i,{"data-row":e,role:"presentation"}),i},Vo=Ho.resolve("resizer-bar"),Go=Ho.resolve("resizer-rows"),Yo=Ho.resolve("resizer-cols"),Xo=function(e){var t=Xt(e.parent(),"."+Vo);P(t,Pt)},Ko=function(n,e,r){var o=n.origin();P(e,function(e,t){e.each(function(e){var t=r(o,e);Io(t,Vo),Ot(n.parent(),t)})})},Jo=function(e,t,n,r,o,i){var u,a,c,l,f=uo(t),s=0=t.length||e.column()>ui.cellLength(t[0]))return yi.error("invalid start address out of table bounds, row: "+e.row()+", column: "+e.column());var r=t.slice(e.row()),o=r[0].cells().slice(e.column()),i=ui.cellLength(n[0]),u=n.length;return yi.value({rowDelta:C(r.length-u),colDelta:C(o.length-i)})},Ti=function(e,t){var n=ui.cellLength(e[0]),r=ui.cellLength(t[0]);return{rowDelta:C(0),colDelta:C(n-r)}},Di=function(e,t,n){var r=t.colDelta()<0?Si:o;return(t.rowDelta()<0?Ci:o)(r(e,Math.abs(t.colDelta()),n),Math.abs(t.rowDelta()),n)},Oi=function(e,t,n,r){if(0===e.length)return e;for(var o=t.startRow();o<=t.finishRow();o++)for(var i=t.startCol();i<=t.finishCol();i++)ui.mutateCell(e[o],i,jt(r(),!1));return e},Ni=function(e,t,n,r){for(var o=!0,i=0;i',t.insertBefore(r,t.firstChild)),ba(e,t),o.align&&pa(e,t,o.align),e.focus(),e.addVisual()})},Ma=function(t,e){var n,r,o,i,u,a,c,l,f,s,d=t.dom,m={};!0===e?(n=d.getParent(t.selection.getStart(),"table"))&&(c=n,l=(a=t).dom,f={width:l.getStyle(c,"width")||l.getAttrib(c,"width"),height:l.getStyle(c,"height")||l.getAttrib(c,"height"),cellspacing:l.getStyle(c,"border-spacing")||l.getAttrib(c,"cellspacing"),cellpadding:l.getAttrib(c,"data-mce-cell-padding")||l.getAttrib(c,"cellpadding")||ya(a.dom,c,"padding"),border:l.getAttrib(c,"data-mce-border")||l.getAttrib(c,"border")||ya(a.dom,c,"border"),borderColor:l.getAttrib(c,"data-mce-border-color"),caption:!!l.select("caption",c)[0],"class":l.getAttrib(c,"class")},ha.each("left center right".split(" "),function(e){a.formatter.matchNode(c,"align"+e)&&(f.align=e)}),ra(a)&&ha.extend(f,Sa.extractAdvancedStyles(l,c)),m=f):(r={label:"Cols",name:"cols"},o={label:"Rows",name:"rows"}),0=e.left&&t<=e.right&&n>=e.top&&n<=e.bottom},Ac=function(n,r,e,t,o){var i=function(e){var t=n.dom().createRange();return t.setStart(r.dom(),e),t.collapse(!0),t},u=xn(r).length,a=function(e,t,n,r,o){if(0===o)return 0;if(t===r)return o-1;for(var i=r,u=1;ur.left&&o.left ("+e.right()+", "+e.bottom()+")"}},Fl=function(e){return Ll.nu({left:e.left,top:e.top,right:e.right,bottom:e.bottom})},jl=function(e,t){return S.some(e.getRect(t))},zl=function(e,t,n){return de(t)?jl(e,t).map(Fl):me(t)?(r=e,o=t,i=n,0<=i&&in.right();var t,n})});var n,o,i},Vl={point:Ll.getTop,adjuster:function(e,t,n,r,o){var i=Ll.moveUp(o,5);return Math.abs(n.top()-r.top())<1?Ul.retry(i):n.bottom()o.bottom()?Ul.retry(i):n.top()===o.bottom()?Ul.retry(Ll.moveDown(o,1)):ql(e,t,o)?Ul.retry(Ll.translate(i,5,0)):Ul.none()},move:Ll.moveDown,gather:Tl},Yl=function(n,r,o,i,u){return 0===u?S.some(i):(c=n,l=i.left(),f=r.point(i),c.elementFromPoint(l,f).filter(function(e){return"table"===ce(e)}).isSome()?(t=i,a=u-1,Yl(n,e=r,o,e.move(t,5),a)):n.situsFromPoint(i.left(),r.point(i)).bind(function(e){return e.start().fold(S.none,function(t){return Hl(n,t).bind(function(e){return r.adjuster(n,t,e,o,i).fold(S.none,function(e){return Yl(n,r,o,e,u-1)})}).orThunk(function(){return S.some(i)})},S.none)}));var e,t,a,c,l,f},Xl=function(t,n,e){var r,o,i,u=t.move(e,5),a=Yl(n,t,e,u,100).getOr(u);return(r=t,o=a,i=n,r.point(o)>i.getInnerHeight()?S.some(r.point(o)-i.getInnerHeight()):r.point(o)<0?S.some(-r.point(o)):S.none()).fold(function(){return n.situsFromPoint(a.left(),t.point(a))},function(e){return n.scrollBy(0,e),n.situsFromPoint(a.left(),t.point(a)-e)})},Kl={tryUp:b(Xl,Vl),tryDown:b(Xl,Gl),ieTryUp:function(e,t){return e.situsFromPoint(t.left(),t.top()-5)},ieTryDown:function(e,t){return e.situsFromPoint(t.left(),t.bottom()+5)},getJumpSize:C(5)},Jl=lt.detect(),$l=function(r,o,i,u,a,c){return 0===c?S.none():ef(r,o,i,u,a).bind(function(e){var t=r.fromSitus(e),n=El.verify(r,i,u,t.finish(),t.foffset(),a.failure,o);return El.cata(n,function(){return S.none()},function(){return S.some(e)},function(e){return gt(i,e)&&0===u?Ql(r,i,u,Ll.moveUp,a):$l(r,o,e,0,a,c-1)},function(e){return gt(i,e)&&u===Rn(e)?Ql(r,i,u,Ll.moveDown,a):$l(r,o,e,Rn(e),a,c-1)})})},Ql=function(t,e,n,r,o){return zl(t,e,n).bind(function(e){return Zl(t,o,r(e,Kl.getJumpSize()))})},Zl=function(e,t,n){return Jl.browser.isChrome()||Jl.browser.isSafari()||Jl.browser.isFirefox()||Jl.browser.isEdge()?t.otherRetry(e,n):Jl.browser.isIE()?t.ieRetry(e,n):S.none()},ef=function(t,e,n,r,o){return zl(t,n,r).bind(function(e){return Zl(t,o,e)})},tf=function(t,n,r){return(o=t,i=n,u=r,o.getSelection().bind(function(r){return Wl(i,r.finish(),r.foffset(),u).fold(function(){return S.some(Dl(r.finish(),r.foffset()))},function(e){var t=o.fromSitus(e),n=El.verify(o,r.finish(),r.foffset(),t.finish(),t.foffset(),u.failure,i);return Ml(n)})})).bind(function(e){return $l(t,n,e.element(),e.offset(),r,20).map(t.fromSitus)});var o,i,u},nf=lt.detect(),rf=function(e,t){return Zt(e,function(e){return bt(e).exists(function(e){return gt(e,t)})},n).isSome();var n},of=function(t,r,o,e,i){return rn(e,"td,th",r).bind(function(n){return rn(n,"table",r).bind(function(e){return rf(i,e)?tf(t,r,o).bind(function(t){return rn(t.finish(),"td,th",r).map(function(e){return{start:C(n),finish:C(e),range:C(t)}})}):S.none()})})},uf=function(e,t,n,r,o,i){return nf.browser.isIE()?S.none():i(r,t).orThunk(function(){return of(e,t,n,r,o).map(function(e){var t=e.range();return ul.create(S.some(cl.makeSitus(t.start(),t.soffset(),t.finish(),t.foffset())),!0)})})},af=function(e,t,n,r,o,i,u){return of(e,n,r,o,i).bind(function(e){return fl.detect(t,n,e.start(),e.finish(),u)})},cf=function(e,u){return rn(e,"tr",u).bind(function(i){return rn(i,"table",u).bind(function(e){var t,n,r,o=Xt(e,"tr");return gt(i,o[0])?(t=e,n=function(e){return Nn(e).isSome()},r=u,xl(Sl,t,n,r)).map(function(e){var t=Rn(e);return ul.create(S.some(cl.makeSitus(e,t,e,t)),!0)}):S.none()})})},lf=function(e,u){return rn(e,"tr",u).bind(function(i){return rn(i,"table",u).bind(function(e){var t,n,r,o=Xt(e,"tr");return gt(i,o[o.length-1])?(t=e,n=function(e){return On(e).isSome()},r=u,Cl(Sl,t,n,r)).map(function(e){return ul.create(S.some(cl.makeSitus(e,0,e,0)),!0)}):S.none()})})},ff=function(e,t){return rn(e,"td,th",t)},sf={down:{traverse:xt,gather:Tl,relative:wc.before,otherRetry:Kl.tryDown,ieRetry:Kl.ieTryDown,failure:El.failedDown},up:{traverse:yt,gather:Rl,relative:wc.before,otherRetry:Kl.tryUp,ieRetry:Kl.ieTryUp,failure:El.failedUp}},df=function(t){return function(e){return e===t}},mf=df(38),gf=df(40),hf={ltr:{isBackward:df(37),isForward:df(39)},rtl:{isBackward:df(39),isForward:df(37)},isUp:mf,isDown:gf,isNavigation:function(e){return 37<=e&&e<=40}},pf=function(e){return{left:e.left(),top:e.top(),right:e.right(),bottom:e.bottom(),width:e.width(),height:e.height()}},vf=(lt.detect().browser.isSafari(),function(a){return{elementFromPoint:function(e,t){return Te.fromPoint(Te.fromDom(a.document),e,t)},getRect:function(e){return e.dom().getBoundingClientRect()},getRangedRect:function(e,t,n,r){var o=xc.exact(e,t,n,r);return Jc(a,o).map(pf)},getSelection:function(){return Kc(a).map(function(e){return cl.convertToRange(a,e)})},fromSitus:function(e){var t=xc.relative(e.start(),e.finish());return cl.convertToRange(a,t)},situsFromPoint:function(e,t){return $c(a,e,t).map(function(e){return al(e.start(),e.soffset(),e.finish(),e.foffset())})},clearSelection:function(){a.getSelection().removeAllRanges()},setSelection:function(e){var t,n,r,o,i,u;t=a,n=e.start(),r=e.soffset(),o=e.finish(),i=e.foffset(),u=zc(n,r,o,i),Vc(t,u)},setRelativeSelection:function(e,t){var n,r;n=a,r=jc(e,t),Vc(n,r)},selectContents:function(e){Xc(a,e)},getInnerHeight:function(){return a.innerHeight},getScrollY:function(){var e,t,n,r;return(e=Te.fromDom(a.document),t=e!==undefined?e.dom():m.document,n=t.body.scrollLeft||t.documentElement.scrollLeft,r=t.body.scrollTop||t.documentElement.scrollTop,oo(n,r)).top()},scrollBy:function(e,t){var n,r,o;n=e,r=t,((o=Te.fromDom(a.document))!==undefined?o.dom():m.document).defaultView.scrollBy(n,r)}}}),bf=X("rows","cols"),wf={mouse:function(e,t,n,r){var o,i,u,a,c,l,f=vf(e),s=(o=f,i=t,u=n,a=r,c=S.none(),l=function(){c=S.none()},{mousedown:function(e){a.clear(i),c=ff(e.target(),u)},mouseover:function(e){c.each(function(r){a.clear(i),ff(e.target(),u).each(function(n){hr(r,n,u).each(function(e){var t=e.boxes().getOr([]);(1";for(var n=0;n<10;n++)e+='';e+=""}return e+="",e+=''}(),onPostRender:function(){this.lastX=this.lastY=0},onmousemove:function(e){var t,n,r=e.target;"A"===r.tagName.toUpperCase()&&(t=parseInt(r.getAttribute("data-mce-x"),10),n=parseInt(r.getAttribute("data-mce-y"),10),(this.isRtl()||"tl-tr"===this.parent().rel)&&(t=9-t),t===this.lastX&&n===this.lastY||(s(o,t,n,e.control),this.lastX=t,this.lastY=n))},onclick:function(e){var t=this;"A"===e.target.tagName.toUpperCase()&&(e.preventDefault(),e.stopPropagation(),t.parent().cancel(),o.undoManager.transact(function(){Pa(o,t.lastX+1,t.lastY+1)}),o.addVisual())}}]};function m(e){return function(){o.execCommand(e)}}var g={text:"Table properties",context:"table",onPostRender:e,onclick:m("mceTableProps")},h={text:"Delete table",context:"table",onPostRender:e,cmd:"mceTableDelete"},p={text:"Row",context:"table",menu:[{text:"Insert row before",onclick:m("mceTableInsertRowBefore"),onPostRender:t},{text:"Insert row after",onclick:m("mceTableInsertRowAfter"),onPostRender:t},{text:"Delete row",onclick:m("mceTableDeleteRow"),onPostRender:t},{text:"Row properties",onclick:m("mceTableRowProps"),onPostRender:t},{text:"-"},{text:"Cut row",onclick:m("mceTableCutRow"),onPostRender:t},{text:"Copy row",onclick:m("mceTableCopyRow"),onPostRender:t},{text:"Paste row before",onclick:m("mceTablePasteRowBefore"),onPostRender:t},{text:"Paste row after",onclick:m("mceTablePasteRowAfter"),onPostRender:t}]},v={text:"Column",context:"table",menu:[{text:"Insert column before",onclick:m("mceTableInsertColBefore"),onPostRender:t},{text:"Insert column after",onclick:m("mceTableInsertColAfter"),onPostRender:t},{text:"Delete column",onclick:m("mceTableDeleteCol"),onPostRender:t}]},b={separator:"before",text:"Cell",context:"table",menu:[{text:"Cell properties",onclick:m("mceTableCellProps"),onPostRender:t},{text:"Merge cells",onclick:m("mceTableMergeCells"),onPostRender:function(){var t=this;a.push(t),r.fold(function(){l(t)},function(e){t.disabled(e.mergable().isNone())})}},{text:"Split cell",onclick:m("mceTableSplitCells"),onPostRender:function(){var t=this;c.push(t),r.fold(function(){l(t)},function(e){t.disabled(e.unmergable().isNone())})}}]};o.addMenuItem("inserttable",d),o.addMenuItem("tableprops",g),o.addMenuItem("deletetable",h),o.addMenuItem("row",p),o.addMenuItem("column",v),o.addMenuItem("cell",b)},Nf=function(n,r){return{insertTable:function(e,t){return Pa(n,e,t)},setClipboardRows:function(e){return t=r,n=A(e,Te.fromDom),void t.set(S.from(n));var t,n},getClipboardRows:function(){return r.get().fold(function(){},function(e){return A(e,function(e){return e.dom()})})}}};e.add("table",function(t){var n,r=sc(t),e=Sf(t,r.lazyResize),o=ma(t,r.lazyWire),i=(n=t,{get:function(){var e=Uu(n);return wr(e,Rr.selectedSelector()).fold(function(){return n.selection.getStart()===undefined?Or.none():Or.single(n.selection)},function(e){return Or.multiple(e)})}}),u=mu(S.none());return La(t,o,e,i,u),Wr(t,i,o,e),Of(t,i),Tf(t),Df(t),t.on("PreInit",function(){t.serializer.addTempAttr(Rr.firstSelected()),t.serializer.addTempAttr(Rr.lastSelected())}),t.getParam("table_tab_navigation",!0,"boolean")&&t.on("keydown",function(e){il(e,t,o,r.lazyWire)}),t.on("remove",function(){r.destroy(),e.destroy()}),Nf(t,u)})}(window);