agenda-libre-ruby/public/assets/tinymce/plugins/table/plugin-b11c6cd37f6d5badf46a9d96e452118b81881beb07fe41d2c0a3f7b405902234.js
2019-05-11 17:19:15 +02:00

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