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