2022-02-15 15:11:00 +08:00

11511 lines
392 KiB
JavaScript
Vendored

/**
* 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.10.3 (2022-02-09)
*/
(function () {
'use strict';
var typeOf = function (x) {
var t = typeof x;
if (x === null) {
return 'null';
} else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {
return 'array';
} else if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {
return 'string';
} else {
return t;
}
};
var isType$1 = function (type) {
return function (value) {
return typeOf(value) === type;
};
};
var isSimpleType = function (type) {
return function (value) {
return typeof value === type;
};
};
var eq$2 = function (t) {
return function (a) {
return t === a;
};
};
var isString = isType$1('string');
var isObject = isType$1('object');
var isArray = isType$1('array');
var isNull = eq$2(null);
var isBoolean = isSimpleType('boolean');
var isUndefined = eq$2(undefined);
var isNullable = function (a) {
return a === null || a === undefined;
};
var isNonNullable = function (a) {
return !isNullable(a);
};
var isFunction = isSimpleType('function');
var isNumber = isSimpleType('number');
var noop = function () {
};
var compose = function (fa, fb) {
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return fa(fb.apply(null, args));
};
};
var compose1 = function (fbc, fab) {
return function (a) {
return fbc(fab(a));
};
};
var constant = function (value) {
return function () {
return value;
};
};
var identity = function (x) {
return x;
};
var tripleEquals = function (a, b) {
return a === b;
};
function curry(fn) {
var initialArgs = [];
for (var _i = 1; _i < arguments.length; _i++) {
initialArgs[_i - 1] = arguments[_i];
}
return function () {
var restArgs = [];
for (var _i = 0; _i < arguments.length; _i++) {
restArgs[_i] = arguments[_i];
}
var all = initialArgs.concat(restArgs);
return fn.apply(null, all);
};
}
var not = function (f) {
return function (t) {
return !f(t);
};
};
var die = function (msg) {
return function () {
throw new Error(msg);
};
};
var never = constant(false);
var always = constant(true);
var none$2 = function () {
return NONE;
};
var NONE = function () {
var call = function (thunk) {
return thunk();
};
var id = identity;
var me = {
fold: function (n, _s) {
return n();
},
isSome: never,
isNone: always,
getOr: id,
getOrThunk: call,
getOrDie: function (msg) {
throw new Error(msg || 'error: getOrDie called on none.');
},
getOrNull: constant(null),
getOrUndefined: constant(undefined),
or: id,
orThunk: call,
map: none$2,
each: noop,
bind: none$2,
exists: never,
forall: always,
filter: function () {
return none$2();
},
toArray: function () {
return [];
},
toString: constant('none()')
};
return me;
}();
var some = function (a) {
var constant_a = constant(a);
var self = function () {
return me;
};
var bind = function (f) {
return f(a);
};
var me = {
fold: function (n, s) {
return s(a);
},
isSome: always,
isNone: never,
getOr: constant_a,
getOrThunk: constant_a,
getOrDie: constant_a,
getOrNull: constant_a,
getOrUndefined: constant_a,
or: self,
orThunk: self,
map: function (f) {
return some(f(a));
},
each: function (f) {
f(a);
},
bind: bind,
exists: bind,
forall: bind,
filter: function (f) {
return f(a) ? me : NONE;
},
toArray: function () {
return [a];
},
toString: function () {
return 'some(' + a + ')';
}
};
return me;
};
var from$1 = function (value) {
return value === null || value === undefined ? NONE : some(value);
};
var Optional = {
some: some,
none: none$2,
from: from$1
};
var nativeSlice = Array.prototype.slice;
var nativeIndexOf = Array.prototype.indexOf;
var nativePush = Array.prototype.push;
var rawIndexOf = function (ts, t) {
return nativeIndexOf.call(ts, t);
};
var contains$2 = function (xs, x) {
return rawIndexOf(xs, x) > -1;
};
var exists = function (xs, pred) {
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
if (pred(x, i)) {
return true;
}
}
return false;
};
var range$1 = function (num, f) {
var r = [];
for (var i = 0; i < num; i++) {
r.push(f(i));
}
return r;
};
var map$1 = function (xs, f) {
var len = xs.length;
var r = new Array(len);
for (var i = 0; i < len; i++) {
var x = xs[i];
r[i] = f(x, i);
}
return r;
};
var each$2 = function (xs, f) {
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
f(x, i);
}
};
var eachr = function (xs, f) {
for (var i = xs.length - 1; i >= 0; i--) {
var x = xs[i];
f(x, i);
}
};
var partition = function (xs, pred) {
var pass = [];
var fail = [];
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
var arr = pred(x, i) ? pass : fail;
arr.push(x);
}
return {
pass: pass,
fail: fail
};
};
var filter$2 = function (xs, pred) {
var r = [];
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
if (pred(x, i)) {
r.push(x);
}
}
return r;
};
var foldr = function (xs, f, acc) {
eachr(xs, function (x, i) {
acc = f(acc, x, i);
});
return acc;
};
var foldl = function (xs, f, acc) {
each$2(xs, function (x, i) {
acc = f(acc, x, i);
});
return acc;
};
var findUntil = function (xs, pred, until) {
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
if (pred(x, i)) {
return Optional.some(x);
} else if (until(x, i)) {
break;
}
}
return Optional.none();
};
var find$1 = function (xs, pred) {
return findUntil(xs, pred, never);
};
var findIndex = function (xs, pred) {
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
if (pred(x, i)) {
return Optional.some(i);
}
}
return Optional.none();
};
var flatten$1 = function (xs) {
var r = [];
for (var i = 0, len = xs.length; i < len; ++i) {
if (!isArray(xs[i])) {
throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
}
nativePush.apply(r, xs[i]);
}
return r;
};
var bind$2 = function (xs, f) {
return flatten$1(map$1(xs, f));
};
var forall = function (xs, pred) {
for (var i = 0, len = xs.length; i < len; ++i) {
var x = xs[i];
if (pred(x, i) !== true) {
return false;
}
}
return true;
};
var reverse = function (xs) {
var r = nativeSlice.call(xs, 0);
r.reverse();
return r;
};
var mapToObject = function (xs, f) {
var r = {};
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
r[String(x)] = f(x, i);
}
return r;
};
var pure = function (x) {
return [x];
};
var sort$1 = function (xs, comparator) {
var copy = nativeSlice.call(xs, 0);
copy.sort(comparator);
return copy;
};
var get$d = function (xs, i) {
return i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none();
};
var head = function (xs) {
return get$d(xs, 0);
};
var last$2 = function (xs) {
return get$d(xs, xs.length - 1);
};
var findMap = function (arr, f) {
for (var i = 0; i < arr.length; i++) {
var r = f(arr[i], i);
if (r.isSome()) {
return r;
}
}
return Optional.none();
};
var __assign = function () {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s)
if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __spreadArray(to, from, pack) {
if (pack || arguments.length === 2)
for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar)
ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
}
var cached = function (f) {
var called = false;
var r;
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (!called) {
called = true;
r = f.apply(null, args);
}
return r;
};
};
var DeviceType = function (os, browser, userAgent, mediaMatch) {
var isiPad = os.isiOS() && /ipad/i.test(userAgent) === true;
var isiPhone = os.isiOS() && !isiPad;
var isMobile = os.isiOS() || os.isAndroid();
var isTouch = isMobile || mediaMatch('(pointer:coarse)');
var isTablet = isiPad || !isiPhone && isMobile && mediaMatch('(min-device-width:768px)');
var isPhone = isiPhone || isMobile && !isTablet;
var iOSwebview = browser.isSafari() && os.isiOS() && /safari/i.test(userAgent) === false;
var isDesktop = !isPhone && !isTablet && !iOSwebview;
return {
isiPad: constant(isiPad),
isiPhone: constant(isiPhone),
isTablet: constant(isTablet),
isPhone: constant(isPhone),
isTouch: constant(isTouch),
isAndroid: os.isAndroid,
isiOS: os.isiOS,
isWebView: constant(iOSwebview),
isDesktop: constant(isDesktop)
};
};
var firstMatch = function (regexes, s) {
for (var i = 0; i < regexes.length; i++) {
var x = regexes[i];
if (x.test(s)) {
return x;
}
}
return undefined;
};
var find = function (regexes, agent) {
var r = firstMatch(regexes, agent);
if (!r) {
return {
major: 0,
minor: 0
};
}
var group = function (i) {
return Number(agent.replace(r, '$' + i));
};
return nu$2(group(1), group(2));
};
var detect$6 = function (versionRegexes, agent) {
var cleanedAgent = String(agent).toLowerCase();
if (versionRegexes.length === 0) {
return unknown$2();
}
return find(versionRegexes, cleanedAgent);
};
var unknown$2 = function () {
return nu$2(0, 0);
};
var nu$2 = function (major, minor) {
return {
major: major,
minor: minor
};
};
var Version = {
nu: nu$2,
detect: detect$6,
unknown: unknown$2
};
var detectBrowser$1 = function (browsers, userAgentData) {
return findMap(userAgentData.brands, function (uaBrand) {
var lcBrand = uaBrand.brand.toLowerCase();
return find$1(browsers, function (browser) {
var _a;
return lcBrand === ((_a = browser.brand) === null || _a === void 0 ? void 0 : _a.toLowerCase());
}).map(function (info) {
return {
current: info.name,
version: Version.nu(parseInt(uaBrand.version, 10), 0)
};
});
});
};
var detect$5 = function (candidates, userAgent) {
var agent = String(userAgent).toLowerCase();
return find$1(candidates, function (candidate) {
return candidate.search(agent);
});
};
var detectBrowser = function (browsers, userAgent) {
return detect$5(browsers, userAgent).map(function (browser) {
var version = Version.detect(browser.versionRegexes, userAgent);
return {
current: browser.name,
version: version
};
});
};
var detectOs = function (oses, userAgent) {
return detect$5(oses, userAgent).map(function (os) {
var version = Version.detect(os.versionRegexes, userAgent);
return {
current: os.name,
version: version
};
});
};
var removeFromStart = function (str, numChars) {
return str.substring(numChars);
};
var checkRange = function (str, substr, start) {
return substr === '' || str.length >= substr.length && str.substr(start, start + substr.length) === substr;
};
var removeLeading = function (str, prefix) {
return startsWith(str, prefix) ? removeFromStart(str, prefix.length) : str;
};
var contains$1 = function (str, substr) {
return str.indexOf(substr) !== -1;
};
var startsWith = function (str, prefix) {
return checkRange(str, prefix, 0);
};
var endsWith = function (str, suffix) {
return checkRange(str, suffix, str.length - suffix.length);
};
var blank = function (r) {
return function (s) {
return s.replace(r, '');
};
};
var trim = blank(/^\s+|\s+$/g);
var isNotEmpty = function (s) {
return s.length > 0;
};
var isEmpty$1 = function (s) {
return !isNotEmpty(s);
};
var toFloat = function (value) {
var num = parseFloat(value);
return isNaN(num) ? Optional.none() : Optional.some(num);
};
var normalVersionRegex = /.*?version\/\ ?([0-9]+)\.([0-9]+).*/;
var checkContains = function (target) {
return function (uastring) {
return contains$1(uastring, target);
};
};
var browsers = [
{
name: 'Edge',
versionRegexes: [/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],
search: function (uastring) {
return contains$1(uastring, 'edge/') && contains$1(uastring, 'chrome') && contains$1(uastring, 'safari') && contains$1(uastring, 'applewebkit');
}
},
{
name: 'Chrome',
brand: 'Chromium',
versionRegexes: [
/.*?chrome\/([0-9]+)\.([0-9]+).*/,
normalVersionRegex
],
search: function (uastring) {
return contains$1(uastring, 'chrome') && !contains$1(uastring, 'chromeframe');
}
},
{
name: 'IE',
versionRegexes: [
/.*?msie\ ?([0-9]+)\.([0-9]+).*/,
/.*?rv:([0-9]+)\.([0-9]+).*/
],
search: function (uastring) {
return contains$1(uastring, 'msie') || contains$1(uastring, 'trident');
}
},
{
name: 'Opera',
versionRegexes: [
normalVersionRegex,
/.*?opera\/([0-9]+)\.([0-9]+).*/
],
search: checkContains('opera')
},
{
name: 'Firefox',
versionRegexes: [/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],
search: checkContains('firefox')
},
{
name: 'Safari',
versionRegexes: [
normalVersionRegex,
/.*?cpu os ([0-9]+)_([0-9]+).*/
],
search: function (uastring) {
return (contains$1(uastring, 'safari') || contains$1(uastring, 'mobile/')) && contains$1(uastring, 'applewebkit');
}
}
];
var oses = [
{
name: 'Windows',
search: checkContains('win'),
versionRegexes: [/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]
},
{
name: 'iOS',
search: function (uastring) {
return contains$1(uastring, 'iphone') || contains$1(uastring, 'ipad');
},
versionRegexes: [
/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,
/.*cpu os ([0-9]+)_([0-9]+).*/,
/.*cpu iphone os ([0-9]+)_([0-9]+).*/
]
},
{
name: 'Android',
search: checkContains('android'),
versionRegexes: [/.*?android\ ?([0-9]+)\.([0-9]+).*/]
},
{
name: 'OSX',
search: checkContains('mac os x'),
versionRegexes: [/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]
},
{
name: 'Linux',
search: checkContains('linux'),
versionRegexes: []
},
{
name: 'Solaris',
search: checkContains('sunos'),
versionRegexes: []
},
{
name: 'FreeBSD',
search: checkContains('freebsd'),
versionRegexes: []
},
{
name: 'ChromeOS',
search: checkContains('cros'),
versionRegexes: [/.*?chrome\/([0-9]+)\.([0-9]+).*/]
}
];
var PlatformInfo = {
browsers: constant(browsers),
oses: constant(oses)
};
var edge = 'Edge';
var chrome = 'Chrome';
var ie = 'IE';
var opera = 'Opera';
var firefox = 'Firefox';
var safari = 'Safari';
var unknown$1 = function () {
return nu$1({
current: undefined,
version: Version.unknown()
});
};
var nu$1 = function (info) {
var current = info.current;
var version = info.version;
var isBrowser = function (name) {
return function () {
return current === name;
};
};
return {
current: current,
version: version,
isEdge: isBrowser(edge),
isChrome: isBrowser(chrome),
isIE: isBrowser(ie),
isOpera: isBrowser(opera),
isFirefox: isBrowser(firefox),
isSafari: isBrowser(safari)
};
};
var Browser = {
unknown: unknown$1,
nu: nu$1,
edge: constant(edge),
chrome: constant(chrome),
ie: constant(ie),
opera: constant(opera),
firefox: constant(firefox),
safari: constant(safari)
};
var windows = 'Windows';
var ios = 'iOS';
var android = 'Android';
var linux = 'Linux';
var osx = 'OSX';
var solaris = 'Solaris';
var freebsd = 'FreeBSD';
var chromeos = 'ChromeOS';
var unknown = function () {
return nu({
current: undefined,
version: Version.unknown()
});
};
var nu = function (info) {
var current = info.current;
var version = info.version;
var isOS = function (name) {
return function () {
return current === name;
};
};
return {
current: current,
version: version,
isWindows: isOS(windows),
isiOS: isOS(ios),
isAndroid: isOS(android),
isOSX: isOS(osx),
isLinux: isOS(linux),
isSolaris: isOS(solaris),
isFreeBSD: isOS(freebsd),
isChromeOS: isOS(chromeos)
};
};
var OperatingSystem = {
unknown: unknown,
nu: nu,
windows: constant(windows),
ios: constant(ios),
android: constant(android),
linux: constant(linux),
osx: constant(osx),
solaris: constant(solaris),
freebsd: constant(freebsd),
chromeos: constant(chromeos)
};
var detect$4 = function (userAgent, userAgentDataOpt, mediaMatch) {
var browsers = PlatformInfo.browsers();
var oses = PlatformInfo.oses();
var browser = userAgentDataOpt.bind(function (userAgentData) {
return detectBrowser$1(browsers, userAgentData);
}).orThunk(function () {
return detectBrowser(browsers, userAgent);
}).fold(Browser.unknown, Browser.nu);
var os = detectOs(oses, userAgent).fold(OperatingSystem.unknown, OperatingSystem.nu);
var deviceType = DeviceType(os, browser, userAgent, mediaMatch);
return {
browser: browser,
os: os,
deviceType: deviceType
};
};
var PlatformDetection = { detect: detect$4 };
var mediaMatch = function (query) {
return window.matchMedia(query).matches;
};
var platform = cached(function () {
return PlatformDetection.detect(navigator.userAgent, Optional.from(navigator.userAgentData), mediaMatch);
});
var detect$3 = function () {
return platform();
};
var compareDocumentPosition = function (a, b, match) {
return (a.compareDocumentPosition(b) & match) !== 0;
};
var documentPositionContainedBy = function (a, b) {
return compareDocumentPosition(a, b, Node.DOCUMENT_POSITION_CONTAINED_BY);
};
var COMMENT = 8;
var DOCUMENT = 9;
var DOCUMENT_FRAGMENT = 11;
var ELEMENT = 1;
var TEXT = 3;
var fromHtml$1 = function (html, scope) {
var doc = scope || document;
var div = doc.createElement('div');
div.innerHTML = html;
if (!div.hasChildNodes() || div.childNodes.length > 1) {
console.error('HTML does not have a single root node', html);
throw new Error('HTML must have a single root node');
}
return fromDom$1(div.childNodes[0]);
};
var fromTag = function (tag, scope) {
var doc = scope || document;
var node = doc.createElement(tag);
return fromDom$1(node);
};
var fromText = function (text, scope) {
var doc = scope || document;
var node = doc.createTextNode(text);
return fromDom$1(node);
};
var fromDom$1 = function (node) {
if (node === null || node === undefined) {
throw new Error('Node cannot be null or undefined');
}
return { dom: node };
};
var fromPoint$1 = function (docElm, x, y) {
return Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom$1);
};
var SugarElement = {
fromHtml: fromHtml$1,
fromTag: fromTag,
fromText: fromText,
fromDom: fromDom$1,
fromPoint: fromPoint$1
};
var is$2 = function (element, selector) {
var dom = element.dom;
if (dom.nodeType !== ELEMENT) {
return false;
} else {
var elem = dom;
if (elem.matches !== undefined) {
return elem.matches(selector);
} else if (elem.msMatchesSelector !== undefined) {
return elem.msMatchesSelector(selector);
} else if (elem.webkitMatchesSelector !== undefined) {
return elem.webkitMatchesSelector(selector);
} else if (elem.mozMatchesSelector !== undefined) {
return elem.mozMatchesSelector(selector);
} else {
throw new Error('Browser lacks native selectors');
}
}
};
var bypassSelector = function (dom) {
return dom.nodeType !== ELEMENT && dom.nodeType !== DOCUMENT && dom.nodeType !== DOCUMENT_FRAGMENT || dom.childElementCount === 0;
};
var all$1 = function (selector, scope) {
var base = scope === undefined ? document : scope.dom;
return bypassSelector(base) ? [] : map$1(base.querySelectorAll(selector), SugarElement.fromDom);
};
var one = function (selector, scope) {
var base = scope === undefined ? document : scope.dom;
return bypassSelector(base) ? Optional.none() : Optional.from(base.querySelector(selector)).map(SugarElement.fromDom);
};
var eq$1 = function (e1, e2) {
return e1.dom === e2.dom;
};
var regularContains = function (e1, e2) {
var d1 = e1.dom;
var d2 = e2.dom;
return d1 === d2 ? false : d1.contains(d2);
};
var ieContains = function (e1, e2) {
return documentPositionContainedBy(e1.dom, e2.dom);
};
var contains = function (e1, e2) {
return detect$3().browser.isIE() ? ieContains(e1, e2) : regularContains(e1, e2);
};
var is$1 = is$2;
var keys = Object.keys;
var hasOwnProperty = Object.hasOwnProperty;
var each$1 = function (obj, f) {
var props = keys(obj);
for (var k = 0, len = props.length; k < len; k++) {
var i = props[k];
var x = obj[i];
f(x, i);
}
};
var map = function (obj, f) {
return tupleMap(obj, function (x, i) {
return {
k: i,
v: f(x, i)
};
});
};
var tupleMap = function (obj, f) {
var r = {};
each$1(obj, function (x, i) {
var tuple = f(x, i);
r[tuple.k] = tuple.v;
});
return r;
};
var objAcc = function (r) {
return function (x, i) {
r[i] = x;
};
};
var internalFilter = function (obj, pred, onTrue, onFalse) {
var r = {};
each$1(obj, function (x, i) {
(pred(x, i) ? onTrue : onFalse)(x, i);
});
return r;
};
var filter$1 = function (obj, pred) {
var t = {};
internalFilter(obj, pred, objAcc(t), noop);
return t;
};
var mapToArray = function (obj, f) {
var r = [];
each$1(obj, function (value, name) {
r.push(f(value, name));
});
return r;
};
var values = function (obj) {
return mapToArray(obj, identity);
};
var size = function (obj) {
return keys(obj).length;
};
var get$c = function (obj, key) {
return has$1(obj, key) ? Optional.from(obj[key]) : Optional.none();
};
var has$1 = function (obj, key) {
return hasOwnProperty.call(obj, key);
};
var hasNonNullableKey = function (obj, key) {
return has$1(obj, key) && obj[key] !== undefined && obj[key] !== null;
};
var isEmpty = function (r) {
for (var x in r) {
if (hasOwnProperty.call(r, x)) {
return false;
}
}
return true;
};
var validSectionList = [
'tfoot',
'thead',
'tbody',
'colgroup'
];
var isValidSection = function (parentName) {
return contains$2(validSectionList, parentName);
};
var grid = function (rows, columns) {
return {
rows: rows,
columns: columns
};
};
var address = function (row, column) {
return {
row: row,
column: column
};
};
var detail = function (element, rowspan, colspan) {
return {
element: element,
rowspan: rowspan,
colspan: colspan
};
};
var detailnew = function (element, rowspan, colspan, isNew) {
return {
element: element,
rowspan: rowspan,
colspan: colspan,
isNew: isNew
};
};
var extended = function (element, rowspan, colspan, row, column, isLocked) {
return {
element: element,
rowspan: rowspan,
colspan: colspan,
row: row,
column: column,
isLocked: isLocked
};
};
var rowdetail = function (element, cells, section) {
return {
element: element,
cells: cells,
section: section
};
};
var rowdetailnew = function (element, cells, section, isNew) {
return {
element: element,
cells: cells,
section: section,
isNew: isNew
};
};
var elementnew = function (element, isNew, isLocked) {
return {
element: element,
isNew: isNew,
isLocked: isLocked
};
};
var rowcells = function (element, cells, section, isNew) {
return {
element: element,
cells: cells,
section: section,
isNew: isNew
};
};
var bounds = function (startRow, startCol, finishRow, finishCol) {
return {
startRow: startRow,
startCol: startCol,
finishRow: finishRow,
finishCol: finishCol
};
};
var columnext = function (element, colspan, column) {
return {
element: element,
colspan: colspan,
column: column
};
};
var colgroup = function (element, columns) {
return {
element: element,
columns: columns
};
};
typeof window !== 'undefined' ? window : Function('return this;')();
var name = function (element) {
var r = element.dom.nodeName;
return r.toLowerCase();
};
var type$1 = function (element) {
return element.dom.nodeType;
};
var isType = function (t) {
return function (element) {
return type$1(element) === t;
};
};
var isComment = function (element) {
return type$1(element) === COMMENT || name(element) === '#comment';
};
var isElement = isType(ELEMENT);
var isText = isType(TEXT);
var isDocument = isType(DOCUMENT);
var isDocumentFragment = isType(DOCUMENT_FRAGMENT);
var isTag = function (tag) {
return function (e) {
return isElement(e) && name(e) === tag;
};
};
var owner = function (element) {
return SugarElement.fromDom(element.dom.ownerDocument);
};
var documentOrOwner = function (dos) {
return isDocument(dos) ? dos : owner(dos);
};
var defaultView = function (element) {
return SugarElement.fromDom(documentOrOwner(element).dom.defaultView);
};
var parent = function (element) {
return Optional.from(element.dom.parentNode).map(SugarElement.fromDom);
};
var parentElement = function (element) {
return Optional.from(element.dom.parentElement).map(SugarElement.fromDom);
};
var parents = function (element, isRoot) {
var stop = isFunction(isRoot) ? isRoot : never;
var dom = element.dom;
var ret = [];
while (dom.parentNode !== null && dom.parentNode !== undefined) {
var rawParent = dom.parentNode;
var p = SugarElement.fromDom(rawParent);
ret.push(p);
if (stop(p) === true) {
break;
} else {
dom = rawParent;
}
}
return ret;
};
var prevSibling = function (element) {
return Optional.from(element.dom.previousSibling).map(SugarElement.fromDom);
};
var nextSibling = function (element) {
return Optional.from(element.dom.nextSibling).map(SugarElement.fromDom);
};
var children$3 = function (element) {
return map$1(element.dom.childNodes, SugarElement.fromDom);
};
var child$3 = function (element, index) {
var cs = element.dom.childNodes;
return Optional.from(cs[index]).map(SugarElement.fromDom);
};
var firstChild = function (element) {
return child$3(element, 0);
};
var isShadowRoot = function (dos) {
return isDocumentFragment(dos) && isNonNullable(dos.dom.host);
};
var supported = isFunction(Element.prototype.attachShadow) && isFunction(Node.prototype.getRootNode);
var isSupported$1 = constant(supported);
var getRootNode = supported ? function (e) {
return SugarElement.fromDom(e.dom.getRootNode());
} : documentOrOwner;
var getShadowRoot = function (e) {
var r = getRootNode(e);
return isShadowRoot(r) ? Optional.some(r) : Optional.none();
};
var getShadowHost = function (e) {
return SugarElement.fromDom(e.dom.host);
};
var getOriginalEventTarget = function (event) {
if (isSupported$1() && isNonNullable(event.target)) {
var el = SugarElement.fromDom(event.target);
if (isElement(el) && isOpenShadowHost(el)) {
if (event.composed && event.composedPath) {
var composedPath = event.composedPath();
if (composedPath) {
return head(composedPath);
}
}
}
}
return Optional.from(event.target);
};
var isOpenShadowHost = function (element) {
return isNonNullable(element.dom.shadowRoot);
};
var inBody = function (element) {
var dom = isText(element) ? element.dom.parentNode : element.dom;
if (dom === undefined || dom === null || dom.ownerDocument === null) {
return false;
}
var doc = dom.ownerDocument;
return getShadowRoot(SugarElement.fromDom(dom)).fold(function () {
return doc.body.contains(dom);
}, compose1(inBody, getShadowHost));
};
var body$1 = function () {
return getBody$1(SugarElement.fromDom(document));
};
var getBody$1 = function (doc) {
var b = doc.dom.body;
if (b === null || b === undefined) {
throw new Error('Body is not available yet');
}
return SugarElement.fromDom(b);
};
var ancestors$4 = function (scope, predicate, isRoot) {
return filter$2(parents(scope, isRoot), predicate);
};
var children$2 = function (scope, predicate) {
return filter$2(children$3(scope), predicate);
};
var descendants$1 = function (scope, predicate) {
var result = [];
each$2(children$3(scope), function (x) {
if (predicate(x)) {
result = result.concat([x]);
}
result = result.concat(descendants$1(x, predicate));
});
return result;
};
var ancestors$3 = function (scope, selector, isRoot) {
return ancestors$4(scope, function (e) {
return is$2(e, selector);
}, isRoot);
};
var children$1 = function (scope, selector) {
return children$2(scope, function (e) {
return is$2(e, selector);
});
};
var descendants = function (scope, selector) {
return all$1(selector, scope);
};
function ClosestOrAncestor (is, ancestor, scope, a, isRoot) {
if (is(scope, a)) {
return Optional.some(scope);
} else if (isFunction(isRoot) && isRoot(scope)) {
return Optional.none();
} else {
return ancestor(scope, a, isRoot);
}
}
var ancestor$2 = function (scope, predicate, isRoot) {
var element = scope.dom;
var stop = isFunction(isRoot) ? isRoot : never;
while (element.parentNode) {
element = element.parentNode;
var el = SugarElement.fromDom(element);
if (predicate(el)) {
return Optional.some(el);
} else if (stop(el)) {
break;
}
}
return Optional.none();
};
var closest$2 = function (scope, predicate, isRoot) {
var is = function (s, test) {
return test(s);
};
return ClosestOrAncestor(is, ancestor$2, scope, predicate, isRoot);
};
var child$2 = function (scope, predicate) {
var pred = function (node) {
return predicate(SugarElement.fromDom(node));
};
var result = find$1(scope.dom.childNodes, pred);
return result.map(SugarElement.fromDom);
};
var descendant$1 = function (scope, predicate) {
var descend = function (node) {
for (var i = 0; i < node.childNodes.length; i++) {
var child_1 = SugarElement.fromDom(node.childNodes[i]);
if (predicate(child_1)) {
return Optional.some(child_1);
}
var res = descend(node.childNodes[i]);
if (res.isSome()) {
return res;
}
}
return Optional.none();
};
return descend(scope.dom);
};
var ancestor$1 = function (scope, selector, isRoot) {
return ancestor$2(scope, function (e) {
return is$2(e, selector);
}, isRoot);
};
var child$1 = function (scope, selector) {
return child$2(scope, function (e) {
return is$2(e, selector);
});
};
var descendant = function (scope, selector) {
return one(selector, scope);
};
var closest$1 = function (scope, selector, isRoot) {
var is = function (element, selector) {
return is$2(element, selector);
};
return ClosestOrAncestor(is, ancestor$1, scope, selector, isRoot);
};
var rawSet = function (dom, key, value) {
if (isString(value) || isBoolean(value) || isNumber(value)) {
dom.setAttribute(key, value + '');
} else {
console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom);
throw new Error('Attribute value was not simple');
}
};
var set$2 = function (element, key, value) {
rawSet(element.dom, key, value);
};
var setAll$1 = function (element, attrs) {
var dom = element.dom;
each$1(attrs, function (v, k) {
rawSet(dom, k, v);
});
};
var setOptions = function (element, attrs) {
each$1(attrs, function (v, k) {
v.fold(function () {
remove$7(element, k);
}, function (value) {
rawSet(element.dom, k, value);
});
});
};
var get$b = function (element, key) {
var v = element.dom.getAttribute(key);
return v === null ? undefined : v;
};
var getOpt = function (element, key) {
return Optional.from(get$b(element, key));
};
var remove$7 = function (element, key) {
element.dom.removeAttribute(key);
};
var clone$2 = function (element) {
return foldl(element.dom.attributes, function (acc, attr) {
acc[attr.name] = attr.value;
return acc;
}, {});
};
var is = function (lhs, rhs, comparator) {
if (comparator === void 0) {
comparator = tripleEquals;
}
return lhs.exists(function (left) {
return comparator(left, rhs);
});
};
var cat = function (arr) {
var r = [];
var push = function (x) {
r.push(x);
};
for (var i = 0; i < arr.length; i++) {
arr[i].each(push);
}
return r;
};
var lift2 = function (oa, ob, f) {
return oa.isSome() && ob.isSome() ? Optional.some(f(oa.getOrDie(), ob.getOrDie())) : Optional.none();
};
var bindFrom = function (a, f) {
return a !== undefined && a !== null ? f(a) : Optional.none();
};
var flatten = function (oot) {
return oot.bind(identity);
};
var someIf = function (b, a) {
return b ? Optional.some(a) : Optional.none();
};
var isSupported = function (dom) {
return dom.style !== undefined && isFunction(dom.style.getPropertyValue);
};
var internalSet = function (dom, property, value) {
if (!isString(value)) {
console.error('Invalid call to CSS.set. Property ', property, ':: Value ', value, ':: Element ', dom);
throw new Error('CSS value must be a string: ' + value);
}
if (isSupported(dom)) {
dom.style.setProperty(property, value);
}
};
var internalRemove = function (dom, property) {
if (isSupported(dom)) {
dom.style.removeProperty(property);
}
};
var set$1 = function (element, property, value) {
var dom = element.dom;
internalSet(dom, property, value);
};
var setAll = function (element, css) {
var dom = element.dom;
each$1(css, function (v, k) {
internalSet(dom, k, v);
});
};
var get$a = function (element, property) {
var dom = element.dom;
var styles = window.getComputedStyle(dom);
var r = styles.getPropertyValue(property);
return r === '' && !inBody(element) ? getUnsafeProperty(dom, property) : r;
};
var getUnsafeProperty = function (dom, property) {
return isSupported(dom) ? dom.style.getPropertyValue(property) : '';
};
var getRaw$2 = function (element, property) {
var dom = element.dom;
var raw = getUnsafeProperty(dom, property);
return Optional.from(raw).filter(function (r) {
return r.length > 0;
});
};
var remove$6 = function (element, property) {
var dom = element.dom;
internalRemove(dom, property);
if (is(getOpt(element, 'style').map(trim), '')) {
remove$7(element, 'style');
}
};
var copy$2 = function (source, target) {
var sourceDom = source.dom;
var targetDom = target.dom;
if (isSupported(sourceDom) && isSupported(targetDom)) {
targetDom.style.cssText = sourceDom.style.cssText;
}
};
var getAttrValue = function (cell, name, fallback) {
if (fallback === void 0) {
fallback = 0;
}
return getOpt(cell, name).map(function (value) {
return parseInt(value, 10);
}).getOr(fallback);
};
var getSpan = function (cell, type) {
return getAttrValue(cell, type, 1);
};
var hasColspan = function (cellOrCol) {
if (isTag('col')(cellOrCol)) {
return getAttrValue(cellOrCol, 'span', 1) > 1;
} else {
return getSpan(cellOrCol, 'colspan') > 1;
}
};
var hasRowspan = function (cell) {
return getSpan(cell, 'rowspan') > 1;
};
var getCssValue = function (element, property) {
return parseInt(get$a(element, property), 10);
};
var minWidth = constant(10);
var minHeight = constant(10);
var firstLayer = function (scope, selector) {
return filterFirstLayer(scope, selector, always);
};
var filterFirstLayer = function (scope, selector, predicate) {
return bind$2(children$3(scope), function (x) {
if (is$2(x, selector)) {
return predicate(x) ? [x] : [];
} else {
return filterFirstLayer(x, selector, predicate);
}
});
};
var lookup = function (tags, element, isRoot) {
if (isRoot === void 0) {
isRoot = never;
}
if (isRoot(element)) {
return Optional.none();
}
if (contains$2(tags, name(element))) {
return Optional.some(element);
}
var isRootOrUpperTable = function (elm) {
return is$2(elm, 'table') || isRoot(elm);
};
return ancestor$1(element, tags.join(','), isRootOrUpperTable);
};
var cell = function (element, isRoot) {
return lookup([
'td',
'th'
], element, isRoot);
};
var cells$1 = function (ancestor) {
return firstLayer(ancestor, 'th,td');
};
var columns$1 = function (ancestor) {
if (is$2(ancestor, 'colgroup')) {
return children$1(ancestor, 'col');
} else {
return bind$2(columnGroups(ancestor), function (columnGroup) {
return children$1(columnGroup, 'col');
});
}
};
var table = function (element, isRoot) {
return closest$1(element, 'table', isRoot);
};
var rows$1 = function (ancestor) {
return firstLayer(ancestor, 'tr');
};
var columnGroups = function (ancestor) {
return table(ancestor).fold(constant([]), function (table) {
return children$1(table, 'colgroup');
});
};
var fromRowsOrColGroups = function (elems, getSection) {
return map$1(elems, function (row) {
if (name(row) === 'colgroup') {
var cells = map$1(columns$1(row), function (column) {
var colspan = getAttrValue(column, 'span', 1);
return detail(column, 1, colspan);
});
return rowdetail(row, cells, 'colgroup');
} else {
var cells = map$1(cells$1(row), function (cell) {
var rowspan = getAttrValue(cell, 'rowspan', 1);
var colspan = getAttrValue(cell, 'colspan', 1);
return detail(cell, rowspan, colspan);
});
return rowdetail(row, cells, getSection(row));
}
});
};
var getParentSection = function (group) {
return parent(group).map(function (parent) {
var parentName = name(parent);
return isValidSection(parentName) ? parentName : 'tbody';
}).getOr('tbody');
};
var fromTable$1 = function (table) {
var rows = rows$1(table);
var columnGroups$1 = columnGroups(table);
var elems = __spreadArray(__spreadArray([], columnGroups$1, true), rows, true);
return fromRowsOrColGroups(elems, getParentSection);
};
var fromPastedRows = function (elems, section) {
return fromRowsOrColGroups(elems, function () {
return section;
});
};
var addCells = function (gridRow, index, cells) {
var existingCells = gridRow.cells;
var before = existingCells.slice(0, index);
var after = existingCells.slice(index);
var newCells = before.concat(cells).concat(after);
return setCells(gridRow, newCells);
};
var addCell = function (gridRow, index, cell) {
return addCells(gridRow, index, [cell]);
};
var mutateCell = function (gridRow, index, cell) {
var cells = gridRow.cells;
cells[index] = cell;
};
var setCells = function (gridRow, cells) {
return rowcells(gridRow.element, cells, gridRow.section, gridRow.isNew);
};
var mapCells = function (gridRow, f) {
var cells = gridRow.cells;
var r = map$1(cells, f);
return rowcells(gridRow.element, r, gridRow.section, gridRow.isNew);
};
var getCell = function (gridRow, index) {
return gridRow.cells[index];
};
var getCellElement = function (gridRow, index) {
return getCell(gridRow, index).element;
};
var cellLength = function (gridRow) {
return gridRow.cells.length;
};
var extractGridDetails = function (grid) {
var result = partition(grid, function (row) {
return row.section === 'colgroup';
});
return {
rows: result.fail,
cols: result.pass
};
};
var clone$1 = function (gridRow, cloneRow, cloneCell) {
var newCells = map$1(gridRow.cells, cloneCell);
return rowcells(cloneRow(gridRow.element), newCells, gridRow.section, true);
};
var LOCKED_COL_ATTR = 'data-snooker-locked-cols';
var getLockedColumnsFromTable = function (table) {
return getOpt(table, LOCKED_COL_ATTR).bind(function (lockedColStr) {
return Optional.from(lockedColStr.match(/\d+/g));
}).map(function (lockedCols) {
return mapToObject(lockedCols, always);
});
};
var getLockedColumnsFromGrid = function (grid) {
var locked = foldl(extractGridDetails(grid).rows, function (acc, row) {
each$2(row.cells, function (cell, idx) {
if (cell.isLocked) {
acc[idx] = true;
}
});
return acc;
}, {});
var lockedArr = mapToArray(locked, function (_val, key) {
return parseInt(key, 10);
});
return sort$1(lockedArr);
};
var key = function (row, column) {
return row + ',' + column;
};
var getAt = function (warehouse, row, column) {
return Optional.from(warehouse.access[key(row, column)]);
};
var findItem = function (warehouse, item, comparator) {
var filtered = filterItems(warehouse, function (detail) {
return comparator(item, detail.element);
});
return filtered.length > 0 ? Optional.some(filtered[0]) : Optional.none();
};
var filterItems = function (warehouse, predicate) {
var all = bind$2(warehouse.all, function (r) {
return r.cells;
});
return filter$2(all, predicate);
};
var generateColumns = function (rowData) {
var columnsGroup = {};
var index = 0;
each$2(rowData.cells, function (column) {
var colspan = column.colspan;
range$1(colspan, function (columnIndex) {
var colIndex = index + columnIndex;
columnsGroup[colIndex] = columnext(column.element, colspan, colIndex);
});
index += colspan;
});
return columnsGroup;
};
var generate$1 = function (list) {
var access = {};
var cells = [];
var tableOpt = head(list).map(function (rowData) {
return rowData.element;
}).bind(table);
var lockedColumns = tableOpt.bind(getLockedColumnsFromTable).getOr({});
var maxRows = 0;
var maxColumns = 0;
var rowCount = 0;
var _a = partition(list, function (rowData) {
return rowData.section === 'colgroup';
}), colgroupRows = _a.pass, rows = _a.fail;
each$2(rows, function (rowData) {
var currentRow = [];
each$2(rowData.cells, function (rowCell) {
var start = 0;
while (access[key(rowCount, start)] !== undefined) {
start++;
}
var isLocked = hasNonNullableKey(lockedColumns, start.toString());
var current = extended(rowCell.element, rowCell.rowspan, rowCell.colspan, rowCount, start, isLocked);
for (var occupiedColumnPosition = 0; occupiedColumnPosition < rowCell.colspan; occupiedColumnPosition++) {
for (var occupiedRowPosition = 0; occupiedRowPosition < rowCell.rowspan; occupiedRowPosition++) {
var rowPosition = rowCount + occupiedRowPosition;
var columnPosition = start + occupiedColumnPosition;
var newpos = key(rowPosition, columnPosition);
access[newpos] = current;
maxColumns = Math.max(maxColumns, columnPosition + 1);
}
}
currentRow.push(current);
});
maxRows++;
cells.push(rowdetail(rowData.element, currentRow, rowData.section));
rowCount++;
});
var _b = last$2(colgroupRows).map(function (rowData) {
var columns = generateColumns(rowData);
var colgroup$1 = colgroup(rowData.element, values(columns));
return {
colgroups: [colgroup$1],
columns: columns
};
}).getOrThunk(function () {
return {
colgroups: [],
columns: {}
};
}), columns = _b.columns, colgroups = _b.colgroups;
var grid$1 = grid(maxRows, maxColumns);
return {
grid: grid$1,
access: access,
all: cells,
columns: columns,
colgroups: colgroups
};
};
var fromTable = function (table) {
var list = fromTable$1(table);
return generate$1(list);
};
var justCells = function (warehouse) {
return bind$2(warehouse.all, function (w) {
return w.cells;
});
};
var justColumns = function (warehouse) {
return values(warehouse.columns);
};
var hasColumns = function (warehouse) {
return keys(warehouse.columns).length > 0;
};
var getColumnAt = function (warehouse, columnIndex) {
return Optional.from(warehouse.columns[columnIndex]);
};
var Warehouse = {
fromTable: fromTable,
generate: generate$1,
getAt: getAt,
findItem: findItem,
filterItems: filterItems,
justCells: justCells,
justColumns: justColumns,
hasColumns: hasColumns,
getColumnAt: getColumnAt
};
var inSelection = function (bounds, detail) {
var leftEdge = detail.column;
var rightEdge = detail.column + detail.colspan - 1;
var topEdge = detail.row;
var bottomEdge = detail.row + detail.rowspan - 1;
return leftEdge <= bounds.finishCol && rightEdge >= bounds.startCol && (topEdge <= bounds.finishRow && bottomEdge >= bounds.startRow);
};
var isWithin = function (bounds, detail) {
return detail.column >= bounds.startCol && detail.column + detail.colspan - 1 <= bounds.finishCol && detail.row >= bounds.startRow && detail.row + detail.rowspan - 1 <= bounds.finishRow;
};
var isRectangular = function (warehouse, bounds) {
var isRect = true;
var detailIsWithin = curry(isWithin, bounds);
for (var i = bounds.startRow; i <= bounds.finishRow; i++) {
for (var j = bounds.startCol; j <= bounds.finishCol; j++) {
isRect = isRect && Warehouse.getAt(warehouse, i, j).exists(detailIsWithin);
}
}
return isRect ? Optional.some(bounds) : Optional.none();
};
var getBounds = function (detailA, detailB) {
return bounds(Math.min(detailA.row, detailB.row), Math.min(detailA.column, detailB.column), Math.max(detailA.row + detailA.rowspan - 1, detailB.row + detailB.rowspan - 1), Math.max(detailA.column + detailA.colspan - 1, detailB.column + detailB.colspan - 1));
};
var getAnyBox = function (warehouse, startCell, finishCell) {
var startCoords = Warehouse.findItem(warehouse, startCell, eq$1);
var finishCoords = Warehouse.findItem(warehouse, finishCell, eq$1);
return startCoords.bind(function (sc) {
return finishCoords.map(function (fc) {
return getBounds(sc, fc);
});
});
};
var getBox$1 = function (warehouse, startCell, finishCell) {
return getAnyBox(warehouse, startCell, finishCell).bind(function (bounds) {
return isRectangular(warehouse, bounds);
});
};
var moveBy$1 = function (warehouse, cell, row, column) {
return Warehouse.findItem(warehouse, cell, eq$1).bind(function (detail) {
var startRow = row > 0 ? detail.row + detail.rowspan - 1 : detail.row;
var startCol = column > 0 ? detail.column + detail.colspan - 1 : detail.column;
var dest = Warehouse.getAt(warehouse, startRow + row, startCol + column);
return dest.map(function (d) {
return d.element;
});
});
};
var intercepts$1 = function (warehouse, start, finish) {
return getAnyBox(warehouse, start, finish).map(function (bounds) {
var inside = Warehouse.filterItems(warehouse, curry(inSelection, bounds));
return map$1(inside, function (detail) {
return detail.element;
});
});
};
var parentCell = function (warehouse, innerCell) {
var isContainedBy = function (c1, c2) {
return contains(c2, c1);
};
return Warehouse.findItem(warehouse, innerCell, isContainedBy).map(function (detail) {
return detail.element;
});
};
var moveBy = function (cell, deltaRow, deltaColumn) {
return table(cell).bind(function (table) {
var warehouse = getWarehouse(table);
return moveBy$1(warehouse, cell, deltaRow, deltaColumn);
});
};
var intercepts = function (table, first, last) {
var warehouse = getWarehouse(table);
return intercepts$1(warehouse, first, last);
};
var nestedIntercepts = function (table, first, firstTable, last, lastTable) {
var warehouse = getWarehouse(table);
var optStartCell = eq$1(table, firstTable) ? Optional.some(first) : parentCell(warehouse, first);
var optLastCell = eq$1(table, lastTable) ? Optional.some(last) : parentCell(warehouse, last);
return optStartCell.bind(function (startCell) {
return optLastCell.bind(function (lastCell) {
return intercepts$1(warehouse, startCell, lastCell);
});
});
};
var getBox = function (table, first, last) {
var warehouse = getWarehouse(table);
return getBox$1(warehouse, first, last);
};
var getWarehouse = Warehouse.fromTable;
var before$4 = function (marker, element) {
var parent$1 = parent(marker);
parent$1.each(function (v) {
v.dom.insertBefore(element.dom, marker.dom);
});
};
var after$5 = function (marker, element) {
var sibling = nextSibling(marker);
sibling.fold(function () {
var parent$1 = parent(marker);
parent$1.each(function (v) {
append$1(v, element);
});
}, function (v) {
before$4(v, element);
});
};
var prepend = function (parent, element) {
var firstChild$1 = firstChild(parent);
firstChild$1.fold(function () {
append$1(parent, element);
}, function (v) {
parent.dom.insertBefore(element.dom, v.dom);
});
};
var append$1 = function (parent, element) {
parent.dom.appendChild(element.dom);
};
var appendAt = function (parent, element, index) {
child$3(parent, index).fold(function () {
append$1(parent, element);
}, function (v) {
before$4(v, element);
});
};
var wrap = function (element, wrapper) {
before$4(element, wrapper);
append$1(wrapper, element);
};
var before$3 = function (marker, elements) {
each$2(elements, function (x) {
before$4(marker, x);
});
};
var after$4 = function (marker, elements) {
each$2(elements, function (x, i) {
var e = i === 0 ? marker : elements[i - 1];
after$5(e, x);
});
};
var append = function (parent, elements) {
each$2(elements, function (x) {
append$1(parent, x);
});
};
var empty = function (element) {
element.dom.textContent = '';
each$2(children$3(element), function (rogue) {
remove$5(rogue);
});
};
var remove$5 = function (element) {
var dom = element.dom;
if (dom.parentNode !== null) {
dom.parentNode.removeChild(dom);
}
};
var unwrap = function (wrapper) {
var children = children$3(wrapper);
if (children.length > 0) {
before$3(wrapper, children);
}
remove$5(wrapper);
};
var NodeValue = function (is, name) {
var get = function (element) {
if (!is(element)) {
throw new Error('Can only get ' + name + ' value of a ' + name + ' node');
}
return getOption(element).getOr('');
};
var getOption = function (element) {
return is(element) ? Optional.from(element.dom.nodeValue) : Optional.none();
};
var set = function (element, value) {
if (!is(element)) {
throw new Error('Can only set raw ' + name + ' value of a ' + name + ' node');
}
element.dom.nodeValue = value;
};
return {
get: get,
getOption: getOption,
set: set
};
};
var api$2 = NodeValue(isText, 'text');
var get$9 = function (element) {
return api$2.get(element);
};
var getOption = function (element) {
return api$2.getOption(element);
};
var set = function (element, value) {
return api$2.set(element, value);
};
var TagBoundaries = [
'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 DomUniverse () {
var clone = function (element) {
return SugarElement.fromDom(element.dom.cloneNode(false));
};
var document = function (element) {
return documentOrOwner(element).dom;
};
var isBoundary = function (element) {
if (!isElement(element)) {
return false;
}
if (name(element) === 'body') {
return true;
}
return contains$2(TagBoundaries, name(element));
};
var isEmptyTag = function (element) {
if (!isElement(element)) {
return false;
}
return contains$2([
'br',
'img',
'hr',
'input'
], name(element));
};
var isNonEditable = function (element) {
return isElement(element) && get$b(element, 'contenteditable') === 'false';
};
var comparePosition = function (element, other) {
return element.dom.compareDocumentPosition(other.dom);
};
var copyAttributesTo = function (source, destination) {
var as = clone$2(source);
setAll$1(destination, as);
};
var isSpecial = function (element) {
var tag = name(element);
return contains$2([
'script',
'noscript',
'iframe',
'noframes',
'noembed',
'title',
'style',
'textarea',
'xmp'
], tag);
};
var getLanguage = function (element) {
return isElement(element) ? getOpt(element, 'lang') : Optional.none();
};
return {
up: constant({
selector: ancestor$1,
closest: closest$1,
predicate: ancestor$2,
all: parents
}),
down: constant({
selector: descendants,
predicate: descendants$1
}),
styles: constant({
get: get$a,
getRaw: getRaw$2,
set: set$1,
remove: remove$6
}),
attrs: constant({
get: get$b,
set: set$2,
remove: remove$7,
copyTo: copyAttributesTo
}),
insert: constant({
before: before$4,
after: after$5,
afterAll: after$4,
append: append$1,
appendAll: append,
prepend: prepend,
wrap: wrap
}),
remove: constant({
unwrap: unwrap,
remove: remove$5
}),
create: constant({
nu: SugarElement.fromTag,
clone: clone,
text: SugarElement.fromText
}),
query: constant({
comparePosition: comparePosition,
prevSibling: prevSibling,
nextSibling: nextSibling
}),
property: constant({
children: children$3,
name: name,
parent: parent,
document: document,
isText: isText,
isComment: isComment,
isElement: isElement,
isSpecial: isSpecial,
getLanguage: getLanguage,
getText: get$9,
setText: set,
isBoundary: isBoundary,
isEmptyTag: isEmptyTag,
isNonEditable: isNonEditable
}),
eq: eq$1,
is: is$1
};
}
var all = function (universe, look, elements, f) {
var head = elements[0];
var tail = elements.slice(1);
return f(universe, look, head, tail);
};
var oneAll = function (universe, look, elements) {
return elements.length > 0 ? all(universe, look, elements, unsafeOne) : Optional.none();
};
var unsafeOne = function (universe, look, head, tail) {
var start = look(universe, head);
return foldr(tail, function (b, a) {
var current = look(universe, a);
return commonElement(universe, b, current);
}, start);
};
var commonElement = function (universe, start, end) {
return start.bind(function (s) {
return end.filter(curry(universe.eq, s));
});
};
var eq = function (universe, item) {
return curry(universe.eq, item);
};
var ancestors$2 = function (universe, start, end, isRoot) {
if (isRoot === void 0) {
isRoot = never;
}
var ps1 = [start].concat(universe.up().all(start));
var ps2 = [end].concat(universe.up().all(end));
var prune = function (path) {
var index = findIndex(path, isRoot);
return index.fold(function () {
return path;
}, function (ind) {
return path.slice(0, ind + 1);
});
};
var pruned1 = prune(ps1);
var pruned2 = prune(ps2);
var shared = find$1(pruned1, function (x) {
return exists(pruned2, eq(universe, x));
});
return {
firstpath: pruned1,
secondpath: pruned2,
shared: shared
};
};
var sharedOne$1 = oneAll;
var ancestors$1 = ancestors$2;
var universe$3 = DomUniverse();
var sharedOne = function (look, elements) {
return sharedOne$1(universe$3, function (_universe, element) {
return look(element);
}, elements);
};
var ancestors = function (start, finish, isRoot) {
return ancestors$1(universe$3, start, finish, isRoot);
};
var lookupTable = function (container) {
return ancestor$1(container, 'table');
};
var identify = function (start, finish, isRoot) {
var getIsRoot = function (rootTable) {
return function (element) {
return isRoot !== undefined && isRoot(element) || eq$1(element, rootTable);
};
};
if (eq$1(start, finish)) {
return Optional.some({
boxes: Optional.some([start]),
start: start,
finish: finish
});
} else {
return lookupTable(start).bind(function (startTable) {
return lookupTable(finish).bind(function (finishTable) {
if (eq$1(startTable, finishTable)) {
return Optional.some({
boxes: intercepts(startTable, start, finish),
start: start,
finish: finish
});
} else if (contains(startTable, finishTable)) {
var ancestorCells = ancestors$3(finish, 'td,th', getIsRoot(startTable));
var finishCell = ancestorCells.length > 0 ? ancestorCells[ancestorCells.length - 1] : finish;
return Optional.some({
boxes: nestedIntercepts(startTable, start, startTable, finish, finishTable),
start: start,
finish: finishCell
});
} else if (contains(finishTable, startTable)) {
var ancestorCells = ancestors$3(start, 'td,th', getIsRoot(finishTable));
var startCell = ancestorCells.length > 0 ? ancestorCells[ancestorCells.length - 1] : start;
return Optional.some({
boxes: nestedIntercepts(finishTable, start, startTable, finish, finishTable),
start: start,
finish: startCell
});
} else {
return ancestors(start, finish).shared.bind(function (lca) {
return closest$1(lca, 'table', isRoot).bind(function (lcaTable) {
var finishAncestorCells = ancestors$3(finish, 'td,th', getIsRoot(lcaTable));
var finishCell = finishAncestorCells.length > 0 ? finishAncestorCells[finishAncestorCells.length - 1] : finish;
var startAncestorCells = ancestors$3(start, 'td,th', getIsRoot(lcaTable));
var startCell = startAncestorCells.length > 0 ? startAncestorCells[startAncestorCells.length - 1] : start;
return Optional.some({
boxes: nestedIntercepts(lcaTable, start, startTable, finish, finishTable),
start: startCell,
finish: finishCell
});
});
});
}
});
});
}
};
var retrieve$1 = function (container, selector) {
var sels = descendants(container, selector);
return sels.length > 0 ? Optional.some(sels) : Optional.none();
};
var getLast = function (boxes, lastSelectedSelector) {
return find$1(boxes, function (box) {
return is$2(box, lastSelectedSelector);
});
};
var getEdges = function (container, firstSelectedSelector, lastSelectedSelector) {
return descendant(container, firstSelectedSelector).bind(function (first) {
return descendant(container, lastSelectedSelector).bind(function (last) {
return sharedOne(lookupTable, [
first,
last
]).map(function (table) {
return {
first: first,
last: last,
table: table
};
});
});
});
};
var expandTo = function (finish, firstSelectedSelector) {
return ancestor$1(finish, 'table').bind(function (table) {
return descendant(table, firstSelectedSelector).bind(function (start) {
return identify(start, finish).bind(function (identified) {
return identified.boxes.map(function (boxes) {
return {
boxes: boxes,
start: identified.start,
finish: identified.finish
};
});
});
});
});
};
var shiftSelection = function (boxes, deltaRow, deltaColumn, firstSelectedSelector, lastSelectedSelector) {
return getLast(boxes, lastSelectedSelector).bind(function (last) {
return moveBy(last, deltaRow, deltaColumn).bind(function (finish) {
return expandTo(finish, firstSelectedSelector);
});
});
};
var retrieve = function (container, selector) {
return retrieve$1(container, selector);
};
var retrieveBox = function (container, firstSelectedSelector, lastSelectedSelector) {
return getEdges(container, firstSelectedSelector, lastSelectedSelector).bind(function (edges) {
var isRoot = function (ancestor) {
return eq$1(container, ancestor);
};
var sectionSelector = 'thead,tfoot,tbody,table';
var firstAncestor = ancestor$1(edges.first, sectionSelector, isRoot);
var lastAncestor = ancestor$1(edges.last, sectionSelector, isRoot);
return firstAncestor.bind(function (fA) {
return lastAncestor.bind(function (lA) {
return eq$1(fA, lA) ? getBox(edges.table, edges.first, edges.last) : Optional.none();
});
});
});
};
var generate = function (cases) {
if (!isArray(cases)) {
throw new Error('cases must be an array');
}
if (cases.length === 0) {
throw new Error('there must be at least one case');
}
var constructors = [];
var adt = {};
each$2(cases, function (acase, count) {
var keys$1 = keys(acase);
if (keys$1.length !== 1) {
throw new Error('one and only one name per case');
}
var key = keys$1[0];
var value = acase[key];
if (adt[key] !== undefined) {
throw new Error('duplicate key detected:' + key);
} else if (key === 'cata') {
throw new Error('cannot have a case named cata (sorry)');
} else if (!isArray(value)) {
throw new Error('case arguments must be an array');
}
constructors.push(key);
adt[key] = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var argLength = args.length;
if (argLength !== value.length) {
throw new Error('Wrong number of arguments to case ' + key + '. Expected ' + value.length + ' (' + value + '), got ' + argLength);
}
var match = function (branches) {
var branchKeys = keys(branches);
if (constructors.length !== branchKeys.length) {
throw new Error('Wrong number of arguments to match. Expected: ' + constructors.join(',') + '\nActual: ' + branchKeys.join(','));
}
var allReqd = forall(constructors, function (reqKey) {
return contains$2(branchKeys, reqKey);
});
if (!allReqd) {
throw new Error('Not all branches were specified when using match. Specified: ' + branchKeys.join(', ') + '\nRequired: ' + constructors.join(', '));
}
return branches[key].apply(null, args);
};
return {
fold: function () {
var foldArgs = [];
for (var _i = 0; _i < arguments.length; _i++) {
foldArgs[_i] = arguments[_i];
}
if (foldArgs.length !== cases.length) {
throw new Error('Wrong number of arguments to fold. Expected ' + cases.length + ', got ' + foldArgs.length);
}
var target = foldArgs[count];
return target.apply(null, args);
},
match: match,
log: function (label) {
console.log(label, {
constructors: constructors,
constructor: key,
params: args
});
}
};
};
});
return adt;
};
var Adt = { generate: generate };
var type = Adt.generate([
{ none: [] },
{ multiple: ['elements'] },
{ single: ['element'] }
]);
var cata$2 = function (subject, onNone, onMultiple, onSingle) {
return subject.fold(onNone, onMultiple, onSingle);
};
var none$1 = type.none;
var multiple = type.multiple;
var single = type.single;
var Selections = function (lazyRoot, getStart, selectedSelector) {
var get = function () {
return retrieve(lazyRoot(), selectedSelector).fold(function () {
return getStart().fold(none$1, single);
}, function (cells) {
return multiple(cells);
});
};
return { get: get };
};
var global$3 = tinymce.util.Tools.resolve('tinymce.PluginManager');
var clone = function (original, isDeep) {
return SugarElement.fromDom(original.dom.cloneNode(isDeep));
};
var shallow = function (original) {
return clone(original, false);
};
var deep = function (original) {
return clone(original, true);
};
var shallowAs = function (original, tag) {
var nu = SugarElement.fromTag(tag);
var attributes = clone$2(original);
setAll$1(nu, attributes);
return nu;
};
var copy$1 = function (original, tag) {
var nu = shallowAs(original, tag);
var cloneChildren = children$3(deep(original));
append(nu, cloneChildren);
return nu;
};
var mutate$1 = function (original, tag) {
var nu = shallowAs(original, tag);
before$4(original, nu);
var children = children$3(original);
append(nu, children);
remove$5(original);
return nu;
};
var Dimension = function (name, getOffset) {
var set = function (element, h) {
if (!isNumber(h) && !h.match(/^[0-9]+$/)) {
throw new Error(name + '.set accepts only positive integer values. Value was ' + h);
}
var dom = element.dom;
if (isSupported(dom)) {
dom.style[name] = h + 'px';
}
};
var get = function (element) {
var r = getOffset(element);
if (r <= 0 || r === null) {
var css = get$a(element, name);
return parseFloat(css) || 0;
}
return r;
};
var getOuter = get;
var aggregate = function (element, properties) {
return foldl(properties, function (acc, property) {
var val = get$a(element, property);
var value = val === undefined ? 0 : parseInt(val, 10);
return isNaN(value) ? acc : acc + value;
}, 0);
};
var max = function (element, value, properties) {
var cumulativeInclusions = aggregate(element, properties);
var absoluteMax = value > cumulativeInclusions ? value - cumulativeInclusions : 0;
return absoluteMax;
};
return {
set: set,
get: get,
getOuter: getOuter,
aggregate: aggregate,
max: max
};
};
var needManualCalc = function () {
var browser = detect$3().browser;
return browser.isIE() || browser.isEdge();
};
var toNumber = function (px, fallback) {
return toFloat(px).getOr(fallback);
};
var getProp = function (element, name, fallback) {
return toNumber(get$a(element, name), fallback);
};
var getBoxSizing = function (element) {
return get$a(element, 'box-sizing');
};
var calcContentBoxSize = function (element, size, upper, lower) {
var paddingUpper = getProp(element, 'padding-' + upper, 0);
var paddingLower = getProp(element, 'padding-' + lower, 0);
var borderUpper = getProp(element, 'border-' + upper + '-width', 0);
var borderLower = getProp(element, 'border-' + lower + '-width', 0);
return size - paddingUpper - paddingLower - borderUpper - borderLower;
};
var getCalculatedHeight = function (element, boxSizing) {
var dom = element.dom;
var height = dom.getBoundingClientRect().height || dom.offsetHeight;
return boxSizing === 'border-box' ? height : calcContentBoxSize(element, height, 'top', 'bottom');
};
var getCalculatedWidth = function (element, boxSizing) {
var dom = element.dom;
var width = dom.getBoundingClientRect().width || dom.offsetWidth;
return boxSizing === 'border-box' ? width : calcContentBoxSize(element, width, 'left', 'right');
};
var getHeight$1 = function (element) {
return needManualCalc() ? getCalculatedHeight(element, getBoxSizing(element)) : getProp(element, 'height', element.dom.offsetHeight);
};
var getWidth = function (element) {
return needManualCalc() ? getCalculatedWidth(element, getBoxSizing(element)) : getProp(element, 'width', element.dom.offsetWidth);
};
var getInnerWidth = function (element) {
return getCalculatedWidth(element, 'content-box');
};
var api$1 = Dimension('width', function (element) {
return element.dom.offsetWidth;
});
var get$8 = function (element) {
return api$1.get(element);
};
var getOuter$2 = function (element) {
return api$1.getOuter(element);
};
var getInner = getInnerWidth;
var getRuntime$1 = getWidth;
var columns = function (warehouse, isValidCell) {
if (isValidCell === void 0) {
isValidCell = always;
}
var grid = warehouse.grid;
var cols = range$1(grid.columns, identity);
var rowsArr = range$1(grid.rows, identity);
return map$1(cols, function (col) {
var getBlock = function () {
return bind$2(rowsArr, function (r) {
return Warehouse.getAt(warehouse, r, col).filter(function (detail) {
return detail.column === col;
}).toArray();
});
};
var isValid = function (detail) {
return detail.colspan === 1 && isValidCell(detail.element);
};
var getFallback = function () {
return Warehouse.getAt(warehouse, 0, col);
};
return decide(getBlock, isValid, getFallback);
});
};
var decide = function (getBlock, isValid, getFallback) {
var inBlock = getBlock();
var validInBlock = find$1(inBlock, isValid);
var detailOption = validInBlock.orThunk(function () {
return Optional.from(inBlock[0]).orThunk(getFallback);
});
return detailOption.map(function (detail) {
return detail.element;
});
};
var rows = function (warehouse) {
var grid = warehouse.grid;
var rowsArr = range$1(grid.rows, identity);
var cols = range$1(grid.columns, identity);
return map$1(rowsArr, function (row) {
var getBlock = function () {
return bind$2(cols, function (c) {
return Warehouse.getAt(warehouse, row, c).filter(function (detail) {
return detail.row === row;
}).fold(constant([]), function (detail) {
return [detail];
});
});
};
var isSingle = function (detail) {
return detail.rowspan === 1;
};
var getFallback = function () {
return Warehouse.getAt(warehouse, row, 0);
};
return decide(getBlock, isSingle, getFallback);
});
};
var deduce = function (xs, index) {
if (index < 0 || index >= xs.length - 1) {
return Optional.none();
}
var current = xs[index].fold(function () {
var rest = reverse(xs.slice(0, index));
return findMap(rest, function (a, i) {
return a.map(function (aa) {
return {
value: aa,
delta: i + 1
};
});
});
}, function (c) {
return Optional.some({
value: c,
delta: 0
});
});
var next = xs[index + 1].fold(function () {
var rest = xs.slice(index + 1);
return findMap(rest, function (a, i) {
return a.map(function (aa) {
return {
value: aa,
delta: i + 1
};
});
});
}, function (n) {
return Optional.some({
value: n,
delta: 1
});
});
return current.bind(function (c) {
return next.map(function (n) {
var extras = n.delta + c.delta;
return Math.abs(n.value - c.value) / extras;
});
});
};
var onDirection = function (isLtr, isRtl) {
return function (element) {
return getDirection(element) === 'rtl' ? isRtl : isLtr;
};
};
var getDirection = function (element) {
return get$a(element, 'direction') === 'rtl' ? 'rtl' : 'ltr';
};
var api = Dimension('height', function (element) {
var dom = element.dom;
return inBody(element) ? dom.getBoundingClientRect().height : dom.offsetHeight;
});
var get$7 = function (element) {
return api.get(element);
};
var getOuter$1 = function (element) {
return api.getOuter(element);
};
var getRuntime = getHeight$1;
var r = function (left, top) {
var translate = function (x, y) {
return r(left + x, top + y);
};
return {
left: left,
top: top,
translate: translate
};
};
var SugarPosition = r;
var boxPosition = function (dom) {
var box = dom.getBoundingClientRect();
return SugarPosition(box.left, box.top);
};
var firstDefinedOrZero = function (a, b) {
if (a !== undefined) {
return a;
} else {
return b !== undefined ? b : 0;
}
};
var absolute = function (element) {
var doc = element.dom.ownerDocument;
var body = doc.body;
var win = doc.defaultView;
var html = doc.documentElement;
if (body === element.dom) {
return SugarPosition(body.offsetLeft, body.offsetTop);
}
var scrollTop = firstDefinedOrZero(win === null || win === void 0 ? void 0 : win.pageYOffset, html.scrollTop);
var scrollLeft = firstDefinedOrZero(win === null || win === void 0 ? void 0 : win.pageXOffset, html.scrollLeft);
var clientTop = firstDefinedOrZero(html.clientTop, body.clientTop);
var clientLeft = firstDefinedOrZero(html.clientLeft, body.clientLeft);
return viewport(element).translate(scrollLeft - clientLeft, scrollTop - clientTop);
};
var viewport = function (element) {
var dom = element.dom;
var doc = dom.ownerDocument;
var body = doc.body;
if (body === dom) {
return SugarPosition(body.offsetLeft, body.offsetTop);
}
if (!inBody(element)) {
return SugarPosition(0, 0);
}
return boxPosition(dom);
};
var rowInfo = function (row, y) {
return {
row: row,
y: y
};
};
var colInfo = function (col, x) {
return {
col: col,
x: x
};
};
var rtlEdge = function (cell) {
var pos = absolute(cell);
return pos.left + getOuter$2(cell);
};
var ltrEdge = function (cell) {
return absolute(cell).left;
};
var getLeftEdge = function (index, cell) {
return colInfo(index, ltrEdge(cell));
};
var getRightEdge = function (index, cell) {
return colInfo(index, rtlEdge(cell));
};
var getTop$1 = function (cell) {
return absolute(cell).top;
};
var getTopEdge = function (index, cell) {
return rowInfo(index, getTop$1(cell));
};
var getBottomEdge = function (index, cell) {
return rowInfo(index, getTop$1(cell) + getOuter$1(cell));
};
var findPositions = function (getInnerEdge, getOuterEdge, array) {
if (array.length === 0) {
return [];
}
var lines = map$1(array.slice(1), function (cellOption, index) {
return cellOption.map(function (cell) {
return getInnerEdge(index, cell);
});
});
var lastLine = array[array.length - 1].map(function (cell) {
return getOuterEdge(array.length - 1, cell);
});
return lines.concat([lastLine]);
};
var negate = function (step) {
return -step;
};
var height = {
delta: identity,
positions: function (optElements) {
return findPositions(getTopEdge, getBottomEdge, optElements);
},
edge: getTop$1
};
var ltr$1 = {
delta: identity,
edge: ltrEdge,
positions: function (optElements) {
return findPositions(getLeftEdge, getRightEdge, optElements);
}
};
var rtl$1 = {
delta: negate,
edge: rtlEdge,
positions: function (optElements) {
return findPositions(getRightEdge, getLeftEdge, optElements);
}
};
var detect$2 = onDirection(ltr$1, rtl$1);
var width = {
delta: function (amount, table) {
return detect$2(table).delta(amount, table);
},
positions: function (cols, table) {
return detect$2(table).positions(cols, table);
},
edge: function (cell) {
return detect$2(cell).edge(cell);
}
};
var units = {
unsupportedLength: [
'em',
'ex',
'cap',
'ch',
'ic',
'rem',
'lh',
'rlh',
'vw',
'vh',
'vi',
'vb',
'vmin',
'vmax',
'cm',
'mm',
'Q',
'in',
'pc',
'pt',
'px'
],
fixed: [
'px',
'pt'
],
relative: ['%'],
empty: ['']
};
var pattern = function () {
var decimalDigits = '[0-9]+';
var signedInteger = '[+-]?' + decimalDigits;
var exponentPart = '[eE]' + signedInteger;
var dot = '\\.';
var opt = function (input) {
return '(?:' + input + ')?';
};
var unsignedDecimalLiteral = [
'Infinity',
decimalDigits + dot + opt(decimalDigits) + opt(exponentPart),
dot + decimalDigits + opt(exponentPart),
decimalDigits + opt(exponentPart)
].join('|');
var float = '[+-]?(?:' + unsignedDecimalLiteral + ')';
return new RegExp('^(' + float + ')(.*)$');
}();
var isUnit = function (unit, accepted) {
return exists(accepted, function (acc) {
return exists(units[acc], function (check) {
return unit === check;
});
});
};
var parse = function (input, accepted) {
var match = Optional.from(pattern.exec(input));
return match.bind(function (array) {
var value = Number(array[1]);
var unitRaw = array[2];
if (isUnit(unitRaw, accepted)) {
return Optional.some({
value: value,
unit: unitRaw
});
} else {
return Optional.none();
}
});
};
var rPercentageBasedSizeRegex = /(\d+(\.\d+)?)%/;
var rPixelBasedSizeRegex = /(\d+(\.\d+)?)px|em/;
var isCol$2 = isTag('col');
var getPercentSize = function (elm, outerGetter, innerGetter) {
var relativeParent = parentElement(elm).getOrThunk(function () {
return getBody$1(owner(elm));
});
return outerGetter(elm) / innerGetter(relativeParent) * 100;
};
var setPixelWidth = function (cell, amount) {
set$1(cell, 'width', amount + 'px');
};
var setPercentageWidth = function (cell, amount) {
set$1(cell, 'width', amount + '%');
};
var setHeight = function (cell, amount) {
set$1(cell, 'height', amount + 'px');
};
var getHeightValue = function (cell) {
return getRuntime(cell) + 'px';
};
var convert = function (cell, number, getter, setter) {
var newSize = table(cell).map(function (table) {
var total = getter(table);
return Math.floor(number / 100 * total);
}).getOr(number);
setter(cell, newSize);
return newSize;
};
var normalizePixelSize = function (value, cell, getter, setter) {
var number = parseFloat(value);
return endsWith(value, '%') && name(cell) !== 'table' ? convert(cell, number, getter, setter) : number;
};
var getTotalHeight = function (cell) {
var value = getHeightValue(cell);
if (!value) {
return get$7(cell);
}
return normalizePixelSize(value, cell, get$7, setHeight);
};
var get$6 = function (cell, type, f) {
var v = f(cell);
var span = getSpan(cell, type);
return v / span;
};
var getRaw$1 = function (element, prop) {
return getRaw$2(element, prop).orThunk(function () {
return getOpt(element, prop).map(function (val) {
return val + 'px';
});
});
};
var getRawWidth$1 = function (element) {
return getRaw$1(element, 'width');
};
var getRawHeight = function (element) {
return getRaw$1(element, 'height');
};
var getPercentageWidth = function (cell) {
return getPercentSize(cell, get$8, getInner);
};
var getPixelWidth$1 = function (cell) {
return isCol$2(cell) ? get$8(cell) : getRuntime$1(cell);
};
var getHeight = function (cell) {