agenda-libre-ruby/public/assets/tinymce/plugins/table/plugin-dfc042334b1a3868bacda8fcc9509da40eb8004a7c10014db302d7b707a8e969.js
2019-10-06 13:40:59 +02:00

11 lines
119 KiB
JavaScript

/**
* 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.0.16 (2019-09-24)
*/
!function(f){"use strict";function o(e){return e}var l=function(e){function n(){return t}var t=e;return{get:n,set:function(e){t=e},clone:function(){return l(n())}}},y=function(){},C=function(t,r){return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return t(r.apply(null,e))}},S=function(e){return function(){return e}};function b(r){for(var o=[],e=1;e<arguments.length;e++)o[e-1]=arguments[e];return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var t=o.concat(e);return r.apply(null,t)}}function d(t){return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return!t.apply(null,e)}}function e(){return u}var n,s=S(!1),i=S(!0),u=(n={fold:function(e,n){return e()},is:s,isSome:s,isNone:i,getOr:c,getOrThunk:r,getOrDie:function(e){throw new Error(e||"error: getOrDie called on none.")},getOrNull:S(null),getOrUndefined:S(undefined),or:c,orThunk:r,map:e,each:y,bind:e,exists:s,forall:i,filter:e,equals:t,equals_:t,toArray:function(){return[]},toString:S("none()")},Object.freeze&&Object.freeze(n),n);function t(e){return e.isNone()}function r(e){return e()}function c(e){return e}function a(n){return function(e){return function(e){if(null===e)return"null";var n=typeof e;return"object"==n&&(Array.prototype.isPrototypeOf(e)||e.constructor&&"Array"===e.constructor.name)?"array":"object"==n&&(String.prototype.isPrototypeOf(e)||e.constructor&&"String"===e.constructor.name)?"string":n}(e)===n}}function m(e,n){return-1<function(e,n){return qe.call(e,n)}(e,n)}function g(e,n){for(var t=0,r=e.length;t<r;t++){if(n(e[t],t))return!0}return!1}function p(e,n){for(var t=e.length,r=new Array(t),o=0;o<t;o++){var i=e[o];r[o]=n(i,o)}return r}function h(e,n){for(var t=0,r=e.length;t<r;t++){n(e[t],t)}}function v(e,n){for(var t=[],r=0,o=e.length;r<o;r++){var i=e[r];n(i,r)&&t.push(i)}return t}function w(e,n,t){return function(e,n){for(var t=e.length-1;0<=t;t--){n(e[t],t)}}(e,function(e){t=n(t,e)}),t}function x(e,n,t){return h(e,function(e){t=n(t,e)}),t}function R(e,n){for(var t=0,r=e.length;t<r;t++){var o=e[t];if(n(o,t))return We.some(o)}return We.none()}function T(e,n){for(var t=0,r=e.length;t<r;t++){if(n(e[t],t))return We.some(t)}return We.none()}function O(e){for(var n=[],t=0,r=e.length;t<r;++t){if(!je(e[t]))throw new Error("Arr.flatten item "+t+" was not an array, input: "+e);Ve.apply(n,e[t])}return n}function D(e,n){var t=p(e,n);return O(t)}function A(e,n){for(var t=0,r=e.length;t<r;++t){if(!0!==n(e[t],t))return!1}return!0}function E(e){var n=Ue.call(e,0);return n.reverse(),n}function N(e,n){for(var t=Ge(e),r=0,o=t.length;r<o;r++){var i=t[r];n(e[i],i)}}function I(e,t){return Ke(e,function(e,n){return{k:n,v:t(e,n)}})}function k(e,n){return Xe(e,n)?We.from(e[n]):We.none()}function P(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(n.length!==t.length)throw new Error('Wrong number of arguments to struct. Expected "['+n.length+']", got '+t.length+" arguments");var r={};return h(n,function(e,n){r[e]=S(t[n])}),r}}function B(e){return e.slice(0).sort()}function M(e,n){throw new Error("All required keys ("+B(e).join(", ")+") were not specified. Specified keys were: "+B(n).join(", ")+".")}function W(e){throw new Error("Unsupported keys for object: "+B(e).join(", "))}function _(n,e){if(!je(e))throw new Error("The "+n+" fields must be an array. Was: "+e+".");h(e,function(e){if(!Le(e))throw new Error("The value "+e+" in the "+n+" fields was not a string.")})}function L(e){var t=B(e);R(t,function(e,n){return n<t.length-1&&e===t[n+1]}).each(function(e){throw new Error("The field: "+e+" occurs more than once in the combined fields: ["+t.join(", ")+"].")})}function j(e){return e.dom().nodeName.toLowerCase()}function z(e){return e.dom().nodeType}function H(n){return function(e){return z(e)===n}}function F(e){return z(e)===Je||"#comment"===j(e)}function U(e,n,t){if(!(Le(t)||ze(t)||Fe(t)))throw f.console.error("Invalid call to Attr.set. Key ",n,":: Value ",t,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(n,t+"")}function q(e,n,t){U(e.dom(),n,t)}function V(e,n){var t=e.dom();N(n,function(e,n){U(t,n,e)})}function G(e,n){var t=e.dom().getAttribute(n);return null===t?undefined:t}function Y(e,n){var t=e.dom();return!(!t||!t.hasAttribute)&&t.hasAttribute(n)}function K(e,n){e.dom().removeAttribute(n)}function X(e){return x(e.dom().attributes,function(e,n){return e[n.name]=n.value,e},{})}function $(e,n,t){return""===n||!(e.length<n.length)&&e.substr(t,t+n.length)===n}function J(e,n){return-1!==e.indexOf(n)}function Q(e,n){return $(e,n,0)}function Z(e){return e.style!==undefined&&He(e.style.getPropertyValue)}function ee(t){var r,o=!1;return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return o||(o=!0,r=t.apply(null,e)),r}}function ne(e){var n=tn(e)?e.dom().parentNode:e.dom();return n!==undefined&&null!==n&&n.ownerDocument.body.contains(n)}function te(e,n,t){if(!Le(t))throw f.console.error("Invalid call to CSS.set. Property ",n,":: Value ",t,":: Element ",e),new Error("CSS value must be a string: "+t);Z(e)&&e.style.setProperty(n,t)}function re(e,n,t){var r=e.dom();te(r,n,t)}function oe(e,n){var t=e.dom();N(n,function(e,n){te(t,n,e)})}function ie(e,n){var t=e.dom(),r=f.window.getComputedStyle(t).getPropertyValue(n),o=""!==r||ne(e)?r:an(t,n);return null===o?undefined:o}function ue(e,n){var t=e.dom(),r=an(t,n);return We.from(r).filter(function(e){return 0<e.length})}function ce(e,n){!function(e,n){Z(e)&&e.style.removeProperty(n)}(e.dom(),n),Y(e,"style")&&""===function(e){return e.replace(/^\s+|\s+$/g,"")}(G(e,"style"))&&K(e,"style")}function ae(e,n,t){return 0!=(e.compareDocumentPosition(n)&t)}function le(e,n){var t=function(e,n){for(var t=0;t<e.length;t++){var r=e[t];if(r.test(n))return r}return undefined}(e,n);if(!t)return{major:0,minor:0};function r(e){return Number(n.replace(t,"$"+e))}return sn(r(1),r(2))}function fe(e,n){return function(){return n===e}}function se(e,n){return function(){return n===e}}function de(e,n){var t=String(n).toLowerCase();return R(e,function(e){return e.search(t)})}function me(n){return function(e){return J(e,n)}}function ge(e,n){var t=e.dom();if(t.nodeType!==Nn)return!1;var r=t;if(r.matches!==undefined)return r.matches(n);if(r.msMatchesSelector!==undefined)return r.msMatchesSelector(n);if(r.webkitMatchesSelector!==undefined)return r.webkitMatchesSelector(n);if(r.mozMatchesSelector!==undefined)return r.mozMatchesSelector(n);throw new Error("Browser lacks native selectors")}function pe(e){return e.nodeType!==Nn&&e.nodeType!==In||0===e.childElementCount}function he(e,n){return e.dom()===n.dom()}function ve(e){return on.fromDom(e.dom().ownerDocument)}function be(e){return We.from(e.dom().parentNode).map(on.fromDom)}function we(e,n){for(var t=He(n)?n:s,r=e.dom(),o=[];null!==r.parentNode&&r.parentNode!==undefined;){var i=r.parentNode,u=on.fromDom(i);if(o.push(u),!0===t(u))break;r=i}return o}function ye(e){return We.from(e.dom().previousSibling).map(on.fromDom)}function Ce(e){return We.from(e.dom().nextSibling).map(on.fromDom)}function Se(e){return p(e.dom().childNodes,on.fromDom)}function xe(e,n){var t=e.dom().childNodes;return We.from(t[n]).map(on.fromDom)}function Re(n,t){be(n).each(function(e){e.dom().insertBefore(t.dom(),n.dom())})}function Te(e,n){Ce(e).fold(function(){be(e).each(function(e){Bn(e,n)})},function(e){Re(e,n)})}function Oe(n,t){(function(e){return xe(e,0)})(n).fold(function(){Bn(n,t)},function(e){n.dom().insertBefore(t.dom(),e.dom())})}function De(e,n){Re(e,n),Bn(n,e)}function Ae(r,o){h(o,function(e,n){var t=0===n?r:o[n-1];Te(t,e)})}function Ee(n,e){h(e,function(e){Bn(n,e)})}function Ne(e){e.dom().textContent="",h(Se(e),function(e){Mn(e)})}function Ie(e){var n=Se(e);0<n.length&&function(n,e){h(e,function(e){Re(n,e)})}(e,n),Mn(e)}function ke(e,n,t){return function(e,n,t){return v(we(e,t),n)}(e,function(e){return ge(e,n)},t)}function Pe(e,n){return function(e,n){return v(Se(e),n)}(e,function(e){return ge(e,n)})}function Be(e,n){return function(e,n){var t=n===undefined?f.document:n.dom();return pe(t)?[]:p(t.querySelectorAll(e),on.fromDom)}(n,e)}var Me=function(t){function e(){return o}function n(e){return e(t)}var r=S(t),o={fold:function(e,n){return n(t)},is:function(e){return t===e},isSome:i,isNone:s,getOr:r,getOrThunk:r,getOrDie:r,getOrNull:r,getOrUndefined:r,or:e,orThunk:e,map:function(e){return Me(e(t))},each:function(e){e(t)},bind:n,exists:n,forall:n,filter:function(e){return e(t)?o:u},toArray:function(){return[t]},toString:function(){return"some("+t+")"},equals:function(e){return e.is(t)},equals_:function(e,n){return e.fold(s,function(e){return n(t,e)})}};return o},We={some:Me,none:e,from:function(e){return null===e||e===undefined?u:Me(e)}},_e=tinymce.util.Tools.resolve("tinymce.PluginManager"),Le=a("string"),je=a("array"),ze=a("boolean"),He=a("function"),Fe=a("number"),Ue=Array.prototype.slice,qe=Array.prototype.indexOf,Ve=Array.prototype.push,Ge=(He(Array.from)&&Array.from,Object.keys),Ye=Object.hasOwnProperty,Ke=function(e,r){var o={};return N(e,function(e,n){var t=r(e,n);o[t.k]=t.v}),o},Xe=function(e,n){return Ye.call(e,n)},$e=function(o,i){var u=o.concat(i);if(0===u.length)throw new Error("You must specify at least one required or optional field.");return _("required",o),_("optional",i),L(u),function(n){var t=Ge(n);A(o,function(e){return m(t,e)})||M(o,t);var e=v(t,function(e){return!m(u,e)});0<e.length&&W(e);var r={};return h(o,function(e){r[e]=S(n[e])}),h(i,function(e){r[e]=S(Object.prototype.hasOwnProperty.call(n,e)?We.some(n[e]):We.none())}),r}},Je=(f.Node.ATTRIBUTE_NODE,f.Node.CDATA_SECTION_NODE,f.Node.COMMENT_NODE),Qe=f.Node.DOCUMENT_NODE,Ze=(f.Node.DOCUMENT_TYPE_NODE,f.Node.DOCUMENT_FRAGMENT_NODE,f.Node.ELEMENT_NODE),en=f.Node.TEXT_NODE,nn=(f.Node.PROCESSING_INSTRUCTION_NODE,f.Node.ENTITY_REFERENCE_NODE,f.Node.ENTITY_NODE,f.Node.NOTATION_NODE,"undefined"!=typeof f.window?f.window:Function("return this;")(),H(Ze)),tn=H(en),rn=function(e){if(null===e||e===undefined)throw new Error("Node cannot be null or undefined");return{dom:S(e)}},on={fromHtml:function(e,n){var t=(n||f.document).createElement("div");if(t.innerHTML=e,!t.hasChildNodes()||1<t.childNodes.length)throw f.console.error("HTML does not have a single root node",e),new Error("HTML must have a single root node");return rn(t.childNodes[0])},fromTag:function(e,n){var t=(n||f.document).createElement(e);return rn(t)},fromText:function(e,n){var t=(n||f.document).createTextNode(e);return rn(t)},fromDom:rn,fromPoint:function(e,n,t){var r=e.dom();return We.from(r.elementFromPoint(n,t)).map(rn)}},un=ee(function(){return cn(on.fromDom(f.document))}),cn=function(e){var n=e.dom().body;if(null===n||n===undefined)throw new Error("Body is not available yet");return on.fromDom(n)},an=function(e,n){return Z(e)?e.style.getPropertyValue(n):""},ln=function(e,n){return ae(e,n,f.Node.DOCUMENT_POSITION_CONTAINED_BY)},fn=function(){return sn(0,0)},sn=function(e,n){return{major:e,minor:n}},dn={nu:sn,detect:function(e,n){var t=String(n).toLowerCase();return 0===e.length?fn():le(e,t)},unknown:fn},mn="Firefox",gn=function(e){var n=e.current;return{current:n,version:e.version,isEdge:fe("Edge",n),isChrome:fe("Chrome",n),isIE:fe("IE",n),isOpera:fe("Opera",n),isFirefox:fe(mn,n),isSafari:fe("Safari",n)}},pn={unknown:function(){return gn({current:undefined,version:dn.unknown()})},nu:gn,edge:S("Edge"),chrome:S("Chrome"),ie:S("IE"),opera:S("Opera"),firefox:S(mn),safari:S("Safari")},hn="Windows",vn="Android",bn="Solaris",wn="FreeBSD",yn=function(e){var n=e.current;return{current:n,version:e.version,isWindows:se(hn,n),isiOS:se("iOS",n),isAndroid:se(vn,n),isOSX:se("OSX",n),isLinux:se("Linux",n),isSolaris:se(bn,n),isFreeBSD:se(wn,n)}},Cn={unknown:function(){return yn({current:undefined,version:dn.unknown()})},nu:yn,windows:S(hn),ios:S("iOS"),android:S(vn),linux:S("Linux"),osx:S("OSX"),solaris:S(bn),freebsd:S(wn)},Sn=function(e,t){return de(e,t).map(function(e){var n=dn.detect(e.versionRegexes,t);return{current:e.name,version:n}})},xn=function(e,t){return de(e,t).map(function(e){var n=dn.detect(e.versionRegexes,t);return{current:e.name,version:n}})},Rn=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,Tn=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:function(e){return J(e,"edge/")&&J(e,"chrome")&&J(e,"safari")&&J(e,"applewebkit")}},{name:"Chrome",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,Rn],search:function(e){return J(e,"chrome")&&!J(e,"chromeframe")}},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:function(e){return J(e,"msie")||J(e,"trident")}},{name:"Opera",versionRegexes:[Rn,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:me("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:me("firefox")},{name:"Safari",versionRegexes:[Rn,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:function(e){return(J(e,"safari")||J(e,"mobile/"))&&J(e,"applewebkit")}}],On=[{name:"Windows",search:me("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:function(e){return J(e,"iphone")||J(e,"ipad")},versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:me("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"OSX",search:me("os x"),versionRegexes:[/.*?os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:me("linux"),versionRegexes:[]},{name:"Solaris",search:me("sunos"),versionRegexes:[]},{name:"FreeBSD",search:me("freebsd"),versionRegexes:[]}],Dn={browsers:S(Tn),oses:S(On)},An=function(e){var n=Dn.browsers(),t=Dn.oses(),r=Sn(n,e).fold(pn.unknown,pn.nu),o=xn(t,e).fold(Cn.unknown,Cn.nu);return{browser:r,os:o,deviceType:function(e,n,t){var r=e.isiOS()&&!0===/ipad/i.test(t),o=e.isiOS()&&!r,i=e.isAndroid()&&3===e.version.major,u=e.isAndroid()&&4===e.version.major,c=r||i||u&&!0===/mobile/i.test(t),a=e.isiOS()||e.isAndroid(),l=a&&!c,f=n.isSafari()&&e.isiOS()&&!1===/safari/i.test(t);return{isiPad:S(r),isiPhone:S(o),isTablet:S(c),isPhone:S(l),isTouch:S(a),isAndroid:e.isAndroid,isiOS:e.isiOS,isWebView:S(f)}}(o,r,e)}},En={detect:ee(function(){var e=f.navigator.userAgent;return An(e)})},Nn=Ze,In=Qe,kn=En.detect().browser.isIE()?function(e,n){return ln(e.dom(),n.dom())}:function(e,n){var t=e.dom(),r=n.dom();return t!==r&&t.contains(r)},Pn=ge,Bn=(P("element","offset"),function(e,n){e.dom().appendChild(n.dom())}),Mn=function(e){var n=e.dom();null!==n.parentNode&&n.parentNode.removeChild(n)},Wn=(P("width","height"),P("width","height"),P("rows","columns")),_n=P("row","column"),Ln=(P("x","y"),P("element","rowspan","colspan")),jn=P("element","rowspan","colspan","isNew"),zn=P("element","rowspan","colspan","row","column"),Hn=P("element","cells","section"),Fn=P("element","isNew"),Un=P("element","cells","section","isNew"),qn=P("cells","section"),Vn=P("details","section"),Gn=P("startRow","startCol","finishRow","finishCol"),Yn=function(e,n){var t=[];return h(Se(e),function(e){n(e)&&(t=t.concat([e])),t=t.concat(Yn(e,n))}),t};function Kn(e,n,t,r,o){return e(t,r)?We.some(t):He(o)&&o(t)?We.none():n(t,r,o)}function Xn(e,n,t){for(var r=e.dom(),o=He(t)?t:S(!1);r.parentNode;){r=r.parentNode;var i=on.fromDom(r);if(n(i))return We.some(i);if(o(i))break}return We.none()}function $n(e,n,t){return Xn(e,function(e){return ge(e,n)},t)}function Jn(e,n){return function(e,n){return R(e.dom().childNodes,function(e){return n(on.fromDom(e))}).map(on.fromDom)}(e,function(e){return ge(e,n)})}function Qn(e,n){return function(e,n){var t=n===undefined?f.document:n.dom();return pe(t)?We.none():We.from(t.querySelector(e)).map(on.fromDom)}(n,e)}function Zn(e,n,t){return Kn(ge,$n,e,n,t)}function et(e,n,t){return void 0===t&&(t=s),t(n)?We.none():m(e,j(n))?We.some(n):$n(n,e.join(","),function(e){return ge(e,"table")||t(e)})}function nt(n,e){return be(e).map(function(e){return Pe(e,n)})}function tt(e,n){return parseInt(G(e,n),10)}function rt(e,n){return e+","+n}var ot=function(e,n,t){return D(Se(e),function(e){return ge(e,n)?t(e)?[e]:[]:ot(e,n,t)})},it={firstLayer:function(e,n){return ot(e,n,S(!0))},filterFirstLayer:ot},ut=b(nt,"th,td"),ct=b(nt,"tr"),at={cell:function(e,n){return et(["td","th"],e,n)},firstCell:function(e){return Qn(e,"th,td")},cells:function(e){return it.firstLayer(e,"th,td")},neighbourCells:ut,table:function(e,n){return Zn(e,"table",n)},row:function(e,n){return et(["tr"],e,n)},rows:function(e){return it.firstLayer(e,"tr")},notCell:function(e,n){return et(["caption","tr","tbody","tfoot","thead"],e,n)},neighbourRows:ct,attr:tt,grid:function(e,n,t){var r=tt(e,n),o=tt(e,t);return Wn(r,o)}},lt=function(e){var n=at.rows(e);return p(n,function(e){var n=e,t=be(n).map(function(e){var n=j(e);return"tfoot"===n||"thead"===n||"tbody"===n?n:"tbody"}).getOr("tbody"),r=p(at.cells(e),function(e){var n=Y(e,"rowspan")?parseInt(G(e,"rowspan"),10):1,t=Y(e,"colspan")?parseInt(G(e,"colspan"),10):1;return Ln(e,n,t)});return Hn(n,r,t)})},ft=function(e,t){return p(e,function(e){var n=p(at.cells(e),function(e){var n=Y(e,"rowspan")?parseInt(G(e,"rowspan"),10):1,t=Y(e,"colspan")?parseInt(G(e,"colspan"),10):1;return Ln(e,n,t)});return Hn(e,n,t.section())})},st=function(e,n){var t=D(e.all(),function(e){return e.cells()});return v(t,n)},dt={generate:function(e){var l={},n=[],t=e.length,f=0;h(e,function(e,c){var a=[];h(e.cells(),function(e){for(var n=0;l[rt(c,n)]!==undefined;)n++;for(var t=zn(e.element(),e.rowspan(),e.colspan(),c,n),r=0;r<e.colspan();r++)for(var o=0;o<e.rowspan();o++){var i=n+r,u=rt(c+o,i);l[u]=t,f=Math.max(f,i+1)}a.push(t)}),n.push(Hn(e.element(),a,e.section()))});var r=Wn(t,f);return{grid:S(r),access:S(l),all:S(n)}},getAt:function(e,n,t){var r=e.access()[rt(n,t)];return r!==undefined?We.some(r):We.none()},findItem:function(e,n,t){var r=st(e,function(e){return t(n,e.element())});return 0<r.length?We.some(r[0]):We.none()},filterItems:st,justCells:function(e){var n=p(e.all(),function(e){return e.cells()});return O(n)}},mt=P("minRow","minCol","maxRow","maxCol"),gt=function(e,n){function t(e){return ge(e.element(),n)}var r=lt(e),o=dt.generate(r),i=function(e,i){var n=e.grid().columns(),u=e.grid().rows(),c=n,a=0,l=0;return N(e.access(),function(e){if(i(e)){var n=e.row(),t=n+e.rowspan()-1,r=e.column(),o=r+e.colspan()-1;n<u?u=n:a<t&&(a=t),r<c?c=r:l<o&&(l=o)}}),mt(u,c,a,l)}(o,t),u="th:not("+n+"),td:not("+n+")",c=it.filterFirstLayer(e,"th,td",function(e){return ge(e,u)});return h(c,Mn),function(e,n,t,r){for(var o,i,u,c=n.grid().columns(),a=n.grid().rows(),l=0;l<a;l++)for(var f=!1,s=0;s<c;s++){if(!(l<t.minRow()||l>t.maxRow()||s<t.minCol()||s>t.maxCol()))dt.getAt(n,l,s).filter(r).isNone()?(o=f,void 0,i=e[l].element(),u=on.fromTag("td"),Bn(u,on.fromTag("br")),(o?Bn:Oe)(i,u)):f=!0}}(r,o,i,t),function(e,n){var t=v(it.firstLayer(e,"tr"),function(e){return 0===e.dom().childElementCount});h(t,Mn),n.minCol()!==n.maxCol()&&n.minRow()!==n.maxRow()||h(it.firstLayer(e,"th,td"),function(e){K(e,"rowspan"),K(e,"colspan")}),K(e,"width"),K(e,"height"),ce(e,"width"),ce(e,"height")}(e,i),e};function pt(e){return kt.get(e)}function ht(e){return kt.getOption(e)}function vt(e,n){kt.set(e,n)}function bt(e){return"img"===j(e)?1:ht(e).fold(function(){return Se(e).length},function(e){return e.length})}function wt(e){return function(e){return ht(e).filter(function(e){return 0!==e.trim().length||-1<e.indexOf("\xa0")}).isSome()}(e)||m(Pt,j(e))}function yt(e){return function(e,o){var i=function(e){for(var n=0;n<e.childNodes.length;n++){var t=on.fromDom(e.childNodes[n]);if(o(t))return We.some(t);var r=i(e.childNodes[n]);if(r.isSome())return r}return We.none()};return i(e.dom())}(e,wt)}function Ct(e){return Bt(e,wt)}function St(e,n){return on.fromDom(e.dom().cloneNode(n))}function xt(e){return St(e,!1)}function Rt(e){return St(e,!0)}function Tt(e,n){var t=function(e,n){var t=on.fromTag(n),r=X(e);return V(t,r),t}(e,n),r=Se(Rt(e));return Ee(t,r),t}function Ot(){var e=on.fromTag("td");return Bn(e,on.fromTag("br")),e}function Dt(e,n,t){var r=Tt(e,n);return N(t,function(e,n){null===e?K(r,n):q(r,n,e)}),r}function At(e){return e}function Et(e){return function(){return on.fromTag("tr",e.dom())}}function Nt(e,n){return n.column()>=e.startCol()&&n.column()+n.colspan()-1<=e.finishCol()&&n.row()>=e.startRow()&&n.row()+n.rowspan()-1<=e.finishRow()}function It(e,n,t){var r=dt.findItem(e,n,he),o=dt.findItem(e,t,he);return r.bind(function(n){return o.map(function(e){return function(e,n){return Gn(Math.min(e.row(),n.row()),Math.min(e.column(),n.column()),Math.max(e.row()+e.rowspan()-1,n.row()+n.rowspan()-1),Math.max(e.column()+e.colspan()-1,n.column()+n.colspan()-1))}(n,e)})})}var kt=function Yf(t,r){var n=function(e){return t(e)?We.from(e.dom().nodeValue):We.none()};return{get:function(e){if(!t(e))throw new Error("Can only get "+r+" value of a "+r+" node");return n(e).getOr("")},getOption:n,set:function(e,n){if(!t(e))throw new Error("Can only set raw "+r+" value of a "+r+" node");e.dom().nodeValue=n}}}(tn,"text"),Pt=["img","br"],Bt=function(e,i){var u=function(e){for(var n=Se(e),t=n.length-1;0<=t;t--){var r=n[t];if(i(r))return We.some(r);var o=u(r);if(o.isSome())return o}return We.none()};return u(e)},Mt=function(i,e,u){return{row:Et(e),cell:function(e){var n=ve(e.element()),t=on.fromTag(j(e.element()),n.dom()),r=u.getOr(["strong","em","b","i","span","font","h1","h2","h3","h4","h5","h6","p","div"]),o=0<r.length?function(r,o,i){return yt(r).map(function(e){var n=i.join(","),t=ke(e,n,function(e){return he(e,r)});return w(t,function(e,n){var t=xt(n);return K(t,"contenteditable"),Bn(e,t),t},o)}).getOr(o)}(e.element(),t,r):t;return Bn(o,on.fromTag("br")),function(e,n){var t=e.dom(),r=n.dom();Z(t)&&Z(r)&&(r.style.cssText=t.style.cssText)}(e.element(),t),ce(t,"height"),1!==e.colspan()&&ce(e.element(),"width"),i(e.element(),t),t},replace:Dt,gap:Ot}},Wt=function(e){return{row:Et(e),cell:Ot,replace:At,gap:Ot}},_t=function(e,n){var t=n.column(),r=n.column()+n.colspan()-1,o=n.row(),i=n.row()+n.rowspan()-1;return t<=e.finishCol()&&r>=e.startCol()&&o<=e.finishRow()&&i>=e.startRow()},Lt=function(e,n){for(var t=!0,r=b(Nt,n),o=n.startRow();o<=n.finishRow();o++)for(var i=n.startCol();i<=n.finishCol();i++)t=t&&dt.getAt(e,o,i).exists(r);return t?We.some(n):We.none()},jt=It,zt=function(n,e,t){return It(n,e,t).bind(function(e){return Lt(n,e)})},Ht=function(r,e,o,i){return dt.findItem(r,e,he).bind(function(e){var n=0<o?e.row()+e.rowspan()-1:e.row(),t=0<i?e.column()+e.colspan()-1:e.column();return dt.getAt(r,n+o,t+i).map(function(e){return e.element()})})},Ft=function(t,e,n){return jt(t,e,n).map(function(e){var n=dt.filterItems(t,b(_t,e));return p(n,function(e){return e.element()})})},Ut=function(e,n){return dt.findItem(e,n,function(e,n){return kn(n,e)}).map(function(e){return e.element()})},qt=function(e){var n=lt(e);return dt.generate(n)},Vt=function(t,r,o){return at.table(t).bind(function(e){var n=qt(e);return Ht(n,t,r,o)})},Gt=function(e,n,t){var r=qt(e);return Ft(r,n,t)},Yt=function(e,n,t,r,o){var i=qt(e),u=he(e,t)?We.some(n):Ut(i,n),c=he(e,o)?We.some(r):Ut(i,r);return u.bind(function(n){return c.bind(function(e){return Ft(i,n,e)})})},Kt=function(e,n,t){var r=qt(e);return zt(r,n,t)},Xt=["body","p","div","article","aside","figcaption","figure","footer","header","nav","section","ol","ul","li","table","thead","tbody","tfoot","caption","tr","td","th","h1","h2","h3","h4","h5","h6","blockquote","pre","address"];function $t(){return{up:S({selector:$n,closest:Zn,predicate:Xn,all:we}),down:S({selector:Be,predicate:Yn}),styles:S({get:ie,getRaw:ue,set:re,remove:ce}),attrs:S({get:G,set:q,remove:K,copyTo:function(e,n){var t=X(e);V(n,t)}}),insert:S({before:Re,after:Te,afterAll:Ae,append:Bn,appendAll:Ee,prepend:Oe,wrap:De}),remove:S({unwrap:Ie,remove:Mn}),create:S({nu:on.fromTag,clone:function(e){return on.fromDom(e.dom().cloneNode(!1))},text:on.fromText}),query:S({comparePosition:function(e,n){return e.dom().compareDocumentPosition(n.dom())},prevSibling:ye,nextSibling:Ce}),property:S({children:Se,name:j,parent:be,document:function(e){return e.dom().ownerDocument},isText:tn,isComment:F,isElement:nn,getText:pt,setText:vt,isBoundary:function(e){return!!nn(e)&&("body"===j(e)||m(Xt,j(e)))},isEmptyTag:function(e){return!!nn(e)&&m(["br","img","hr","input"],j(e))}}),eq:he,is:Pn}}function Jt(e,n,t){var r=e.property().children(n);return T(r,b(e.eq,t)).map(function(e){return{before:S(r.slice(0,e)),after:S(r.slice(e+1))}})}function Qt(e,n){return b(e.eq,n)}function Zt(n,e,t,r){function o(n){return T(n,r).fold(function(){return n},function(e){return n.slice(0,e+1)})}void 0===r&&(r=s);var i=[e].concat(n.up().all(e)),u=[t].concat(n.up().all(t)),c=o(i),a=o(u),l=R(c,function(e){return g(a,Qt(n,e))});return{firstpath:S(c),secondpath:S(a),shared:S(l)}}function er(e){return $n(e,"table")}function nr(c,a,r){function l(n){return function(e){return r!==undefined&&r(e)||he(e,n)}}return he(c,a)?We.some(sr.create({boxes:We.some([c]),start:c,finish:a})):er(c).bind(function(u){return er(a).bind(function(i){if(he(u,i))return We.some(sr.create({boxes:Gt(u,c,a),start:c,finish:a}));if(kn(u,i)){var e=0<(n=ke(a,"td,th",l(u))).length?n[n.length-1]:a;return We.some(sr.create({boxes:Yt(u,c,u,a,i),start:c,finish:e}))}if(kn(i,u)){var n,t=0<(n=ke(c,"td,th",l(i))).length?n[n.length-1]:c;return We.some(sr.create({boxes:Yt(i,c,u,a,i),start:c,finish:t}))}return fr.ancestors(c,a).shared().bind(function(e){return Zn(e,"table",r).bind(function(e){var n=ke(a,"td,th",l(e)),t=0<n.length?n[n.length-1]:a,r=ke(c,"td,th",l(e)),o=0<r.length?r[r.length-1]:c;return We.some(sr.create({boxes:Yt(e,c,u,a,i),start:o,finish:t}))})})})})}function tr(e,n){return Rr.cata(n.get(),S([]),o,S([e]))}function rr(e){return{element:S(e),mergable:We.none,unmergable:We.none,selection:S([e])}}var or=P("left","right"),ir=P("first","second","splits"),ur=function(r,o,e,n){var t=o(r,e);return w(n,function(e,n){var t=o(r,n);return cr(r,e,t)},t)},cr=function(n,e,t){return e.bind(function(e){return t.filter(b(n.eq,e))})},ar={sharedOne:function(e,n,t){return 0<t.length?function(e,n,t,r){return r(e,n,t[0],t.slice(1))}(e,n,t,ur):We.none()},subset:function(n,e,t){var r=Zt(n,e,t);return r.shared().bind(function(e){return function(o,i,e,n){var u=o.property().children(i);if(o.eq(i,e[0]))return We.some([e[0]]);if(o.eq(i,n[0]))return We.some([n[0]]);function t(e){var n=E(e),t=T(n,Qt(o,i)).getOr(-1),r=t<n.length-1?n[t+1]:n[t];return T(u,Qt(o,r))}var r=t(e),c=t(n);return r.bind(function(r){return c.map(function(e){var n=Math.min(r,e),t=Math.max(r,e);return u.slice(n,t+1)})})}(n,e,r.firstpath(),r.secondpath())})},ancestors:Zt,breakToLeft:function(t,r,o){return Jt(t,r,o).map(function(e){var n=t.create().clone(r);return t.insert().appendAll(n,e.before().concat([o])),t.insert().appendAll(r,e.after()),t.insert().before(r,n),or(n,r)})},breakToRight:function(t,r,e){return Jt(t,r,e).map(function(e){var n=t.create().clone(r);return t.insert().appendAll(n,e.after()),t.insert().after(r,n),or(r,n)})},breakPath:function(i,e,u,c){var a=function(e,n,o){var t=ir(e,We.none(),o);return u(e)?ir(e,n,o):i.property().parent(e).bind(function(r){return c(i,r,e).map(function(e){var n=[{first:e.left,second:e.right}],t=u(r)?r:e.left();return a(t,We.some(e.right()),o.concat(n))})}).getOr(t)};return a(e,We.none(),[])}},lr=$t(),fr={sharedOne:function(t,e){return ar.sharedOne(lr,function(e,n){return t(n)},e)},subset:function(e,n){return ar.subset(lr,e,n)},ancestors:function(e,n,t){return ar.ancestors(lr,e,n,t)},breakToLeft:function(e,n){return ar.breakToLeft(lr,e,n)},breakToRight:function(e,n){return ar.breakToRight(lr,e,n)},breakPath:function(e,n,r){return ar.breakPath(lr,e,n,function(e,n,t){return r(n,t)})}},sr={create:$e(["boxes","start","finish"],[])},dr=nr,mr=function(e,n){var t=Be(e,n);return 0<t.length?We.some(t):We.none()},gr=function(e,n,t,r,o){return function(e,n){return R(e,function(e){return ge(e,n)})}(e,o).bind(function(e){return Vt(e,n,t).bind(function(e){return function(n,t){return $n(n,"table").bind(function(e){return Qn(e,t).bind(function(e){return nr(e,n).bind(function(n){return n.boxes().map(function(e){return{boxes:S(e),start:S(n.start()),finish:S(n.finish())}})})})})}(e,r)})})},pr=function(e,n,r){return Qn(e,n).bind(function(t){return Qn(e,r).bind(function(n){return fr.sharedOne(er,[t,n]).map(function(e){return{first:S(t),last:S(n),table:S(e)}})})})},hr=function(e,n){return mr(e,n)},vr=function(o,e,n){return pr(o,e,n).bind(function(t){function e(e){return he(o,e)}var n=$n(t.first(),"thead,tfoot,tbody,table",e),r=$n(t.last(),"thead,tfoot,tbody,table",e);return n.bind(function(n){return r.bind(function(e){return he(n,e)?Kt(t.table(),t.first(),t.last()):We.none()})})})},br="data-mce-selected",wr="data-mce-first-selected",yr="data-mce-last-selected",Cr={selected:S(br),selectedSelector:S("td[data-mce-selected],th[data-mce-selected]"),attributeSelector:S("[data-mce-selected]"),firstSelected:S(wr),firstSelectedSelector:S("td[data-mce-first-selected],th[data-mce-first-selected]"),lastSelected:S(yr),lastSelectedSelector:S("td[data-mce-last-selected],th[data-mce-last-selected]")},Sr=function(u){if(!je(u))throw new Error("cases must be an array");if(0===u.length)throw new Error("there must be at least one case");var c=[],t={};return h(u,function(e,r){var n=Ge(e);if(1!==n.length)throw new Error("one and only one name per case");var o=n[0],i=e[o];if(t[o]!==undefined)throw new Error("duplicate key detected:"+o);if("cata"===o)throw new Error("cannot have a case named cata (sorry)");if(!je(i))throw new Error("case arguments must be an array");c.push(o),t[o]=function(){var e=arguments.length;if(e!==i.length)throw new Error("Wrong number of arguments to case "+o+". Expected "+i.length+" ("+i+"), got "+e);for(var t=new Array(e),n=0;n<t.length;n++)t[n]=arguments[n];return{fold:function(){if(arguments.length!==u.length)throw new Error("Wrong number of arguments to fold. Expected "+u.length+", got "+arguments.length);return arguments[r].apply(null,t)},match:function(e){var n=Ge(e);if(c.length!==n.length)throw new Error("Wrong number of arguments to match. Expected: "+c.join(",")+"\nActual: "+n.join(","));if(!A(c,function(e){return m(n,e)}))throw new Error("Not all branches were specified when using match. Specified: "+n.join(", ")+"\nRequired: "+c.join(", "));return e[o].apply(null,t)},log:function(e){f.console.log(e,{constructors:c,constructor:o,params:t})}}}}),t},xr=Sr([{none:[]},{multiple:["elements"]},{single:["selection"]}]),Rr={cata:function(e,n,t,r){return e.fold(n,t,r)},none:xr.none,multiple:xr.multiple,single:xr.single},Tr=function(t,e){return Rr.cata(e.get(),We.none,function(n,e){return 0===n.length?We.none():vr(t,Cr.firstSelectedSelector(),Cr.lastSelectedSelector()).bind(function(e){return 1<n.length?We.some({bounds:S(e),cells:S(n)}):We.none()})},We.none)},Or=function(e,n){var t=tr(e,n);return 0<t.length&&A(t,function(e){return Y(e,"rowspan")&&1<parseInt(G(e,"rowspan"),10)||Y(e,"colspan")&&1<parseInt(G(e,"colspan"),10)})?We.some(t):We.none()},Dr=tr,Ar=P("element","clipboard","generators"),Er={noMenu:rr,forMenu:function(e,n,t){return{element:S(t),mergable:S(Tr(n,e)),unmergable:S(Or(t,e)),selection:S(Dr(t,e))}},notCell:function(e){return rr(e)},paste:Ar,pasteRows:function(e,n,t,r,o){return{element:S(t),mergable:We.none,unmergable:We.none,selection:S(Dr(t,e)),clipboard:S(r),generators:S(o)}}},Nr={registerEvents:function(c,e,a,l){c.on("BeforeGetContent",function(n){!0===n.selection&&Rr.cata(e.get(),y,function(e){n.preventDefault(),function(e){return at.table(e[0]).map(Rt).map(function(e){return[gt(e,Cr.attributeSelector())]})}(e).each(function(e){n.content="text"===n.format?function(e){return p(e,function(e){return e.dom().innerText}).join("")}(e):function(n,e){return p(e,function(e){return n.selection.serializer.serialize(e.dom(),{})}).join("")}(c,e)})},y)}),c.on("BeforeSetContent",function(u){!0===u.selection&&!0===u.paste&&We.from(c.dom.getParent(c.selection.getStart(),"th,td")).each(function(e){var i=on.fromDom(e);at.table(i).each(function(n){var e=v(function(e,n){var t=(n||f.document).createElement("div");return t.innerHTML=e,Se(on.fromDom(t))}(u.content),function(e){return"meta"!==j(e)});if(1===e.length&&"table"===j(e[0])){u.preventDefault();var t=on.fromDom(c.getDoc()),r=Wt(t),o=Er.paste(i,e[0],r);a.pasteCells(n,o).each(function(e){c.selection.setRng(e),c.focus(),l.clear(n)})}})})})}};function Ir(r,o){function e(e){var n=o(e);if(n<=0||null===n){var t=ie(e,r);return parseFloat(t)||0}return n}function i(o,e){return x(e,function(e,n){var t=ie(o,n),r=t===undefined?0:parseInt(t,10);return isNaN(r)?e:e+r},0)}return{set:function(e,n){if(!Fe(n)&&!n.match(/^[0-9]+$/))throw new Error(r+".set accepts only positive integer values. Value was "+n);var t=e.dom();Z(t)&&(t.style[r]=n+"px")},get:e,getOuter:e,aggregate:i,max:function(e,n,t){var r=i(e,t);return r<n?n-r:0}}}function kr(e){return Qr.get(e)}function Pr(e){return Qr.getOuter(e)}function Br(e){return Zr.get(e)}function Mr(e){return Zr.getOuter(e)}function Wr(e,n,t){return function(e,n){var t=parseFloat(e);return isNaN(t)?n:t}(ie(e,n),t)}function _r(e,n){re(e,"height",n+"px")}function Lr(e,n,t,r){var o=parseInt(e,10);return function(e,n){return $(e,n,e.length-n.length)}(e,"%")&&"table"!==j(n)?function(e,t,r,n){var o=at.table(e).map(function(e){var n=r(e);return Math.floor(t/100*n)}).getOr(t);return n(e,o),o}(n,o,t,r):o}function jr(e){var n=function(e){return ue(e,"height").getOrThunk(function(){return no(e)+"px"})}(e);return n?Lr(n,e,kr,_r):kr(e)}function zr(e){return ue(e,"width").fold(function(){return We.from(G(e,"width"))},function(e){return We.some(e)})}function Hr(e,n){return e/n.pixelWidth()*100}function Fr(e,n){return e!==undefined?e:n!==undefined?n:0}function Ur(e){var n=e.dom().ownerDocument,t=n.body,r=n.defaultView,o=n.documentElement,i=Fr(r.pageYOffset,o.scrollTop),u=Fr(r.pageXOffset,o.scrollLeft),c=Fr(o.clientTop,t.clientTop),a=Fr(o.clientLeft,t.clientLeft);return fo(e).translate(u-a,i-c)}function qr(e){return Ur(e).left()+Mr(e)}function Vr(e){return Ur(e).left()}function Gr(e,n){return mo(e,Vr(n))}function Yr(e,n){return mo(e,qr(n))}function Kr(e){return Ur(e).top()}function Xr(e,n){return so(e,Kr(n))}function $r(e,n){return so(e,Kr(n)+Pr(n))}function Jr(t,n,r){if(0===r.length)return[];var e=p(r.slice(1),function(e,n){return e.map(function(e){return t(n,e)})}),o=r[r.length-1].map(function(e){return n(r.length-1,e)});return e.concat([o])}var Qr=Ir("height",function(e){var n=e.dom();return ne(e)?n.getBoundingClientRect().height:n.offsetHeight}),Zr=Ir("width",function(e){return e.dom().offsetWidth}),eo=En.detect(),no=function(e){return eo.browser.isIE()||eo.browser.isEdge()?function(e){var n=Wr(e,"padding-top",0),t=Wr(e,"padding-bottom",0),r=Wr(e,"border-top-width",0),o=Wr(e,"border-bottom-width",0),i=e.dom().getBoundingClientRect().height;return"border-box"===ie(e,"box-sizing")?i:i-n-t-(r+o)}(e):Wr(e,"height",kr(e))},to=/(\d+(\.\d+)?)(\w|%)*/,ro=/(\d+(\.\d+)?)%/,oo=/(\d+(\.\d+)?)px|em/,io=function(e,n){return Y(e,n)?parseInt(G(e,n),10):1},uo={percentageBasedSizeRegex:S(ro),pixelBasedSizeRegex:S(oo),setPixelWidth:function(e,n){re(e,"width",n+"px")},setPercentageWidth:function(e,n){re(e,"width",n+"%")},setHeight:_r,getPixelWidth:function(n,t){return zr(n).fold(function(){return Br(n)},function(e){return function(e,n,t){var r=oo.exec(n);if(null!==r)return parseInt(r[1],10);var o=ro.exec(n);return null===o?Br(e):function(e,n){return e/100*n.pixelWidth()}(parseFloat(o[1]),t)}(n,e,t)})},getPercentageWidth:function(n,t){return zr(n).fold(function(){var e=Br(n);return Hr(e,t)},function(e){return function(e,n,t){var r=ro.exec(n);if(null!==r)return parseFloat(r[1]);var o=Br(e);return Hr(o,t)}(n,e,t)})},getGenericWidth:function(e){return zr(e).bind(function(e){var n=to.exec(e);return null!==n?We.some({width:S(parseFloat(n[1])),unit:S(n[3])}):We.none()})},setGenericWidth:function(e,n,t){re(e,"width",n+t)},getHeight:function(e){return function(e,n,t){return t(e)/io(e,n)}(e,"rowspan",jr)},getRawWidth:zr},co=function(t,r){uo.getGenericWidth(t).each(function(e){var n=e.width()/2;uo.setGenericWidth(t,n,e.unit()),uo.setGenericWidth(r,n,e.unit())})},ao=function(t,r){return{left:S(t),top:S(r),translate:function(e,n){return ao(t+e,r+n)}}},lo=ao,fo=function(e){var n=e.dom(),t=n.ownerDocument.body;return t===n?lo(t.offsetLeft,t.offsetTop):ne(e)?function(e){var n=e.getBoundingClientRect();return lo(n.left,n.top)}(n):lo(0,0)},so=P("row","y"),mo=P("col","x"),go={height:{delta:o,positions:function(e){return Jr(Xr,$r,e)},edge:Kr},rtl:{delta:function(e){return-e},edge:qr,positions:function(e){return Jr(Yr,Gr,e)}},ltr:{delta:o,edge:Vr,positions:function(e){return Jr(Gr,Yr,e)}}},po={ltr:go.ltr,rtl:go.rtl};function ho(n){function t(e){return n(e).isRtl()?po.rtl:po.ltr}return{delta:function(e,n){return t(n).delta(e,n)},edge:function(e){return t(e).edge(e)},positions:function(e,n){return t(n).positions(e,n)}}}function vo(e){for(var n=[],t=function(e){n.push(e)},r=0;r<e.length;r++)e[r].each(t);return n}function bo(e,n){for(var t=0;t<e.length;t++){var r=n(e[t],t);if(r.isSome())return r}return We.none()}function wo(e,n,t,r){t===r?K(e,n):q(e,n,t)}function yo(e,n){var t=G(e,n);return t===undefined||""===t?[]:t.split(" ")}function Co(e){return e.dom().classList!==undefined}function So(e,n){return function(e,n,t){var r=yo(e,n).concat([t]);return q(e,n,r.join(" ")),!0}(e,"class",n)}function xo(e,n){return function(e,n,t){var r=v(yo(e,n),function(e){return e!==t});return 0<r.length?q(e,n,r.join(" ")):K(e,n),!1}(e,"class",n)}function Ro(e,n){Co(e)?e.dom().classList.add(n):So(e,n)}function To(e){0===(Co(e)?e.dom().classList:function(e){return yo(e,"class")}(e)).length&&K(e,"class")}function Oo(e,n){return Co(e)&&e.dom().classList.contains(n)}function Do(e,n){for(var t=[],r=e;r<n;r++)t.push(r);return t}function Ao(n,t){if(t<0||t>=n.length-1)return We.none();var e=n[t].fold(function(){var e=E(n.slice(0,t));return bo(e,function(e,n){return e.map(function(e){return{value:e,delta:n+1}})})},function(e){return We.some({value:e,delta:0})}),r=n[t+1].fold(function(){var e=n.slice(t+1);return bo(e,function(e,n){return e.map(function(e){return{value:e,delta:n+1}})})},function(e){return We.some({value:e,delta:1})});return e.bind(function(t){return r.map(function(e){var n=e.delta+t.delta;return Math.abs(e.value-t.value)/n})})}function Eo(e){var n=e.replace(/\./g,"-");return{resolve:function(e){return n+"-"+e}}}function No(e){var n=Be(e.parent(),"."+uu);h(n,Mn)}function Io(t,e,r){var o=t.origin();h(e,function(e,n){e.each(function(e){var n=r(o,e);Ro(n,uu),Bn(t.parent(),n)})})}function ko(e,n,t,r,o,i){var u=Ur(n);!function(e,n,r,o){Io(e,n,function(e,n){var t=iu(n.row(),r.left()-e.left(),n.y()-e.top(),o,7);return Ro(t,cu),t})}(e,0<t.length?o.positions(t,n):[],u,Mr(n)),function(e,n,r,o){Io(e,n,function(e,n){var t=ou(n.col(),n.x()-e.left(),r.top()-e.top(),7,o);return Ro(t,au),t})}(e,0<r.length?i.positions(r,n):[],u,Pr(n))}function Po(e,n){var t=Be(e.parent(),"."+uu);h(t,n)}function Bo(e,n){return e.cells()[n]}function Mo(e,n){if(0===e.length)return 0;var t=e[0];return T(e,function(e){return!n(t.element(),e.element())}).fold(function(){return e.length},function(e){return e})}function Wo(e,t){return p(e,function(e){var n=function(e){return bo(e,function(e){return be(e.element()).map(function(e){var n=be(e).isNone();return Fn(e,n)})}).getOrThunk(function(){return Fn(t.row(),!0)})}(e.details());return Un(n.element(),e.details(),e.section(),n.isNew())})}function _o(e,n){var t=bu(e,he);return Wo(t,n)}function Lo(e,n){var t=O(p(e.all(),function(e){return e.cells()}));return R(t,function(e){return he(n,e.element())})}function jo(c,a,l,f,s){return function(t,r,e,o,i){var n=lt(r),u=dt.generate(n);return a(u,e).map(function(e){var n=function(e,n){return wu(e,n,!1)}(u,o),t=c(n,e,he,s(o)),r=_o(t.grid(),o);return{grid:S(r),cursor:t.cursor}}).fold(function(){return We.none()},function(e){var n=Qi(r,e.grid());return l(r,e.grid(),i),f(r),lu(t,r,go.height,i),We.some({cursor:e.cursor,newRows:n.newRows,newCells:n.newCells})})}}function zo(n,e){return at.cell(e.element()).bind(function(e){return Lo(n,e)})}function Ho(n,e){var t=p(e.selection(),function(e){return at.cell(e).bind(function(e){return Lo(n,e)})}),r=vo(t);return 0<r.length?We.some({cells:r,generators:e.generators,clipboard:e.clipboard}):We.none()}function Fo(n,e){var t=p(e.selection(),function(e){return at.cell(e).bind(function(e){return Lo(n,e)})}),r=vo(t);return 0<r.length?We.some(r):We.none()}function Uo(e,n){return p(e,function(){return Fn(n.cell(),!0)})}function qo(n,e,t){return n.concat(function(e,n){for(var t=[],r=0;r<e;r++)t.push(n(r));return t}(e,function(e){return hu.setCells(n[n.length-1],Uo(n[n.length-1].cells(),t))}))}function Vo(e,n,t){return p(e,function(e){return hu.setCells(e,e.cells().concat(Uo(Do(0,n),t)))})}function Go(e,t,r,n){return p(e,function(e){return hu.mapCells(e,function(e){return function(n){return g(t,function(e){return r(n.element(),e.element())})}(e)?Fn(n(e.element(),r),!0):e})})}function Yo(e,n,t,r){return hu.getCellElement(e[n],t)!==undefined&&0<n&&r(hu.getCellElement(e[n-1],t),hu.getCellElement(e[n],t))}function Ko(e,n,t){return 0<n&&t(hu.getCellElement(e,n-1),hu.getCellElement(e,n))}function Xo(e,n){return Y(e,n)&&1<parseInt(G(e,n),10)}function $o(e,n,t){return ue(e,n).fold(function(){return t(e)+"px"},function(e){return e})}function Jo(e,n){return $o(e,"width",function(e){return uo.getPixelWidth(e,n)})}function Qo(e){return $o(e,"height",uo.getHeight)}function Zo(e,n,t,r,o){var i=nu(e),u=p(i,function(e){return e.map(n.edge)});return p(i,function(e,n){return e.filter(d(Fu.hasColspan)).fold(function(){var e=Ao(u,n);return r(e)},function(e){return t(e,o)})})}function ei(e){return e.map(function(e){return e+"px"}).getOr("")}function ni(e,n,t,r){var o=tu(e),i=p(o,function(e){return e.map(n.edge)});return p(o,function(e,n){return e.filter(d(Fu.hasRowspan)).fold(function(){var e=Ao(i,n);return r(e)},function(e){return t(e)})})}function ti(e,n,t){for(var r=0,o=e;o<n;o++)r+=t[o]!==undefined?t[o]:0;return r}function ri(e){var n=o;return{width:S(e),pixelWidth:S(e),getWidths:Uu.getPixelWidths,getCellDelta:n,singleColumnWidth:function(e,n){return[Math.max(Fu.minWidth(),e+n)-e]},minCellWidth:Fu.minWidth,setElementWidth:uo.setPixelWidth,setTableWidth:function(e,n,t){var r=w(n,function(e,n){return e+n},0);uo.setPixelWidth(e,r)}}}function oi(e,n){var t=uo.percentageBasedSizeRegex().exec(n);if(null!==t)return function(e,n){var o=parseFloat(e),t=Br(n);return{width:S(o),pixelWidth:S(t),getWidths:Uu.getPercentageWidths,getCellDelta:function(e){return e/t*100},singleColumnWidth:function(e,n){return[100-e]},minCellWidth:function(){return Fu.minWidth()/t*100},setElementWidth:uo.setPercentageWidth,setTableWidth:function(e,n,t){var r=t/100*o;uo.setPercentageWidth(e,o+r)}}}(t[1],e);var r=uo.pixelBasedSizeRegex().exec(n);if(null!==r){var o=parseInt(r[1],10);return ri(o)}var i=Br(e);return ri(i)}function ii(e){return dt.generate(e)}function ui(e){var n=lt(e);return ii(n)}function ci(n,e){var t=v(e,function(e){return!m(n,e)});0<t.length&&W(t)}function ai(e){return function(e,n){return Ju(e,n,{validate:He,label:"function"})}(ci,e)}function li(e){var n=Y(e,"colspan")?parseInt(G(e,"colspan"),10):1,t=Y(e,"rowspan")?parseInt(G(e,"rowspan"),10):1;return{element:S(e),colspan:S(n),rowspan:S(t)}}function fi(e,n){var t=e.property().name(n);return m(tc,t)}function si(e,n){return m(["br","img","hr","input"],e.property().name(n))}function di(e){0===at.cells(e).length&&Mn(e)}function mi(e,n,t){return dc(e,n,t).orThunk(function(){return dc(e,0,0)})}function gi(e,n,t){return sc(e,dc(e,n,t))}function pi(e){return x(e,function(e,n){return g(e,function(e){return e.row()===n.row()})?e:e.concat([n])},[]).sort(function(e,n){return e.row()-n.row()})}function hi(e){return x(e,function(e,n){return g(e,function(e){return e.column()===n.column()})?e:e.concat([n])},[]).sort(function(e,n){return e.column()-n.column()})}function vi(e,n,t){var r=ft(e,t),o=dt.generate(r);return wu(o,n,!0)}function bi(e){return e.getBoundingClientRect().width}function wi(e){return e.getBoundingClientRect().height}function yi(e){return/^[0-9]+$/.test(e)&&(e+="px"),e}function Ci(e){var n=Be(e,"td[data-mce-style],th[data-mce-style]");K(e,"data-mce-style"),h(n,function(e){K(e,"data-mce-style")})}function Si(e){return e.getParam("table_default_attributes",Cc,"object")}function xi(e){return e.getParam("table_default_styles",yc,"object")}function Ri(e){return e.getParam("table_cell_advtab",!0,"boolean")}function Ti(e){return e.getParam("table_row_advtab",!0,"boolean")}function Oi(e){return e.getParam("table_advtab",!0,"boolean")}function Di(e){return e.getParam("table_style_by_css",!1,"boolean")}function Ai(e){return e.getParam("table_class_list",[],"array")}function Ei(e){return!1===e.getParam("table_responsive_width")}function Ni(e,n){return e.fire("newrow",{node:n})}function Ii(e,n){return e.fire("newcell",{node:n})}function ki(e,n,t,r){e.fire("ObjectResizeStart",{target:n,width:t,height:r})}function Pi(e,n,t,r){e.fire("ObjectResized",{target:n,width:t,height:r})}function Bi(n,e){function t(e){return Q(e,"rgb")?n.toHex(e):e}return{borderstyle:ue(on.fromDom(e),"border-style").getOr(""),bordercolor:ue(on.fromDom(e),"border-color").map(t).getOr(""),backgroundcolor:ue(on.fromDom(e),"background-color").map(t).getOr("")}}function Mi(e,n,t,r,o){var i={};return Tc.each(e.split(" "),function(e){r.formatter.matchNode(o,n+e)&&(i[t]=e)}),i[t]||(i[t]=""),i}function Wi(e,n){e.setAttrib("scope",n.scope),e.setAttrib("class",n["class"]),e.setStyle("width",yi(n.width)),e.setStyle("height",yi(n.height))}function _i(e,n){e.setStyle("background-color",n.backgroundcolor),e.setStyle("border-color",n.bordercolor),e.setStyle("border-style",n.borderstyle)}function Li(e,n,t){var r=e.dom,o=t.celltype&&n[0].nodeName.toLowerCase()!==t.celltype?r.rename(n[0],t.celltype):n[0],i=Fc.normal(r,o);Wi(i,t),Ri(e)&&_i(i,t),Ac(e,o),Ec(e,o),t.halign&&Oc(e,o,t.halign),t.valign&&Dc(e,o,t.valign)}function ji(t,e,r){var o=t.dom;Tc.each(e,function(e){r.celltype&&e.nodeName.toLowerCase()!==r.celltype&&(e=o.rename(e,r.celltype));var n=Fc.ifTruthy(o,e);Wi(n,r),Ri(t)&&_i(n,r),r.halign&&Oc(t,e,r.halign),r.valign&&Dc(t,e,r.valign)})}function zi(e,n,t){var r=t.getData();t.close(),e.undoManager.transact(function(){(1===n.length?Li:ji)(e,n,r),e.focus()})}function Hi(t,e,r,n){var o=t.dom,i=n.getData();n.close();var u=1===e.length?Fc.normal:Fc.ifTruthy;t.undoManager.transact(function(){Tc.each(e,function(e){i.type!==e.parentNode.nodeName.toLowerCase()&&function(e,n,t){var r=e.getParent(n,"table"),o=n.parentNode,i=e.select(t,r)[0];i||(i=e.create(t),r.firstChild?"CAPTION"===r.firstChild.nodeName?e.insertAfter(i,r.firstChild):r.insertBefore(i,r.firstChild):r.appendChild(i)),i.appendChild(n),o.hasChildNodes()||e.remove(o)}(t.dom,e,i.type);var n=u(o,e);n.setAttrib("scope",i.scope),n.setAttrib("class",i["class"]),n.setStyle("height",yi(i.height)),Ti(t)&&function(e,n){e.setStyle("background-color",n.backgroundcolor),e.setStyle("border-color",n.bordercolor),e.setStyle("border-style",n.borderstyle)}(n,i),i.align!==r.align&&(Ac(t,e),Oc(t,e,i.align))}),t.focus()})}function Fi(e,n,t,r,o){void 0===o&&(o=$c);var i=on.fromTag("table");oe(i,o.styles),V(i,o.attributes);var u=on.fromTag("tbody");Bn(i,u);for(var c=[],a=0;a<e;a++){for(var l=on.fromTag("tr"),f=0;f<n;f++){var s=a<t||f<r?on.fromTag("th"):on.fromTag("td");f<r&&q(s,"scope","row"),a<t&&q(s,"scope","col"),Bn(s,on.fromTag("br")),o.percentages&&re(s,"width",100/n+"%"),Bn(l,s)}c.push(l)}return Ee(u,c),i}function Ui(e,n){e.selection.select(n.dom(),!0),e.selection.collapse(!0)}function qi(t,r,e){var o,i=t.dom,u=e.getData();e.close(),""===u["class"]&&delete u["class"],t.undoManager.transact(function(){if(!r){var e=parseInt(u.cols,10)||1,n=parseInt(u.rows,10)||1;r=Jc(t,e,n)}!function(e,n,t){var r=e.dom,o={},i={};if(o["class"]=t["class"],i.height=yi(t.height),r.getAttrib(n,"width")&&!Di(e)?o.width=function(e){return e?e.replace(/px$/,""):""}(t.width):i.width=yi(t.width),Di(e)?(i["border-width"]=yi(t.border),i["border-spacing"]=yi(t.cellspacing)):(o.border=t.border,o.cellpadding=t.cellpadding,o.cellspacing=t.cellspacing),Di(e)&&n.children)for(var u=0;u<n.children.length;u++)Zc(r,n.children[u],{"border-width":yi(t.border),padding:yi(t.cellpadding)}),Oi(e)&&Zc(r,n.children[u],{"border-color":t.bordercolor});Oi(e)&&(i["background-color"]=t.backgroundcolor,i["border-color"]=t.bordercolor,i["border-style"]=t.borderstyle),o.style=r.serializeStyle(Kc(xi(e),i)),r.setAttribs(n,Kc(Si(e),o))}(t,r,u),(o=i.select("caption",r)[0])&&!u.caption&&i.remove(o),!o&&u.caption&&((o=i.create("caption")).innerHTML=Xc.ie?"\xa0":'<br data-mce-bogus="1"/>',r.insertBefore(o,r.firstChild)),""===u.align?Ac(t,r):Oc(t,r,u.align),t.focus(),t.addVisual()})}function Vi(n){return function(e){return We.from(e.dom.getParent(e.selection.getStart(),n)).map(on.fromDom)}}function Gi(u,c){return function(e){if(u(e)){var n=on.fromDom(e.target),t=function(){e.stopPropagation()},r=function(){e.preventDefault()},o=C(r,t),i=function(e,n,t,r,o,i,u){return{target:S(e),x:S(n),y:S(t),stop:r,prevent:o,kill:i,raw:S(u)}}(n,e.clientX,e.clientY,t,r,o,e);c(i)}}}function Yi(e,n,t,r){return function(e,n,t,r,o){var i=Gi(t,r);return e.dom().addEventListener(n,i,o),{unbind:b(la,e,n,i,o)}}(e,n,t,r,!1)}function Ki(e,n,t){return Yi(e,n,fa,t)}var Xi,$i=function(e){var n=lt(e);return dt.generate(n).grid()},Ji=function(){return(Ji=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e}).apply(this,arguments)},Qi=function(o,e){function n(e,n){0<e.length?function(e,n){var t=Jn(o,n).getOrThunk(function(){var e=on.fromTag(n,ve(o).dom());return Bn(o,e),e});Ne(t);var r=p(e,function(e){e.isNew()&&i.push(e.element());var n=e.element();return Ne(n),h(e.cells(),function(e){e.isNew()&&u.push(e.element()),wo(e.element(),"colspan",e.colspan(),1),wo(e.element(),"rowspan",e.rowspan(),1),Bn(n,e.element())}),n});Ee(t,r)}(e,n):function(e){Jn(o,e).each(Mn)}(n)}var i=[],u=[],t=[],r=[],c=[];return h(e,function(e){switch(e.section()){case"thead":t.push(e);break;case"tbody":r.push(e);break;case"tfoot":c.push(e)}}),n(t,"thead"),n(r,"tbody"),n(c,"tfoot"),{newRows:S(i),newCells:S(u)}},Zi=function(e){return p(e,function(e){var t=xt(e.element());return h(e.cells(),function(e){var n=Rt(e.element());wo(n,"colspan",e.colspan(),1),wo(n,"rowspan",e.rowspan(),1),Bn(t,n)}),t})},eu=function(e,n,t){var r=e();return R(r,n).orThunk(function(){return We.from(r[0]).orThunk(t)}).map(function(e){return e.element()})},nu=function(t){var e=t.grid(),n=Do(0,e.columns()),r=Do(0,e.rows());return p(n,function(n){return eu(function(){return D(r,function(e){return dt.getAt(t,e,n).filter(function(e){return e.column()===n}).fold(S([]),function(e){return[e]})})},function(e){return 1===e.colspan()},function(){return dt.getAt(t,0,n)})})},tu=function(t){var e=t.grid(),n=Do(0,e.rows()),r=Do(0,e.columns());return p(n,function(n){return eu(function(){return D(r,function(e){return dt.getAt(t,n,e).filter(function(e){return e.row()===n}).fold(S([]),function(e){return[e]})})},function(e){return 1===e.rowspan()},function(){return dt.getAt(t,n,0)})})},ru={resolve:Eo("ephox-snooker").resolve},ou=function(e,n,t,r,o){var i=on.fromTag("div");return oe(i,{position:"absolute",left:n-r/2+"px",top:t+"px",height:o+"px",width:r+"px"}),V(i,{"data-column":e,role:"presentation"}),i},iu=function(e,n,t,r,o){var i=on.fromTag("div");return oe(i,{position:"absolute",left:n+"px",top:t-o/2+"px",height:o+"px",width:r+"px"}),V(i,{"data-row":e,role:"presentation"}),i},uu=ru.resolve("resizer-bar"),cu=ru.resolve("resizer-rows"),au=ru.resolve("resizer-cols"),lu=function(e,n,t,r){No(e);var o=lt(n),i=dt.generate(o),u=tu(i),c=nu(i);ko(e,n,u,c,t,r)},fu=function(e){Po(e,function(e){re(e,"display","none")})},su=function(e){Po(e,function(e){re(e,"display","block")})},du=No,mu=function(e){return Oo(e,cu)},gu=function(e){return Oo(e,au)},pu=function(e,n){return qn(n,e.section())},hu={addCell:function(e,n,t){var r=e.cells(),o=r.slice(0,n),i=r.slice(n),u=o.concat([t]).concat(i);return pu(e,u)},setCells:pu,mutateCell:function(e,n,t){e.cells()[n]=t},getCell:Bo,getCellElement:function(e,n){return Bo(e,n).element()},mapCells:function(e,n){var t=e.cells(),r=p(t,n);return qn(r,e.section())},cellLength:function(e){return e.cells().length}},vu=function(e,n,t,r){var o=function(e,n){return e[n]}(e,n).cells().slice(t),i=Mo(o,r),u=function(e,n){return p(e,function(e){return hu.getCell(e,n)})}(e,t).slice(n),c=Mo(u,r);return{colspan:S(i),rowspan:S(c)}},bu=function(o,i){var u=p(o,function(e,n){return p(e.cells(),function(e,n){return!1})});return p(o,function(e,r){var n=D(e.cells(),function(e,n){if(!1!==u[r][n])return[];var t=vu(o,r,n,i);return function(e,n,t,r){for(var o=e;o<e+t;o++)for(var i=n;i<n+r;i++)u[o][i]=!0}(r,n,t.rowspan(),t.colspan()),[jn(e.element(),t.rowspan(),t.colspan(),e.isNew())]});return Vn(n,e.section())})},wu=function(e,n,t){for(var r=[],o=0;o<e.grid().rows();o++){for(var i=[],u=0;u<e.grid().columns();u++){var c=dt.getAt(e,o,u).map(function(e){return Fn(e.element(),t)}).getOrThunk(function(){return Fn(n.gap(),!0)});i.push(c)}var a=qn(i,e.all()[o].section());r.push(a)}return r},yu=function(t){return{is:function(e){return t===e},isValue:i,isError:s,getOr:S(t),getOrThunk:S(t),getOrDie:S(t),or:function(e){return yu(t)},orThunk:function(e){return yu(t)},fold:function(e,n){return n(t)},map:function(e){return yu(e(t))},mapError:function(e){return yu(t)},each:function(e){e(t)},bind:function(e){return e(t)},exists:function(e){return e(t)},forall:function(e){return e(t)},toOption:function(){return We.some(t)}}},Cu=function(t){return{is:s,isValue:s,isError:i,getOr:o,getOrThunk:function(e){return e()},getOrDie:function(){return function(e){return function(){throw new Error(e)}}(String(t))()},or:function(e){return e},orThunk:function(e){return e()},fold:function(e,n){return e(t)},map:function(e){return Cu(t)},mapError:function(e){return Cu(e(t))},each:y,bind:function(e){return Cu(t)},exists:s,forall:i,toOption:We.none}},Su={value:yu,error:Cu,fromOption:function(e,n){return e.fold(function(){return Cu(n)},yu)}},xu=function(e,n,t){if(e.row()>=n.length||e.column()>hu.cellLength(n[0]))return Su.error("invalid start address out of table bounds, row: "+e.row()+", column: "+e.column());var r=n.slice(e.row()),o=r[0].cells().slice(e.column()),i=hu.cellLength(t[0]),u=t.length;return Su.value({rowDelta:S(r.length-u),colDelta:S(o.length-i)})},Ru=function(e,n){var t=hu.cellLength(e[0]),r=hu.cellLength(n[0]);return{rowDelta:S(0),colDelta:S(t-r)}},Tu=function(e,n,t){var r=n.colDelta()<0?Vo:o;return(n.rowDelta()<0?qo:o)(r(e,Math.abs(n.colDelta()),t),Math.abs(n.rowDelta()),t)},Ou=function(e,n,t,r){if(0===e.length)return e;for(var o=n.startRow();o<=n.finishRow();o++)for(var i=n.startCol();i<=n.finishCol();i++)hu.mutateCell(e[o],i,Fn(r(),!1));return e},Du=function(e,n,t,r){for(var o=!0,i=0;i<e.length;i++)for(var u=0;u<hu.cellLength(e[0]);u++){var c=t(hu.getCellElement(e[i],u),n);!0===c&&!1===o?hu.mutateCell(e[i],u,Fn(r(),!0)):!0===c&&(o=!1)}return e},Au=function(i,t,u,c){if(0<t&&t<i.length){var e=function(e,t){return x(e,function(e,n){return g(e,function(e){return t(e.element(),n.element())})?e:e.concat([n])},[])}(i[t-1].cells(),u);h(e,function(r){for(var o=We.none(),e=function(t){for(var e=function(n){var e=i[t].cells()[n];u(e.element(),r.element())&&(o.isNone()&&(o=We.some(c())),o.each(function(e){hu.mutateCell(i[t],n,Fn(e,!0))}))},n=0;n<hu.cellLength(i[0]);n++)e(n)},n=t;n<i.length;n++)e(n)})}return i},Eu=function(t,r,o,i,u){return xu(t,r,o).map(function(e){var n=Tu(r,e,i);return function(e,n,t,r,o){for(var i,u,c,a,l,f=e.row(),s=e.column(),d=f+t.length,m=s+hu.cellLength(t[0]),g=f;g<d;g++)for(var p=s;p<m;p++){i=n,u=g,c=p,l=a=void 0,a=b(o,hu.getCell(i[u],c).element()),l=i[u],1<i.length&&1<hu.cellLength(l)&&(0<c&&a(hu.getCellElement(l,c-1))||c<l.cells().length-1&&a(hu.getCellElement(l,c+1))||0<u&&a(hu.getCellElement(i[u-1],c))||u<i.length-1&&a(hu.getCellElement(i[u+1],c)))&&Du(n,hu.getCellElement(n[g],p),o,r.cell);var h=hu.getCellElement(t[g-f],p-s),v=r.replace(h);hu.mutateCell(n[g],p,Fn(v,!0))}return n}(t,n,o,i,u)})},Nu=function(e,n,t,r,o){Au(n,e,o,r.cell);var i=Ru(t,n),u=Tu(t,i,r),c=Ru(n,u),a=Tu(n,c,r);return a.slice(0,e).concat(u).concat(a.slice(e,a.length))},Iu=function(t,r,e,o,i){var n=t.slice(0,r),u=t.slice(r),c=hu.mapCells(t[e],function(e,n){return 0<r&&r<t.length&&o(hu.getCellElement(t[r-1],n),hu.getCellElement(t[r],n))?hu.getCell(t[r],n):Fn(i(e.element(),o),!0)});return n.concat([c]).concat(u)},ku=function(e,t,r,o,i){return p(e,function(e){var n=0<t&&t<hu.cellLength(e)&&o(hu.getCellElement(e,t-1),hu.getCellElement(e,t))?hu.getCell(e,t):Fn(i(hu.getCellElement(e,r),o),!0);return hu.addCell(e,t,n)})},Pu=function(e,r,o,i,u){var c=o+1;return p(e,function(e,n){var t=n===r?Fn(u(hu.getCellElement(e,o),i),!0):hu.getCell(e,o);return hu.addCell(e,c,t)})},Bu=function(e,n,t,r,o){var i=n+1,u=e.slice(0,i),c=e.slice(i),a=hu.mapCells(e[n],function(e,n){return n===t?Fn(o(e.element(),r),!0):e});return u.concat([a]).concat(c)},Mu=function(e,n,t){return e.slice(0,n).concat(e.slice(t+1))},Wu=function(e,t,r){var n=p(e,function(e){var n=e.cells().slice(0,t).concat(e.cells().slice(r+1));return qn(n,e.section())});return v(n,function(e){return 0<e.cells().length})},_u=function(t,r,o,e){var n=D(t,function(e,n){return Yo(t,n,r,o)||Ko(e,r,o)?[]:[hu.getCell(e,r)]});return Go(t,n,o,e)},Lu=function(t,r,o,e){var i=t[r],n=D(i.cells(),function(e,n){return Yo(t,r,n,o)||Ko(i,n,o)?[]:[e]});return Go(t,n,o,e)},ju=Sr([{none:[]},{only:["index"]},{left:["index","next"]},{middle:["prev","index","next"]},{right:["prev","index"]}]),zu=Ji({},ju),Hu=function(e,n,i,u){function c(e){return p(e,S(0))}function r(e,n){if(0<=i){var t=Math.max(u.minCellWidth(),a[n]-i);return c(a.slice(0,e)).concat([i,t-a[n]]).concat(c(a.slice(n+1)))}var r=Math.max(u.minCellWidth(),a[e]+i),o=a[e]-r;return c(a.slice(0,e)).concat([r-a[e],o]).concat(c(a.slice(n+1)))}var a=e.slice(0),t=function(e,n){return 0===e.length?zu.none():1===e.length?zu.only(0):0===n?zu.left(0,1):n===e.length-1?zu.right(n-1,n):0<n&&n<e.length-1?zu.middle(n-1,n,n+1):zu.none()}(e,n),o=S(c(a)),l=r;return t.fold(o,function(e){return u.singleColumnWidth(a[e],i)},l,function(e,n,t){return r(n,t)},function(e,n){if(0<=i)return c(a.slice(0,n)).concat([i]);var t=Math.max(u.minCellWidth(),a[n]+i);return c(a.slice(0,n)).concat([t-a[n]])})},Fu={hasColspan:function(e){return Xo(e,"colspan")},hasRowspan:function(e){return Xo(e,"rowspan")},minWidth:S(10),minHeight:S(10),getInt:function(e,n){return parseInt(ie(e,n),10)}},Uu={getRawWidths:function(e,n,t){return Zo(e,n,Jo,ei,t)},getPixelWidths:function(e,n,t){return Zo(e,n,uo.getPixelWidth,function(e){return e.getOrThunk(t.minCellWidth)},t)},getPercentageWidths:function(e,n,t){return Zo(e,n,uo.getPercentageWidth,function(e){return e.fold(function(){return t.minCellWidth()},function(e){return e/t.pixelWidth()*100})},t)},getPixelHeights:function(e,n){return ni(e,n,uo.getHeight,function(e){return e.getOrThunk(Fu.minHeight)})},getRawHeights:function(e,n){return ni(e,n,Qo,ei)}},qu=function(e,t){var n=dt.justCells(e);return p(n,function(e){var n=ti(e.column(),e.column()+e.colspan(),t);return{element:e.element,width:S(n),colspan:e.colspan}})},Vu=function(e,t){var n=dt.justCells(e);return p(n,function(e){var n=ti(e.row(),e.row()+e.rowspan(),t);return{element:e.element,height:S(n),rowspan:e.rowspan}})},Gu=function(e,t){return p(e.all(),function(e,n){return{element:e.element,height:S(t[n])}})},Yu=function(n){return uo.getRawWidth(n).fold(function(){var e=Br(n);return ri(e)},function(e){return oi(n,e)})},Ku=function(e,n,t,r){var o=Yu(e),i=o.getCellDelta(n),u=ui(e),c=o.getWidths(u,r,o),a=Hu(c,t,i,o),l=p(a,function(e,n){return e+c[n]}),f=qu(u,l);h(f,function(e){o.setElementWidth(e.element(),e.width())}),t===u.grid().columns()-1&&o.setTableWidth(e,l,i)},Xu=function(e,t,r,n){var o=ui(e),i=Uu.getPixelHeights(o,n),u=p(i,function(e,n){return r===n?Math.max(t+e,Fu.minHeight()):e}),c=Vu(o,u),a=Gu(o,u);h(a,function(e){uo.setHeight(e.element(),e.height())}),h(c,function(e){uo.setHeight(e.element(),e.height())});var l=function(e){return w(e,function(e,n){return e+n},0)}(u);uo.setHeight(e,l)},$u=function(e,n,t){var r=Yu(e),o=ii(n),i=r.getWidths(o,t,r),u=qu(o,i);h(u,function(e){r.setElementWidth(e.element(),e.width())}),0<u.length&&r.setTableWidth(e,i,r.getCellDelta(0))},Ju=function(r,o,i){if(0===o.length)throw new Error("You must specify at least one required field.");return _("required",o),L(o),function(n){var t=Ge(n);A(o,function(e){return m(t,e)})||M(o,t),r(o,t);var e=v(o,function(e){return!i.validate(n[e],e)});return 0<e.length&&function(e,n){throw new Error("All values need to be of type: "+n+". Keys ("+B(e).join(", ")+") were not.")}(e,i.label),n}},Qu=ai(["cell","row","replace","gap"]),Zu=function(n,t){void 0===t&&(t=li),Qu(n);function r(e){return function(e){return n.cell(e)}(t(e))}function o(e){var n=r(e);return i.get().isNone()&&i.set(We.some(n)),u=We.some({item:e,replacement:n}),n}var i=l(We.none()),u=We.none();return{getOrInit:function(n,t){return u.fold(function(){return o(n)},function(e){return t(n,e.item)?e.replacement:o(n)})},cursor:i.get}},ec=function(c,a){return function(r){var o=l(We.none());Qu(r);function i(e){var n={scope:c},t=r.replace(e,a,n);return u.push({item:e,sub:t}),o.get().isNone()&&o.set(We.some(t)),t}var u=[];return{replaceOrInit:function(n,t){return function(n,t){return R(u,function(e){return t(e.item,n)})}(n,t).fold(function(){return i(n)},function(e){return t(n,e.item)?e.sub:i(n)})},cursor:o.get}}},nc=function(t){Qu(t);var e=l(We.none());return{combine:function(n){return e.get().isNone()&&e.set(We.some(n)),function(){var e=t.cell({element:S(n),colspan:S(1),rowspan:S(1)});return ce(e,"width"),ce(n,"width"),e}},cursor:e.get}},tc=["body","p","div","article","aside","figcaption","figure","footer","header","nav","section","ol","ul","table","thead","tfoot","tbody","caption","tr","td","th","h1","h2","h3","h4","h5","h6","blockquote","pre","address"],rc=fi,oc=function(e,n){var t=e.property().name(n);return m(["ol","ul"],t)},ic=si,uc=$t(),cc=function(e){return rc(uc,e)},ac=function(e){return oc(uc,e)},lc=function(e){return ic(uc,e)},fc=function(e){function o(e){return"br"===j(e)}function t(r){return Ct(r).bind(function(n){var t=function(e){return Ce(e).map(function(e){return!!cc(e)||!!lc(e)&&"img"!==j(e)}).getOr(!1)}(n);return be(n).map(function(e){return!0===t||function(e){return"li"===j(e)||Xn(e,ac).isSome()}(e)||o(n)||cc(e)&&!he(r,e)?[]:[on.fromTag("br")]})}).getOr([])}var n,r=0===(n=D(e,function(e){var n=Se(e);return function(e){return A(e,function(e){return o(e)||tn(e)&&0===pt(e).trim().length})}(n)?[]:n.concat(t(e))})).length?[on.fromTag("br")]:n;Ne(e[0]),Ee(e[0],r)},sc=P("grid","cursor"),dc=function(e,n,t){return We.from(e[n]).bind(function(e){return We.from(e.cells()[t]).bind(function(e){return We.from(e.element())})})},mc=$u,gc={insertRowBefore:jo(function(e,n,t,r){var o=n.row(),i=n.row(),u=Iu(e,i,o,t,r.getOrInit);return gi(u,i,n.column())},zo,y,y,Zu),insertRowsBefore:jo(function(e,n,t,r){var o=n[0].row(),i=n[0].row(),u=pi(n),c=x(u,function(e,n){return Iu(e,i,o,t,r.getOrInit)},e);return gi(c,i,n[0].column())},Fo,y,y,Zu),insertRowAfter:jo(function(e,n,t,r){var o=n.row(),i=n.row()+n.rowspan(),u=Iu(e,i,o,t,r.getOrInit);return gi(u,i,n.column())},zo,y,y,Zu),insertRowsAfter:jo(function(e,n,t,r){var o=pi(n),i=o[o.length-1].row(),u=o[o.length-1].row()+o[o.length-1].rowspan(),c=x(o,function(e,n){return Iu(e,u,i,t,r.getOrInit)},e);return gi(c,u,n[0].column())},Fo,y,y,Zu),insertColumnBefore:jo(function(e,n,t,r){var o=n.column(),i=n.column(),u=ku(e,i,o,t,r.getOrInit);return gi(u,n.row(),i)},zo,mc,y,Zu),insertColumnsBefore:jo(function(e,n,t,r){var o=hi(n),i=o[0].column(),u=o[0].column(),c=x(o,function(e,n){return ku(e,u,i,t,r.getOrInit)},e);return gi(c,n[0].row(),u)},Fo,mc,y,Zu),insertColumnAfter:jo(function(e,n,t,r){var o=n.column(),i=n.column()+n.colspan(),u=ku(e,i,o,t,r.getOrInit);return gi(u,n.row(),i)},zo,mc,y,Zu),insertColumnsAfter:jo(function(e,n,t,r){var o=n[n.length-1].column(),i=n[n.length-1].column()+n[n.length-1].colspan(),u=hi(n),c=x(u,function(e,n){return ku(e,i,o,t,r.getOrInit)},e);return gi(c,n[0].row(),i)},Fo,mc,y,Zu),splitCellIntoColumns:jo(function(e,n,t,r){var o=Pu(e,n.row(),n.column(),t,r.getOrInit);return gi(o,n.row(),n.column())},zo,mc,y,Zu),splitCellIntoRows:jo(function(e,n,t,r){var o=Bu(e,n.row(),n.column(),t,r.getOrInit);return gi(o,n.row(),n.column())},zo,y,y,Zu),eraseColumns:jo(function(e,n,t,r){var o=hi(n),i=Wu(e,o[0].column(),o[o.length-1].column()),u=mi(i,n[0].row(),n[0].column());return sc(i,u)},Fo,mc,di,Zu),eraseRows:jo(function(e,n,t,r){var o=pi(n),i=Mu(e,o[0].row(),o[o.length-1].row()),u=mi(i,n[0].row(),n[0].column());return sc(i,u)},Fo,y,di,Zu),makeColumnHeader:jo(function(e,n,t,r){var o=_u(e,n.column(),t,r.replaceOrInit);return gi(o,n.row(),n.column())},zo,y,y,ec("row","th")),unmakeColumnHeader:jo(function(e,n,t,r){var o=_u(e,n.column(),t,r.replaceOrInit);return gi(o,n.row(),n.column())},zo,y,y,ec(null,"td")),makeRowHeader:jo(function(e,n,t,r){var o=Lu(e,n.row(),t,r.replaceOrInit);return gi(o,n.row(),n.column())},zo,y,y,ec("col","th")),unmakeRowHeader:jo(function(e,n,t,r){var o=Lu(e,n.row(),t,r.replaceOrInit);return gi(o,n.row(),n.column())},zo,y,y,ec(null,"td")),mergeCells:jo(function(e,n,t,r){var o=n.cells();fc(o);var i=Ou(e,n.bounds(),t,S(o[0]));return sc(i,We.from(o[0]))},function(e,n){return n.mergable()},y,y,nc),unmergeCells:jo(function(e,n,t,r){var o=w(n,function(e,n){return Du(e,n,t,r.combine(n))},e);return sc(o,We.from(n[0]))},function(e,n){return n.unmergable()},mc,y,nc),pasteCells:jo(function(e,t,n,r){var o,i,u,c,a=(o=t.clipboard(),i=t.generators(),u=lt(o),c=dt.generate(u),wu(c,i,!0)),l=_n(t.row(),t.column());return Eu(l,e,a,t.generators(),n).fold(function(){return sc(e,We.some(t.element()))},function(e){var n=mi(e,t.row(),t.column());return sc(e,n)})},function(n,t){return at.cell(t.element()).bind(function(e){return Lo(n,e).map(function(e){return Ji(Ji({},e),{generators:t.generators,clipboard:t.clipboard})})})},mc,y,Zu),pasteRowsBefore:jo(function(e,n,t,r){var o=e[n.cells[0].row()],i=n.cells[0].row(),u=vi(n.clipboard(),n.generators(),o),c=Nu(i,e,u,n.generators(),t),a=mi(c,n.cells[0].row(),n.cells[0].column());return sc(c,a)},Ho,y,y,Zu),pasteRowsAfter:jo(function(e,n,t,r){var o=e[n.cells[0].row()],i=n.cells[n.cells.length-1].row()+n.cells[n.cells.length-1].rowspan(),u=vi(n.clipboard(),n.generators(),o),c=Nu(i,e,u,n.generators(),t),a=mi(c,n.cells[0].row(),n.cells[0].column());return sc(c,a)},Ho,y,y,Zu)},pc=function(e){return on.fromDom(e.getBody())},hc=function(n){return function(e){return he(e,pc(n))}},vc={isRtl:S(!1)},bc={isRtl:S(!0)},wc={directionAt:function(e){return"rtl"===function(e){return"rtl"===ie(e,"direction")?"rtl":"ltr"}(e)?bc:vc}},yc={"border-collapse":"collapse",width:"100%"},Cc={border:"1"},Sc=function(e){return e.getParam("table_tab_navigation",!0,"boolean")},xc=function(f,e){function t(e){return"table"===j(pc(e))}function n(u,c,a,l){return function(e,n){Ci(e);var t=l(),r=on.fromDom(f.getDoc()),o=ho(wc.directionAt),i=Mt(a,r,s);return c(e)?u(t,e,n,i,o).bind(function(e){return h(e.newRows(),function(e){Ni(f,e.dom())}),h(e.newCells(),function(e){Ii(f,e.dom())}),e.cursor().map(function(e){var n=f.dom.createRng();return n.setStart(e.dom(),0),n.setEnd(e.dom(),0),n})}):We.none()}}var s=function(e){var n=e.getParam("table_clone_elements");return Le(n)?We.some(n.split(/[ ,]/)):Array.isArray(n)?We.some(n):We.none()}(f);return{deleteRow:n(gc.eraseRows,function(e){var n=$i(e);return!1===t(f)||1<n.rows()},y,e),deleteColumn:n(gc.eraseColumns,function(e){var n=$i(e);return!1===t(f)||1<n.columns()},y,e),insertRowsBefore:n(gc.insertRowsBefore,i,y,e),insertRowsAfter:n(gc.insertRowsAfter,i,y,e),insertColumnsBefore:n(gc.insertColumnsBefore,i,co,e),insertColumnsAfter:n(gc.insertColumnsAfter,i,co,e),mergeCells:n(gc.mergeCells,i,y,e),unmergeCells:n(gc.unmergeCells,i,y,e),pasteRowsBefore:n(gc.pasteRowsBefore,i,y,e),pasteRowsAfter:n(gc.pasteRowsAfter,i,y,e),pasteCells:n(gc.pasteCells,i,y,e)}},Rc=function(e,n,r){var t=lt(e),o=dt.generate(t);return Fo(o,n).map(function(e){var n=wu(o,r,!1).slice(e[0].row(),e[e.length-1].row()+e[e.length-1].rowspan()),t=_o(n,r);return Zi(t)})},Tc=tinymce.util.Tools.resolve("tinymce.util.Tools"),Oc=function(e,n,t){t&&e.formatter.apply("align"+t,{},n)},Dc=function(e,n,t){t&&e.formatter.apply("valign"+t,{},n)},Ac=function(n,t){Tc.each("left center right".split(" "),function(e){n.formatter.remove("align"+e,{},t)})},Ec=function(n,t){Tc.each("top middle bottom".split(" "),function(e){n.formatter.remove("valign"+e,{},t)})},Nc=function(o,e,i){var n;return n=function(e,n){for(var t=0;t<n.length;t++){var r=o.getStyle(n[t],i);if(void 0===e&&(e=r),e!==r)return""}return e}(n,o.select("td,th",e))},Ic=b(Mi,"left center right"),kc=b(Mi,"top middle bottom"),Pc=function(e,r,n){var o=function(e,t){return t=t||[],Tc.each(e,function(e){var n={text:e.text||e.title};e.menu?n.menu=o(e.menu):(n.value=e.value,r&&r(n)),t.push(n)}),t};return o(e,n||[])},Bc=function(e){var o=e[0],n=e.slice(1),t=Ge(o);return h(n,function(e){h(t,function(r){N(e,function(e,n){var t=o[r];""!==t&&r===n&&t!==e&&(o[r]="")})})}),o},Mc=function(){return{title:"Advanced",name:"advanced",items:[{name:"borderstyle",type:"selectbox",label:"Border style",items:[{text:"Select...",value:""},{text:"Solid",value:"solid"},{text:"Dotted",value:"dotted"},{text:"Dashed",value:"dashed"},{text:"Double",value:"double"},{text:"Groove",value:"groove"},{text:"Ridge",value:"ridge"},{text:"Inset",value:"inset"},{text:"Outset",value:"outset"},{text:"None",value:"none"},{text:"Hidden",value:"hidden"}]},{name:"bordercolor",type:"colorinput",label:"Border color"},{name:"backgroundcolor",type:"colorinput",label:"Background color"}]}},Wc=function(e,n,t){var r,o,i,u=e.dom;return Ji(Ji({width:u.getStyle(n,"width")||u.getAttrib(n,"width"),height:u.getStyle(n,"height")||u.getAttrib(n,"height"),cellspacing:u.getStyle(n,"border-spacing")||u.getAttrib(n,"cellspacing"),cellpadding:u.getAttrib(n,"cellpadding")||Nc(e.dom,n,"padding"),border:(r=u,o=n,i=ue(on.fromDom(o),"border-width"),Di(e)&&i.isSome()?i.getOr(""):r.getAttrib(o,"border")||Nc(e.dom,o,"border-width")||Nc(e.dom,o,"border")),caption:!!u.select("caption",n)[0],"class":u.getAttrib(n,"class","")},Ic("align","align",e,n)),t?Bi(u,n):{})},_c=function(e,n,t){var r=e.dom;return Ji(Ji({height:r.getStyle(n,"height")||r.getAttrib(n,"height"),scope:r.getAttrib(n,"scope"),"class":r.getAttrib(n,"class",""),align:"",type:n.parentNode.nodeName.toLowerCase()},Ic("align","align",e,n)),t?Bi(r,n):{})},Lc=function(e,n,t){var r=e.dom;return Ji(Ji(Ji({width:r.getStyle(n,"width")||r.getAttrib(n,"width"),height:r.getStyle(n,"height")||r.getAttrib(n,"height"),scope:r.getAttrib(n,"scope"),celltype:n.nodeName.toLowerCase(),"class":r.getAttrib(n,"class","")},Ic("align","halign",e,n)),kc("valign","valign",e,n)),t?Bi(r,n):{})},jc=function(e,n){var t,r,o,i,u=xi(e),c=Si(e),a=e.dom,l=n?(t=a,r=k(u,"border-style").getOr(""),o=k(u,"border-color").getOr(""),i=k(u,"background-color").getOr(""),{borderstyle:r,bordercolor:f(o),backgroundcolor:f(i)}):{};function f(e){return Q(e,"rgb")?t.toHex(e):e}var s,d,m;return Ji(Ji(Ji(Ji(Ji(Ji({},{height:"",width:"100%",cellspacing:"",cellpadding:"",caption:!1,"class":"",align:"",border:""}),u),c),l),(m=u["border-width"],Di(e)&&m?{border:m}:k(c,"border").fold(function(){return{}},function(e){return{border:e}}))),(s=k(u,"border-spacing").or(k(c,"cellspacing")).fold(function(){return{}},function(e){return{cellspacing:e}}),d=k(u,"border-padding").or(k(c,"cellpadding")).fold(function(){return{}},function(e){return{cellpadding:e}}),Ji(Ji({},s),d)))},zc=[{name:"width",type:"input",label:"Width"},{name:"height",type:"input",label:"Height"},{name:"celltype",type:"selectbox",label:"Cell type",items:[{text:"Cell",value:"td"},{text:"Header cell",value:"th"}]},{name:"scope",type:"selectbox",label:"Scope",items:[{text:"None",value:""},{text:"Row",value:"row"},{text:"Column",value:"col"},{text:"Row group",value:"rowgroup"},{text:"Column group",value:"colgroup"}]},{name:"halign",type:"selectbox",label:"H Align",items:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},{name:"valign",type:"selectbox",label:"V Align",items:[{text:"None",value:""},{text:"Top",value:"top"},{text:"Middle",value:"middle"},{text:"Bottom",value:"bottom"}]}],Hc=function(e){return function(n){var e=function(e){return e.getParam("table_cell_class_list",[],"array")}(n),t=Pc(e,function(e){e.value&&(e.textStyle=function(){return n.formatter.getCssText({block:"tr",classes:[e.value]})})});return 0<e.length?We.some({name:"class",type:"selectbox",label:"Class",items:t}):We.none()}(e).fold(function(){return zc},function(e){return zc.concat(e)})},Fc={normal:function(t,r){return{setAttrib:function(e,n){t.setAttrib(r,e,n)},setStyle:function(e,n){t.setStyle(r,e,n)}}},ifTruthy:function(t,r){return{setAttrib:function(e,n){n&&t.setAttrib(r,e,n)},setStyle:function(e,n){n&&t.setStyle(r,e,n)}}}},Uc=function(n){var e,t=[];if(t=n.dom.select("td[data-mce-selected],th[data-mce-selected]"),e=n.dom.getParent(n.selection.getStart(),"td,th"),!t.length&&e&&t.push(e),e=e||t[0]){var r=Tc.map(t,function(e){return Lc(n,e,Ri(n))}),o=Bc(r),i={type:"tabpanel",tabs:[{title:"General",name:"general",items:Hc(n)},Mc()]},u={type:"panel",items:[{type:"grid",columns:2,items:Hc(n)}]};n.windowManager.open({title:"Cell Properties",size:"normal",body:Ri(n)?i:u,buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:o,onSubmit:b(zi,n,t)})}},qc=[{type:"selectbox",name:"type",label:"Row type",items:[{text:"Header",value:"thead"},{text:"Body",value:"tbody"},{text:"Footer",value:"tfoot"}]},{type:"selectbox",name:"align",label:"Alignment",items:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},{label:"Height",name:"height",type:"input"}],Vc=function(e){return function(n){var e=function(e){return e.getParam("table_row_class_list",[],"array")}(n),t=Pc(e,function(e){e.value&&(e.textStyle=function(){return n.formatter.getCssText({block:"tr",classes:[e.value]})})});return 0<e.length?We.some({name:"class",type:"selectbox",label:"Class",items:t}):We.none()}(e).fold(function(){return qc},function(e){return qc.concat(e)})},Gc=function(n){var e,t,r=n.dom,o=[];if((e=r.getParent(n.selection.getStart(),"table"))&&(t=r.getParent(n.selection.getStart(),"td,th"),Tc.each(e.rows,function(n){Tc.each(n.cells,function(e){if((r.getAttrib(e,"data-mce-selected")||e===t)&&o.indexOf(n)<0)return o.push(n),!1})}),o[0])){var i=Tc.map(o,function(e){return _c(n,e,Ti(n))}),u=Bc(i),c={type:"tabpanel",tabs:[{title:"General",name:"general",items:Vc(n)},Mc()]},a={type:"panel",items:[{type:"grid",columns:2,items:Vc(n)}]};n.windowManager.open({title:"Row Properties",size:"normal",body:Ti(n)?c:a,buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:u,onSubmit:b(Hi,n,o,u)})}},Yc=Object.prototype.hasOwnProperty,Kc=(Xi=function(e,n){return n},function(){for(var e=new Array(arguments.length),n=0;n<e.length;n++)e[n]=arguments[n];if(0===e.length)throw new Error("Can't merge zero objects");for(var t={},r=0;r<e.length;r++){var o=e[r];for(var i in o)Yc.call(o,i)&&(t[i]=Xi(t[i],o[i]))}return t}),Xc=tinymce.util.Tools.resolve("tinymce.Env"),$c={styles:{"border-collapse":"collapse",width:"100%"},attributes:{border:"1"},percentages:!0},Jc=function(n,e,t){var r=xi(n),o={styles:r,attributes:Si(n),percentages:function(e){return Le(e)&&-1!==e.indexOf("%")}(r.width)&&!Ei(n)},i=Fi(t,e,0,0,o);q(i,"data-mce-id","__mce");var u=function(e){var n=on.fromTag("div"),t=on.fromDom(e.dom().cloneNode(!0));return Bn(n,t),function(e){return e.dom().innerHTML}(n)}(i);return n.insertContent(u),Qn(pc(n),'table[data-mce-id="__mce"]').map(function(e){return Ei(n)&&re(e,"width",ie(e,"width")),K(e,"data-mce-id"),function(n,e){h(Be(e,"tr"),function(e){Ni(n,e.dom()),h(Be(e,"th,td"),function(e){Ii(n,e.dom())})})}(n,e),function(e,n){Qn(n,"td,th").each(b(Ui,e))}(n,e),e.dom()}).getOr(null)},Qc=function(n,e,t){var r=t?[{type:"input",name:"cols",label:"Cols"},{type:"input",name:"rows",label:"Rows"}]:[],o=function(e){return e.getParam("table_appearance_options",!0,"boolean")}(n)?[{type:"input",name:"cellspacing",label:"Cell spacing"},{type:"input",name:"cellpadding",label:"Cell padding"},{type:"input",name:"border",label:"Border width"},{type:"label",label:"Caption",items:[{type:"checkbox",name:"caption",label:"Show caption"}]}]:[],i=e?[{type:"selectbox",name:"class",label:"Class",items:Pc(Ai(n),function(e){e.value&&(e.textStyle=function(){return n.formatter.getCssText({block:"table",classes:[e.value]})})})}]:[];return r.concat([{type:"input",name:"width",label:"Width"},{type:"input",name:"height",label:"Height"}]).concat(o).concat([{type:"selectbox",name:"align",label:"Alignment",items:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]}]).concat(i)},Zc=function(e,n,t,r){if("TD"===n.tagName||"TH"===n.tagName)Le(t)?e.setStyle(n,t,r):e.setStyle(n,t);else if(n.children)for(var o=0;o<n.children.length;o++)Zc(e,n.children[o],t,r)},ea=function(e,n){var t,r=e.dom,o=jc(e,Oi(e));!1===n?(t=r.getParent(e.selection.getStart(),"table"))?o=Wc(e,t,Oi(e)):Oi(e)&&(o.borderstyle="",o.bordercolor="",o.backgroundcolor=""):(o.cols="1",o.rows="1",Oi(e)&&(o.borderstyle="",o.bordercolor="",o.backgroundcolor=""));var i=0<Ai(e).length;i&&o["class"]&&(o["class"]=o["class"].replace(/\s*mce\-item\-table\s*/g,""));var u={type:"grid",columns:2,items:Qc(e,i,n)},c=Oi(e)?{type:"tabpanel",tabs:[{title:"General",name:"general",items:[u]},Mc()]}:{type:"panel",items:[u]};e.windowManager.open({title:"Table Properties",size:"normal",body:c,onSubmit:b(qi,e,t),buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:o})},na=Vi("th,td"),ta=Vi("th,td,caption"),ra=Tc.each,oa={registerCommands:function(c,n,a,l,t){function f(e){return at.table(e,s)}function i(e){return{width:bi(e.dom()),height:bi(e.dom())}}function r(o){na(c).each(function(r){f(r).each(function(n){var e=Er.forMenu(l,n,r),t=i(n);o(n,e).each(function(e){!function(e,n,t){var r=i(t);n.width===r.width&&n.height===r.height||(ki(e,t.dom(),n.width,n.height),Pi(e,t.dom(),r.width,r.height))}(c,t,n),c.selection.setRng(e),c.focus(),a.clear(n),Ci(n)})})})}function o(e){return na(c).map(function(o){return f(o).bind(function(e){var n=on.fromDom(c.getDoc()),t=Er.forMenu(l,e,o),r=Mt(y,n,We.none());return Rc(e,t,r)})})}function u(u){t.get().each(function(e){var i=p(e,function(e){return Rt(e)});na(c).each(function(o){f(o).each(function(n){var e=on.fromDom(c.getDoc()),t=Wt(e),r=Er.pasteRows(l,n,o,i,t);u(n,r).each(function(e){c.selection.setRng(e),c.focus(),a.clear(n)})})})})}var s=hc(c);ra({mceTableSplitCells:function(){r(n.unmergeCells)},mceTableMergeCells:function(){r(n.mergeCells)},mceTableInsertRowBefore:function(){r(n.insertRowsBefore)},mceTableInsertRowAfter:function(){r(n.insertRowsAfter)},mceTableInsertColBefore:function(){r(n.insertColumnsBefore)},mceTableInsertColAfter:function(){r(n.insertColumnsAfter)},mceTableDeleteCol:function(){r(n.deleteColumn)},mceTableDeleteRow:function(){r(n.deleteRow)},mceTableCutRow:function(e){o().each(function(e){t.set(e),r(n.deleteRow)})},mceTableCopyRow:function(e){o().each(function(e){t.set(e)})},mceTablePasteRowBefore:function(e){u(n.pasteRowsBefore)},mceTablePasteRowAfter:function(e){u(n.pasteRowsAfter)},mceTableDelete:function(){ta(c).each(function(e){at.table(e,s).filter(d(s)).each(function(e){var n=on.fromText("");if(Te(e,n),Mn(e),c.dom.isEmpty(c.getBody()))c.setContent(""),c.selection.setCursorLocation();else{var t=c.dom.createRng();t.setStart(n.dom(),0),t.setEnd(n.dom(),0),c.selection.setRng(t),c.nodeChanged()}})})}},function(e,n){c.addCommand(n,e)}),ra({mceInsertTable:b(ea,c,!0),mceTableProps:b(ea,c,!1),mceTableRowProps:b(Gc,c),mceTableCellProps:b(Uc,c)},function(e,n){c.addCommand(n,function(){e()})})}},ia=function(e){var n=We.from(e.dom().documentElement).map(on.fromDom).getOr(e);return{parent:S(n),view:S(e),origin:S(lo(0,0))}},ua=function(e,n){return{parent:S(n),view:S(e),origin:S(lo(0,0))}},ca=function(e){var r=P.apply(null,e),o=[];return{bind:function(e){if(e===undefined)throw new Error("Event bind error: undefined handler");o.push(e)},unbind:function(n){o=v(o,function(e){return e!==n})},trigger:function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var t=r.apply(null,e);h(o,function(e){e(t)})}}},aa={create:function(e){return{registry:I(e,function(e){return{bind:e.bind,unbind:e.unbind}}),trigger:I(e,function(e){return e.trigger})}}},la=function(e,n,t,r){e.dom().removeEventListener(n,t,r)},fa=S(!0),sa={resolve:Eo("ephox-dragster").resolve},da=ai(["compare","extract","mutate","sink"]),ma=ai(["element","start","stop","destroy"]),ga=ai(["forceDrop","drop","move","delayDrop"]),pa=da({compare:function(e,n){return lo(n.left()-e.left(),n.top()-e.top())},extract:function(e){return We.some(lo(e.x(),e.y()))},sink:function(e,n){var t=function(e){var n=Kc({layerClass:sa.resolve("blocker")},e),t=on.fromTag("div");q(t,"role","presentation"),oe(t,{position:"fixed",left:"0px",top:"0px",width:"100%",height:"100%"}),Ro(t,sa.resolve("blocker")),Ro(t,n.layerClass);return{element:function(){return t},destroy:function(){Mn(t)}}}(n),r=Ki(t.element(),"mousedown",e.forceDrop),o=Ki(t.element(),"mouseup",e.drop),i=Ki(t.element(),"mousemove",e.move),u=Ki(t.element(),"mouseout",e.delayDrop);return ma({element:t.element,start:function(e){Bn(e,t.element())},stop:function(){Mn(t.element())},destroy:function(){t.destroy(),o.unbind(),i.unbind(),u.unbind(),r.unbind()}})},mutate:function(e,n){e.mutate(n.left(),n.top())}});function ha(){var r=We.none(),t=aa.create({move:ca(["info"])});return{onEvent:function(e,n){n.extract(e).each(function(e){(function(n,t){var e=r.map(function(e){return n.compare(e,t)});return r=We.some(t),e})(n,e).each(function(e){t.trigger.move(e)})})},reset:function(){r=We.none()},events:t.registry}}function va(){var e=function r(){return{onEvent:y,reset:y}}(),n=ha(),t=e;return{on:function(){t.reset(),t=n},off:function(){t.reset(),t=e},isOn:function(){return t===n},onEvent:function(e,n){t.onEvent(e,n)},events:n.events}}function ba(){var t=aa.create({drag:ca(["xDelta","yDelta","target"])}),r=We.none(),e=function(){var t=aa.create({drag:ca(["xDelta","yDelta"])});return{mutate:function(e,n){t.trigger.drag(e,n)},events:t.registry}}();return e.events.drag.bind(function(n){r.each(function(e){t.trigger.drag(n.xDelta(),n.yDelta(),e)})}),{assign:function(e){r=We.some(e)},get:function(){return r},mutate:e.mutate,events:t.registry}}function wa(e){return"true"===G(e,"contenteditable")}function ya(o,n,i){function e(e,n){return We.from(G(e,n))}var t=ba(),r=ml(t,{}),u=We.none();function c(e,n){return Fu.getInt(e,n)-parseInt(G(e,"data-initial-"+n),10)}function a(e,n){m.trigger.startAdjust(),t.assign(e),q(e,"data-initial-"+n,parseInt(ie(e,n),10)),Ro(e,gl),re(e,"opacity","0.2"),r.go(o.parent())}function l(e){return he(e,o.view())}function f(e){return Zn(e,"table",l).filter(function(e){return function(e,n){return Zn(e,"[contenteditable]",n)}(e,l).exists(wa)})}t.events.drag.bind(function(t){e(t.target(),"data-row").each(function(e){var n=Fu.getInt(t.target(),"top");re(t.target(),"top",n+t.yDelta()+"px")}),e(t.target(),"data-column").each(function(e){var n=Fu.getInt(t.target(),"left");re(t.target(),"left",n+t.xDelta()+"px")})}),r.events.stop.bind(function(){t.get().each(function(r){u.each(function(t){e(r,"data-row").each(function(e){var n=c(r,"top");K(r,"data-initial-top"),m.trigger.adjustHeight(t,n,parseInt(e,10))}),e(r,"data-column").each(function(e){var n=c(r,"left");K(r,"data-initial-left"),m.trigger.adjustWidth(t,n,parseInt(e,10))}),lu(o,t,i,n)})})});var s=Ki(o.parent(),"mousedown",function(e){mu(e.target())&&a(e.target(),"top"),gu(e.target())&&a(e.target(),"left")}),d=Ki(o.view(),"mouseover",function(e){f(e.target()).fold(function(){ne(e.target())&&du(o)},function(e){u=We.some(e),lu(o,e,i,n)})}),m=aa.create({adjustHeight:ca(["table","delta","row"]),adjustWidth:ca(["table","delta","column"]),startAdjust:ca([])});return{destroy:function(){s.unbind(),d.unbind(),r.destroy(),du(o)},refresh:function(e){lu(o,e,i,n)},on:r.on,off:r.off,hideBars:b(fu,o),showBars:b(su,o),events:m.registry}}function Ca(e,n){return bi(e.dom())/bi(n.dom())*100+"%"}function Sa(t,e){return at.table(t,e).bind(function(e){var n=at.cells(e);return T(n,function(e){return he(t,e)}).map(function(e){return{index:S(e),all:S(n)}})})}function xa(e,n,t){var r=e.document.createRange();return function(t,e){e.fold(function(e){t.setStartBefore(e.dom())},function(e,n){t.setStart(e.dom(),n)},function(e){t.setStartAfter(e.dom())})}(r,n),function(t,e){e.fold(function(e){t.setEndBefore(e.dom())},function(e,n){t.setEnd(e.dom(),n)},function(e){t.setEndAfter(e.dom())})}(r,t),r}function Ra(e,n,t,r,o){var i=e.document.createRange();return i.setStart(n.dom(),t),i.setEnd(r.dom(),o),i}function Ta(e){return{left:S(e.left),top:S(e.top),right:S(e.right),bottom:S(e.bottom),width:S(e.width),height:S(e.height)}}function Oa(e,n,t){return n(on.fromDom(t.startContainer),t.startOffset,on.fromDom(t.endContainer),t.endOffset)}function Da(e,n){return function(e,n){var t=n.ltr();return t.collapsed?n.rtl().filter(function(e){return!1===e.collapsed}).map(function(e){return El.rtl(on.fromDom(e.endContainer),e.endOffset,on.fromDom(e.startContainer),e.startOffset)}).getOrThunk(function(){return Oa(0,El.ltr,t)}):Oa(0,El.ltr,t)}(0,function(o,e){return e.match({domRange:function(e){return{ltr:S(e),rtl:We.none}},relative:function(e,n){return{ltr:ee(function(){return xa(o,e,n)}),rtl:ee(function(){return We.some(xa(o,n,e))})}},exact:function(e,n,t,r){return{ltr:ee(function(){return Ra(o,e,n,t,r)}),rtl:ee(function(){return We.some(Ra(o,t,r,e,n))})}}})}(e,n))}function Aa(e,n,t){return n>=e.left&&n<=e.right&&t>=e.top&&t<=e.bottom}function Ea(t,r,e,n,o){function i(e){var n=t.dom().createRange();return n.setStart(r.dom(),e),n.collapse(!0),n}var u=pt(r).length,c=function(e,n,t,r,o){if(0===o)return 0;if(n===r)return o-1;for(var i=r,u=1;u<o;u++){var c=e(u),a=Math.abs(n-c.left);if(t<=c.bottom){if(t<c.top||i<a)return u-1;i=a}}return 0}(function(e){return i(e).getBoundingClientRect()},e,n,o.right,u);return i(c)}function Na(e,n){return n-e.left<e.right-n}function Ia(e,n,t){var r=e.dom().createRange();return r.selectNode(n.dom()),r.collapse(t),r}function ka(n,e,t){var r=n.dom().createRange();r.selectNode(e.dom());var o=r.getBoundingClientRect(),i=Na(o,t);return(!0===i?yt:Ct)(e).map(function(e){return Ia(n,e,i)})}function Pa(e,n,t){var r=n.dom().getBoundingClientRect(),o=Na(r,t);return We.some(Ia(e,n,o))}function Ba(e,n,t,r){var o=e.dom().createRange();o.selectNode(n.dom());var i=o.getBoundingClientRect();return function(e,n,t,r){var o=e.dom().createRange();o.selectNode(n.dom());var i=o.getBoundingClientRect(),u=Math.max(i.left,Math.min(i.right,t)),c=Math.max(i.top,Math.min(i.bottom,r));return Il(e,n,u,c)}(e,n,Math.max(i.left,Math.min(i.right,t)),Math.max(i.top,Math.min(i.bottom,r)))}function Ma(e,n){var t=j(e);return"input"===t?Tl.after(e):m(["br","img"],t)?0===n?Tl.before(e):Tl.after(e):Tl.on(e,n)}function Wa(e,n){var t=e.fold(Tl.before,Ma,Tl.after),r=n.fold(Tl.before,Ma,Tl.after);return Dl.relative(t,r)}function _a(e,n,t,r){var o=Ma(e,n),i=Ma(t,r);return Dl.relative(o,i)}function La(e,n,t,r){var o=function(e,n,t,r){var o=ve(e).dom().createRange();return o.setStart(e.dom(),n),o.setEnd(t.dom(),r),o}(e,n,t,r),i=he(e,t)&&n===r;return o.collapsed&&!i}function ja(e,n){We.from(e.getSelection()).each(function(e){e.removeAllRanges(),e.addRange(n)})}function za(e,n,t,r,o){var i=Ra(e,n,t,r,o);ja(e,i)}function Ha(u,e){return Da(u,e).match({ltr:function(e,n,t,r){za(u,e,n,t,r)},rtl:function(e,n,t,r){var o=u.getSelection();if(o.setBaseAndExtent)o.setBaseAndExtent(e.dom(),n,t.dom(),r);else if(o.extend)try{!function(e,n,t,r,o,i){n.collapse(t.dom(),r),n.extend(o.dom(),i)}(0,o,e,n,t,r)}catch(i){za(u,t,r,e,n)}else za(u,t,r,e,n)}})}function Fa(e){function n(e,n,t,r){return Ra(o,e,n,t,r)}var o=Dl.getWin(e).dom(),t=function(e){return e.match({domRange:function(e){var n=on.fromDom(e.startContainer),t=on.fromDom(e.endContainer);return _a(n,e.startOffset,t,e.endOffset)},relative:Wa,exact:_a})}(e);return Da(o,t).match({ltr:n,rtl:n})}function Ua(e){var n=on.fromDom(e.anchorNode),t=on.fromDom(e.focusNode);return La(n,e.anchorOffset,t,e.focusOffset)?We.some(xl.create(n,e.anchorOffset,t,e.focusOffset)):function(e){if(0<e.rangeCount){var n=e.getRangeAt(0),t=e.getRangeAt(e.rangeCount-1);return We.some(xl.create(on.fromDom(n.startContainer),n.startOffset,on.fromDom(t.endContainer),t.endOffset))}return We.none()}(e)}function qa(e,n){var t=function(e,n){var t=e.document.createRange();return Al(t,n),t}(e,n);ja(e,t)}function Va(e){return function(e){return We.from(e.getSelection()).filter(function(e){return 0<e.rangeCount}).bind(Ua)}(e).map(function(e){return Dl.exact(e.start(),e.soffset(),e.finish(),e.foffset())})}function Ga(e,n){return function(e){var n=e.getClientRects(),t=0<n.length?n[0]:e.getBoundingClientRect();return 0<t.width||0<t.height?We.some(t).map(Ta):We.none()}(Nl(e,n))}function Ya(e,n,t){return function(e,n,t){var r=on.fromDom(e.document);return kl(r,n,t).map(function(e){return xl.create(on.fromDom(e.startContainer),e.startOffset,on.fromDom(e.endContainer),e.endOffset)})}(e,n,t)}function Ka(e,n,t,r){return Bl(e,n,Cl(t),r)}function Xa(e,n,t,r){return Bl(e,n,Sl(t),r)}function $a(e,n){var t=Dl.exact(n,0,n,0);return Fa(t)}function Ja(e,n){return function(e){return 0===e.length?We.none():We.some(e[e.length-1])}(Be(n,"tr")).bind(function(e){return Qn(e,"td,th").map(function(e){return $a(0,e)})})}function Qa(e,n,t,r){return void 0===r&&(r=Ul),e.property().parent(n).map(function(e){return Fl(e,r)})}function Za(n){return function(e){return 0===n.property().children(e).length}}function el(e,n){return function(e,n,t){return $l(e,n,Za(e),t)}(Ql,e,n)}function nl(e,n){return function(e,n,t){return Jl(e,n,Za(e),t)}(Ql,e,n)}function tl(e){return Zn(e,"tr")}function rl(e){return"br"===j(e)}function ol(n,e,t,r){return function(e,n){return xe(e,n).filter(rl).orThunk(function(){return xe(e,n-1).filter(rl)})}(e,t).bind(function(e){return r.traverse(e).fold(function(){return of(e,r.gather,n).map(r.relative)},function(e){return function(r){return be(r).bind(function(n){var t=Se(n);return rf(t,r).map(function(e){return tf(n,t,r,e)})})}(e).map(function(e){return Tl.on(e.parent(),e.index())})})})}function il(e){return lf.nu({left:e.left,top:e.top,right:e.right,bottom:e.bottom})}function ul(e,n){return We.some(e.getRect(n))}function cl(n,e,t){return function(e,n,t){return Kn(function(e,n){return n(e)},Xn,e,n,t)}(e,cc).fold(S(!1),function(e){return sf(n,e).exists(function(e){return function(e,n){return e.left()<n.left()||Math.abs(n.right()-e.left())<1||e.left()>n.right()}(t,e)})})}function al(n,t,e){var r=n.move(e,5),o=pf(t,n,e,r,100).getOr(r);return function(e,n,t){return e.point(n)>t.getInnerHeight()?We.some(e.point(n)-t.getInnerHeight()):e.point(n)<0?We.some(-e.point(n)):We.none()}(n,o,t).fold(function(){return t.situsFromPoint(o.left(),n.point(o))},function(e){return t.scrollBy(0,e),t.situsFromPoint(o.left(),n.point(o)-e)})}function ll(e,n){return function(e,n,t){return Xn(e,n,t).isSome()}(e,function(e){return be(e).exists(function(e){return he(e,n)})})}function fl(n,r,o,e,i){return Zn(e,"td,th",r).bind(function(t){return Zn(t,"table",r).bind(function(e){return ll(i,e)?Sf(n,r,o).bind(function(n){return Zn(n.finish(),"td,th",r).map(function(e){return{start:S(t),finish:S(e),range:S(n)}})}):We.none()})})}function sl(e,n){return Zn(e,"td,th",n)}var dl=function(n,t,e){function r(){l.stop(),u.isOn()&&(u.off(),i.trigger.stop())}var o=!1,i=aa.create({start:ca([]),stop:ca([])}),u=va(),c=function(t,r){var o=null;return{cancel:function(){null!==o&&(f.clearTimeout(o),o=null)},throttle:function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];null!==o&&f.clearTimeout(o),o=f.setTimeout(function(){t.apply(null,e),o=null},r)}}}(r,200);u.events.move.bind(function(e){t.mutate(n,e.info())});function a(t){return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];o&&t.apply(null,e)}}var l=t.sink(ga({forceDrop:r,drop:a(r),move:a(function(e){c.cancel(),u.onEvent(e,t)}),delayDrop:a(c.throttle)}),e);return{element:l.element,go:function(e){l.start(e),u.on(),i.trigger.start()},on:function(){o=!0},off:function(){o=!1},destroy:function(){l.destroy()},events:i.registry}},ml=function(e,n){void 0===n&&(n={});var t=n.mode!==undefined?n.mode:pa;return dl(e,t,n)},gl=ru.resolve("resizer-bar-dragging"),pl=function(e,t){var r=go.height,n=ya(e,t,r),o=aa.create({beforeResize:ca(["table"]),afterResize:ca(["table"]),startDrag:ca([])});return n.events.adjustHeight.bind(function(e){o.trigger.beforeResize(e.table());var n=r.delta(e.delta(),e.table());Xu(e.table(),n,e.row(),r),o.trigger.afterResize(e.table())}),n.events.startAdjust.bind(function(e){o.trigger.startDrag()}),n.events.adjustWidth.bind(function(e){o.trigger.beforeResize(e.table());var n=t.delta(e.delta(),e.table());Ku(e.table(),n,e.column(),t),o.trigger.afterResize(e.table())}),{on:n.on,off:n.off,hideBars:n.hideBars,showBars:n.showBars,destroy:n.destroy,events:o.registry}},hl=function(e,n){return e.inline?ua(pc(e),function(){var e=on.fromTag("div");return oe(e,{position:"static",height:"0",width:"0",padding:"0",margin:"0",border:"0"}),Bn(un(),e),e}()):ia(on.fromDom(e.getDoc()))},vl=function(e,n){e.inline&&Mn(n.parent())},bl=function(u){function c(e){return"TABLE"===e.nodeName}function r(e){var n=u.dom.getStyle(e,"width")||u.dom.getAttrib(e,"width");return We.from(n).filter(function(e){return 0<e.length})}function e(){return i}var a,l,o=We.none(),i=We.none(),f=We.none(),s=/(\d+(\.\d+)?)%/;return u.on("init",function(){var e=ho(wc.directionAt),n=hl(u);if(f=We.some(n),function(e){var n=e.getParam("object_resizing",!0);return Le(n)?"table"===n:n}(u)&&function(e){return e.getParam("table_resize_bars",!0,"boolean")}(u)){var t=pl(n,e);t.on(),t.events.startDrag.bind(function(e){o=We.some(u.selection.getRng())}),t.events.beforeResize.bind(function(e){var n=e.table().dom();ki(u,n,bi(n),wi(n))}),t.events.afterResize.bind(function(e){var n=e.table(),t=n.dom();Ci(n),o.each(function(e){u.selection.setRng(e),u.focus()}),Pi(u,t,bi(t),wi(t)),u.undoManager.add()}),i=We.some(t)}}),u.on("ObjectResizeStart",function(e){var n=e.target;if(c(n)){var t=r(n).map(function(e){return s.test(e)}).getOr(!1);t&&Ei(u)?function(e){re(on.fromDom(e),"width",bi(e).toString()+"px")}(n):!t&&function(e){return!0===e.getParam("table_responsive_width")}(u)&&function(e){var n=on.fromDom(e);be(n).map(function(e){return Ca(n,e)}).each(function(e){re(n,"width",e),h(Be(n,"tr"),function(n){h(Se(n),function(e){re(e,"width",Ca(e,n))})})})}(n),a=e.width,l=r(n).getOr("")}}),u.on("ObjectResized",function(e){var n=e.target;if(c(n)){var t=n;if(s.test(l)){var r=parseFloat(s.exec(l)[1]),o=e.width*r/a;u.dom.setStyle(t,"width",o+"%")}else{var i=[];Tc.each(t.rows,function(e){Tc.each(e.cells,function(e){var n=u.dom.getStyle(e,"width",!0);i.push({cell:e,width:n})})}),Tc.each(i,function(e){u.dom.setStyle(e.cell,"width",e.width),u.dom.setAttrib(e.cell,"width",null)})}}}),u.on("SwitchMode",function(){e().each(function(e){u.readonly?e.hideBars():e.showBars()})}),{lazyResize:e,lazyWire:function(){return f.getOr(ia(on.fromDom(u.getBody())))},destroy:function(){i.each(function(e){e.destroy()}),f.each(function(e){vl(u,e)})}}},wl=Sr([{none:["current"]},{first:["current"]},{middle:["current","target"]},{last:["current"]}]),yl=Ji(Ji({},wl),{none:function(e){return void 0===e&&(e=undefined),wl.none(e)}}),Cl=function(n,e){return Sa(n,e).fold(function(){return yl.none(n)},function(e){return e.index()+1<e.all().length?yl.middle(n,e.all()[e.index()+1]):yl.last(n)})},Sl=function(n,e){return Sa(n,e).fold(function(){return yl.none()},function(e){return 0<=e.index()-1?yl.middle(n,e.all()[e.index()-1]):yl.first(n)})},xl={create:P("start","soffset","finish","foffset")},Rl=Sr([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),Tl={before:Rl.before,on:Rl.on,after:Rl.after,cata:function(e,n,t,r){return e.fold(n,t,r)},getStart:function(e){return e.fold(o,o,o)}},Ol=Sr([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),Dl={domRange:Ol.domRange,relative:Ol.relative,exact:Ol.exact,exactFromRange:function(e){return Ol.exact(e.start(),e.soffset(),e.finish(),e.foffset())},getWin:function(e){return function(e){return on.fromDom(e.dom().ownerDocument.defaultView)}(function(e){return e.match({domRange:function(e){return on.fromDom(e.startContainer)},relative:function(e,n){return Tl.getStart(e)},exact:function(e,n,t,r){return e}})}(e))},range:xl.create},Al=function(e,n){e.selectNodeContents(n.dom())},El=Sr([{ltr:["start","soffset","finish","foffset"]},{rtl:["start","soffset","finish","foffset"]}]),Nl=function(i,e){return Da(i,e).match({ltr:function(e,n,t,r){var o=i.document.createRange();return o.setStart(e.dom(),n),o.setEnd(t.dom(),r),o},rtl:function(e,n,t,r){var o=i.document.createRange();return o.setStart(t.dom(),r),o.setEnd(e.dom(),n),o}})},Il=function(e,n,t,r){return tn(n)?function(n,t,r,o){var e=n.dom().createRange();e.selectNode(t.dom());var i=e.getClientRects();return bo(i,function(e){return Aa(e,r,o)?We.some(e):We.none()}).map(function(e){return Ea(n,t,r,o,e)})}(e,n,t,r):function(n,e,t,r){var o=n.dom().createRange(),i=Se(e);return bo(i,function(e){return o.selectNode(e.dom()),Aa(o.getBoundingClientRect(),t,r)?Il(n,e,t,r):We.none()})}(e,n,t,r)},kl=document.caretPositionFromPoint?function(t,e,n){return We.from(t.dom().caretPositionFromPoint(e,n)).bind(function(e){if(null===e.offsetNode)return We.none();var n=t.dom().createRange();return n.setStart(e.offsetNode,e.offset),n.collapse(),We.some(n)})}:document.caretRangeFromPoint?function(e,n,t){return We.from(e.dom().caretRangeFromPoint(n,t))}:function(t,r,o){return on.fromPoint(t,r,o).bind(function(e){function n(){return function(e,n,t){return(0===Se(n).length?Pa:ka)(e,n,t)}(t,e,r)}return 0===Se(e).length?n():Ba(t,e,r,o).orThunk(n)})},Pl=tinymce.util.Tools.resolve("tinymce.util.VK"),Bl=function(r,e,n,o,t){return n.fold(We.none,We.none,function(e,n){return yt(n).map(function(e){return $a(0,e)})},function(t){return at.table(t,e).bind(function(e){var n=Er.noMenu(t);return r.undoManager.transact(function(){o.insertRowsAfter(e,n)}),Ja(0,e)})})},Ml=["table","li","dl"],Wl={handle:function(n,t,r,o){if(n.keyCode===Pl.TAB){var i=pc(t),u=function(e){var n=j(e);return he(e,i)||m(Ml,n)},e=t.selection.getRng();if(e.collapsed){var c=on.fromDom(e.startContainer);at.cell(c,u).each(function(e){n.preventDefault(),(n.shiftKey?Xa:Ka)(t,u,e,r,o).each(function(e){t.selection.setRng(e)})})}}}},_l={create:P("selection","kill")},Ll=function(e,n,t,r){return{start:S(Tl.on(e,n)),finish:S(Tl.on(t,r))}},jl={convertToRange:function(e,n){var t=Nl(e,n);return xl.create(on.fromDom(t.startContainer),t.startOffset,on.fromDom(t.endContainer),t.endOffset)},makeSitus:Ll},zl=function(t,e,r,n,o){return he(r,n)?We.none():dr(r,n,e).bind(function(e){var n=e.boxes().getOr([]);return 0<n.length?(o(t,n,e.start(),e.finish()),We.some(_l.create(We.some(jl.makeSitus(r,0,r,bt(r))),!0))):We.none()})},Hl={sync:function(t,r,e,n,o,i,u){return he(e,o)&&n===i?We.none():Zn(e,"td,th",r).bind(function(n){return Zn(o,"td,th",r).bind(function(e){return zl(t,r,n,e,u)})})},detect:zl,update:function(e,n,t,r,o){return gr(r,e,n,o.firstSelectedSelector(),o.lastSelectedSelector()).map(function(e){return o.clear(t),o.selectRange(t,e.boxes(),e.start(),e.finish()),e.boxes()})}},Fl=P("item","mode"),Ul=function(e,n,t,r){return void 0===r&&(r=ql),t.sibling(e,n).map(function(e){return Fl(e,r)})},ql=function(e,n,t,r){void 0===r&&(r=ql);var o=e.property().children(n);return t.first(o).map(function(e){return Fl(e,r)})},Vl=[{current:Qa,next:Ul,fallback:We.none()},{current:Ul,next:ql,fallback:We.some(Qa)},{current:ql,next:ql,fallback:We.some(Ul)}],Gl=function(n,t,r,o,e){return void 0===e&&(e=Vl),R(e,function(e){return e.current===r}).bind(function(e){return e.current(n,t,o,e.next).orThunk(function(){return e.fallback.bind(function(e){return Gl(n,t,e,o)})})})},Yl=function(){return{sibling:function(e,n){return e.query().prevSibling(n)},first:function(e){return 0<e.length?We.some(e[e.length-1]):We.none()}}},Kl=function(){return{sibling:function(e,n){return e.query().nextSibling(n)},first:function(e){return 0<e.length?We.some(e[0]):We.none()}}},Xl=function(n,e,t,r,o,i){return Gl(n,e,r,o).bind(function(e){return i(e.item())?We.none():t(e.item())?We.some(e.item()):Xl(n,e.item(),t,e.mode(),o,i)})},$l=function(e,n,t,r){return Xl(e,n,t,Ul,Yl(),r)},Jl=function(e,n,t,r){return Xl(e,n,t,Ul,Kl(),r)},Ql=$t(),Zl=P("element","offset"),ef=(P("element","deltaOffset"),P("element","start","finish"),P("begin","end"),P("element","text"),Sr([{none:["message"]},{success:[]},{failedUp:["cell"]},{failedDown:["cell"]}])),nf=Ji(Ji({},ef),{verify:function(t,n,e,r,o,i,u){return Zn(r,"td,th",u).bind(function(e){return Zn(n,"td,th",u).map(function(n){return he(e,n)?he(r,e)&&bt(e)===o?i(n):ef.none("in same cell"):fr.sharedOne(tl,[e,n]).fold(function(){return function(e,n,t){var r=e.getRect(n),o=e.getRect(t);return o.right>r.left&&o.left<r.right}(t,n,e)?ef.success():i(n)},function(e){return i(n)})})}).getOr(ef.none("default"))},cata:function(e,n,t,r,o){return e.fold(n,t,r,o)}}),tf=(P("ancestor","descendants","element","index"),P("parent","children","element","index")),rf=function(e,n){return T(e,b(he,n))},of=function(e,n,t){return n(e,t).bind(function(e){return tn(e)&&0===pt(e).trim().length?of(e,n,t):We.some(e)})},uf=function(e,n,t,r){return(rl(n)?function(e,n,t){return t.traverse(n).orThunk(function(){return of(n,t.gather,e)}).map(t.relative)}(e,n,r):ol(e,n,t,r)).map(function(e){return{start:S(e),finish:S(e)}})},cf=function(e){return nf.cata(e,function(e){return We.none()},function(){return We.none()},function(e){return We.some(Zl(e,0))},function(e){return We.some(Zl(e,bt(e)))})},af=$e(["left","top","right","bottom"],[]),lf={nu:af,moveUp:function(e,n){return af({left:e.left(),top:e.top()-n,right:e.right(),bottom:e.bottom()-n})},moveDown:function(e,n){return af({left:e.left(),top:e.top()+n,right:e.right(),bottom:e.bottom()+n})},moveBottomTo:function(e,n){var t=e.bottom()-e.top();return af({left:e.left(),top:n-t,right:e.right(),bottom:n})},moveTopTo:function(e,n){var t=e.bottom()-e.top();return af({left:e.left(),top:n,right:e.right(),bottom:n+t})},getTop:function(e){return e.top()},getBottom:function(e){return e.bottom()},translate:function(e,n,t){return af({left:e.left()+n,top:e.top()+t,right:e.right()+n,bottom:e.bottom()+t})},toString:function(e){return"("+e.left()+", "+e.top()+") -> ("+e.right()+", "+e.bottom()+")"}},ff=function(e,n,t){return nn(n)?ul(e,n).map(il):tn(n)?function(e,n,t){return 0<=t&&t<bt(n)?e.getRangedRect(n,t,n,t+1):0<t?e.getRangedRect(n,t-1,n,t):We.none()}(e,n,t).map(il):We.none()},sf=function(e,n){return nn(n)?ul(e,n).map(il):tn(n)?e.getRangedRect(n,0,n,bt(n)).map(il):We.none()},df=Sr([{none:[]},{retry:["caret"]}]),mf={point:lf.getTop,adjuster:function(e,n,t,r,o){var i=lf.moveUp(o,5);return Math.abs(t.top()-r.top())<1?df.retry(i):t.bottom()<o.top()?df.retry(i):t.bottom()===o.top()?df.retry(lf.moveUp(o,1)):cl(e,n,o)?df.retry(lf.translate(i,5,0)):df.none()},move:lf.moveUp,gather:el},gf={point:lf.getBottom,adjuster:function(e,n,t,r,o){var i=lf.moveDown(o,5);return Math.abs(t.bottom()-r.bottom())<1?df.retry(i):t.top()>o.bottom()?df.retry(i):t.top()===o.bottom()?df.retry(lf.moveDown(o,1)):cl(e,n,o)?df.retry(lf.translate(i,5,0)):df.none()},move:lf.moveDown,gather:nl},pf=function(t,r,o,i,u){return 0===u?We.some(i):function(e,n,t){return e.elementFromPoint(n,t).filter(function(e){return"table"===j(e)}).isSome()}(t,i.left(),r.point(i))?function(e,n,t,r,o){return pf(e,n,t,n.move(r,5),o)}(t,r,o,i,u-1):t.situsFromPoint(i.left(),r.point(i)).bind(function(e){return e.start().fold(We.none,function(n){return sf(t,n).bind(function(e){return r.adjuster(t,n,e,o,i).fold(We.none,function(e){return pf(t,r,o,e,u-1)})}).orThunk(function(){return We.some(i)})},We.none)})},hf={tryUp:b(al,mf),tryDown:b(al,gf),ieTryUp:function(e,n){return e.situsFromPoint(n.left(),n.top()-5)},ieTryDown:function(e,n){return e.situsFromPoint(n.left(),n.bottom()+5)},getJumpSize:S(5)},vf=En.detect(),bf=function(r,o,i,u,c,a){return 0===a?We.none():Cf(r,o,i,u,c).bind(function(e){var n=r.fromSitus(e),t=nf.verify(r,i,u,n.finish(),n.foffset(),c.failure,o);return nf.cata(t,function(){return We.none()},function(){return We.some(e)},function(e){return he(i,e)&&0===u?wf(r,i,u,lf.moveUp,c):bf(r,o,e,0,c,a-1)},function(e){return he(i,e)&&u===bt(e)?wf(r,i,u,lf.moveDown,c):bf(r,o,e,bt(e),c,a-1)})})},wf=function(n,e,t,r,o){return ff(n,e,t).bind(function(e){return yf(n,o,r(e,hf.getJumpSize()))})},yf=function(e,n,t){return vf.browser.isChrome()||vf.browser.isSafari()||vf.browser.isFirefox()||vf.browser.isEdge()?n.otherRetry(e,t):vf.browser.isIE()?n.ieRetry(e,t):We.none()},Cf=function(n,e,t,r,o){return ff(n,t,r).bind(function(e){return yf(n,o,e)})},Sf=function(n,t,r){return function(o,i,u){return o.getSelection().bind(function(r){return uf(i,r.finish(),r.foffset(),u).fold(function(){return We.some(Zl(r.finish(),r.foffset()))},function(e){var n=o.fromSitus(e),t=nf.verify(o,r.finish(),r.foffset(),n.finish(),n.foffset(),u.failure,i);return cf(t)})})}(n,t,r).bind(function(e){return bf(n,t,e.element(),e.offset(),r,20).map(n.fromSitus)})},xf=En.detect(),Rf=function(e,n,t,r,o,i){return xf.browser.isIE()?We.none():i(r,n).orThunk(function(){return fl(e,n,t,r,o).map(function(e){var n=e.range();return _l.create(We.some(jl.makeSitus(n.start(),n.soffset(),n.finish(),n.foffset())),!0)})})},Tf=function(e,n,t,r,o,i,u){return fl(e,t,r,o,i).bind(function(e){return Hl.detect(n,t,e.start(),e.finish(),u)})},Of=function(e,r){return Zn(e,"tr",r).bind(function(t){return Zn(t,"table",r).bind(function(e){var n=Be(e,"tr");return he(t,n[0])?function(e,n,t){return $l(Ql,e,n,t)}(e,function(e){return Ct(e).isSome()},r).map(function(e){var n=bt(e);return _l.create(We.some(jl.makeSitus(e,n,e,n)),!0)}):We.none()})})},Df=function(e,r){return Zn(e,"tr",r).bind(function(t){return Zn(t,"table",r).bind(function(e){var n=Be(e,"tr");return he(t,n[n.length-1])?function(e,n,t){return Jl(Ql,e,n,t)}(e,function(e){return yt(e).isSome()},r).map(function(e){return _l.create(We.some(jl.makeSitus(e,0,e,0)),!0)}):We.none()})})};function Af(n){return function(e){return e===n}}function Ef(i){return{elementFromPoint:function(e,n){return on.fromPoint(on.fromDom(i.document),e,n)},getRect:function(e){return e.dom().getBoundingClientRect()},getRangedRect:function(e,n,t,r){var o=Dl.exact(e,n,t,r);return Ga(i,o).map(Mf)},getSelection:function(){return Va(i).map(function(e){return jl.convertToRange(i,e)})},fromSitus:function(e){var n=Dl.relative(e.start(),e.finish());return jl.convertToRange(i,n)},situsFromPoint:function(e,n){return Ya(i,e,n).map(function(e){return Ll(e.start(),e.soffset(),e.finish(),e.foffset())})},clearSelection:function(){!function(e){e.getSelection().removeAllRanges()}(i)},setSelection:function(e){!function(e,n,t,r,o){var i=_a(n,t,r,o);Ha(e,i)}(i,e.start(),e.soffset(),e.finish(),e.foffset())},setRelativeSelection:function(e,n){!function(e,n,t){var r=Wa(n,t);Ha(e,r)}(i,e,n)},selectContents:function(e){qa(i,e)},getInnerHeight:function(){return i.innerHeight},getScrollY:function(){return function(e){var n=e!==undefined?e.dom():f.document,t=n.body.scrollLeft||n.documentElement.scrollLeft,r=n.body.scrollTop||n.documentElement.scrollTop;return lo(t,r)}(on.fromDom(i.document)).top()},scrollBy:function(e,n){!function(e,n,t){(t!==undefined?t.dom():f.document).defaultView.scrollBy(e,n)}(e,n,on.fromDom(i.document))}}}function Nf(n,e){h(e,function(e){!function(e,n){Co(e)?e.dom().classList.remove(n):xo(e,n);To(e)}(n,e)})}var If={down:{traverse:Ce,gather:nl,relative:Tl.before,otherRetry:hf.tryDown,ieRetry:hf.ieTryDown,failure:nf.failedDown},up:{traverse:ye,gather:el,relative:Tl.before,otherRetry:hf.tryUp,ieRetry:hf.ieTryUp,failure:nf.failedUp}},kf=Af(38),Pf=Af(40),Bf={ltr:{isBackward:Af(37),isForward:Af(39)},rtl:{isBackward:Af(39),isForward:Af(37)},isUp:kf,isDown:Pf,isNavigation:function(e){return 37<=e&&e<=40}},Mf=function(e){return{left:e.left(),top:e.top(),right:e.right(),bottom:e.bottom(),width:e.width(),height:e.height()}},Wf=(En.detect().browser.isSafari(),P("rows","cols")),_f={mouse:function(e,n,t,r){var o=function c(o,i,n,u){function t(){r=We.none()}var r=We.none();return{mousedown:function(e){u.clear(i),r=sl(e.target(),n)},mouseover:function(e){r.each(function(r){u.clear(i),sl(e.target(),n).each(function(t){dr(r,t,n).each(function(e){var n=e.boxes().getOr([]);(1<n.length||1===n.length&&!he(r,t))&&(u.selectRange(i,n,e.start(),e.finish()),o.selectContents(t))})})})},mouseup:function(e){r.each(t)}}}(Ef(e),n,t,r);return{mousedown:o.mousedown,mouseover:o.mouseover,mouseup:o.mouseup}},keyboard:function(e,l,f,s){function d(){return s.clear(l),We.none()}var m=Ef(e);return{keydown:function(e,n,t,r,o,i){var u=e.raw(),c=u.which,a=!0===u.shiftKey;return mr(l,s.selectedSelector()).fold(function(){return Bf.isDown(c)&&a?b(Tf,m,l,f,If.down,r,n,s.selectRange):Bf.isUp(c)&&a?b(Tf,m,l,f,If.up,r,n,s.selectRange):Bf.isDown(c)?b(Rf,m,f,If.down,r,n,Df):Bf.isUp(c)?b(Rf,m,f,If.up,r,n,Of):We.none},function(n){function e(e){return function(){return bo(e,function(e){return Hl.update(e.rows(),e.cols(),l,n,s)}).fold(function(){return pr(l,s.firstSelectedSelector(),s.lastSelectedSelector()).map(function(e){var n=Bf.isDown(c)||i.isForward(c)?Tl.after:Tl.before;return m.setRelativeSelection(Tl.on(e.first(),0),n(e.table())),s.clear(l),_l.create(We.none(),!0)})},function(e){return We.some(_l.create(We.none(),!0))})}}return Bf.isDown(c)&&a?e([Wf(1,0)]):Bf.isUp(c)&&a?e([Wf(-1,0)]):i.isBackward(c)&&a?e([Wf(0,-1),Wf(-1,0)]):i.isForward(c)&&a?e([Wf(0,1),Wf(1,0)]):Bf.isNavigation(c)&&!1==a?d:We.none})()},keyup:function(t,r,o,i,u){return mr(l,s.selectedSelector()).fold(function(){var e=t.raw(),n=e.which;return!1==(!0===e.shiftKey)?We.none():Bf.isNavigation(n)?Hl.sync(l,f,r,o,i,u,s.selectRange):We.none()},We.none)}}}},Lf={byClass:function(o){function i(e){var n=Be(e,o.selectedSelector());h(n,t)}var u=function(n){return function(e){Ro(e,n)}}(o.selected()),t=function(n){return function(e){Nf(e,n)}}([o.selected(),o.lastSelected(),o.firstSelected()]);return{clear:i,selectRange:function(e,n,t,r){i(e),h(n,u),Ro(t,o.firstSelected()),Ro(r,o.lastSelected())},selectedSelector:o.selectedSelector,firstSelectedSelector:o.firstSelectedSelector,lastSelectedSelector:o.lastSelectedSelector}},byAttr:function(o){function t(e){K(e,o.selected()),K(e,o.firstSelected()),K(e,o.lastSelected())}function i(e){q(e,o.selected(),"1")}function u(e){var n=Be(e,o.selectedSelector());h(n,t)}return{clear:u,selectRange:function(e,n,t,r){u(e),h(n,i),q(t,o.firstSelected(),"1"),q(r,o.lastSelected(),"1")},selectedSelector:o.selectedSelector,firstSelectedSelector:o.firstSelectedSelector,lastSelectedSelector:o.lastSelectedSelector}}},jf=function(e){return!1===Oo(on.fromDom(e.target),"ephox-snooker-resizer-bar")};function zf(p,h){var v=$e(["mousedown","mouseover","mouseup","keyup","keydown"],[]),b=We.none(),w=Lf.byAttr(Cr);p.on("init",function(e){function c(e,n){!function(e){return!0===e.raw().shiftKey}(e)||(n.kill()&&e.kill(),n.selection().each(function(e){var n=Dl.relative(e.start(),e.finish()),t=Nl(l,n);p.selection.setRng(t)}))}function n(e){var n=g(e);if(n.raw().shiftKey&&Bf.isNavigation(n.raw().which)){var t=p.selection.getRng(),r=on.fromDom(t.startContainer),o=on.fromDom(t.endContainer);m.keyup(n,r,t.startOffset,o,t.endOffset).each(function(e){c(n,e)})}}function t(e){var n=g(e);h().each(function(e){e.hideBars()});var t=p.selection.getRng(),r=on.fromDom(p.selection.getStart()),o=on.fromDom(t.startContainer),i=on.fromDom(t.endContainer),u=wc.directionAt(r).isRtl()?Bf.rtl:Bf.ltr;m.keydown(n,o,t.startOffset,i,t.endOffset,u).each(function(e){c(n,e)}),h().each(function(e){e.showBars()})}function i(e){return e.hasOwnProperty("x")&&e.hasOwnProperty("y")}function r(e){return 0===e.button}function o(e){r(e)&&jf(e)&&d.mousedown(g(e))}function u(e){(function(e){return e.buttons===undefined||0!=(1&e.buttons)})(e)&&jf(e)&&d.mouseover(g(e))}function a(e){r(e)&&jf(e)&&d.mouseup(g(e))}var l=p.getWin(),f=pc(p),s=hc(p),d=_f.mouse(l,f,s,w),m=_f.keyboard(l,f,s,w),g=function(e){function n(){e.stopPropagation()}function t(){e.preventDefault()}var r=on.fromDom(e.target),o=C(t,n);return{target:S(r),x:S(i(e)?e.x:null),y:S(i(e)?e.y:null),stop:n,prevent:t,kill:o,raw:S(e)}};p.on("mousedown",o),p.on("mouseover",u),p.on("mouseup",a),p.on("keyup",n),p.on("keydown",t),p.on("NodeChange",function(){var e=p.selection,n=on.fromDom(e.getStart()),t=on.fromDom(e.getEnd());fr.sharedOne(at.table,[n,t]).fold(function(){w.clear(f)},y)}),b=We.some(v({mousedown:o,mouseover:u,mouseup:a,keyup:n,keydown:t}))});return{clear:w.clear,destroy:function(){b.each(function(e){})}}}var Hf=function(n){return{get:function(){var e=pc(n);return hr(e,Cr.selectedSelector()).fold(function(){return n.selection.getStart()===undefined?Rr.none():Rr.single(n.selection)},function(e){return Rr.multiple(e)})}}},Ff=function(e,t){function n(){return ta(e).bind(function(n){return at.table(n).map(function(e){return"caption"===j(n)?Er.notCell(n):Er.forMenu(t,e,n)})})}function r(){i.set(ee(n)()),h(u.get(),function(e){return e()})}function o(n,t){function r(){return i.get().fold(function(){n.setDisabled(!0)},function(e){n.setDisabled(t(e))})}return r(),u.set(u.get().concat([r])),function(){u.set(v(u.get(),function(e){return e!==r}))}}var i=l(We.none()),u=l([]);return e.on("NodeChange",r),{onSetupTable:function(e){return o(e,function(e){return!1})},onSetupCellOrRow:function(e){return o(e,function(e){return"caption"===j(e.element())})},onSetupMergeable:function(e){return o(e,function(e){return e.mergable().isNone()})},onSetupUnmergeable:function(e){return o(e,function(e){return e.unmergable().isNone()})},resetTargets:r,targets:function(){return i.get()}}},Uf={addButtons:function(n,e){n.ui.registry.addMenuButton("table",{tooltip:"Table",icon:"table",fetch:function(e){return e("inserttable tableprops deletetable | cell row column")}});function t(e){return function(){return n.execCommand(e)}}n.ui.registry.addButton("tableprops",{tooltip:"Table properties",onAction:t("mceTableProps"),icon:"table",onSetup:e.onSetupTable}),n.ui.registry.addButton("tabledelete",{tooltip:"Delete table",onAction:t("mceTableDelete"),icon:"table-delete-table",onSetup:e.onSetupTable}),n.ui.registry.addButton("tablecellprops",{tooltip:"Cell properties",onAction:t("mceTableCellProps"),icon:"table-cell-properties",onSetup:e.onSetupCellOrRow}),n.ui.registry.addButton("tablemergecells",{tooltip:"Merge cells",onAction:t("mceTableMergeCells"),icon:"table-merge-cells",onSetup:e.onSetupMergeable}),n.ui.registry.addButton("tablesplitcells",{tooltip:"Split cell",onAction:t("mceTableSplitCells"),icon:"table-split-cells",onSetup:e.onSetupUnmergeable}),n.ui.registry.addButton("tableinsertrowbefore",{tooltip:"Insert row before",onAction:t("mceTableInsertRowBefore"),icon:"table-insert-row-above",onSetup:e.onSetupCellOrRow}),n.ui.registry.addButton("tableinsertrowafter",{tooltip:"Insert row after",onAction:t("mceTableInsertRowAfter"),icon:"table-insert-row-after",onSetup:e.onSetupCellOrRow}),n.ui.registry.addButton("tabledeleterow",{tooltip:"Delete row",onAction:t("mceTableDeleteRow"),icon:"table-delete-row",onSetup:e.onSetupCellOrRow}),n.ui.registry.addButton("tablerowprops",{tooltip:"Row properties",onAction:t("mceTableRowProps"),icon:"table-row-properties",onSetup:e.onSetupCellOrRow}),n.ui.registry.addButton("tableinsertcolbefore",{tooltip:"Insert column before",onAction:t("mceTableInsertColBefore"),icon:"table-insert-column-before",onSetup:e.onSetupCellOrRow}),n.ui.registry.addButton("tableinsertcolafter",{tooltip:"Insert column after",onAction:t("mceTableInsertColAfter"),icon:"table-insert-column-after",onSetup:e.onSetupCellOrRow}),n.ui.registry.addButton("tabledeletecol",{tooltip:"Delete column",onAction:t("mceTableDeleteCol"),icon:"table-delete-column",onSetup:e.onSetupCellOrRow}),n.ui.registry.addButton("tablecutrow",{tooltip:"Cut row",onAction:t("mceTableCutRow"),icon:"temporary-placeholder",onSetup:e.onSetupCellOrRow}),n.ui.registry.addButton("tablecopyrow",{tooltip:"Copy row",onAction:t("mceTableCopyRow"),icon:"temporary-placeholder",onSetup:e.onSetupCellOrRow}),n.ui.registry.addButton("tablepasterowbefore",{tooltip:"Paste row before",onAction:t("mceTablePasteRowBefore"),icon:"temporary-placeholder",onSetup:e.onSetupCellOrRow}),n.ui.registry.addButton("tablepasterowafter",{tooltip:"Paste row after",onAction:t("mceTablePasteRowAfter"),icon:"temporary-placeholder",onSetup:e.onSetupCellOrRow}),n.ui.registry.addButton("tableinsertdialog",{tooltip:"Insert table",onAction:t("mceInsertTable"),icon:"table"})},addToolbars:function(n){var e=function(e){return e.getParam("table_toolbar","tableprops tabledelete | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol")}(n);0<e.length&&n.ui.registry.addContextToolbar("table",{predicate:function(e){return n.dom.is(e,"table")&&n.getBody().contains(e)},items:e,scope:"node",position:"node"})}},qf={addMenuItems:function(r,e){function n(e){return function(){return r.execCommand(e)}}function t(e){var n=e.numRows,t=e.numColumns;r.undoManager.transact(function(){Jc(r,t,n)}),r.addVisual()}var o={text:"Table properties",onSetup:e.onSetupTable,onAction:n("mceTableProps")},i={text:"Delete table",icon:"table-delete-table",onSetup:e.onSetupTable,onAction:n("mceTableDelete")},u=[{type:"menuitem",text:"Insert row before",icon:"table-insert-row-above",onAction:n("mceTableInsertRowBefore"),onSetup:e.onSetupCellOrRow},{type:"menuitem",text:"Insert row after",icon:"table-insert-row-after",onAction:n("mceTableInsertRowAfter"),onSetup:e.onSetupCellOrRow},{type:"menuitem",text:"Delete row",icon:"table-delete-row",onAction:n("mceTableDeleteRow"),onSetup:e.onSetupCellOrRow},{type:"menuitem",text:"Row properties",icon:"table-row-properties",onAction:n("mceTableRowProps"),onSetup:e.onSetupCellOrRow},{type:"separator"},{type:"menuitem",text:"Cut row",onAction:n("mceTableCutRow"),onSetup:e.onSetupCellOrRow},{type:"menuitem",text:"Copy row",onAction:n("mceTableCopyRow"),onSetup:e.onSetupCellOrRow},{type:"menuitem",text:"Paste row before",onAction:n("mceTablePasteRowBefore"),onSetup:e.onSetupCellOrRow},{type:"menuitem",text:"Paste row after",onAction:n("mceTablePasteRowAfter"),onSetup:e.onSetupCellOrRow}],c={type:"nestedmenuitem",text:"Row",getSubmenuItems:function(){return u}},a=[{type:"menuitem",text:"Insert column before",icon:"table-insert-column-before",onAction:n("mceTableInsertColBefore"),onSetup:e.onSetupCellOrRow},{type:"menuitem",text:"Insert column after",icon:"table-insert-column-after",onAction:n("mceTableInsertColAfter"),onSetup:e.onSetupCellOrRow},{type:"menuitem",text:"Delete column",icon:"table-delete-column",onAction:n("mceTableDeleteCol"),onSetup:e.onSetupCellOrRow}],l={type:"nestedmenuitem",text:"Column",getSubmenuItems:function(){return a}},f=[{type:"menuitem",text:"Cell properties",icon:"table-cell-properties",onAction:n("mceTableCellProps"),onSetup:e.onSetupCellOrRow},{type:"menuitem",text:"Merge cells",icon:"table-merge-cells",onAction:n("mceTableMergeCells"),onSetup:e.onSetupMergeable},{type:"menuitem",text:"Split cell",icon:"table-split-cells",onAction:n("mceTableSplitCells"),onSetup:e.onSetupUnmergeable}],s={type:"nestedmenuitem",text:"Cell",getSubmenuItems:function(){return f}};return!1===function(e){return e.getParam("table_grid",!0,"boolean")}(r)?r.ui.registry.addMenuItem("inserttable",{text:"Table",icon:"table",onAction:n("mceInsertTable")}):r.ui.registry.addNestedMenuItem("inserttable",{text:"Table",icon:"table",getSubmenuItems:function(){return[{type:"fancymenuitem",fancytype:"inserttable",onAction:t}]}}),r.ui.registry.addMenuItem("inserttabledialog",{text:"Insert table",icon:"table",onAction:n("mceInsertTable")}),r.ui.registry.addMenuItem("tableprops",o),r.ui.registry.addMenuItem("deletetable",i),r.ui.registry.addNestedMenuItem("row",c),r.ui.registry.addNestedMenuItem("column",l),r.ui.registry.addNestedMenuItem("cell",s),r.ui.registry.addContextMenu("table",{update:function(){return e.resetTargets(),e.targets().fold(function(){return""},function(e){return"caption"===j(e.element())?"tableprops deletetable":"cell row column | tableprops deletetable"})}}),{rowItems:u,columnItems:a,cellItems:f}}},Vf=function(t,n,e,r,o){return{insertTable:function(e,n){return Jc(t,e,n)},setClipboardRows:function(e){return function(e,n){var t=p(e,on.fromDom);n.set(We.from(t))}(e,n)},getClipboardRows:function(){return function(e){return e.get().fold(function(){},function(e){return p(e,function(e){return e.dom()})})}(n)},resizeHandler:e,menuItems:o,selectionTargets:r}};function Gf(n){var t=bl(n),e=zf(n,t.lazyResize),r=xc(n,t.lazyWire),o=Hf(n),i=Ff(n,o),u=l(We.none());oa.registerCommands(n,r,e,o,u),Nr.registerEvents(n,o,r,e);var c=qf.addMenuItems(n,i);return Uf.addButtons(n,i),Uf.addToolbars(n),n.on("PreInit",function(){n.serializer.addTempAttr(Cr.firstSelected()),n.serializer.addTempAttr(Cr.lastSelected())}),Sc(n)&&n.on("keydown",function(e){Wl.handle(e,n,r,t.lazyWire)}),n.on("remove",function(){t.destroy(),e.destroy()}),Vf(n,u,t,i,c)}!function Kf(){_e.add("table",Gf)}()}(window);