/** * Copyright (c) Tiny Technologies, Inc. All rights reserved. * Licensed under the LGPL or a commercial license. * For LGPL see License.txt in the project root for license information. * For commercial licenses see https://www.tiny.cloud/ * * Version: 5.4.2 (2020-08-17) */ !function(h){"use strict";var n=tinymce.util.Tools.resolve("tinymce.PluginManager"),w=function(){},b=function(n){return function(){return n}},u=function(n){return n};function y(r){for(var o=[],n=1;n=e.length&&n.substr(t,t+e.length)===e},hn=function(n,e){return-1!==n.indexOf(e)},vn=function(n,e){return pn(n,e,n.length-e.length)},bn=(o=/^\s+|\s+$/g,function(n){return n.replace(o,"")}),wn=function(n){return 0t.maxRow||st.maxCol))mt.getAt(e,l,s).filter(r).isNone()?(o=f,0,u=n[l].element(),i=Sn.fromTag("td"),Be(i,Sn.fromTag("br")),(o?Be:Ae)(u,i)):f=!0}}(m,g,p,d),f=p,s=M(rt(o=n,"tr"),function(n){return 0===n.dom().childElementCount}),E(s,Me),f.minCol!==f.maxCol&&f.minRow!==f.maxRow||E(rt(o,"th,td"),function(n){mn(n,"rowspan"),mn(n,"colspan")}),mn(o,"width"),mn(o,"height"),Re(o,"width"),Re(o,"height"),n};var pt=function zs(t,r){var e=function(n){return t(n)?S.from(n.dom().nodeValue):S.none()};return{get:function(n){if(!t(n))throw new Error("Can only get "+r+" value of a "+r+" node");return e(n).getOr("")},getOption:e,set:function(n,e){if(!t(n))throw new Error("Can only set raw "+r+" value of a "+r+" node");n.dom().nodeValue=e}}}(rn,"text"),ht=function(n){return pt.get(n)},vt=function(n){return pt.getOption(n)},bt=function(n,e){return pt.set(n,e)},wt=function(n){return"img"===Q(n)?1:vt(n).fold(function(){return ae(n).length},function(n){return n.length})},yt=["img","br"],Ct=function(n){return vt(n).filter(function(n){return 0!==n.trim().length||-1=n.startCol()&&o<=n.finishRow()&&u>=n.startRow()},_t=function(n,e){return e.column()>=n.startCol()&&e.column()+e.colspan()-1<=n.finishCol()&&e.row()>=n.startRow()&&e.row()+e.rowspan()-1<=n.finishRow()},Wt=function(n,e){return t=Math.min(n.row(),e.row()),r=Math.min(n.column(),e.column()),o=Math.max(n.row()+n.rowspan()-1,e.row()+e.rowspan()-1),u=Math.max(n.column()+n.colspan()-1,e.column()+e.colspan()-1),{startRow:b(t),startCol:b(r),finishRow:b(o),finishCol:b(u)};var t,r,o,u},jt=function(n,e,t){var r=mt.findItem(n,e,Zn),o=mt.findItem(n,t,Zn);return r.bind(function(e){return o.map(function(n){return Wt(e,n)})})},zt=function(e,n,t){return jt(e,n,t).bind(function(n){return function(n,e){for(var t=!0,r=y(_t,e),o=e.startRow();o<=e.finishRow();o++)for(var u=e.startCol();u<=e.finishCol();u++)t=t&&mt.getAt(n,o,u).exists(r);return t?S.some(e):S.none()}(e,n)})},Ft=function(t,n,e){return jt(t,n,e).map(function(n){var e=mt.filterItems(t,y(Nt,n));return k(e,function(n){return n.element()})})},Lt=function(n,e){return mt.findItem(n,e,function(n,e){return ee(e,n)}).map(function(n){return n.element()})},Ht=function(i,c,a){return ct(i).bind(function(n){var r,e,o,u,t=Vt(n);return r=t,e=i,o=c,u=a,mt.findItem(r,e,Zn).bind(function(n){var e=0=r.length-1)return S.none();var n=r[o].fold(function(){var n,e,t=(n=r.slice(0,o),(e=O.call(n,0)).reverse(),e);return q(t,function(n,e){return n.map(function(n){return{value:n,delta:e+1}})})},function(n){return S.some({value:n,delta:0})}),e=r[o+1].fold(function(){var n=r.slice(o+1);return q(n,function(n,e){return n.map(function(n){return{value:n,delta:e+1}})})},function(n){return S.some({value:n,delta:1})});return n.bind(function(t){return e.map(function(n){var e=n.delta+t.delta;return Math.abs(n.value-t.value)/e})})},ro=function(){var n=Yn().browser;return n.isIE()||n.isEdge()},oo=function(n,e,t){return r=Se(n,e),o=t,u=parseFloat(r),isNaN(u)?o:u;var r,o,u},uo=function(n){return ro()?(t=(e=n).dom().getBoundingClientRect().height,"border-box"===Se(e,"box-sizing")?t:t-oo(e,"padding-top",0)-oo(e,"padding-bottom",0)-(oo(e,"border-top-width",0)+oo(e,"border-bottom-width",0))):oo(n,"height",Nr(n));var e,t},io=function(n){return ro()?(t=(e=n).dom().getBoundingClientRect().width,"border-box"===Se(e,"box-sizing")?t:t-oo(e,"padding-left",0)-oo(e,"padding-right",0)-(oo(e,"border-left-width",0)+oo(e,"border-right-width",0))):oo(n,"width",jr(n));var e,t},co=/(\d+(\.\d+)?)(\w|%)*/,ao=/(\d+(\.\d+)?)%/,lo=/(\d+(\.\d+)?)px|em/,fo=function(n,e){var t,r=(t=n,S.from(t.dom().offsetParent).map(Sn.fromDom).getOr(be(re(n))));return e(n)/e(r)*100},so=function(n,e){ye(n,"width",e+"px")},mo=function(n,e){ye(n,"width",e+"%")},go=function(n,e){ye(n,"height",e+"px")},po=function(n,e,t,r){var o,u,i,c,a,l=parseInt(n,10);return vn(n,"%")&&"table"!==Q(e)?(u=l,i=t,c=r,a=ct(o=e).map(function(n){var e=i(n);return Math.floor(u/100*e)}).getOr(u),c(o,a),a):l},ho=function(n){var e,t=Te(e=n,"height").getOrThunk(function(){return uo(e)+"px"});return t?po(t,n,Nr,go):Nr(n)},vo=function(n){return Te(n,"width").fold(function(){return S.from(fn(n,"width"))},function(n){return S.some(n)})},bo=function(n,e){return n/e.pixelWidth()*100},wo=function(e,t){return vo(e).fold(function(){var n=jr(e);return bo(n,t)},function(n){return function(n,e,t){var r=ao.exec(e);if(null!==r)return parseFloat(r[1]);var o=io(n);return bo(o,t)}(e,n,t)})},yo=function(e,t){return vo(e).fold(function(){return io(e)},function(n){return function(n,e,t){var r=lo.exec(e);if(null!==r)return parseInt(r[1],10);var o=ao.exec(e);if(null===o)return io(n);var u=parseFloat(o[1]);return u/100*t.pixelWidth()}(e,n,t)})},Co=function(n){return t="rowspan",ho(e=n)/Je(e,t);var e,t},So=function(n,e,t){ye(n,"width",e+t)},xo=function(n){return fo(n,jr)+"%"},To=b(ao),Ro=b(lo),Oo=function(n,e,t){return Te(n,e).fold(function(){return t(n)+"px"},function(n){return n})},Do=function(n,e){return Oo(n,"width",function(n){return yo(n,e)})},Ao=function(n){return Oo(n,"height",Co)},Bo=function(n,e,t,r,o){var u=Zr(n),i=k(u,function(n){return n.map(e.edge)});return k(u,function(n,e){return n.filter(d(Qe)).fold(function(){var n=to(i,e);return r(n)},function(n){return t(n,o)})})},Io=function(n){return n.map(function(n){return n+"px"}).getOr("")},Po=function(n,e,t){return Bo(n,e,wo,function(n){return n.fold(function(){return t.minCellWidth()},function(n){return n/t.pixelWidth()*100})},t)},ko=function(n,e,t){return Bo(n,e,yo,function(n){return n.getOrThunk(t.minCellWidth)},t)},Eo=function(n,e,t,r){var o=eo(n),u=k(o,function(n){return n.map(e.edge)});return k(o,function(n,e){return n.filter(d(Ze)).fold(function(){var n=to(u,e);return r(n)},function(n){return t(n)})})},Mo=hr([{invalid:["raw"]},{pixels:["value"]},{percent:["value"]}]),No=function(n,e,t){var r=t.substring(0,t.length-n.length),o=parseFloat(r);return r===o.toString()?e(o):Mo.invalid(t)},_o=xn(xn({},Mo),{from:function(n){return vn(n,"%")?No("%",Mo.percent,n):vn(n,"px")?No("px",Mo.pixels,n):Mo.invalid(n)}}),Wo=function(n,r,o){return n.fold(function(){return r},function(n){return t=(e=n)/o,k(r,function(n){return _o.from(n).fold(function(){return n},function(n){return n*t+"px"},function(n){return n/100*e+"px"})});var e,t},function(n){return e=o,k(r,function(n){return _o.from(n).fold(function(){return n},function(n){return n/e*100+"%"},function(n){return n+"%"})});var e})},jo=function(n,e,t){var r,o,u,i=_o.from(t),c=L(n,function(n){return"0px"===n})?(r=i,o=n.length,u=r.fold(function(){return b("")},function(n){return b(n/o+"px")},function(n){return b(n/o+"px")}),P(o,u)):Wo(i,n,e);return Fo(c)},zo=function(n,e){return 0===n.length?e:N(n,function(n,e){return _o.from(e).fold(b(0),u,u)+n},0)},Fo=function(n){if(0===n.length)return n;var e,t,r=N(n,function(n,e){var t=_o.from(e).fold(function(){return{value:e,remainder:0}},function(n){return e=n,t="px",{value:(r=Math.floor(e))+t,remainder:e-r};var e,t,r},function(n){return{value:n+"%",remainder:0}});return{output:[t.value].concat(n.output),remainder:n.remainder+t.remainder}},{output:[],remainder:0}),o=r.output;return o.slice(0,o.length-1).concat([(e=o[o.length-1],t=Math.round(r.remainder),_o.from(e).fold(b(e),function(n){return n+t+"px"},function(n){return n+t+"%"}))])},Lo=_o.from,Ho=function(n){return Lo(n).fold(b("px"),b("px"),b("%"))},qo=function(a,n,e,c,l){var f=mt.fromTable(a),s=f.all,d=mt.justCells(f);n.each(function(n){var r,o,e=Ho(n),t=jr(a),u=Bo(f,c,Do,Io,l),i=jo(u,t,n);r=i,o=e,E(d,function(n){var e=r.slice(n.column(),n.colspan()+n.column()),t=zo(e,et());ye(n.element(),"width",t+o)}),ye(a,"width",n)}),e.each(function(n){var r,e,o,t=Ho(n),u=Nr(a),i=Eo(f,Yr,Ao,Io),c=jo(i,u,n);r=c,e=s,o=t,E(d,function(n){var e=r.slice(n.row(),n.rowspan()+n.row()),t=zo(e,tt());ye(n.element(),"height",t+o)}),E(e,function(n,e){ye(n.element(),"height",r[e])}),ye(a,"height",n)})},Vo=function(n){return vo(n).exists(function(n){return ao.test(n)})},Uo=function(n){return vo(n).exists(function(n){return lo.test(n)})},Ko=function(n){return vo(n).isNone()},$o=xo,Xo={ltr:Jr,rtl:Qr},Go=function(e){var t=function(n){return e(n).isRtl()?Xo.rtl:Xo.ltr};return{delta:function(n,e){return t(e).delta(n,e)},edge:function(n){return t(n).edge(n)},positions:function(n,e){return t(e).positions(n,e)}}},Yo=function(n){var r=function(){for(var e=[],n=0;n=e.length||n.column()>tc(e[0]))return bc.error("invalid start address out of table bounds, row: "+n.row()+", column: "+n.column());var r=e.slice(n.row()),o=r[0].cells().slice(n.column()),u=tc(t[0]),i=t.length;return bc.value({rowDelta:r.length-i,colDelta:o.length-u})}(t,r,o).map(function(n){var e=Tc(r,n,u);return function(n,e,t,r,o){for(var u,i,c,a,l,f=n.row(),s=n.column(),d=f+t.length,m=s+tc(t[0]),g=f;g=t&&n.column()=i&&n.column()',r.insertBefore(o,r.firstChild)),""===i.align?Va(t,r):qa(t,r,i.align),t.focus(),t.addVisual()})},pl=function(n,e){var t,r,o,u,i,c,a,l,f=n.dom,s=Za(n,ii(n));!1===e?(t=f.getParent(n.selection.getStart(),"table"))?(o=t,u=ii(r=n),l=r.dom,s=xn({width:l.getStyle(o,"width")||l.getAttrib(o,"width"),height:l.getStyle(o,"height")||l.getAttrib(o,"height"),cellspacing:l.getStyle(o,"border-spacing")||l.getAttrib(o,"cellspacing"),cellpadding:l.getAttrib(o,"cellpadding")||Ha(r.dom,o,"padding"),border:(i=l,c=o,a=Te(Sn.fromDom(c),"border-width"),ci(r)&&a.isSome()?a.getOr(""):i.getAttrib(c,"border")||Ha(r.dom,c,"border-width")||Ha(r.dom,c,"border")),caption:!!l.select("caption",o)[0],"class":l.getAttrib(o,"class",""),align:Ja(r,o)},u?$a(l,o):{})):ii(n)&&(s.borderstyle="",s.bordercolor="",s.backgroundcolor=""):(s.cols="1",s.rows="1",ii(n)&&(s.borderstyle="",s.bordercolor="",s.backgroundcolor=""));var d=Ua(n.getParam("table_class_list",[],"array"));0=n.left&&e<=n.right&&t>=n.top&&t<=n.bottom}),_l=function(t,r,n,e,o){var u=function(n){var e=t.dom().createRange();return e.setStart(r.dom(),n),e.collapse(!0),e},i=ht(r).length,c=function(n,e,t,r,o){if(0===o)return 0;if(e===r)return o-1;for(var u=r,i=1;ir.left&&o.leftt.right;var e,t})});var t},Jf={point:function(n){return n.bottom},adjuster:function(n,e,t,r,o){var u=Hf(o,5);return Math.abs(t.bottom-r.bottom)<1||t.top>o.bottom?Gf.retry(u):t.top===o.bottom?Gf.retry(Hf(o,1)):Yf(n,e,o)?Gf.retry(Vf(u,5,0)):Gf.none()},move:Hf,gather:kf},Qf=function(t,r,o,u,i){return 0===i?S.some(u):(a=t,l=u.left,f=r.point(u),a.elementFromPoint(l,f).filter(function(n){return"table"===Q(n)}).isSome()?(e=u,c=i-1,Qf(t,n=r,o,n.move(e,5),c)):t.situsFromPoint(u.left,r.point(u)).bind(function(n){return n.start().fold(S.none,function(e){return Xf(t,e).bind(function(n){return r.adjuster(t,e,n,o,u).fold(S.none,function(n){return Qf(t,r,o,n,i-1)})}).orThunk(function(){return S.some(u)})},S.none)}));var n,e,c,a,l,f},Zf=function(e,t,n){var r,o,u,i=e.move(n,5),c=Qf(t,e,n,i,100).getOr(i);return o=c,u=t,((r=e).point(o)>u.getInnerHeight()?S.some(r.point(o)-u.getInnerHeight()):r.point(o)<0?S.some(-r.point(o)):S.none()).fold(function(){return t.situsFromPoint(c.left,e.point(c))},function(n){return t.scrollBy(0,n),t.situsFromPoint(c.left,e.point(c)-n)})},ns={tryUp:y(Zf,{point:function(n){return n.top},adjuster:function(n,e,t,r,o){var u=qf(o,5);return Math.abs(t.top-r.top)<1||t.bottom