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